Conversation
10fbec9 to
7446583
Compare
ad0165b to
6e34838
Compare
6e34838 to
39c3ebb
Compare
a912915 to
e4d992d
Compare
|
PR_Github #74760 [ run ] completed with state
|
| import torch | ||
|
|
||
|
|
||
| def timestep_to_float(timestep: object) -> Optional[float]: |
There was a problem hiding this comment.
@bobboli can you please help review the ss-related changes?
Mirror tests/unittest/_torch/attention/sparse: each algorithm owns a folder under visual_gen/sparse_attention with its backend behavior tests, its kernel tests and a parity module that runs the TRTLLM and CuTeDSL backends on the same inputs and compares them with dense attention and with each other. The CuTeDSL SOL tests merge into the SOL behavior module, the VSA module tests leave the attention integration module, and the CPU and B200 test lists follow the new paths. The SOL parity module sweeps the routing threshold from a value few blocks reach to one most blocks clear and checks both backends against the exact-token/proxy-summary contract of the routes the predictor emits, so a backend that routes a borderline block differently fails locally instead of hiding behind a global similarity to dense attention. Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
…n the model matrix Replace the VSA section of the model guide with a short overview of the three sparse attention algorithms that points to the feature guide, and move the VSA requirements, configuration and examples into the feature guide next to the SOL section. The feature matrix now carries a SOL-Attn column: SOL is a runtime feature of the TRTLLM and CuTeDSL backends, while VSA needs a fine-tuned checkpoint and stays a model row. Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
75fca39 to
f5046d3
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #74963 [ run ] triggered by Bot. Commit: |
Hi @karljang , I have updated the description and added the LPIPS and Speedups with the PrimsTS kernels. Could you help check the results of LPIPS? Because i found that the case of dense TRTLLM v.s. dense CuteDSL has a LPIPS value of 0.303, it's a little strange for me. The others looks make sense and consistent for me. |
|
PR_Github #74963 [ run ] completed with state
|
SOLTrtllmAttention reports support_fused_qkv() == False because its in-core route prediction needs separate Q, K and V, and the VisualGen TRTLLM wrapper turned that into "always pass separate tensors". A dense layer or a dense-phase step returns no routes, so the core fell back to the standard TRTLLM attention op, which serves dense self-attention from fused QKV only and failed with "only fused QKV is supported now". The documented SOL configuration (disabled_until_timestep with dense_layers) therefore could not run on the TRTLLM backend, in eager mode or under CUDA Graph capture. The wrapper now requests separate Q, K and V from such a backend only for calls that run its sparse path; dense-layer and dense-phase calls take the existing fused path. The decision uses the host timestep the metadata adapter prepares, and the sparse phase is already part of the CUDA Graph key, so both phases capture. SkipSoftmax and VSA report fused support and are unchanged. Tests: the SOL behavior module checks that dense-layer and dense-phase calls reach the stubbed core as fused QKV without prediction; the SOL parity module runs the real op for a dense layer and a dense-phase step against dense attention with no block-sparse launch, then a sparse step of the same backend through the block-sparse FMHA. Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
The per-algorithm test reorganization merged tests/unittest/_torch/visual_gen/test_attention_cute_dsl_sol_attn.py into sparse_attention/sol/test_sol_attention.py and removed the old file, but l0_b300.yml still listed the old path, so the B300 unit-test stage failed to collect it. The list validator only checks entries with node ids, which is why the stale file entry passed pre-commit. The replacement module carries the same CuTeDSL SOL tests under the same CUDA gate. Signed-off-by: yuhangh <58161490+heyuhhh@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #75041 [ run ] triggered by Bot. Commit: |
|
PR_Github #75041 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #75117 [ run ] triggered by Bot. Commit: |
|
PR_Github #75117 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #75152 [ run ] triggered by Bot. Commit: |
|
PR_Github #75152 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #75179 [ run ] triggered by Bot. Commit: |
|
PR_Github #75179 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #75202 [ run ] triggered by Bot. Commit: |
Description
VisualGen sparse attention on the PrimTS block-sparse FMHA merged in #18815. VisualGen ships two block-sparse algorithms for DiT video models; this PR gives both a TRTLLM backend (Triton predictor + generic block-sparse FMHA) next to the existing CuTeDSL kernels, selected by
AttentionConfig.backendunder one configuration per algorithm:VideoSparseAttentionConfig): coarse/fine Video Sparse Attention for the FastVideo VSA checkpoints. Metadata, route prediction and post-processing are shared by the TRTLLM and CuTeDSL backends (attention_backend/sparse/vsa); the TRTLLM backend runs the top-k prediction as Triton kernels and the fine stage through the block-sparse FMHA, with dense fallback, packed or separate QKV, TP, Ulysses and CUDA Graph support.SolAttentionConfig:tau,thresh_type,disabled_until_timestep,dense_layers): the TRTLLM backend runs the SOL predictor as a functional Triton operator (block pooling, key statistics,diag/exactthresholds, exact-block selection) and executes the exact blocks plus proxy K/V summaries through the block-sparse FMHA (proxy-compensated attention from feat(prims-ts): support proxy-compensated block-sparse attention flashinfer-ai/flashinfer#4872). The fused CuTeDSL Sol-Attn kernel of [TRTLLM-15917][feat] Integrate Sol-Attn sparse attention into VisualGen #18329 stays as the CUTEDSL backend of the same config.attention/backends/sparse/timestep_phase.py) used by SkipSoftmax, both SOL backends and a singlesparse_attn_phaseCUDA Graph key; the VisualGen TRTLLM wrapper passes separate Q/K/V and block-sparse routes into the core for sparse calls, fuses QKV for the dense-layer and dense-phase calls of a route-predicting backend (the TRTLLM kernel serves dense self-attention from fused QKV only), and shares one FMHA plan cache per model component through the new optionalfmha_stateconstructor argument ofTrtllmAttention. These two are the only core attention changes.Behavior notes: per-token timesteps reduce to their largest live value, so a Wan 2.2 5B I2V conditioning frame at timestep zero no longer disables a configured dense prefix; SkipSoftmax dense and sparse CUDA graphs are keyed per phase on every model with a cutoff, including LTX-2. Docs:
docs/source/features/visualgen-sparse-attention.md(per-algorithm guide) and theSOL-Attncolumn indocs/source/models/visual-generation.md.Performance and accuracy of the TRTLLM backends
One B200,
Wan2.1-VSA-T2V-14B-720P, 720x1280, seed 42, guidance 5.0, prompt "A cat sitting on a sunny windowsill watching birds outside.", CUDA Graph on, torch.compile off. Long = 81 frames (75,600 tokens per stream), Short = 9 frames (10,800 tokens). Deployment settings follow the documentation: SOLtau=1.0,diag,disabled_until_timestep=0.6,dense_layers=[0, 2, 3, 4], which on this checkpoint's UniPC schedule (flow shift 3.0) runs 34 of 50 steps dense and 16 sparse; VSA has no dense prefix or dense-layer option and follows the checkpoint recipe, sparsity 0.9 at 81 frames and 0.875 at 9 frames. LPIPS is AlexNet on the raw frames, scaled to [-1, 1], mean over frames (the normalization ofscripts/visualgen_eval/visual_gen_lpips_score_eval.py); scoring the same clips as H.264 MP4 agrees within 0.005 except on near-identical pairs, where the codec adds 0.01 to 0.015.End to end, 50 denoising steps (the timed request after warmup and one settle request):
Sparse phase alone (the dense prefix disabled so every timed step is sparse; ms per self-attention call, mean over 40 layers and 24 Long / 48 Short timed steps, CUDA events inside the captured graph). This is the kernel-level comparison the end-to-end numbers are built from:
On Long the TRTLLM backends spend 2.7 ms (SOL) and 5.8 ms (VSA) per call in the Triton predictors, against 7.2 ms of in-kernel preprocessing for SOL CuTeDSL and 15.8 ms for the VSA CuTeDSL predictor; the rest of the gap is the block-sparse FMHA itself (57.6 vs 120.5 ms for SOL, 36.0 vs 52.0 ms for VSA). The end-to-end SOL speedup is smaller than the per-call one because the documented example runs 34 of 50 steps and 4 of 40 layers dense.
LPIPS under the deployment settings (mean over frames; lower is closer). The dense TRTLLM pipeline is bit-exact run to run and between eager and CUDA Graph, so every non-zero value is kernel numerics amplified by the sampler; two exact dense kernels (TRTLLM vs CuTeDSL) already differ by 0.30 after 50 steps, which is the floor for any cross-kernel pair:
With the dense prefix, each SOL backend reproduces the sample of its own dense kernel (PSNR 38 dB on Long), and the two SOL backends differ from each other by exactly the dense-kernel floor. VSA converges to a different, clean sample than dense at 0.9 sparsity; both VSA backends agree on that sample within the floor on Long, and the Short VSA pair (0.42) is the most sensitive case (same scene, different framing, at a 9-frame workload the VSA checkpoint was not trained for). With the SOL prefix disabled entirely, SOL likewise converges to its own sample (LPIPS 0.79 vs dense for both backends, 0.10 between them). Kernel-level closeness is asserted by the parity tests in
sparse_attention/{sol,vsa}/test_*_parity.py.Test Coverage
Unit tests live in
tests/unittest/_torch/visual_gen/sparse_attention/{skip_softmax,sol,vsa}/, mirroringtests/unittest/_torch/attention/sparse: per algorithm the backend behavior tests, the kernel tests and a parity module that runs the TRTLLM and CuTeDSL backends on the same inputs and compares them with dense attention and with each other (the SOL parity sweepstau2 / 1 / 0 against the exact-block/proxy-summary contract of the predicted routes, and runs a dense layer and a dense-phase step of the TRTLLM backend through the real kernel against dense attention).l0_b200.ymlregisters the VSA and SOL modules andtest_trtllm_attention_metadata.py(TRTLLM skip-softmax CUDA Graph capture under an SM100 gate);l0_b300.ymlregisters the SOL module for the sm103 stage in place of the merged CuTeDSL file;l0_cpu.ymlregisters the skip-softmax module and the CPU-only parts of the SOL modules.Run on B200 with an SM100 build (CUTLASS DSL 4.8.0.dev0; the changes are Python-only):
sparse_attention/sol/after the dense-call fix: GPU stage (-m "not cpu_only") 61 passed, CPU stage (-m cpu_only, CUDA hidden) 73 passed; the wholesparse_attention/CPU stage 185 passed. The deployment-setting measurements above were taken with that fix.maina1c6c2b:sparse_attention/GPU stage 142 passed plus the 14 SOL parity cases; CPU stage 113 passed.test_attention_integration.py,test_fa4_cutlass_compatibility.pyand the VSA kernel tests: 129 passed.test_attention_mla.py,test_fmha_manager.py,test_fmha_registry.py,sparse/test_flashinfer_utils.py: 205 passed, 1 skipped.test_ltx2_pipeline.pyandtest_ltx2_transformer.py: 67 passed. HunyuanVideo 1.5 and GLM-Imagetest_fp8_trtllm_attention: 2 passed.test_wan_vsa_pipeline.py::TestWanVsa14B_PipelineCorrectness::test_cosine_similarity: 1 passed.sparse_attention/,test_visual_gen_args.py,test_trtllm_attention_metadata.py,test_timestep_phase.py: 188 passed, 29 skipped.PR Checklist
pre-commithooks passDev Engineer Review
QA Engineer Review
l0_b200.ymlandl0_cpu.ymlwith VSA, SOL, CUDA Graph, metadata, backend, and predictor entries.Per-File QA Perspective
l0_b200.yml: Adds B200 VSA, SOL, CUDA Graph, and metadata coverage.l0_cpu.yml: Adds CPU SOL backend and predictor coverage.