Skip to content

[None][fix] Enable the fused per-token AdaLN on SM103 (B300/GB300) - #21396

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:adaln-sm103
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:adaln-sm103

Conversation

@0z5a

@0z5a 0z5a commented Nov 1, 2026 •

Copy link
Copy Markdown

Description

The fused per-token AdaLN for WAN VisualGen (#17695) is gated on exactly compute capability 10.0, in two places:

  • the kernel launch in pertoken_adaln.py raises ValueError("fused per-token AdaLN requires an SM100 GPU");
  • _pertoken_adaln_arch_ok in utils_wan.py returns False, so WAN takes the unfused path.

As a result, B300/GB300 (10.3) always run the unfused eager path.

The kernel itself has nothing SM100-specific. PerTokenAdaLN and reduce.py use only thread_idx/block_idx, shuffle_sync_down, sync_threads and vectorized copies. There is no tcgen05, TMA or TMEM, and cute.compile JIT-compiles it for the device it runs on. sol_attn/interface.py already relies on the same reasoning for SM103 ("no SM100-exclusive construct (measured identical on B200 and B300)").

This PR admits 10.0 and 10.3, and still excludes 10.7, matching is_blackwell_datacenter():

  • pertoken_adaln.py: the launch check accepts (10, 0) and (10, 3).
  • utils_wan.py: _pertoken_adaln_arch_ok uses the same check.
  • test_pertoken_adaln.py: the skip now admits 10.3.
  • test_wan22_ti2v_5b_pipeline.py: the two fused-path engagement asserts now also expect the fused path on 10.3.

Test Coverage

On one B300 (CC 10.3), with nvidia-cutlass-dsl 4.8.0, apache-tvm-ffi 0.1.13.post2 and PyTorch 2.14.0+cu130 as in requirements.txt, I ran the kernel package (pertoken_adaln.py byte-identical to this PR, and to main at 309426d for the baseline) against the kernel-level tests of test_pertoken_adaln.py. Those tests compare against an FP32 reference and cover torch.compile fullgraph and contract checks. I loaded the kernel package standalone and left out the WAN-module test, which needs the full package.

Result
main 5 failed (ValueError: fused per-token AdaLN requires an SM100 GPU), 2 passed (the contract-only tests)
this PR 7 passed

I did not run utils_wan.py or test_wan22_ti2v_5b_pipeline.py, which need the full package and the WAN 2.2 checkpoint, and did not measure the end-to-end speedup on B300. #17695 measured 4.3% end-to-end on B200.

ruff check and ruff format --check pass on the changed files.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

Dev Engineer Review

  • The fused per-token AdaLN kernel launch and Wan architecture check now accept compute capabilities 10.0 and 10.3. Other capabilities, including 10.7, remain ineligible.
  • The change is limited to architecture gating and test assertions. The supplied results do not show a test run or end-to-end speed measurement for this change. The reported B200 measurement is from an earlier PR.

QA Engineer Review

  • test_pertoken_adaln.py now permits tests on compute capability 10.3. The author reports 7 kernel-level tests passing on B300, including FP32-reference comparisons, torch.compile fullgraph coverage, and contract checks. The file is listed in the l0_b200.yml CI list.
  • test_wan22_ti2v_5b_pipeline.py now checks the fused path on capabilities 10.0 and 10.3. It is listed in the l0_b200.yml CI list and the llm_function_core.txt manual-QA list. The author did not run this pipeline test because it requires the full package and WAN 2.2 checkpoint.
  • Coverage verdict: needs follow-up. The kernel tests reportedly pass, but the Wan pipeline coverage and B300 end-to-end behavior remain unverified.

Per-File QA Perspective

  • pertoken_adaln.py: Verify fused-kernel dispatch on SM100 and SM103, and confirm unsupported capabilities still raise ValueError.
  • utils_wan.py: Verify the Wan model selects fused per-token AdaLN on SM100 and SM103 and keeps it disabled on other architectures.
  • test_pertoken_adaln.py: Covers kernel behavior, compilation, and contracts on supported devices. It is listed in the CI test list.
  • test_wan22_ti2v_5b_pipeline.py: Covers fused-path assertions and combined optimizations for the Wan 2.2 TI2V pipeline. It appears in both the CI and manual-QA lists; execution remains unreported.

The WAN VisualGen fused per-token AdaLN was gated on exactly compute
capability 10.0 at the kernel launch and in _pertoken_adaln_arch_ok, so
B300/GB300 (10.3) always took the unfused eager path. The kernel uses
only SIMT CuTe DSL constructs (warp shuffles, CTA reductions, vectorized
copies) and is JIT-compiled for the running device, so admit 10.0 and
10.3 (but not 10.7), and update the test skips and fused-path
assertions to match.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@0z5a
0z5a requested a review from a team as a code owner November 1, 2026 22:00
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 309426d and b3a5bba.

Files selected for processing: 4
  • tensorrt_llm/_torch/visual_gen/kernels/blackwell/pertoken_adaln/pertoken_adaln.py
  • tensorrt_llm/_torch/visual_gen/models/wan/utils_wan.py
  • tests/unittest/_torch/visual_gen/test_pertoken_adaln.py
  • tests/unittest/_torch/visual_gen/test_wan22_ti2v_5b_pipeline.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The per-token AdaLN kernel launch and Wan architecture eligibility check now accept SM103 (10, 3) alongside SM100 (10, 0). Unit and pipeline tests include both capabilities in their architecture checks.

Changes

Per-token AdaLN architecture support

Layer / File(s) Summary
Runtime architecture checks
tensorrt_llm/_torch/visual_gen/kernels/blackwell/pertoken_adaln/pertoken_adaln.py, tensorrt_llm/_torch/visual_gen/models/wan/utils_wan.py
The per-token AdaLN launch and Wan eligibility check accept compute capabilities (10, 0) and (10, 3). Other capabilities remain unsupported by these checks.
Architecture test checks
tests/unittest/_torch/visual_gen/test_pertoken_adaln.py, tests/unittest/_torch/visual_gen/test_wan22_ti2v_5b_pipeline.py
The per-token AdaLN unit and pipeline tests include compute capability (10, 3) in their architecture checks. The unit test still skips when CUDA is unavailable or the capability is unsupported.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: chang-l

Merge Risk: Minimal · up to b3a5b

The change is mergeable based on the consistent runtime and test architecture checks; full pipeline validation remains environment-dependent.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely states the main change: enabling fused per-token AdaLN on SM103.
Description check Passed The description includes the required Description, Test Coverage, and PR Checklist sections. It explains the issue and solution, reports test results and limitations, and marks the checklist as review…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required Description, Test Coverage, and PR Checklist sections. It explains the issue and solution, reports test results and limitations, and marks the checklist as reviewed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant