refactor: unify paged and contiguous attention kernels via KVSource policy

- merge AttentionParams and PagedAttentionParams into one struct
- add attn_kv_source.cuh with ContigKV/PagedKV addressing policies
- template prefill/decode kernels (MMA + scalar) on the KV policy, deleting the four duplicated attn_paged_*.cuh variants
- template dispatcher launchers on KV; single combine kernel
- verify: all correctness tests pass and SASS matches baseline (no perf regression)
This commit is contained in:
2026-08-05 14:06:13 +08:00
parent 6dffb0305a
commit 2667b8116d
17 changed files with 415 additions and 890 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ inline void attn_pack_paged_decode_params(
c10::optional<torch::Tensor> mask,
int64_t causal_offset,
double scale,
PagedAttentionParams<T>& p
AttentionParams<T>& p
) {
const at::cuda::OptionalCUDAGuard device_guard(device_of(q));
@@ -229,7 +229,7 @@ inline void attn_pack_paged_prefill_params(
int64_t max_q_len,
int64_t causal_offset,
double scale,
PagedAttentionParams<T>& p
AttentionParams<T>& p
) {
const at::cuda::OptionalCUDAGuard device_guard(device_of(q));