Skip to content

[TRTLLM-15177][chore] Consolidate trtllm-gen SiTu activation slot handling - #17414

Open
brnguyen2 wants to merge 2 commits into
NVIDIA:mainfrom
brnguyen2:k3/15177-situ-activation
Open

[TRTLLM-15177][chore] Consolidate trtllm-gen SiTu activation slot handling#17414
brnguyen2 wants to merge 2 commits into
NVIDIA:mainfrom
brnguyen2:k3/15177-situ-activation

Conversation

@brnguyen2

@brnguyen2 brnguyen2 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Consolidate the trtllm-gen SiTu activation slot handling, a review follow-up from #17269 tracked in TRTLLM-15177 (item 1.2).

Included

  • Complete item 1.2(b): delete the separate situ_alpha/situ_beta parameters and reuse the swiglu_alpha/swiglu_beta storage. SiTu and SwiGLU are mutually exclusive and feed the same gemm1_alpha/gemm1_beta op slots, so the slot now has a single backing parameter and the interim _gemm1_activation_params accessor is gone.
  • Audited every swiglu_alpha is not None gate for behavior neutrality: create_moe.py validates the constructor kwargs (still None for SiTu; the storage is populated later in create_weights); _get_quant_method consults swiglu_alpha only on the nvfp4 branch (SiTu requires W4A8_MXFP4_MXFP8) and runs before the storage is populated; _check_configs's swiglu gate admits w4a8_mxfp4_mxfp8 and its SiTu branch validates the merged storage; the NVFP4 post-load swiglu_beta rescale is not in SiTu's MXFP4 quant-method ancestry; _validate_backend_local_activation runs from __init__ and still rejects constructor-provided SwiGLU parameters for SiTu.
  • Document, in _torch/utils.py, the deliberate decision to keep SiTu in the trtllm-gen-local ActType_TrtllmGen rather than adding it to the shared ActivationType. The shared enum mirrors the cutlass enum in common.h and drives cutlass kernels; SiTu exists only in the trtllm-gen batched-GEMM kernels, so adding it to the shared enum would force a cutlass member no kernel implements.

Validation

Run on a Blackwell (SM100-class) node:

  • tests/unittest/_torch/modules/moe/test_kimi_k3_situ_moe.py — full suite pass, including fused-vs-reference SiTu parity and MoE-TP shard-loader / TP8 sharded-forward parity.
  • tests/unittest/_torch/modules/moe/test_moe_backend.py -k trtllm — pass; covers the trtllm-gen SwiGLU leg including gptoss-style per-expert swiglu_alpha/swiglu_beta/swiglu_limit on W4A8_MXFP4_MXFP8, proving the merge did not regress the SwiGLU path.
  • tests/unittest/_torch/modules/moe/test_moe_module.py -k "trtllm and not multi_gpu" — pass (single-GPU ConfigurableMoE coverage). The DEP multi-GPU comm parametrizations are not runnable in this single-node harness (they need pre-spawned MPI ranks) and are covered by CI.
  • Kimi KDA spot checks: tests/unittest/_torch/modules/kimi_kda/ and tests/unittest/_torch/modeling/test_kimi_kda_{fused_,}verify_parity.py — pass.
  • Truncated Kimi K3 end-to-end sanity (4 layers, TP4, fused SiTu MoE path): load -> prefill -> decode -> shutdown, pass.

No enum values changed, so the Python/cutlass and Python/KernelRunner.h mappings are untouched.

Related: TRTLLM-15177

Dev Engineer Review

  • SiTu now reuses swiglu_alpha and swiglu_beta storage.
  • Separate SiTu buffers and _gemm1_activation_params access were removed.
  • Validation, meta-device reinitialization, and MoE execution use the shared storage.
  • SiTu and SwiGLU remain mutually exclusive.
  • Documentation explains why SiTu remains in ActType_TrtllmGen.
  • No exported API, enum value, or mapping changes were found.
  • waives.txt adds the layer-wise benchmark waiver for the bug tracked in PR #17414.

QA Engineer Review

  • No test-db/ or qa/ files were modified.
  • Added unittest/tools/test_layer_wise_benchmarks.py::test_performance_alignment[1] to waives.txt.
  • CBTS coverage data is unavailable.
  • Verdict: needs follow-up.
  • File a tracking bug for the CI-waived test(s) and record it with pr-babysitter waive set-bug NVIDIA/TensorRT-LLM#17414 <bug-url> — the waives entry carries a placeholder until then

@brnguyen2
brnguyen2 marked this pull request as ready for review August 7, 2026 14:08
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

SiTu activation parameters now use shared swiglu_alpha and swiglu_beta tensors throughout TRTLLM-Gen fused MoE validation, initialization, materialization, and execution. Documentation defines SiTu as backend-local. An integration test waiver was added.

Changes

SiTu parameter storage

Layer / File(s) Summary
Shared SiTu parameters
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py, tensorrt_llm/_torch/utils.py
The fused MoE module stores SiTu values in non-trainable swiglu_alpha and swiglu_beta parameters. Validation, materialization, and GEMM1 execution use these tensors. Documentation explains why SiTu remains separate from ActivationType.

Benchmark test waiver

Layer / File(s) Summary
Performance-alignment waiver
tests/integration/test_lists/waives.txt
The waiver list skips test_performance_alignment[1] and references PR #17414.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: qijune, barry-delaney, xxi-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the change, rationale, affected paths, validation, and related tracking item; the unchecked waiver-bug item is non-critical.
Title check ✅ Passed The title is concise, specific, and accurately summarizes the consolidation of TRTLLM-Gen SiTu activation slot handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 2
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch k3/15177-situ-activation
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64616 [ run ] triggered by Bot. Commit: e4e12fa Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64616 [ run ] completed with state SUCCESS. Commit: e4e12fa
/LLM/main/L0_MergeRequest_PR pipeline #52476 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64651 [ run ] triggered by Bot. Commit: e4e12fa Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64651 [ run ] completed with state SUCCESS. Commit: e4e12fa
/LLM/main/L0_MergeRequest_PR pipeline #52511 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@brnguyen2
brnguyen2 force-pushed the k3/15177-situ-activation branch from e4e12fa to be08d33 Compare August 7, 2026 18:20
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64674 [ run ] triggered by Bot. Commit: be08d33 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64674 [ run ] completed with state FAILURE. Commit: be08d33
/LLM/main/L0_MergeRequest_PR pipeline #52531 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64683 [ run ] triggered by Bot. Commit: be08d33 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64683 [ run ] completed with state SUCCESS. Commit: be08d33
/LLM/main/L0_MergeRequest_PR pipeline #52539 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64700 [ run ] triggered by Bot. Commit: be08d33 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64700 [ run ] completed with state SUCCESS. Commit: be08d33
/LLM/main/L0_MergeRequest_PR pipeline #52556 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --stage-list "DGX_B200-PyTorch-8, GH200-PackageSanityCheck-PY312-UB2404"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64733 [ run ] triggered by Bot. Commit: be08d33 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64733 [ run ] completed with state SUCCESS. Commit: be08d33
/LLM/main/L0_MergeRequest_PR pipeline #52584 (Partly Tested) 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@brnguyen2
brnguyen2 requested a review from a team as a code owner August 9, 2026 16:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/test_lists/waives.txt`:
- Line 437: Add the repository-standard NVIDIA copyright header for 2026 at the
top of the modified waives.txt file, before its existing test waiver content,
without changing the waiver entry.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a231f53e-e230-4eba-99c7-8da9b85818fd

📥 Commits

Reviewing files that changed from the base of the PR and between e4e12fa and 7c9a039.

📒 Files selected for processing (1)
  • tests/integration/test_lists/waives.txt

Comment thread tests/integration/test_lists/waives.txt Outdated
unittest/llmapi/test_llm_pytorch.py::test_gqa_nemo_lora[cuda_graph_config0] SKIP (https://nvbugs/6162504)
unittest/llmapi/test_llm_pytorch.py::test_llm_context_only_timed_out_kv_cache_exhausted[None-UCX-1000] SKIP (https://nvbugs/6490004)
unittest/llmapi/test_memory_profiling.py::test_profile_kvcache SKIP (https://nvbugs/5580781)
unittest/tools/test_layer_wise_benchmarks.py::test_performance_alignment[1] SKIP (bug pending, tracked in PR #17414)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add the required NVIDIA copyright header.

This modified file has no NVIDIA copyright header. Add the repository-standard header at the top of tests/integration/test_lists/waives.txt with year 2026.

As per coding guidelines, all modified files must contain the NVIDIA copyright header with the year of the latest meaningful modification.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/test_lists/waives.txt` at line 437, Add the
repository-standard NVIDIA copyright header for 2026 at the top of the modified
waives.txt file, before its existing test waiver content, without changing the
waiver entry.

Source: Coding guidelines

…dling

Item 1.2 of the PR NVIDIA#17269 deferred-cleanup bucket.

(a) Record the decision to keep SiTu in the trtllm-gen-local ActType_TrtllmGen
enum rather than adding it to the shared ActivationType, which mirrors the
cutlass enum in common.h and would then need a cutlass member no cutlass
kernel implements. Documented at the enum and left the enums unchanged.

(b) Route SiTu and SwiGLU per-expert alpha/beta through a single
_gemm1_activation_params accessor at the op call instead of duplicating the
is_situ_activation ternary. Behavior-identical: same tensors, same op slot.

The deeper storage merge (eliminating the separate situ_alpha/situ_beta
buffers by reusing swiglu_alpha/swiglu_beta) is left as a TODO because
'swiglu_alpha is not None' gates quant-method selection and validation on the
numeric path; it needs GPU parity revalidation before it can land.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…swiglu_beta storage

Complete item 1.2(b): drop the separate situ_alpha/situ_beta parameters
and reuse the swiglu_alpha/swiglu_beta storage, so the gemm1
alpha/beta op slot has a single backing parameter and the
_gemm1_activation_params accessor branch disappears.

Safe with respect to the 'swiglu_alpha is not None' gates:
- create_moe.py validates the constructor kwargs, which remain None for
  SiTu; the storage is populated later in create_weights.
- _get_quant_method consults swiglu_alpha only on the nvfp4 branch;
  SiTu requires W4A8_MXFP4_MXFP8, and selection also runs before the
  storage is populated.
- _check_configs's swiglu gate admits w4a8_mxfp4_mxfp8, and its SiTu
  branch now validates the merged storage.
- The NVFP4 post-load swiglu_beta rescale
  (NVFP4TRTLLMGenFusedMoEMethod.process_weights_after_loading) is not in
  SiTu's MXFP4 quant-method ancestry.
- _validate_backend_local_activation runs from __init__, before
  create_weights, so it still rejects constructor-provided SwiGLU
  parameters for SiTu.

Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@brnguyen2
brnguyen2 force-pushed the k3/15177-situ-activation branch from 7c9a039 to 505865d Compare August 9, 2026 16:51
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64863 [ run ] triggered by Bot. Commit: 505865d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64863 [ run ] completed with state SUCCESS. Commit: 505865d
/LLM/main/L0_MergeRequest_PR pipeline #52704 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

@longlee0622

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@sunnyqgg sunnyqgg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants