[None][feat] add VisualGen SOL sparse attention - #9
Closed
heyuhhh wants to merge 1 commit into
Closed
Conversation
This was referenced Sep 3, 2026
Merged
heyuhhh
force-pushed
the
user/yuhangh/vsa-block-sparse-integration
branch
from
September 3, 2026 20:04
6a5b339 to
81d4fb7
Compare
heyuhhh
force-pushed
the
user/yuhangh/sol-attention-integration
branch
from
September 3, 2026 20:04
e86650d to
318bf98
Compare
heyuhhh
force-pushed
the
user/yuhangh/vsa-block-sparse-integration
branch
from
September 4, 2026 04:11
81d4fb7 to
1f4e3ad
Compare
heyuhhh
force-pushed
the
user/yuhangh/sol-attention-integration
branch
from
September 4, 2026 04:20
318bf98 to
52a3d5c
Compare
heyuhhh
force-pushed
the
user/yuhangh/vsa-block-sparse-integration
branch
from
September 4, 2026 04:54
1f4e3ad to
ad0165b
Compare
heyuhhh
force-pushed
the
user/yuhangh/sol-attention-integration
branch
from
September 4, 2026 04:54
52a3d5c to
48769dc
Compare
Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
heyuhhh
force-pushed
the
user/yuhangh/sol-attention-integration
branch
from
September 4, 2026 14:55
48769dc to
b5e6d2d
Compare
heyuhhh
force-pushed
the
user/yuhangh/vsa-block-sparse-integration
branch
from
September 4, 2026 14:55
ad0165b to
6e34838
Compare
qsang-nv
pushed a commit
to flashinfer-ai/flashinfer
that referenced
this pull request
Sep 7, 2026
## 📌 Description This PR extends PrimTS contiguous block-sparse attention with **proxy compensation** and a packed **bitmask** sparse format. The proxy path keeps selected blocks exact while approximating omitted KV blocks with one arithmetic-mean K summary and one summed-V summary per semantic KV block. Route preparation emits score-keep metadata so a block already covered by an exact route is not counted again by its proxy. The softmax denominator is corrected by the represented token mass, including the true length of the final partial KV block. ### Sol-Attn motivation and scope This PR is intended to provide the PrimTS **core-attention** substrate for [Sol-Attn's sparse-attention flow](https://github.com/NVlabs/Sana/tree/sol-engine/techniques/sparse_backends), described in the [Sol-Attn paper](https://arxiv.org/abs/2607.24027). Sol-Attn identifies critical KV blocks for exact computation and reuses block-level proxy information from omitted blocks to approximate their contribution during online softmax. At the API boundary, the intended flow is: `prediction / routing (out of scope) → exact-block BSR or bitmask + K/V summaries → PrimTS route preparation → proxy-compensated core attention` This PR implements only the PrimTS route-preparation and core-attention stages. It does **not** include the Sol-Attn predictor, thresholding and exact-block selection, summary generation, or the end-to-end Sana integration; callers provide the selected-block metadata and K/V summaries. ### Bitmask format In addition to canonical BSR `block_indptr` / `block_indices`, contiguous block-sparse attention can now consume packed `UInt32` exact-block bitmaps owned per `(batch, KV head, Q block)`. Each bit selects one semantic KV block and out-of-range padding bits in the final word are ignored. BSR and bitmask inputs are prepared into the same internal route stream, so the attention core remains format-independent. Bitmask and proxy modes can be combined: set bits use raw K/V exact routes, while unset blocks are represented by proxy summaries. Both reusable plan/run and one-shot contiguous APIs are supported. Proxy execution currently requires a dense mask; paged-KV proxy execution is outside this PR. The PR also teaches Trace Apply to honor a runtime-selected trace template, which keeps BSR/bitmask and exact/proxy schemas isolated instead of binding every call to template zero. ## 📊 Proxy overhead Controlled A/B on one NVIDIA B200 with identical inputs, exact-block pattern, capacity, and static scheduler; only `use_proxy_routes` and the required summaries change. | Path | Proxy disabled | Proxy enabled | Additional overhead | | --- | ---: | ---: | ---: | | Public `BlockSparseTSWrapper.run` | 1.3172 ms | 1.4298 ms | **+8.55%** | | Prevalidated adapter | 1.3162 ms | 1.4318 ms | **+8.78%** | Workload: BF16 Q/K/V `[1, 32760, 12, 128]`, Q-block 64, KV-block 64, physical KV route 256, dense bitmask, and 84 of 512 exact blocks per row (16.4%). Proxy adds two prepared routes per row (21 → 23). Results use five balanced rounds with 80 CUDA-event samples per arm (400 samples/arm). Timings include route preparation and attention; summary construction is excluded. Each mode was checked against its own independent reference because proxy compensation intentionally changes the output semantics. Kernel split diagnostic: attention p50 increased by 7.64% (1.1261 → 1.2121 ms); prepare increased by 0.0030 ms (0.0145 → 0.0176 ms). ## 🧪 Tests - [x] `tests/trace_apply/test_trace_apply.py`: 26 passed - [x] `tests/trace/test_fi_trace_template_consistency.py`: 774 passed - [x] `tests/attention/test_attention_ts_block_sparse.py`: 140 passed, 88 skipped - [x] BK8 SWAPS and BK64 Keeps GPU proxy validation passed for both BSR and bitmask - [x] BSR/bitmask results are bitwise identical in the focused GPU cases; final-word padding bits are ignored - [x] Repository pre-commit hooks passed, including mypy, Ruff check, and Ruff format ## 🚀 Pull Request Checklist ### ✅ Pre-commit Checks - [x] I have run the hooks manually and fixed all reported issues. ### ✅ Tests - [x] Tests have been added or updated as needed. - [x] All targeted tests are passing. ## Reviewer Notes The commits are separated into generic runtime trace dispatch, block-sparse functionality, focused correctness/trace tests, and review-driven cleanup. `experimental/sol_attention` is not part of this PR. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added BSR and bitmask routing options for block-sparse attention. * Added proxy-route support using caller-provided K/V summaries. * Added route-specific validation and metadata handling for wrapper and one-shot APIs. * Expanded tracing to support all sparse format and route-mode combinations. * Improved trace application to select and execute only the runtime-matched template. * **Documentation** * Documented contiguous bitmask routing, proxy routes, capacity semantics, and summary behavior. * **Tests** * Added GPU coverage for BSR and bitmask proxy routes and multi-template trace dispatch. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ## Current integration stack (2026-09-04) - This branch is rebased onto FlashInfer `main` `60b49158ab4fb81718aef486c2d3c89aec4c1901`; current PR head: `6b5b2d31f3314be77ccf6655c899b7b971863a1a`. - The TRT-LLM composite pin is [heyuhhh/flashinfer@`71bf7842`](https://github.com/heyuhhh/flashinfer/tree/yuhangh/tmp-sol-attn-trtllm-pr17399), which reapplies all eight commits from Yuxian's newest `trtllm-prims-ts` head (`edddf6f5`) on top of this PR. - TensorRT-LLM stack: [#17399 PrimTS base](NVIDIA/TensorRT-LLM#17399) → [general block-sparse FMHA](yuxianq/TensorRT-LLM#2) → [VisualGen VSA/shared workflow](heyuhhh/TensorRT-LLM#7) → [VisualGen SOL integration](heyuhhh/TensorRT-LLM#9). - Final B200 integration verification includes raw/proxy/paged generic routes, VSA CUDA Graph live routes, SOL all-exact parity, and mixed proxy parity at sequence lengths 256 and 257. --------- Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
Owner
Author
|
Superseded by the re-stacked pull requests now that NVIDIA#17399 has merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is the focused VisualGen SOL layer stacked on VisualGen VSA #7. Generic sparse runtime transport and PrimTS block-sparse execution remain in PR #2.
Dependencies
SOL commit:
b5e6d2d354(feat: add VisualGen SOL sparse attention).Summary
SolAttentionConfigand the VisualGenSOLTrtllmAttentionbackend.SparseRuntimeParams.block_sparse_inputs.Scope
This single-commit layer contains no
benchmark-results/and makes no separate performance claim. Kernel implementation and performance evidence remain in FlashInfer NVIDIA#4872; this PR covers TensorRT-LLM VisualGen integration and correctness.Validation