Repository navigation
Conversation
2838707 to
685f1ca
Compare
|
/bot run |
|
PR_Github #79985 [ run ] triggered by Bot. Commit: |
|
PR_Github #79985 [ run ] completed with state
|
685f1ca to
4e80131
Compare
|
/bot run |
4e80131 to
fe23c60
Compare
|
/bot run |
fe23c60 to
18c66a1
Compare
|
/bot run |
|
PR_Github #80963 [ run ] triggered by Bot. Commit: |
|
PR_Github #80963 [ run ] completed with state
|
18c66a1 to
4c9e660
Compare
|
/bot run |
|
PR_Github #81007 [ run ] triggered by Bot. Commit: |
|
PR_Github #81007 [ run ] completed with state
|
4c9e660 to
c07064e
Compare
|
/bot run |
|
PR_Github #81720 [ run ] triggered by Bot. Commit: |
|
PR_Github #81720 [ run ] completed with state
|
|
/bot run |
c07064e to
4d1031d
Compare
|
/bot run |
|
PR_Github #82943 [ run ] triggered by Bot. Commit: |
|
PR_Github #82943 [ run ] completed with state
|
4d1031d to
271ac69
Compare
|
/bot run |
|
PR_Github #86457 [ run ] completed with state
|
| @@ -0,0 +1,257 @@ | |||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |||
There was a problem hiding this comment.
@yuxianq Could you help review this part or suggest someone who could? thanks
e7e4b6c to
d7af346
Compare
|
/bot run |
|
PR_Github #86814 [ run ] triggered by Bot. Commit: |
|
PR_Github #86814 [ run ] completed with state
|
|
/bot run |
|
PR_Github #87018 [ run ] triggered by Bot. Commit: |
|
PR_Github #87018 [ run ] completed with state
|
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
| # availability rules (SM, sparse layers) also cover this path. | ||
| self._prequantized_fp8_lib: Optional[Fmha] = None | ||
| if is_per_tensor_fp8(quant_attention_config): | ||
| self._prequantized_fp8_lib = next( |
There was a problem hiding this comment.
If TrtllmGenDenseFp8Fmha is only used here, and there will not be other fmha libs support prequantized_fp8, why do we add TrtllmGenDenseFp8Fmha to fmha_libs and extract it here? Can we directly use it here or even declare it inside visual_gen? Then we don't need to modify the shared interface.py and registry.py.
| """ | ||
| return False | ||
|
|
||
| def run_prequantized( |
There was a problem hiding this comment.
Don't need a new interface, we can reuse the existed forward, just add v_descale to AttentionForwardArgs, other arguments can be parsed from existed q/k/v/metadata/forward_args.
| """ | ||
| return True | ||
|
|
||
| def supports_prequantized_fp8(self, fp8_output: bool = False) -> bool: |
There was a problem hiding this comment.
We prefer to use class variable supports_prequantized_fp8 instead. If you need more complex check method, define it for supports_prequantized_fp8=True fmha libs only instead of in the shared interface.
yuxianq
left a comment
There was a problem hiding this comment.
Please reconsider the design of TrtllmGenDenseFp8Fmha as I commented above.
…as_scaled_mm epilogues - trtllm::fused_residual_norm_quant: gated residual x + gate * (y + bias), then LayerNorm / AdaLN and static FP8 quantization in one row kernel; hidden any multiple of 1024 up to 8192, device and argument checks. - cublas_scaled_mm: bias / GELU epilogues and e4m3 output (d_scale) through CublasMMWrapper (epilogue, D scale and separate D layout setters; tuned LUT only for bf16 outputs without GELU). Defaults unchanged. - fused_dit_qk_norm_rope_fp8_supported: support query for the FP8 QK norm + RoPE producer. - Tests: row kernel vs torch, supported widths, fake op under compile; GEMM epilogues vs torch (bias / GELU x bf16 / e4m3). Signed-off-by: Tin-Yin Lai <[email protected]>
…-gen dense FP8 kernels - VisualGen DenseFp8Attention (visual_gen/attention/backends/dense_fp8.py): dense, per-tensor FP8 self-attention on trtllm::fmha_dense_fp8. Built by the VisualGen TRTLLM backend for layers with a per-tensor FP8 quant_attention_config on SM107; MHA only, no sparse layers. Shared FMHA code is unchanged. - BF16 Q/K/V are quantized per tensor; pre-quantized e4m3 Q/K/V with the softmax scale folded into Q/K take the FP16-softmax kernels, BF16 or e4m3 output, probed per output dtype at construction. - Self-attention: fused QK norm + RoPE + FP8 quantization hands e4m3 Q/K/V to the kernel; Ulysses moves them through the all-to-all with one V scale per group. - Cross-attention and Attention2D / Ring run the same recipe on cuDNN FP8 (masked cross-attention on VANILLA). - cuDNN forward_with_lse returns the LSE as [B, H, S], the layout the Attention2D / Ring merges read. - AttentionConfig accepts the per-tensor FP8 recipe for TRTLLM on SM107. - Tests: Ulysses FP8 vs one GPU and CUDA graph replay, BF16 cuDNN under Attention2D (2x2, 4x1) and Ring vs SDPA, LSE layout, recipe validation. Signed-off-by: Tin-Yin Lai <[email protected]>
…e_fp8_block_fusions) - Linear / MLP: bias and GELU in the FP8 GEMM epilogue, FP8 output into the next GEMM; off for row-parallel TP partial outputs. - WanBlock.plan_fp8_fusions() enables them after weight load when every site qualifies: residual + norm + FP8 quantization in the row kernel, biases in epilogues or the next row kernel, FFN GELU with FP8 output, FP8 attention output into to_out. Other configurations keep the existing path; with the key on, a warning lists the reasons and block counts. - WanPipeline key enable_fp8_block_fusions (default false); pipeline_config bool keys must be bools. - Docs: the key, its scope (WanPipeline) and the validated setup. - Tests: dense FP8 attention and routing, fused vs unfused block with distinct per-Linear scales, compile, planner rejections, config keys. Signed-off-by: Tin-Yin Lai <[email protected]>
d7af346 to
012a157
Compare
|
/bot run |
|
PR_Github #87313 [ run ] triggered by Bot. Commit: |
|
PR_Github #87313 [ run ] completed with state
|
Description
Part 2 of Wan 2.2 fused fp8 on Rubin (SM107). Part 1 (#20005, merged) added the ops. This PR uses them in VisualGen attn and the Wan block. No env vars; each fusion is picked only when its conditions hold, otherwise current code runs.
3 commits, review in order:
1. fp8 ops
trtllm::fused_residual_norm_quant: gated residual + LayerNorm / AdaLN + static fp8 quant in one row kernel. hidden any multiple of 1024 up to 8192.cublas_scaled_mm: bias / gelu epilogues and e4m3 output, throughCublasMMWrapper(epilogue, D scale, separate D layout setters). defaults unchanged.fused_dit_qk_norm_rope_fp8_supported: support query for the fp8 qk prep.2. fp8 attn
DenseFp8Attentioninvisual_gen/attention/backends/dense_fp8.py: per-tensor fp8 self-attn ontrtllm::fmha_dense_fp8. the VisualGen TRTLLM backend builds it for layers with a per-tensor fp8quant_attention_configon SM107 (MHA, no sparse). shared FMHA code (_torch/attention/) untouched.[B, H, S]. Attention2D / Ring merge in this layout, so cuDNN + Attention2D / Ring gives wrong output on main today (bf16 too).AttentionConfigaccepts the per-tensor fp8 recipe for TRTLLM on SM107.3. static fp8 Wan block (opt-in,
WanPipelinepipeline_configenable_fp8_block_fusions, default off)WanBlock.plan_fp8_fusions()turns these on after weight load when every site qualifies. TP, per-token temb, async Ulysses and VSA keep current code, with one warning listing reasons and block counts.WanPipelineonly; I2V / FastWan reject it) and the validated setup (SM107, Wan 2.2 A14B static fp8, per-tensor fp8 attn). other GPUs / bf16 attn run but are unit-test covered only.not in this PR: Attention2D on the dense fp8 kernels (needs LSE), Ulysses comm overlap, cross-block AdaLN handoff,
_forward_fp8restructure of the block forward.Test Coverage
test_wan_fp8.py: dense fp8 attn vs SDPA / cuDNN fp8, fp8 producer (eager, compile),DenseFp8Attentionrules and routing (cpu), fused vs unfused block with distinct per-Linear scales and gates near 1,state_dictunchanged after planning, compile, planner rejections,enable_fp8_block_fusionsparsing (cpu).multi_gpu/test_ulysses_attention.py(fp8 section): Ulysses U2 / U4 vs single GPU, CUDA graph replay, Attention2D on cuDNN fp8.multi_gpu/test_attn2d_attention.py,multi_gpu/test_ring_attention.py: bf16 cuDNN inner backend vs SDPA (Attention2D 2x2 / 4x1, Ring). 2x2 and Ring fail on main without the LSE fix.kernels/parallel/test_fused_dit_qk_norm_rope_fp8.py: row kernel vs torch, supported widths, fake op under compile.kernels/parallel/test_scaled_mm.py(epilogue): bias / gelu x bf16 / e4m3 vs torch.test_attention_cudnn.py: LSE layout.test_visual_gen_args.py: SM107 recipes.Dev Engineer Review
enable_fp8_block_fusionsdefaults to off.cublas_scaled_mmAPI adds cuBLASLt epilogues and optional output scaling. Check that callers, registered schemas, and fake operators agree, especially when E4M3 output requiresd_scale.[B, H, S_q]. Verify all consumers that merge attention results use this layout.QA Engineer Review
test_fp8_scaled_mm_epilogue,test_fp8_scaled_mm_epilogue_rejects_bad_arguments,test_residual_norm_quant_matches_reference,test_ulysses_fp8_matches_single_gpu,test_ulysses_fp8_cuda_graph_replay, andtest_attn2d_fp8_runs_on_cudnn. Wan tests also cover fused blocks, attention, and pipeline configuration.l0_cpu.ymladdstest_wan_fp8.py.l0_gr100.ymladdstest_wan_fp8.py, the fused QK norm/RoPE test file, andtest_scaled_mm.py -k "epilogue". The modified Ulysses and cuDNN tests are present in the existingl0_dgx_b200andl0_b200lists. No manual-QA list changes appear in this diff.Per-File QA Perspective
cpp/tensorrt_llm/kernels/fusedResidualNormQuantKernel.cu: Verify residual, LayerNorm, and AdaLayerNorm variants, optional inputs, hidden-size limits, and zero-row behavior.cpp/tensorrt_llm/kernels/fusedResidualNormQuantKernel.h: Verify declared parameter shapes and modes match kernel validation and output behavior.cpp/tensorrt_llm/thop/CMakeLists.txt: Verify the new operator source is included in the intended build target.cpp/tensorrt_llm/thop/cublasScaledMM.cpp: Verify epilogue selection, scale requirements, dtype handling, and cuBLASLt algorithm selection.test_scaled_mm.pycovers epilogue cases and is listed inl0_gr100with an epilogue selector.cpp/tensorrt_llm/thop/cublasScaledMM.h: Verify the new default arguments match the registered operator and its callers.cpp/tensorrt_llm/thop/fusedDiTQKNormRopeFp8Op.cpp: Verify the support query matches actual device and layout support.cpp/tensorrt_llm/thop/fusedResidualNormQuantOp.cpp: Verify PyTorch-side validation and empty-tensor returns match each kernel mode.tensorrt_llm/_torch/attention/backends/fmha/interface.py: Verify backends handle the prequantized-FP8 capability and method contract.tensorrt_llm/_torch/attention/backends/fmha/registry.py: Verify registration order preserves intended backend precedence.tensorrt_llm/_torch/attention/backends/fmha/trtllm_gen_dense_fp8.py: Verify support gates, Q/K/V scaling, output scaling, and rejection of unsupported request shapes. Wan FP8 tests cover dense and prequantized attention;test_wan_fp8.pyis listed inl0_gr100andl0_cpu.tensorrt_llm/_torch/custom_ops/cpp_custom_ops.py: Verify fake operator outputs and optional arguments match the real operators during compilation.tensorrt_llm/_torch/modules/linear.py: Verify static-FP8 epilogue eligibility andforward_without_bias, including output-reduction cases.tensorrt_llm/_torch/modules/mlp.py: Verify fused GELU eligibility anddefer_down_bias, including the LoRA error path.tensorrt_llm/_torch/visual_gen/attention/attention.py: Verify fused-QKV eligibility, deferred output bias, and fallback behavior for cross-attention and extra arguments. Wan FP8 tests cover attention output and routing.tensorrt_llm/_torch/visual_gen/attention/backends/cudnn.py: Verify LSE consumers use[B, H, S_q]. The modified cuDNN test is listed inl0_b200.tensorrt_llm/_torch/visual_gen/attention/backends/interface.py: Verify backend FP8 capabilities, V-amax handling, and unsupported default behavior.tensorrt_llm/_torch/visual_gen/attention/backends/parallel.py: Verify FP8 all-to-all exchange and V-amax reduction for supported world sizes. The modified Ulysses test is listed inl0_dgx_b200.tensorrt_llm/_torch/visual_gen/attention/backends/trtllm.py: Verify FP8 library selection and prequantized tensor reshaping.tensorrt_llm/_torch/visual_gen/models/wan/pipeline_wan.py: Verifyenable_fp8_block_fusionsdefaults to off and pipeline overrides reach model configuration. Related tests are listed inl0_cpuandl0_gr100.tensorrt_llm/_torch/visual_gen/models/wan/transformer_wan.py: Verify fusion gates and fused results against the unfused path. Wan fusion tests are intest_wan_fp8.py, listed inl0_cpuandl0_gr100.tensorrt_llm/_torch/visual_gen/models/wan/utils_wan.py: Verify mode selection, row reshaping, and optional residual and normalization outputs.tensorrt_llm/visual_gen/args.py: Verify the SM107 dense-FP8 recipe is accepted only for supported configurations.tests/integration/test_lists/test-db/l0_cpu.yml: Addstest_wan_fp8.pyto the CPU test list.tests/integration/test_lists/test-db/l0_gr100.yml: Adds the fused QK norm/RoPE test file andtest_wan_fp8.py; adds the scaled-MM epilogue selector.tests/unittest/_torch/kernels/parallel/test_scaled_mm.py: Adds scaled-MM epilogue output and invalid-argument tests. The epilogue selector is inl0_gr100.tests/unittest/_torch/visual_gen/kernels/parallel/test_fused_dit_qk_norm_rope_fp8.py: Adds residual-norm-quant reference, support-boundary, CPU-scale rejection, and compile tests. The file is listed inl0_gr100.tests/unittest/_torch/visual_gen/multi_gpu/test_ulysses_attention.py: Adds FP8 Ulysses reference, graph-replay, and Attention2D cuDNN tests. The file is listed inl0_dgx_b200.tests/unittest/_torch/visual_gen/test_attention_cudnn.py: Updates the LSE shape expectation and retains cuDNN attention coverage. The file is listed inl0_b200.tests/unittest/_torch/visual_gen/test_wan_fp8.py: Adds Wan block-fusion, dense/prequantized attention, compilation, fallback, and pipeline-configuration tests. The file is listed inl0_cpuandl0_gr100.