Skip to content

[TRTLLM-15864][chore] Consolidate the VisualGen attention domain under _torch/visual_gen/attention/ - #20214

Merged
YihuiLu512 merged 2 commits into
NVIDIA:mainfrom
YihuiLu512:feat-dev-J15864
Oct 14, 2026
Merged

YihuiLu512 merged 2 commits into
NVIDIA:mainfrom
YihuiLu512:feat-dev-J15864

Conversation

@YihuiLu512

@YihuiLu512 YihuiLu512 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Pure move, mirroring #17968:

Before After
tensorrt_llm/_torch/visual_gen/attention_backend/ tensorrt_llm/_torch/visual_gen/attention/backends/
tensorrt_llm/_torch/visual_gen/modules/attention.py tensorrt_llm/_torch/visual_gen/attention/attention.py

All references, CODEOWNERS, and the groovy file list are updated.

visual_gen.modules no longer re-exports Attention/QKVMode (no in-repo users); #20215 restores it lazily.

Forwarding shims for the old paths come in a follow-up PR, because a shim left at the old path in this squash commit would break rename detection and git blame.

Please hold #19751 and #19358 until the shim PR merges. They add files under the old directory.

Test Coverage

Existing VisualGen tests. Locally, against base: every moved file is detected as a rename, the collected test set is identical, and the l0_cpu VisualGen results are identical.

PR Checklist

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

Dev Engineer Review

The change consolidates VisualGen attention code under tensorrt_llm/_torch/visual_gen/attention/. It moves the backend package and modules/attention.py, then updates source imports, documentation, ownership rules, and the Groovy multi-GPU file list to use the new paths.

visual_gen.modules no longer re-exports Attention or QKVMode. Callers that import these symbols from that package must update; a lazy compatibility re-export is planned for a follow-up. No forwarding shims are included, so consumers of the old module paths must also update. Review finding counts are unavailable.

QA Engineer Review

The change updates existing VisualGen unit-test imports but does not report changes to test functions or test IDs. The PR description reports that the collected test set is unchanged. It also reports identical local l0_cpu VisualGen results. CI comments report failures in two L0 pipelines but do not identify the failing tests. Coverage verdict: needs follow-up until those failures are understood.

Per-File QA Perspective

  • tensorrt_llm/_torch/visual_gen/attention/attention.py: Verify attention construction and calls after updating backend imports.
  • tensorrt_llm/_torch/visual_gen/attention/backends/**: Verify backend imports and behavior after the package move, especially relative imports in sparse and parallel backends.
  • tensorrt_llm/_torch/visual_gen/modules/__init__.py: Verify callers no longer rely on modules re-exporting Attention or QKVMode.
  • VisualGen model files under tensorrt_llm/_torch/visual_gen/models/: Verify model imports resolve from the relocated attention modules.
  • tests/unittest/_torch/visual_gen/**: Updated test imports retain existing coverage, including multi-GPU, sparse attention, backend, and integration behavior. Test-list membership is not established by the supplied evidence.
  • .github/CODEOWNERS, jenkins/L0_MergeRequest.groovy, and documentation files: These updates align ownership, multi-GPU file selection, and documented paths with the new layout; verify the intended review ownership and CI selection.

@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77489 [ run ] triggered by Bot. Commit: e9c6265 Link to invocation

@YihuiLu512
YihuiLu512 enabled auto-merge (squash) October 13, 2026 09:34
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 26cbd6c7-4c57-4eaa-9a52-fc251ef88eeb
📥 Commits

Reviewing files that changed from the base of the PR and between bed96f3 and debb28a.

📒 Files selected for processing: 77
  • .github/CODEOWNERS
  • cpp/tensorrt_llm/thop/asyncUlyssesOp.cpp
  • docs/source/blogs/tech_blog/blog25_Scaling_Video_Generation_Across_NVL72_Rack_with_TensorRT-LLM.md
  • docs/source/features/visualgen-quantized-attention.md
  • jenkins/L0_MergeRequest.groovy
  • tensorrt_llm/_torch/visual_gen/attention/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/attention.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/cudnn.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/cute_dsl/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/cute_dsl/fmha.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/flash_attn4.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/flashinfer.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/interface.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/parallel.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/backend.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/kernels.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/params.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/predictor.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/__init__.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/backend.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/kernels.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/metadata.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/predictor.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/trtllm.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/utils.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/vanilla.py
  • tensorrt_llm/_torch/visual_gen/cute_dsl_kernels/blackwell/sol_attn_backend.py
  • tensorrt_llm/_torch/visual_gen/models/cosmos3/transformer_cosmos3.py
  • tensorrt_llm/_torch/visual_gen/models/flux/attention.py
  • tensorrt_llm/_torch/visual_gen/models/flux/pos_embed_flux.py
  • tensorrt_llm/_torch/visual_gen/models/glm_image/transformer_glm_image.py
  • tensorrt_llm/_torch/visual_gen/models/hunyuan_video1_5/transformer_hunyuan_video1_5.py
  • tensorrt_llm/_torch/visual_gen/models/ltx2/transformer_ltx2.py
  • tensorrt_llm/_torch/visual_gen/models/minimax_h3/transformer_minimax_h3.py
  • tensorrt_llm/_torch/visual_gen/models/qwen_image/transformer_qwen_image.py
  • tensorrt_llm/_torch/visual_gen/models/wan/pipeline_wan.py
  • tensorrt_llm/_torch/visual_gen/models/wan/transformer_wan.py
  • tensorrt_llm/_torch/visual_gen/modules/__init__.py
  • tensorrt_llm/visual_gen/sparse_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_attn2d_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_cosmos3_transformer_parallel.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_flux2_transformer_parallel.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_ltx2_ulysses.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_qwen_image_attention_parallel.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_ring_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_tp_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_ulysses_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_ulysses_sage_attention.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_wan_async_ulysses.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_wan_pipeline_parallel.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_wan_tp.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_wan_transformer_parallel.py
  • tests/unittest/_torch/visual_gen/multi_gpu/test_wan_vsa_ulysses.py
  • tests/unittest/_torch/visual_gen/sparse_attention/skip_softmax/test_skip_softmax.py
  • tests/unittest/_torch/visual_gen/sparse_attention/sol/test_sol_attention.py
  • tests/unittest/_torch/visual_gen/sparse_attention/sol/test_sol_parity.py
  • tests/unittest/_torch/visual_gen/sparse_attention/sol/test_sol_predictor.py
  • tests/unittest/_torch/visual_gen/sparse_attention/sol/test_sol_predictor_kernels.py
  • tests/unittest/_torch/visual_gen/sparse_attention/vsa/test_vsa_attention.py
  • tests/unittest/_torch/visual_gen/sparse_attention/vsa/test_vsa_kernels.py
  • tests/unittest/_torch/visual_gen/sparse_attention/vsa/test_vsa_parity.py
  • tests/unittest/_torch/visual_gen/test_attention_cudnn.py
  • tests/unittest/_torch/visual_gen/test_attention_cute_dsl.py
  • tests/unittest/_torch/visual_gen/test_attention_fa4.py
  • tests/unittest/_torch/visual_gen/test_attention_flashinfer.py
  • tests/unittest/_torch/visual_gen/test_attention_integration.py
  • tests/unittest/_torch/visual_gen/test_attention_perf.py
  • tests/unittest/_torch/visual_gen/test_attention_qkv_share.py
  • tests/unittest/_torch/visual_gen/test_fa4_cutlass_compatibility.py
  • tests/unittest/_torch/visual_gen/test_minimax_h3_transformer.py
  • tests/unittest/_torch/visual_gen/test_qwen_image_pipeline_config.py
  • tests/unittest/_torch/visual_gen/test_trtllm_attention_metadata.py
  • tests/unittest/_torch/visual_gen/test_vanilla_key_padding_mask.py
  • tests/unittest/_torch/visual_gen/test_wan_vsa_pipeline.py
💤 Files with no reviewable changes: 12
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/params.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/utils.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/init.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/interface.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/init.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/init.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/metadata.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/cute_dsl/init.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/init.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/kernels.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/predictor.py
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/vsa/kernels.py
🚧 Files skipped from review as they are similar to previous changes: 7
  • cpp/tensorrt_llm/thop/asyncUlyssesOp.cpp
  • tensorrt_llm/_torch/visual_gen/models/flux/pos_embed_flux.py
  • tensorrt_llm/_torch/visual_gen/cute_dsl_kernels/blackwell/sol_attn_backend.py
  • docs/source/blogs/tech_blog/blog25_Scaling_Video_Generation_Across_NVL72_Rack_with_TensorRT-LLM.md
  • tensorrt_llm/_torch/visual_gen/attention/backends/sparse/sol/backend.py
  • docs/source/features/visualgen-quantized-attention.md
  • .github/CODEOWNERS

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

Visual Gen attention modules and references now use the attention package hierarchy instead of the former attention_backend and modules.attention paths. Backend imports, model callers, tests, and repository references were updated. The modules package no longer exports Attention or QKVMode.

Changes

Visual Gen attention package reorganization

Layer / File(s) Summary
Attention package and backend imports
tensorrt_llm/_torch/visual_gen/attention/*, tensorrt_llm/_torch/visual_gen/modules/__init__.py
The attention package documents its layout. Backend imports use corrected relative paths. modules.__init__ no longer exports Attention or QKVMode.
Production callers use the new paths
tensorrt_llm/_torch/visual_gen/models/*, tensorrt_llm/visual_gen/sparse_attention.py, tensorrt_llm/_torch/visual_gen/cute_dsl_kernels/...
Visual Gen model and sparse-attention imports and code references use the reorganized attention paths.
Repository references and tests
.github/CODEOWNERS, cpp/tensorrt_llm/thop/asyncUlyssesOp.cpp, docs/source/features/visualgen-quantized-attention.md, docs/source/blogs/tech_blog/*, jenkins/L0_MergeRequest.groovy, tests/unittest/_torch/visual_gen/*
Tests and repository references use the new package paths. Ownership and multi-GPU change-detection entries cover the updated locations.

Priority: ⬇️ Low

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

Change: Refactor

Suggested reviewers: chzblych, zhenhuaw-me

Merge Risk: ⚪ Minimal · up to debb2

The reorganization has no established current-head merge-blocking risk.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 50 files. (15 skipped… 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 identifies the chore and the primary change: consolidating the VisualGen attention domain under the new package path.
Description check Passed The description explains the move, lists updated references, documents deferred compatibility shims, identifies affected dependent PRs, and provides relevant test coverage. The required Description, T…
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: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 50 files. (15 skipped: 4 unsupported, 11 over the file limit.)

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

Comment @coderabbitai help to get the list of available commands.

@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77555 [ run ] triggered by Bot. Commit: bed96f3 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77555 [ run ] completed with state SUCCESS. Commit: bed96f3
/LLM/main/L0_MergeRequest_PR pipeline #63935 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

…r _torch/visual_gen/attention/

Move the VisualGen attention backends and the DiT attention module into one
domain package:

  _torch/visual_gen/attention_backend/   -> _torch/visual_gen/attention/backends/
  _torch/visual_gen/modules/attention.py -> _torch/visual_gen/attention/attention.py

Relative imports that leave the moved subtree gain one dot for the new
depth; modules/__init__.py resolves Attention/QKVMode lazily to avoid an
import cycle; CODEOWNERS, the groovy related-file list, docs and comments
follow the new paths. No old path is left behind, so git records every move
as a rename; forwarding shims follow in a separate change.

Signed-off-by: Yihui Lu <269394165+YihuiLu512@users.noreply.github.com>
- Drop the Attention/QKVMode re-export from visual_gen/modules/__init__.py;
  nothing in the repo imports them from there, and the forwarding for
  out-of-tree callers belongs with the shims in the follow-up PR.
- Restore the Lightricks copyright line in transformer_ltx2.py.
- Update the remaining stale references to the old attention_backend path
  (cute_dsl/fmha.py docstring, blog25 links).

Signed-off-by: Yihui Lu <269394165+YihuiLu512@users.noreply.github.com>
@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77587 [ run ] triggered by Bot. Commit: debb28a Link to invocation

@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77623 [ run ] triggered by Bot. Commit: debb28a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77587 [ run ] completed with state ABORTED. Commit: debb28a

Link to invocation

@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77686 [ run ] triggered by Bot. Commit: debb28a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77623 [ run ] completed with state ABORTED. Commit: debb28a

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77686 [ run ] completed with state SUCCESS. Commit: debb28a
/LLM/main/L0_MergeRequest_PR pipeline #64043 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77711 [ run ] triggered by Bot. Commit: debb28a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #77711 [ run ] completed with state SUCCESS. Commit: debb28a
/LLM/main/L0_MergeRequest_PR pipeline #64064 completed with status: 'SUCCESS'

CI Report

Link to invocation

@YihuiLu512
YihuiLu512 merged commit 57aef03 into NVIDIA:main Oct 14, 2026
chang-l added a commit to chang-l/TensorRT-LLM that referenced this pull request Oct 14, 2026
Resolve conflicts with upstream NVIDIA#20214, which consolidated the VisualGen
attention domain under _torch/visual_gen/attention/:

- modules/attention.py moved to attention/attention.py; the PR's changes
  carry over. The L0_MergeRequest.groovy path filter now points at the
  new location, and parallel/ stays.
- Point the two PR-added imports of the moved module at the new path
  (parallel/token_sharded_modules.py, test_token_sharded_tp_layout.py).
- Keep both new multi-GPU unit tests in l0_cpu.yml.
- Feature matrix: keep the token-sharded TP footnote and the SOL-Attn
  column.

Signed-off-by: Chang Liu <9713593+chang-l@users.noreply.github.com>
@YihuiLu512

Copy link
Copy Markdown
Collaborator Author

shim PR:#20215

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.

7 participants