repo stringclasses 3
values | commit stringlengths 40 40 | date stringdate 2023-04-02 02:30:17-0500 2026-10-18 07:42:16-0500 | pr_number int64 20 61.9k ⌀ | pr_url stringlengths 44 53 ⌀ | title stringlengths 8 263 | message stringlengths 8 8k | path stringlengths 10 155 | language stringclasses 4
values | license stringclasses 4
values | before_code stringlengths 160 118k | after_code stringlengths 340 120k | diff stringlengths 149 51k | lines_added int64 0 729 | lines_removed int64 0 488 | files_in_commit int64 1 10 | models_mentioned listlengths 0 4 | hardware_mentioned listlengths 0 16 | speedup_claims listlengths 0 10 | prompt stringlengths 569 119k | pr_body stringlengths 0 24k | gains stringlengths 2 197k | kernel_speedup float64 0.78 150 ⌀ | e2e_speedup float64 0.76 136 ⌀ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
flashinfer | 0d618712faff20a84bbd513d02ac01e16be19306 | 2024-08-17T23:26:02-07:00 | 453 | https://github.com/flashinfer-ai/flashinfer/pull/453 | perf: slight optimization on f16->f8 fragment layout swizzling (#453) | perf: slight optimization on f16->f8 fragment layout swizzling (#453)
swap after dequantize. | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -253,6 +253,12 @@
return (x > y) ? x - y : 0U;
}
+__device__ __forceinline__ void swap(uint32_t& a, uint32_t& b) {
+ uint32_t tmp = a;
+ a = b;
+ b = tmp;
+}
+
} // namespace flashinfer
#endif // FLASHINFER_UTILS_CUH_ | 6 | 0 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: perf: slight optimization on f16->f8 fragment layout swizzling
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Versio... | swap after dequantize.
| [] | null | null |
flashinfer | c93f647a0dd6b58c9ac20b39438316202358463c | 2024-08-10T21:29:53-07:00 | 439 | https://github.com/flashinfer-ai/flashinfer/pull/439 | perf: faster fp8->fp16 dequantization for pre sm_90 arch (#439) | perf: faster fp8->fp16 dequantization for pre sm_90 arch (#439)
hardware fp8->fp16 fast conversion instruction is not available for
sm_80 & sm_89, which makes #420 slow for these architectures.
this pr uses marlin's fast fp8->fp16x4 conversion algorithm (copied from
vllm project) to accelerate such cases.
Co-a... | include/flashinfer/vec_dtypes.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/vec_dtypes.cuh
+++ include/flashinfer/vec_dtypes.cuh
@@ -16,18 +16,18 @@
#ifndef VEC_DTYPES_CUH_
#define VEC_DTYPES_CUH_
-#ifdef FLASHINFER_ENABLE_BF16
#include <cuda_bf16.h>
+#include <cuda_fp16.h>
+#include <cuda_fp8.h>
+#include <cuda_runtime.h>
+
+#include <type_traits>
+
+namespace flas... | 175 | 23 | 1 | [] | [
"SM80",
"SM89",
"SM90"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/vec_dtypes.cuh).
Goal: perf: faster fp8->fp16 dequantization for pre sm_90 arch
Target hardware: SM80, SM89, SM90
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Ve... | hardware fp8->fp16 fast conversion instruction is not available for sm_80 & sm_89, which makes #420 slow for these architectures.
this pr uses marlin's fast fp8->fp16x4 conversion algorithm (copied from vllm project) to accelerate such cases.
Co-authored-by: Antoni Baum <antoni@anyscale.com>
Co-authored-by: Cody Yu <... | [] | null | null |
flashinfer | 701c813cb1266f8dd2b93d17978d35fd6fb975dd | 2024-07-23T23:59:03-07:00 | 313 | https://github.com/flashinfer-ai/flashinfer/pull/313 | perf: slight optimization on merge states (#313) | perf: slight optimization on merge states (#313)
When cudagraph is enabled, we will still call merge states kernels for
short sequence length, which incurs some unnecessary overhead.
This PR accelerates merge states kernel when there is nothing to merge
(`num_index_sets=1`).
We can actually write through to th... | include/flashinfer/attention/cascade.cuh | cuda | Apache-2.0 | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | --- include/flashinfer/attention/cascade.cuh
+++ include/flashinfer/attention/cascade.cuh
@@ -157,9 +157,29 @@
uint32_t tx = threadIdx.x, ty = threadIdx.y;
uint32_t pos = blockIdx.x;
uint32_t head_idx = ty;
+
+ if (num_index_sets == 0) {
+ vec_t<DTypeOut, vec_size> v;
+ v.fill(DTypeOut(0));
+ v.store... | 41 | 2 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/cascade.cuh).
Goal: perf: slight optimization on merge states
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (t... | When cudagraph is enabled, we will still call merge states kernels for short sequence length, which incurs some unnecessary overhead.
This PR accelerates merge states kernel when there is nothing to merge (`num_index_sets=1`).
We can actually write through to the target buffer for small sequence length, but I'm alway... | [] | null | null |
flashinfer | c6f20d1406a3a8c4f134c4a764d16e157a184338 | 2024-07-18T19:43:09-07:00 | 380 | https://github.com/flashinfer-ai/flashinfer/pull/380 | perf: use stmatrix in epilogue for sm90+ (#380) | perf: use stmatrix in epilogue for sm90+ (#380)
sm90+ can benefit from stmatrix in epilogue. | include/flashinfer/attention/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/prefill.cuh
+++ include/flashinfer/attention/prefill.cuh
@@ -893,6 +893,11 @@
for (uint32_t fy = 0; fy < num_frags_y; ++fy) {
uint32_t o_frag_f16[4];
vec_cast<DTypeOut, float, 8>((DTypeOut*)o_frag_f16, o_frag[fx][fy]);
+#ifdef FLASHINFER_STMATRIX_M8N8X4_ENABLED
... | 6 | 0 | 1 | [] | [
"SM90"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/prefill.cuh).
Goal: perf: use stmatrix in epilogue for sm90+
Target hardware: SM90
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Licen... | sm90+ can benefit from stmatrix in epilogue.
| [] | null | null |
flashinfer | 4f0a9f987ad2036f3c466257459de823be85fcc6 | 2024-07-10T16:10:27-07:00 | 365 | https://github.com/flashinfer-ai/flashinfer/pull/365 | perf: accelerate alibi (#365) | perf: accelerate alibi (#365)
Alibi experienced a performance degradation after #262 because of
increased number of integer division.
This PR fixes the issue. | include/flashinfer/fastdiv.cuh | cuda | Apache-2.0 | /*
* Copyright 2014 Maxim Milakov
*
* The code is based on the Chapter 10 of Hacker's Delight book by Henry S. Warren, Jr.
* The struct is adapted from https://github.com/milakov/int_fastdiv/blob/master/int_fastdiv.h
* by Maxim Milakov, the difference is that here we use uint32_t instead of int32_t.
*
* Licensed... | /*
* Copyright 2014 Maxim Milakov
*
* The code is based on the Chapter 10 of Hacker's Delight book by Henry S. Warren, Jr.
* The struct is adapted from https://github.com/milakov/int_fastdiv/blob/master/int_fastdiv.h
* by Maxim Milakov, the difference is that here we use uint32_t instead of int32_t.
*
* Licensed... | --- include/flashinfer/fastdiv.cuh
+++ include/flashinfer/fastdiv.cuh
@@ -65,13 +65,17 @@
__host__ __device__ __forceinline__ operator unsigned int() const { return d; }
__host__ __device__ __forceinline__ void divmod(uint32_t n, uint32_t& q, uint32_t& r) const {
+ if (d == 1) {
+ q = n;
+ } else {
... | 16 | 8 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/fastdiv.cuh).
Goal: perf: accelerate alibi
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright 2014 Maxim Milakov
*
* The code is based on the Chapter 10 of Hacker's Delight book by Henry S. Warren, Jr.
* T... | Alibi experienced a performance degradation after #262 because of increased number of integer division.
This PR fixes the issue.
| [] | null | null |
flashinfer | e56ddadf4bdbb164c3f1a03f9f69cb8a25621ef5 | 2024-07-04T00:57:33-07:00 | 356 | https://github.com/flashinfer-ai/flashinfer/pull/356 | perf: accelerate gqa performance (#356) | perf: accelerate gqa performance (#356)
Changes:
1. Prefetch page indices (we have already done such optimization on
decode kernels, but not on append/prefill kernels which was used in
GQA).
2. Unlock 1x4 warp layout in
https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable
this because the binar... | include/flashinfer/attention/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/handler.cuh
+++ include/flashinfer/attention/handler.cuh
@@ -560,7 +560,12 @@
if (avg_packed_qo_len > 64 && head_dim < 256) {
warp_layout = WarpLayout::k4x1x2; // (num_warps_x = 4, num_warps_z = 1, num_frags_x = 2)
} else {
- warp_layout = WarpLayout::k4x1x1; // (num_war... | 6 | 1 | 3 | [] | [
"H100"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/handler.cuh).
Goal: perf: accelerate gqa performance
Target hardware: H100
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*... | Changes:
1. Prefetch page indices (we have already done such optimization on decode kernels, but not on append/prefill kernels which was used in GQA).
2. Unlock 1x4 warp layout in https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable this because the binary size is too large, we should further reduce s... | [{"scope": "kernel", "hardware": "H100", "model": null, "shape": "num_qo_heads=32,num_kv_heads=4,head_dim=128", "batch_size": 128, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 133, "optimized": 103, "stated_speedup": null, "speedup": 1.2913}] | 1.2913 | null |
flashinfer | e56ddadf4bdbb164c3f1a03f9f69cb8a25621ef5 | 2024-07-04T00:57:33-07:00 | 356 | https://github.com/flashinfer-ai/flashinfer/pull/356 | perf: accelerate gqa performance (#356) | perf: accelerate gqa performance (#356)
Changes:
1. Prefetch page indices (we have already done such optimization on
decode kernels, but not on append/prefill kernels which was used in
GQA).
2. Unlock 1x4 warp layout in
https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable
this because the binar... | include/flashinfer/attention/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/prefill.cuh
+++ include/flashinfer/attention/prefill.cuh
@@ -53,7 +53,7 @@
uint32_t num_warps_z) {
return ((num_frags_y < 4) || (num_frags_y == 4 && num_frags_z % 2 == 1) ||
(num_frags_y > 4 && num_frags_y % (2 * num_warps_x) != 0) ... | 60 | 36 | 3 | [] | [
"H100"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/prefill.cuh).
Goal: perf: accelerate gqa performance
Target hardware: H100
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*... | Changes:
1. Prefetch page indices (we have already done such optimization on decode kernels, but not on append/prefill kernels which was used in GQA).
2. Unlock 1x4 warp layout in https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable this because the binary size is too large, we should further reduce s... | [{"scope": "kernel", "hardware": "H100", "model": null, "shape": "num_qo_heads=32,num_kv_heads=4,head_dim=128", "batch_size": 128, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 133, "optimized": 103, "stated_speedup": null, "speedup": 1.2913}] | 1.2913 | null |
flashinfer | e56ddadf4bdbb164c3f1a03f9f69cb8a25621ef5 | 2024-07-04T00:57:33-07:00 | 356 | https://github.com/flashinfer-ai/flashinfer/pull/356 | perf: accelerate gqa performance (#356) | perf: accelerate gqa performance (#356)
Changes:
1. Prefetch page indices (we have already done such optimization on
decode kernels, but not on append/prefill kernels which was used in
GQA).
2. Unlock 1x4 warp layout in
https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable
this because the binar... | include/flashinfer/attention/warp_layout.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/warp_layout.cuh
+++ include/flashinfer/attention/warp_layout.cuh
@@ -26,7 +26,7 @@
enum class WarpLayout {
k4x1x2 = 0U,
k4x1x1 = 1U,
- // k1x4x1 = 2U,
+ k1x4x1 = 2U,
};
template <WarpLayout warp_layout>
@@ -44,10 +44,10 @@
return 4;
}
-// template <>
-// constexpr uin... | 16 | 13 | 3 | [] | [
"H100"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/warp_layout.cuh).
Goal: perf: accelerate gqa performance
Target hardware: H100
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License")... | Changes:
1. Prefetch page indices (we have already done such optimization on decode kernels, but not on append/prefill kernels which was used in GQA).
2. Unlock 1x4 warp layout in https://github.com/flashinfer-ai/flashinfer/pull/322, we didn't enable this because the binary size is too large, we should further reduce s... | [{"scope": "kernel", "hardware": "H100", "model": null, "shape": "num_qo_heads=32,num_kv_heads=4,head_dim=128", "batch_size": 128, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 133, "optimized": 103, "stated_speedup": null, "speedup": 1.2913}] | 1.2913 | null |
flashinfer | bf2a6c7c05a82e0ee0ea04381d04b84327355b69 | 2024-06-26T23:52:24-07:00 | 336 | https://github.com/flashinfer-ai/flashinfer/pull/336 | perf: more options for kv tile size (#336) | perf: more options for kv tile size (#336)
For small query size setting, we might use large kv tile size. | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -72,7 +72,13 @@
}
#define DISPATCH_NUM_FRAGS_Z(max_frags_z, NUM_FRAGS_Z, ...) \
- if (max_frags_z >= 4) { \
+ if (max_frags_z >= 8) { \
+ constexpr size_t NUM_FRAGS_Z = 8; ... | 7 | 1 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: perf: more options for kv tile size
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* y... | For small query size setting, we might use large kv tile size.
| [] | null | null |
flashinfer | f237f5f80199e2c433fcca750713c6e774693b58 | 2024-06-22T14:40:51-07:00 | 329 | https://github.com/flashinfer-ai/flashinfer/pull/329 | perf: change minimal `kv_chunk_size` back to 128 (#329) | perf: change minimal `kv_chunk_size` back to 128 (#329) | include/flashinfer/attention/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/handler.cuh
+++ include/flashinfer/attention/handler.cuh
@@ -566,7 +566,7 @@
// step 2: determine kv_chunk_size
std::tie(split_kv, kv_chunk_size, new_batch_size) =
PrefillBinarySearchKVChunkSize(max_grid_size, num_kv_heads, packed_qo_len_arr, kv_len_arr,
- ... | 1 | 1 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/handler.cuh).
Goal: perf: change minimal `kv_chunk_size` back to 128
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version ... | [] | null | null | |
flashinfer | 4e89b4dfdeb0c07b290ace9f82edf31e63136cfd | 2024-06-21T11:44:12-07:00 | 322 | https://github.com/flashinfer-ai/flashinfer/pull/322 | perf: use 1x4 warp layout for small query length (#322) | perf: use 1x4 warp layout for small query length (#322)
Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets
merged (ETA: tonight). | include/flashinfer/attention/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/handler.cuh
+++ include/flashinfer/attention/handler.cuh
@@ -16,6 +16,7 @@
#ifndef FLASHINFER_ATTENTION_HANDLER_CUH_
#define FLASHINFER_ATTENTION_HANDLER_CUH_
+#include <cuda_runtime_api.h>
#include <driver_types.h>
#include <algorithm>
@@ -29,6 +30,7 @@
#include "../pos_enc.cu... | 40 | 86 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/handler.cuh).
Goal: perf: use 1x4 warp layout for small query length
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version ... | Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets merged (ETA: tonight).
| [] | null | null |
flashinfer | 4e89b4dfdeb0c07b290ace9f82edf31e63136cfd | 2024-06-21T11:44:12-07:00 | 322 | https://github.com/flashinfer-ai/flashinfer/pull/322 | perf: use 1x4 warp layout for small query length (#322) | perf: use 1x4 warp layout for small query length (#322)
Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets
merged (ETA: tonight). | include/flashinfer/page.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/page.cuh
+++ include/flashinfer/page.cuh
@@ -362,46 +362,6 @@
vec_t<DType, vec_size>::memcpy(
v_ptr,
value + ((append_indptr[batch_idx] + j) * num_heads + head_idx) * head_dim + tx * vec_size);
- }
-}
-
-/*!
- * \brief CUDA kernel to convert the paged key-value cache to a ... | 0 | 121 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/page.cuh).
Goal: perf: use 1x4 warp layout for small query length
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Lic... | Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets merged (ETA: tonight).
| [] | null | null |
flashinfer | 4e89b4dfdeb0c07b290ace9f82edf31e63136cfd | 2024-06-21T11:44:12-07:00 | 322 | https://github.com/flashinfer-ai/flashinfer/pull/322 | perf: use 1x4 warp layout for small query length (#322) | perf: use 1x4 warp layout for small query length (#322)
Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets
merged (ETA: tonight). | include/flashinfer/prefill_attention_decl.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill_attention_decl.cuh
+++ include/flashinfer/prefill_attention_decl.cuh
@@ -21,6 +21,7 @@
#include "attention/handler.cuh"
#include "attention/logits_post_hook.cuh"
#include "attention/mask.cuh"
+#include "flashinfer/attention/warp_layout.cuh"
#include "layout.cuh"
#include "page.cuh"
... | 11 | 10 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill_attention_decl.cuh).
Goal: perf: use 1x4 warp layout for small query length
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Ver... | Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets merged (ETA: tonight).
| [] | null | null |
flashinfer | 4e89b4dfdeb0c07b290ace9f82edf31e63136cfd | 2024-06-21T11:44:12-07:00 | 322 | https://github.com/flashinfer-ai/flashinfer/pull/322 | perf: use 1x4 warp layout for small query length (#322) | perf: use 1x4 warp layout for small query length (#322)
Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets
merged (ETA: tonight). | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -230,12 +230,6 @@
namespace flashinfer {
-inline bool is_device_ptr(const void* ptr) {
- cudaPointerAttributes attrs;
- FLASHINFER_CUDA_CALL(cudaPointerGetAttributes(&attrs, ptr));
- return attrs.type == cudaMemoryTypeDevice;
-}
-
template <t... | 0 | 6 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: perf: use 1x4 warp layout for small query length
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Li... | Duplicate of #304 and #185, just rebased on main.
This PR can accelerate GQA, we will release v0.0.6 after this PR gets merged (ETA: tonight).
| [] | null | null |
flashinfer | 3b50dd59b0e1f23905e583d5af069e43ff5e15a4 | 2024-06-20T01:14:04-07:00 | 317 | https://github.com/flashinfer-ai/flashinfer/pull/317 | feat: add `use_tensor_cores` option to decode kernels to accelerate GQA (#317) | feat: add `use_tensor_cores` option to decode kernels to accelerate GQA (#317)
The tensor-cores accelerated GQA in our [blog
post](https://flashinfer.ai/2024/02/02/introduce-flashinfer.html) was
not enabled by default (user need to use Prefill kernels/wrappers for
decode to get such acceleration).
In this PR we ... | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -91,23 +91,8 @@
if (group_size == 1) { \
constexpr size_t GROUP_SIZE = 1; \
__VA_ARGS__ \
- } else if (group_size == 2) { ... | 0 | 15 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: feat: add `use_tensor_cores` option to decode kernels to accelerate GQA
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache Licens... | The tensor-cores accelerated GQA in our [blog post](https://flashinfer.ai/2024/02/02/introduce-flashinfer.html) was not enabled by default (user need to use Prefill kernels/wrappers for decode to get such acceleration).
In this PR we add an option `use_tensor_cores` to decode operators/wrappers, and user can select wh... | [] | null | null |
flashinfer | f0bb0a3a723cbe1a138c604680e6b573d877f210 | 2024-06-19T23:47:07-07:00 | 310 | https://github.com/flashinfer-ai/flashinfer/pull/310 | perf: split kv-cache for prefill/append kernels (#310) | perf: split kv-cache for prefill/append kernels (#310)
Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a
function argument, which will be passed by value, and cannot change once
captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a
`kv... | include/flashinfer/attention/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/handler.cuh
+++ include/flashinfer/attention/handler.cuh
@@ -15,6 +15,8 @@
*/
#ifndef FLASHINFER_ATTENTION_HANDLER_CUH_
#define FLASHINFER_ATTENTION_HANDLER_CUH_
+
+#include <driver_types.h>
#include <algorithm>
#include <cstddef>
@@ -82,6 +84,39 @@
return {low, new_batch_siz... | 351 | 53 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/handler.cuh).
Goal: perf: split kv-cache for prefill/append kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2... | Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a function argument, which will be passed by value, and cannot change once captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a `kv_chunk_size_ptr` which is a pointer to a global memory addres... | [] | null | null |
flashinfer | f0bb0a3a723cbe1a138c604680e6b573d877f210 | 2024-06-19T23:47:07-07:00 | 310 | https://github.com/flashinfer-ai/flashinfer/pull/310 | perf: split kv-cache for prefill/append kernels (#310) | perf: split kv-cache for prefill/append kernels (#310)
Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a
function argument, which will be passed by value, and cannot change once
captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a
`kv... | include/flashinfer/attention/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/prefill.cuh
+++ include/flashinfer/attention/prefill.cuh
@@ -566,8 +566,8 @@
: kv_idx >= chunk_end);
s_frag[fx][fz][reg_id] =
(out_of_boundary ||
- ((mask_mode == MaskMode::kCustom && q_idx < qo_len &&
- !(custom_mask[(q_... | 294 | 154 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/prefill.cuh).
Goal: perf: split kv-cache for prefill/append kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2... | Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a function argument, which will be passed by value, and cannot change once captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a `kv_chunk_size_ptr` which is a pointer to a global memory addres... | [] | null | null |
flashinfer | f0bb0a3a723cbe1a138c604680e6b573d877f210 | 2024-06-19T23:47:07-07:00 | 310 | https://github.com/flashinfer-ai/flashinfer/pull/310 | perf: split kv-cache for prefill/append kernels (#310) | perf: split kv-cache for prefill/append kernels (#310)
Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a
function argument, which will be passed by value, and cannot change once
captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a
`kv... | include/flashinfer/decode_attention_decl.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/decode_attention_decl.cuh
+++ include/flashinfer/decode_attention_decl.cuh
@@ -64,7 +64,7 @@
paged_kv_t<PAGE_STORAGE, KV_LAYOUT, DTypeKV, IdType> new_paged_kv = paged_kv;
kv_partition_info_t<IdType> kv_partition_info;
DTypeOut* tmp_v = handler->GetTempV<DTypeOut>();
- float* tmp_s = han... | 1 | 1 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode_attention_decl.cuh).
Goal: perf: split kv-cache for prefill/append kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Versi... | Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a function argument, which will be passed by value, and cannot change once captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a `kv_chunk_size_ptr` which is a pointer to a global memory addres... | [] | null | null |
flashinfer | f0bb0a3a723cbe1a138c604680e6b573d877f210 | 2024-06-19T23:47:07-07:00 | 310 | https://github.com/flashinfer-ai/flashinfer/pull/310 | perf: split kv-cache for prefill/append kernels (#310) | perf: split kv-cache for prefill/append kernels (#310)
Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a
function argument, which will be passed by value, and cannot change once
captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a
`kv... | include/flashinfer/prefill_attention_decl.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill_attention_decl.cuh
+++ include/flashinfer/prefill_attention_decl.cuh
@@ -38,44 +38,60 @@
uint32_t kv_len, float sm_scale, float rope_scale,
float rope_theta, cudaStream_t stream);
-template <... | 63 | 33 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill_attention_decl.cuh).
Goal: perf: split kv-cache for prefill/append kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Vers... | Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a function argument, which will be passed by value, and cannot change once captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a `kv_chunk_size_ptr` which is a pointer to a global memory addres... | [] | null | null |
flashinfer | f0bb0a3a723cbe1a138c604680e6b573d877f210 | 2024-06-19T23:47:07-07:00 | 310 | https://github.com/flashinfer-ai/flashinfer/pull/310 | perf: split kv-cache for prefill/append kernels (#310) | perf: split kv-cache for prefill/append kernels (#310)
Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a
function argument, which will be passed by value, and cannot change once
captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a
`kv... | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -50,15 +50,6 @@
}
#endif
-#define DISPATCH_SPLIT_QO_INDPTR(split_qo_indptr, SPLIT_QO_INDPTR, ...) \
- if (split_qo_indptr) { \
- constexpr bool SPLIT_QO_INDPTR = true; ... | 0 | 40 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: perf: split kv-cache for prefill/append kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Lic... | Duplicate of #75, but re-based on the main branch.
Note that to support CUDAGraph, we cannot make `kv_chunk_size` a function argument, which will be passed by value, and cannot change once captured by CUDAGraph. Instead, we pass `kv_chunk_size` through a `kv_chunk_size_ptr` which is a pointer to a global memory addres... | [] | null | null |
flashinfer | 3d43dc9dc1a2ae804eaa7e40b4555e471fd03fe3 | 2024-06-16T00:50:50-07:00 | 308 | https://github.com/flashinfer-ai/flashinfer/pull/308 | perf: use packed bit array for attention mask (#308) | perf: use packed bit array for attention mask (#308) | include/flashinfer/attention/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/prefill.cuh
+++ include/flashinfer/attention/prefill.cuh
@@ -547,7 +547,7 @@
__device__ __forceinline__ void mask_s(const uint32_t qo_packed_idx_base,
const uint32_t kv_idx_base, const uint32_t qo_len,
cons... | 14 | 14 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/prefill.cuh).
Goal: perf: use packed bit array for attention mask
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0... | float attention mask consumes too much gpu memory and makes the attention kernel slow.
In this pr we use 0/1 attention mask and uses bit-packed array (1 bit per element, 8 elements are packed together as uint8) to save gpu memory.
| [] | null | null |
flashinfer | 3d43dc9dc1a2ae804eaa7e40b4555e471fd03fe3 | 2024-06-16T00:50:50-07:00 | 308 | https://github.com/flashinfer-ai/flashinfer/pull/308 | perf: use packed bit array for attention mask (#308) | perf: use packed bit array for attention mask (#308) | include/flashinfer/prefill_attention_decl.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill_attention_decl.cuh
+++ include/flashinfer/prefill_attention_decl.cuh
@@ -32,7 +32,7 @@
PosEncodingMode POS_ENCODING_MODE, bool ALLOW_FP16_QK_REDUCTION, MaskMode MASK_MODE,
typename DTypeIn, typename DTypeOut>
cudaError_t SinglePrefillWithKVCacheDispatched(DTypeIn* q... | 5 | 5 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill_attention_decl.cuh).
Goal: perf: use packed bit array for attention mask
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Versio... | float attention mask consumes too much gpu memory and makes the attention kernel slow.
In this pr we use 0/1 attention mask and uses bit-packed array (1 bit per element, 8 elements are packed together as uint8) to save gpu memory.
| [] | null | null |
flashinfer | 7e9cc7ff42ca283c317061a877305d09a395fad2 | 2024-05-24T15:36:03-07:00 | 256 | https://github.com/flashinfer-ai/flashinfer/pull/256 | perf: initial cuda graph support (#256) | perf: initial cuda graph support (#256)
As requested in #187 , this PR adds initial support of `CUDAGraph`
compatibility of flashinfer batch decode attention kernels. This PR is
the first step towards full CUDAGraph support and we will implement
CUDAGraph compatible prefill operators in later PRs.
# Proposed API... | include/flashinfer/attention/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/handler.cuh
+++ include/flashinfer/attention/handler.cuh
@@ -17,6 +17,7 @@
#define FLASHINFER_HANDLER_CUH_
#include <algorithm>
+#include <cstddef>
#include <memory>
#include <unordered_map>
#include <vector>
@@ -101,7 +102,7 @@
cudaError_t BatchDecodeWithPagedKVCacheWorkEstimat... | 122 | 23 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/handler.cuh).
Goal: perf: initial cuda graph support
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Licens... | As requested in #187 , this PR adds initial support of `CUDAGraph` compatibility of flashinfer batch decode attention kernels. This PR is the first step towards full CUDAGraph support and we will implement CUDAGraph compatible prefill operators in later PRs.
# Proposed APIs
We add another wrapper `CUDAGraphBatchDecode... | [] | null | null |
flashinfer | 7e9cc7ff42ca283c317061a877305d09a395fad2 | 2024-05-24T15:36:03-07:00 | 256 | https://github.com/flashinfer-ai/flashinfer/pull/256 | perf: initial cuda graph support (#256) | perf: initial cuda graph support (#256)
As requested in #187 , this PR adds initial support of `CUDAGraph`
compatibility of flashinfer batch decode attention kernels. This PR is
the first step towards full CUDAGraph support and we will implement
CUDAGraph compatible prefill operators in later PRs.
# Proposed API... | include/flashinfer/attention/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/prefill.cuh
+++ include/flashinfer/attention/prefill.cuh
@@ -309,8 +309,8 @@
#pragma unroll
for (uint32_t fyo = 0; fyo < num_frags_y / 4; ++fyo) {
// load q fragment from gmem to smem
- q_smem->load_128b_async<SharedMemFillMode::kFillZero>(q_smem_offset_w, q_ptr,... | 20 | 16 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/prefill.cuh).
Goal: perf: initial cuda graph support
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Licens... | As requested in #187 , this PR adds initial support of `CUDAGraph` compatibility of flashinfer batch decode attention kernels. This PR is the first step towards full CUDAGraph support and we will implement CUDAGraph compatible prefill operators in later PRs.
# Proposed APIs
We add another wrapper `CUDAGraphBatchDecode... | [] | null | null |
flashinfer | 7e9cc7ff42ca283c317061a877305d09a395fad2 | 2024-05-24T15:36:03-07:00 | 256 | https://github.com/flashinfer-ai/flashinfer/pull/256 | perf: initial cuda graph support (#256) | perf: initial cuda graph support (#256)
As requested in #187 , this PR adds initial support of `CUDAGraph`
compatibility of flashinfer batch decode attention kernels. This PR is
the first step towards full CUDAGraph support and we will implement
CUDAGraph compatible prefill operators in later PRs.
# Proposed API... | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -282,8 +282,8 @@
uint32_t num_qo_tiles = 0;
for (uint32_t i = 0; i < batch_size; ++i) {
- for (uint32_t j = qo_indptr_h[i] * aligned_gqa_group_size; j < qo_indptr_h[i + 1] * aligned_gqa_group_size;
- j += num_rows_per_cta) {
+ fo... | 2 | 2 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: perf: initial cuda graph support
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you ... | As requested in #187 , this PR adds initial support of `CUDAGraph` compatibility of flashinfer batch decode attention kernels. This PR is the first step towards full CUDAGraph support and we will implement CUDAGraph compatible prefill operators in later PRs.
# Proposed APIs
We add another wrapper `CUDAGraphBatchDecode... | [] | null | null |
flashinfer | fb699100507c511553c03bc1b4f32e37df0b9305 | 2024-04-25T01:10:01-07:00 | 212 | https://github.com/flashinfer-ai/flashinfer/pull/212 | perm: optimize sampling performance (#212) | perm: optimize sampling performance (#212)
skip the scan operation on a chunk if we know this chunk do not overlap
with the uniform needle. | include/flashinfer/sampling.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/sampling.cuh
+++ include/flashinfer/sampling.cuh
@@ -52,22 +52,25 @@
}
};
-template <typename T, typename ReduceT, uint32_t BLOCK_THREADS, BlockScanAlgorithm ALGORITHM>
+template <typename T, uint32_t BLOCK_THREADS, BlockScanAlgorithm ALGORITHM>
union SamplingTempStorage {
typename Bloc... | 60 | 46 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/sampling.cuh).
Goal: perm: optimize sampling performance
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2024 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
... | skip the scan operation on a chunk if we know this chunk do not overlap with the uniform needle.
| [] | null | null |
flashinfer | 660c559348ba9710d0d81b53f710f7e4951eee2b | 2024-02-29T16:07:42-08:00 | 144 | https://github.com/flashinfer-ai/flashinfer/pull/144 | perf: multiple q by sm_scale in decode kernels (#144) | perf: multiple q by sm_scale in decode kernels (#144)
The same optimization was used in our prefill attention kernels, this PR
applies this optimization to decode attention kernels. | include/flashinfer/attention/decode.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/attention/decode.cuh
+++ include/flashinfer/attention/decode.cuh
@@ -68,8 +68,8 @@
__device__ __forceinline__ void compute_qk(const T* smem, uint32_t compute_stage_idx,
const vec_t<float, vec_size>& q_vec,
co... | 20 | 7 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/attention/decode.cuh).
Goal: perf: multiple q by sm_scale in decode kernels
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0... | The same optimization was used in our prefill attention kernels, this PR applies this optimization to decode attention kernels.
| [] | null | null |
flashinfer | 51b88d203730a5c6ea1ca5b79286829b4ffa37aa | 2024-01-26T09:51:05+08:00 | 88 | https://github.com/flashinfer-ai/flashinfer/pull/88 | [Performance] Using user-allocated workspace for batch decode/prefill handlers (#88) | [Performance] Using user-allocated workspace for batch decode/prefill handlers (#88)
To avoid the overhead of allocating/destroy memory per step. | include/flashinfer/handler.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/handler.cuh
+++ include/flashinfer/handler.cuh
@@ -28,6 +28,24 @@
namespace flashinfer {
+struct AlignedAlloactor {
+ void* ptr;
+ size_t space;
+ AlignedAlloactor(void* buf, size_t space) : ptr(buf), space(space) {}
+ template <typename T>
+ T* aligned_alloc(size_t size, size_t alignme... | 69 | 58 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/handler.cuh).
Goal: [Performance] Using user-allocated workspace for batch decode/prefill handlers
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apac... | To avoid the overhead of allocating/destroy memory per step.
| [] | null | null |
flashinfer | d10f082b9740b89bbfcb2007f1d3e33ed615d454 | 2024-01-21T21:14:35+08:00 | 87 | https://github.com/flashinfer-ai/flashinfer/pull/87 | [Performance] Accelerate merge function (#87) | [Performance] Accelerate merge function (#87) | include/flashinfer/cascade.cuh | cuda | Apache-2.0 | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | --- include/flashinfer/cascade.cuh
+++ include/flashinfer/cascade.cuh
@@ -427,7 +427,7 @@
SWITCH_HEAD_DIM(head_dim, HEAD_DIM, {
constexpr uint32_t vec_size = std::max(16U / sizeof(DTypeIn), HEAD_DIM / 32U);
constexpr uint32_t bdx = HEAD_DIM / vec_size;
- if (num_index_sets > 2 * (128 / bdx)) {
+ if (... | 1 | 1 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/cascade.cuh).
Goal: [Performance] Accelerate merge function
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License"... | [] | null | null | |
flashinfer | b4987017cc82fd32de089ff653d62ba71de1a559 | 2024-01-21T18:13:40+08:00 | 84 | https://github.com/flashinfer-ai/flashinfer/pull/84 | [Performance] Fix the fp8 decode kernel performance degradation issue (#84) | [Performance] Fix the fp8 decode kernel performance degradation issue (#84)
The fp8 decode kernel performance degrades because of the changes in
previous commits
https://github.com/flashinfer-ai/flashinfer/commit/2a3d6d038d3ee57904b150c0ad107556568c2c1f
. This PR fixes the degradation. | include/flashinfer/decode.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -750,7 +750,8 @@
constexpr uint32_t num_threads =
std::max(get_heuristic_num_threads(GROUP_SIZE, sizeof(DTypeIn)), bdx * bdy);
constexpr uint32_t bdz = num_threads / (bdx * bdy);
- ... | 7 | 4 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: [Performance] Fix the fp8 decode kernel performance degradation issue
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License... | The fp8 decode kernel performance degrades because of the changes in previous commits https://github.com/flashinfer-ai/flashinfer/commit/2a3d6d038d3ee57904b150c0ad107556568c2c1f . This PR fixes the degradation.
| [] | null | null |
flashinfer | 88b9496e1a726ddb353eb42887cfc0ab32c99460 | 2024-01-10T07:02:50-08:00 | 68 | https://github.com/flashinfer-ai/flashinfer/pull/68 | [Performance] Another prefill/append parameter tweak (#68) | [Performance] Another prefill/append parameter tweak (#68) | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -1385,7 +1385,7 @@
min((num_blocks_per_sm * num_sm) /
(num_kv_heads *
ceil_div(qo_len * group_size, num_rows_per_cta)),... | 2 | 2 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: [Performance] Another prefill/append parameter tweak
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (t... | [] | null | null | |
flashinfer | 8320ebe06a8e4bd50cd7e199f8c5e03c255484e2 | 2024-01-09T19:27:18-08:00 | 63 | https://github.com/flashinfer-ai/flashinfer/pull/63 | [Performance] Increase `num_frags_z` for GPUs with larger shared memory per SM (#63) | [Performance] Increase `num_frags_z` for GPUs with larger shared memory per SM (#63)
In our previous design `num_frags_z` is fixed to 2 which is not optimal
for GPUs with large shared memory per SM. | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -1619,30 +1619,47 @@
typename std::conditional<ALLOW_FP16_QK_REDUCTION && std::is_same<DTypeIn, half>::value, half,
float>::type;
- constexpr uint32_t num_frags_z = 2;
- auto kernel =
- BatchPrefill... | 79 | 46 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: [Performance] Increase `num_frags_z` for GPUs with larger shared memory per SM
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apac... | In our previous design `num_frags_z` is fixed to 2 which is not optimal for GPUs with large shared memory per SM.
| [] | null | null |
flashinfer | fc167a0cce3e851d8efb92a776ab1863e82de6ec | 2024-01-07T01:02:10-08:00 | 55 | https://github.com/flashinfer-ai/flashinfer/pull/55 | [Performance] Tweak Prefill Parameters (#55) | [Performance] Tweak Prefill Parameters (#55) | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -1385,7 +1385,7 @@
min((num_blocks_per_sm * num_sm) /
(num_kv_heads *
ceil_div(qo_len * group_size, num_rows_per_cta)),... | 2 | 2 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: [Performance] Tweak Prefill Parameters
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");... | [] | null | null | |
flashinfer | 1fbe6f3f3cde9142e7014870df009d1544cf3a39 | 2024-01-06T07:55:55-08:00 | 53 | https://github.com/flashinfer-ai/flashinfer/pull/53 | [Performance] Accelerate merge function when batch size is small (#53) | [Performance] Accelerate merge function when batch size is small (#53)
Use another schedule for merge states function. | include/flashinfer/cascade.cuh | cuda | Apache-2.0 | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | --- include/flashinfer/cascade.cuh
+++ include/flashinfer/cascade.cuh
@@ -113,6 +113,25 @@
}
}
+template <uint32_t bdx, uint32_t bdy, uint32_t vec_size, typename DTypeIn>
+__device__ __forceinline__ void threadblock_sync_state(state_t<vec_size>& st, DTypeIn* v_smem,
+ ... | 132 | 23 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/cascade.cuh).
Goal: [Performance] Accelerate merge function when batch size is small
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, V... | Use another schedule for merge states function.
| [] | null | null |
flashinfer | c213c7b8b034b49a5cef3641a3e53622709be567 | 2024-01-03T07:48:57-08:00 | 48 | https://github.com/flashinfer-ai/flashinfer/pull/48 | [Performance] Accelerate append prefill kernel (#48) | [Performance] Accelerate append prefill kernel (#48)
We found that cooperative kernel (merge states in the same kernel afte
grid synchronization) actually limits kernel's performance when merging
workload is relatively large (e.g. in GQA or append prefill kernels).
This PR splits the cooperative kernel to two kerne... | include/flashinfer/cascade.cuh | cuda | Apache-2.0 | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | /*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... | --- include/flashinfer/cascade.cuh
+++ include/flashinfer/cascade.cuh
@@ -68,7 +68,9 @@
v_merged_vec[i] = a_scale * v_a_vec[i] + b_scale * v_b_vec[i];
}
v_merged_vec.cast_store(v_merged + (batch_idx * num_heads + head_idx) * head_dim + tx * vec_size);
- s_merged[batch_idx * num_heads + head_idx] = math::ptx... | 9 | 3 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/cascade.cuh).
Goal: [Performance] Accelerate append prefill kernel
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*!
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "L... | We found that cooperative kernel (merge states in the same kernel afte grid synchronization) actually limits kernel's performance when merging workload is relatively large (e.g. in GQA or append prefill kernels). This PR splits the cooperative kernel to two kernels for append prefill kernels.
| [] | null | null |
flashinfer | c213c7b8b034b49a5cef3641a3e53622709be567 | 2024-01-03T07:48:57-08:00 | 48 | https://github.com/flashinfer-ai/flashinfer/pull/48 | [Performance] Accelerate append prefill kernel (#48) | [Performance] Accelerate append prefill kernel (#48)
We found that cooperative kernel (merge states in the same kernel afte
grid synchronization) actually limits kernel's performance when merging
workload is relatively large (e.g. in GQA or append prefill kernels).
This PR splits the cooperative kernel to two kerne... | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -25,6 +25,7 @@
#include <tuple>
+#include "cascade.cuh"
#include "cp_async.cuh"
#include "layout.cuh"
#include "math.cuh"
@@ -415,8 +416,8 @@
*k_smem_offset_r -= num_frags_y * 2;
}
-template <bool cooperative, bool causal, uint32_t g... | 57 | 44 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: [Performance] Accelerate append prefill kernel
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Li... | We found that cooperative kernel (merge states in the same kernel afte grid synchronization) actually limits kernel's performance when merging workload is relatively large (e.g. in GQA or append prefill kernels). This PR splits the cooperative kernel to two kernels for append prefill kernels.
| [] | null | null |
flashinfer | c213c7b8b034b49a5cef3641a3e53622709be567 | 2024-01-03T07:48:57-08:00 | 48 | https://github.com/flashinfer-ai/flashinfer/pull/48 | [Performance] Accelerate append prefill kernel (#48) | [Performance] Accelerate append prefill kernel (#48)
We found that cooperative kernel (merge states in the same kernel afte
grid synchronization) actually limits kernel's performance when merging
workload is relatively large (e.g. in GQA or append prefill kernels).
This PR splits the cooperative kernel to two kerne... | include/flashinfer/utils.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/utils.cuh
+++ include/flashinfer/utils.cuh
@@ -19,12 +19,17 @@
#include <iostream>
-#define FLASHINFER_CUDA_CALL(func, ...) \
- { \
- cudaError_t e = (func); \
- if (e != cudaSuccess) { \
- return e; ... | 11 | 6 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/utils.cuh).
Goal: [Performance] Accelerate append prefill kernel
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "Lice... | We found that cooperative kernel (merge states in the same kernel afte grid synchronization) actually limits kernel's performance when merging workload is relatively large (e.g. in GQA or append prefill kernels). This PR splits the cooperative kernel to two kernels for append prefill kernels.
| [] | null | null |
flashinfer | de3a5e5b94e23ddf84a5f3a849cfcd3beb6e571a | 2024-01-01T02:02:30-08:00 | 41 | https://github.com/flashinfer-ai/flashinfer/pull/41 | [Performance] Cooperative prefill parameter tweak (#41) | [Performance] Cooperative prefill parameter tweak (#41)
Note that prefill kernel's synchronization overhead is larger than
decode's. A naive linear model might not be optimal is finding the best
chunk size. We should create an analytical cost model in the future. | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -1378,7 +1378,7 @@
min((num_blocks_per_sm * num_sm) /
(num_kv_heads *
ceil_div(qo_len * group_size, num_rows_per_cta)),... | 2 | 2 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: [Performance] Cooperative prefill parameter tweak
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the ... | Note that prefill kernel's synchronization overhead is larger than decode's. A naive linear model might not be optimal is finding the best chunk size. We should create an analytical cost model in the future.
| [] | null | null |
flashinfer | 2b36f652c1a219f47cf5d24b06e2c1d47b692513 | 2023-12-18T12:23:57Z | null | null | accelerate batch decode | accelerate batch decode | include/flashinfer/decode.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -553,8 +553,9 @@
* of "theta" used in RoPE (Rotary Positional Embeddings)
*/
template <bool return_lse, bool cooperative, RotaryMode rotary_mode, uint32_t const_page_size,
- uint32_t num_stages_smem, uint32_t vec_size, uint32_t bdx, ... | 106 | 61 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: accelerate batch decode
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not ... | [] | null | null | |
flashinfer | 2a3d6d038d3ee57904b150c0ad107556568c2c1f | 2023-12-17T12:44:32Z | null | null | accelerate single decode | accelerate single decode | include/flashinfer/decode.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -227,8 +227,8 @@
* \param kv_chunk_size A integer indicates the kv-chunk size
*/
template <QKVLayout layout, bool cooperative, RotaryMode rotary_mode, uint32_t num_stages_smem,
- uint32_t vec_size, uint32_t bdx, uint32_t bdy, uint32_t ... | 76 | 51 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: accelerate single decode
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not... | [] | null | null | |
flashinfer | ac09dec62c681cde006481fd86052245863359c7 | 2023-11-20T05:07:45Z | null | null | accelerate f16 qk accum | accelerate f16 qk accum | include/flashinfer/math.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/math.cuh
+++ include/flashinfer/math.cuh
@@ -84,12 +84,24 @@
* \brief Wrapper of PTX shfl.sync.bfly instruction, which performs a butterfly shuffle
* between threads in a warp.
* \param x The value in the source lane
- * \param delta The delta to perform thread index xor with: y[i] <- x[i... | 15 | 3 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/math.cuh).
Goal: accelerate f16 qk accum
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not us... | [] | null | null | |
flashinfer | ac09dec62c681cde006481fd86052245863359c7 | 2023-11-20T05:07:45Z | null | null | accelerate f16 qk accum | accelerate f16 qk accum | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -439,25 +439,28 @@
} else if constexpr (std::is_same<DTypeQKAccum, half>::value) {
#pragma unroll
for (uint32_t fx = 0; fx < num_frags_x; ++fx) {
+ half m_prev[2];
#pragma unroll
for (uint32_t j = 0; j < 2; ++j) {
- ha... | 17 | 8 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: accelerate f16 qk accum
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not... | [] | null | null | |
flashinfer | 3a962e7fe9c24374b7c8b7f9aede45785023f5dc | 2023-11-13T12:17:42Z | null | null | accelerate batch prefill | accelerate batch prefill | include/flashinfer/cp_async.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/cp_async.cuh
+++ include/flashinfer/cp_async.cuh
@@ -22,12 +22,18 @@
namespace cp_async {
+#if (__CUDACC_VER_MAJOR__ >= 11)
+#if (!defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 800))
+#define FLASHINFER_CP_ASYNC_ENABLED
+#endif
+#endif
+
/*!
* \brief Wrapper of PTX cp.async.commit_group ins... | 10 | 6 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/cp_async.cuh).
Goal: accelerate batch prefill
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may n... | [] | null | null | |
flashinfer | 3a962e7fe9c24374b7c8b7f9aede45785023f5dc | 2023-11-13T12:17:42Z | null | null | accelerate batch prefill | accelerate batch prefill | include/flashinfer/decode.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -18,7 +18,9 @@
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
+#ifdef FLASHINFER_ENABLE_FP8
#include <cuda_fp8.h>
+#endif
#include <cuda_runtime.h>
#include <cuda/pipeline> | 2 | 0 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: accelerate batch prefill
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not... | [] | null | null | |
flashinfer | 3a962e7fe9c24374b7c8b7f9aede45785023f5dc | 2023-11-13T12:17:42Z | null | null | accelerate batch prefill | accelerate batch prefill | include/flashinfer/mma.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/mma.cuh
+++ include/flashinfer/mma.cuh
@@ -26,6 +26,19 @@
namespace mma {
+#if (__CUDACC_VER_MAJOR__ >= 11)
+#if (!defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 900))
+#define FLASHINFER_STMATRIX_M8N8X4_ENABLED
+#endif
+#if (!defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 800))
+#define FLASHINFE... | 96 | 1 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/mma.cuh).
Goal: accelerate batch prefill
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not us... | [] | null | null | |
flashinfer | 3a962e7fe9c24374b7c8b7f9aede45785023f5dc | 2023-11-13T12:17:42Z | null | null | accelerate batch prefill | accelerate batch prefill | include/flashinfer/page.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/page.cuh
+++ include/flashinfer/page.cuh
@@ -145,7 +145,8 @@
seq_lens_before_split(seq_lens_before_split) {}
__host__ __device__ __forceinline__ size_t get_k_elem_offset(size_t page_idx, size_t head_idx,
- size_t entry_id... | 35 | 3 | 5 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/page.cuh).
Goal: accelerate batch prefill
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not u... | [] | null | null | |
flashinfer | 301dbd98452213243ef9e82079cbced9be1bbf73 | 2023-11-08T08:11:54Z | null | null | accelerate fused rotary prefill | accelerate fused rotary prefill | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -327,89 +327,67 @@
block.sync();
if constexpr (rotary_mode == RotaryMode::kLlama) {
- // apply rotary
- uint32_t a_frag[num_frags_x][2][4];
- uint32_t b_frag[2][4];
-
- // compute q*k^T
-#pragma unroll
- for (u... | 57 | 79 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: accelerate fused rotary prefill
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you... | [] | null | null | |
flashinfer | feb5aa58ae34b8596dfb809a77cdef8ec15dac8e | 2023-11-05T07:53:27Z | null | null | optimize order | optimize order
bugfix
further reorder | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | /*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -446,6 +446,13 @@
}
m[fx][j] = max(m[fx][j], math::shfl_xor_sync(m[fx][j], 0x2));
m[fx][j] = max(m[fx][j], math::shfl_xor_sync(m[fx][j], 0x1));
+#pragma unroll
+ for (uint32_t fz = 0; fz < num_frags_z; ++fz) {
+ ... | 25 | 21 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: optimize order
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
/*
* Copyright (c) 2023 by FlashInfer team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this... | [] | null | null | |
flashinfer | d5bf2c40e969e2d11c997c5208e9c88823b1322b | 2023-10-07T23:40:34Z | null | null | faster math | faster math | include/flashinfer/decode.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "page.cuh"
#... | #ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "math.cuh"
#include "cp_async.cuh"
#include "layout.cuh"
#... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -10,6 +10,7 @@
#include <iostream>
#include <random>
+#include "math.cuh"
#include "cp_async.cuh"
#include "layout.cuh"
#include "page.cuh"
@@ -95,12 +96,10 @@
for (size_t i = 0; i < vec_size; ++i) {
x += q_vec[i] * k_vec[i] * sm_scal... | 5 | 4 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: faster math
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#i... | [] | null | null | |
flashinfer | d5bf2c40e969e2d11c997c5208e9c88823b1322b | 2023-10-07T23:40:34Z | null | null | faster math | faster math | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "math.cuh"
#include "mma.cuh"
#incl... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -11,6 +11,7 @@
#include "cp_async.cuh"
#include "layout.cuh"
+#include "math.cuh"
#include "mma.cuh"
#include "permuted_smem.cuh"
#include "rope.cuh"
@@ -29,7 +30,6 @@
__device__ __forceinline__ void apply_llama_rope(T *x_first_half, T *x_... | 37 | 62 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: faster math
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>... | [] | null | null | |
flashinfer | d5bf2c40e969e2d11c997c5208e9c88823b1322b | 2023-10-07T23:40:34Z | null | null | faster math | faster math | include/flashinfer/state.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "vec_dtypes.cuh"
namespace flashinfer {
/*!
* \brief The flashattention state.
* \tparam vec_size The size of the vector used in o.
* \tparam norm_on_the_fly Whether to normalize the state on the fly. If true, the state will be
* normalized w... | #ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "math.cuh"
#include "vec_dtypes.cuh"
namespace flashinfer {
/*!
* \brief The flashattention state.
* \tparam vec_size The size of the vector used in o.
* \tparam norm_on_the_fly Whether to normalize the state on the fly. If true, the state will ... | --- include/flashinfer/state.cuh
+++ include/flashinfer/state.cuh
@@ -1,6 +1,7 @@
#ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
+#include "math.cuh"
#include "vec_dtypes.cuh"
namespace flashinfer {
@@ -36,17 +37,17 @@
float other_d) {
float m_prev = m,... | 9 | 7 | 3 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/state.cuh).
Goal: faster math
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "vec_dtypes.cuh"
namespace flashinfer {
/*!
* \brief The flashattentio... | [] | null | null | |
flashinfer | 01dc8ab9d1808b650086b95cd683c03f7f658d27 | 2023-10-06T06:04:34Z | null | null | parameter tuning | parameter tuning | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -194,7 +194,7 @@
size_t consumer_kv_idx_base = 0;
size_t effective_kv_len =
causal ? min(kv_len, (kv_len - qo_len) + ((bx + 1) * num_warps) * mma::frag_size) : kv_len;
-#pragma unroll 8
+#pragma unroll 16
for (size_t iter = 0; iter... | 2 | 2 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: parameter tuning
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp... | [] | null | null | |
flashinfer | 60144a5d26b70fe3325681eecd18c042494d4a78 | 2023-10-02T07:47:08Z | null | null | slight optimization | slight optimization | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -105,6 +105,7 @@
float m_prev[2]{-5e4};
float m[2]{-5e4};
float d[2]{0.f};
+ float o_scale[2]{0.f};
float rope_freq[num_frags_y][4];
if constexpr (rotary_mode == RotaryMode::kLlama) {
#pragma unroll
@@ -269,7 +270,8 @@
m_... | 6 | 6 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: slight optimization
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda... | [] | null | null | |
flashinfer | 6c5603c5de54cce10dc13e246112866934ee08d1 | 2023-09-30T01:36:02-07:00 | null | null | accelerate online softmax states | accelerate online softmax states | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -262,16 +262,28 @@
for (size_t fz = 0; fz < num_frags_z; ++fz) {
float m_local = max(max(x_frag[fz][j * 2 + 0], x_frag[fz][j * 2 + 1]),
max(x_frag[fz][j * 2 + 4], x_frag[fz][j * 2 + 5]));
- float... | 18 | 9 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: accelerate online softmax states
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#... | [] | null | null | |
flashinfer | 6c5603c5de54cce10dc13e246112866934ee08d1 | 2023-09-30T01:36:02-07:00 | null | null | accelerate online softmax states | accelerate online softmax states | include/flashinfer/state.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "vec_dtypes.cuh"
namespace flashinfer {
__device__ __forceinline__ void merge_md(float &m, float &d, const float other_m,
const float other_d) {
float m_prev = m, d_prev = d;
m = max(m_prev, other_m);
... | #ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "vec_dtypes.cuh"
namespace flashinfer {
/*!
* \brief The flashattention state.
* \tparam vec_size The size of the vector used in o.
*/
template <size_t vec_size>
struct state_t {
vec_t<float, vec_size> o; /* the weighted sum of v: exp(pre-soft... | --- include/flashinfer/state.cuh
+++ include/flashinfer/state.cuh
@@ -4,13 +4,6 @@
#include "vec_dtypes.cuh"
namespace flashinfer {
-
-__device__ __forceinline__ void merge_md(float &m, float &d, const float other_m,
- const float other_d) {
- float m_prev = m, d_prev = d;
-... | 0 | 7 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/state.cuh).
Goal: accelerate online softmax states
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_STATE_CUH_
#define FLASHINFER_STATE_CUH_
#include "vec_dtypes.cuh"
namespace flashinfer {
__device__... | [] | null | null | |
flashinfer | 9e3d33dce74837701186d4aa7bdf6f4c6f12f3e1 | 2023-09-29T21:17:42-07:00 | null | null | accelerate scale and mask | accelerate scale and mask | include/flashinfer/prefill.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | #ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <iostream>
#include <random>
#include "cp_async.cuh"
#include "layout.cuh"
#include "mma.cuh"
#include "permuted_smem.c... | --- include/flashinfer/prefill.cuh
+++ include/flashinfer/prefill.cuh
@@ -153,6 +153,21 @@
}
block.sync();
+ // multiply q by sm_scale
+ vec_t<DTypeIn, 2> sm_scale2;
+ sm_scale2.fill(sm_scale);
+#pragma unroll
+ for (size_t fy = 0; fy < num_frags_y; ++fy) {
+#pragma unroll
+ for (size_t reg_id = 0; reg_i... | 21 | 15 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/prefill.cuh).
Goal: accelerate scale and mask
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_PREFILL_CUH_
#define FLASHINFER_PREFILL_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include... | [] | null | null | |
flashinfer | 2977506bad2b49727a65e04211373f53816432ee | 2023-09-01T02:21:12-07:00 | null | null | fix sm80 performance issue | fix sm80 performance issue | include/flashinfer/decode.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "rope.cuh"
#include "state.cuh"
#include "vec_dtypes.cuh"
... | #ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "rope.cuh"
#include "state.cuh"
#include "vec_dtypes.cuh"
... | --- include/flashinfer/decode.cuh
+++ include/flashinfer/decode.cuh
@@ -377,6 +377,14 @@
} \
}
+#define CUDA_CALL(func, ...) \
+ { \
+ cudaError_t e = (func); \
+ if (e != cudaSuccess) { \
+ retur... | 16 | 7 | 1 | [] | [
"SM80"
] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer/decode.cuh).
Goal: fix sm80 performance issue
Target hardware: SM80
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_DECODE_CUH_
#define FLASHINFER_DECODE_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp... | [] | null | null | |
flashinfer | 3ef9ff57443e7cfe7fcf685a046f7e988c7f5309 | 2023-08-31T03:01:17-07:00 | null | null | bugfix and accelerate | bugfix and accelerate | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace cg = cooperative_gro... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace cg = cooperative_gro... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -76,30 +76,44 @@
}
template <size_t vec_size>
-__device__ __forceinline__ void merge_state(float &m, float &d, vec_t<float, vec_size> &o,
- float other_m, float other_d,
- c... | 123 | 87 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: bugfix and accelerate
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cud... | [] | null | null | |
flashinfer | 848d04bd9a18d793c880d4607c4c58e11f92e0e4 | 2023-08-25T00:53:00-07:00 | null | null | accelerate rotary | accelerate rotary | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace {
temp... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace {
temp... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -71,9 +71,8 @@
* used in RoPE (Rotary Positional Embeddings).
*/
template <size_t vec_size, typename T>
-__device__ __forceinline__ vec_t<float, vec_size> apply_rotary(const T *input, size_t offset,
- ... | 20 | 16 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: accelerate rotary
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#inc... | [] | null | null | |
flashinfer | bb422fe34bb6321f1f7146da7a8b9be48f73b598 | 2023-08-24T02:02:01-07:00 | null | null | performance improvement | performance improvement | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace {
temp... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
#include <cuda_fp8.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
#include "vec_dtypes.cuh"
namespace flashinfer {
namespace {
temp... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -69,12 +69,13 @@
* in position interpolation for ROPE(Rotary Positional Embeddings).
*/
template <size_t vec_size, typename T>
-__device__ __forceinline__ vec_t<T, vec_size> apply_rotary(T *input, size_t offset, size_t head_dim,
- ... | 113 | 74 | 2 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: performance improvement
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h... | [] | null | null | |
flashinfer | 2fbb11e546c5c1f4698046ab7c7232b0e1947d5e | 2023-08-10T01:27:08-04:00 | null | null | explore peak performance | explore peak performance | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -108,7 +108,7 @@
if (compute_qk) {
#pragma unroll
- for (size_t j = 0; j < h_chunk_size; ++j) {
+ for (size_t j = 0; j < 1; ++j) {
float k_local = 0.f;
if (apply_rotary_to_k) {
// do not inplace update
@@ -126,7 +126,7 @@
}... | 10 | 8 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: explore peak performance
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runti... | [] | null | null | |
flashinfer | 92035e999de73d4310640fa7c99ee8c9a5dbdfa3 | 2023-08-08T03:35:31-04:00 | null | null | update schedule, performance not idea yet | update schedule, performance not idea yet | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -267,13 +267,13 @@
block.sync();
#pragma unroll
- for (int j = 0; j < h_chunk_size; ++j) {
+ for (int j_ = 0; j_ < h_chunk_size; ++j_) {
+ int j = (j_ + grid.block_rank()) % h_chunk_size;
int head_idx = head_idx_start + j;
// critical region ... | 43 | 16 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: update schedule, performance not idea yet
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#in... | [] | null | null | |
flashinfer | 4ce367372bafeee1b839b8ef75551c8635eb10e6 | 2023-08-07T02:32:26-07:00 | null | null | fixed all numerical issues, and address the performance degration for long sequences, I'll fix the performance for short sequence tmr | fixed all numerical issues, and address the performance degration for long sequences, I'll fix the performance for short sequence tmr | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -98,31 +98,36 @@
* \tparam apply_rotary_to_k A boolean indicates whether to apply rotary positional embeddings to k
* \tparam DTypeIn A template type indicates the input data type
*/
-template <int num_warps, bool apply_rotary_to_k, typename DTypeIn>
+templ... | 124 | 87 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: fixed all numerical issues, and address the performance degration for long sequences, I'll fix the performance for short sequence tmr
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#de... | [] | null | null | |
flashinfer | d4096e0e432562103cd89f1b62d2b5d30318e7d6 | 2023-08-06T22:54:01-07:00 | null | null | fixed bug and passed all tests, performance degration because of non-consecutive read, will fix it in the next PR | fixed bug and passed all tests, performance degration because of non-consecutive read, will fix it in the next PR | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -50,6 +50,19 @@
kApplyRotaryUpdateLastK = 2U,
};
+inline std::string RotaryModeToString(const RotaryMode &rotary_mode) {
+ switch (rotary_mode) {
+ case RotaryMode::kNone:
+ return "None";
+ case RotaryMode::kApplyRotary:
+ return "ApplyRot... | 76 | 77 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: fixed bug and passed all tests, performance degration because of non-consecutive read, will fix it in the next PR
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_... | [] | null | null | |
flashinfer | 65b4f7035b4fe2e187065bf13990d8149e726cec | 2023-08-02T21:00:39Z | null | null | speed up | speed up | include/flashinfer.cuh | cuda | Apache-2.0 | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val) {
#pragma unroll
f... | #ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include <cuda/pipeline>
#include <iostream>
#include <random>
namespace flashinfer {
namespace {
template <typename T>
__device__ T warpReduceSum(T val, unsigned int mask = ... | --- include/flashinfer.cuh
+++ include/flashinfer.cuh
@@ -13,22 +13,53 @@
namespace {
template <typename T>
-__device__ T warpReduceSum(T val) {
+__device__ T warpReduceSum(T val, unsigned int mask = 0xffffffff) {
#pragma unroll
for (int offset = warpSize / 2; offset > 0; offset /= 2) {
- val += __shfl_down_... | 77 | 23 | 1 | [] | [] | [] | Optimize this cuda kernel file from flashinfer (include/flashinfer.cuh).
Goal: speed up
Target hardware: unspecified
Target models: unspecified
Current file:
```cuda
#ifndef FLASHINFER_CUH_
#define FLASHINFER_CUH_
#include <cooperative_groups/memcpy_async.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
#include ... | [] | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.