[https://nvbugs/5567586][feat] Ampere xqa swa specdec for GPT-OSS Eagle3-one-model
Summary by CodeRabbit
-
New Features
- Added sliding-window-aware attention masking, with per-tile masking and early exits when masking is unnecessary.
-
Performance
- Optimized mask computation and packing paths.
- Improved warmup accuracy by using the device memory clock rate.
- Updated memory prefetch to the newer CUDA API.
-
Tests
- Updated warmup utilities to accept device clock rate and reflect it in metrics.
- Adjusted test harness and call sites to use the new warmup interface and prefetch flow.
Before this PR
GPT-OSS Eagle3-one-model TP=2
[11/25/2025-03:48:07] [TRT-LLM] [I] lm-eval gsm8k exact_match,flexible-extract accuracy: 62.09
[11/25/2025-03:48:07] [TRT-LLM] [I] Hypothesis testing report:
===========================================================
= ACCURACY HYPOTHESIS TESTING
===========================================================
Alpha (Type I: False Positive): 0.050
Beta (Type II: False Negative): 0.200
Sigma (Standard deviation): 50.000
#Samples: 1319
Higher is better: True
Theta (Minimum detectable effect): 4.841
Reference accuracy: 90.300
Threshold: 87.097
===========================================================
Evaluated accuracy: 62.092
===========================================================
After this PR
GPT-OSS Eagle3-one-model TP=2
[11/25/2025-02:55:53] [TRT-LLM] [I] lm-eval gsm8k exact_match,flexible-extract accuracy: 89.76
[11/25/2025-02:55:53] [TRT-LLM] [I] Hypothesis testing report:
===========================================================
= ACCURACY HYPOTHESIS TESTING
===========================================================
Alpha (Type I: False Positive): 0.050
Beta (Type II: False Negative): 0.200
Sigma (Standard deviation): 50.000
#Samples: 1319
Higher is better: True
Theta (Minimum detectable effect): 4.841
Reference accuracy: 90.300
Threshold: 87.097
===========================================================
Evaluated accuracy: 89.765
===========================================================
Description
Test Coverage
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)
-
Any new dependencies have been scanned for license and vulnerabilities
-
CODEOWNERS updated if ownership changes
-
Documentation updated as needed
-
The reviewers assigned automatically/manually are appropriate for the PR.
-
[x] Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...
Provide a user friendly way for developers to interact with a Jenkins server.
Run /bot [-h|--help] to print this help message.
See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]
Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.
--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.
--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.
--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.
--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.
--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.
--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.
--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.
--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.
--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.
--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.
--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".
--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.
--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.
For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.
kill
kill
Kill all running builds associated with pull request.
skip
skip --comment COMMENT
Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
reuse-pipeline
reuse-pipeline
Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.
📝 Walkthrough
Walkthrough
The patch updates cuda kernels and tests. It modifies applyMaskFromInput in cpp/kernels/xqa/mha.cu to add sliding-window-aware masking with conditional parameters and logic. Test utilities change warmup’s signature to accept clockRate, retrieve it via CUDA APIs, update prefetch calls, and propagate the new parameter across call sites.
Changes
| Cohort / File(s) | Summary |
|---|---|
XQA MHA sliding-window maskingcpp/kernels/xqa/mha.cu |
Extended applyMaskFromInput signature under SLIDING_WINDOW && !IS_SPEC_DEC_TREE to include tok0WinBeg, seqIter, cacheSeqLen, warpTileTokenBeg. Added per-CTA begMask computation, needMask short-circuit, clamped tokenRow, conditional packed mask assembly, and guarded interactions with SPEC_DEC. Updated call sites accordingly. |
Test warmup API and CUDA attribute usagecpp/kernels/xqa/test/test.cpp, cpp/kernels/xqa/test/warmup.cu |
Changed warmup signature to include int const& clockRate. test.cpp now queries cudaDevAttrMemoryClockRate, passes clockRate to warmup, and replaces prop.memoryClockRate usages. Adjusted cudaMemPrefetchAsync to use cudaMemLocation. warmup.cu computes nbCycles using clockRate. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant K as kernel_mha_impl
participant M as applyMaskFromInput
participant ACC as Accumulator
K->>M: applyMaskFromInput(warp, acc, mask, rowOffset, ..., headGrpSize[, tok0WinBeg, seqIter, cacheSeqLen, warpTileTokenBeg])
rect rgb(240,248,255)
note over M: Determine masking path
M-->>M: Compute needMask (incl. sliding-window)
alt needMask == false
M-->>K: Return (no mask)
else needMask == true
M-->>M: Clamp tokenRow to actualQSeqLen
opt SLIDING_WINDOW && !IS_SPEC_DEC_TREE
M-->>M: Compute begMask per CTA
end
M-->>M: Load/assemble packed mask bits (conditional)
M-->>ACC: Apply mask to accumulator tiles
M-->>K: Return (masked)
end
end
K-->>ACC: Continue with subsequent compute
sequenceDiagram
autonumber
participant T as test.cpp
participant CUDA as CUDA Runtime
participant W as warmup
T->>CUDA: cudaDeviceGetAttribute(memoryClockRate)
CUDA-->>T: clockRate
T->>W: warmup(prop, clockRate, ms, stream?)
W-->>W: nbCycles = f(clockRate, ms)
T->>CUDA: cudaMemPrefetchAsync(..., cudaMemLocation{device/host}, flags=0)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~55 minutes
Pre-merge checks and finishing touches
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
| Description check | ⚠️ Warning | PR description lacks required sections: missing formal PR title with ticket/type format, incomplete Description section (only shows 'Before/After' test results), missing explanation of implementation approach, and incomplete Test Coverage section. | Add PR title in format [TICKET][type] Summary, explain what changes were made and why in the Description section, detail the technical implementation (sliding window masking, warmup parameter changes), and clarify which tests validate the changes. |
✅ Passed checks (1 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | ✅ Passed | The pull request title "[https://nvbugs/5567586][feat] Ampere xqa swa specdec for GPT-OSS Eagle3-one-model" accurately describes the main changes in the pull request. The title references sliding window attention (swa) and speculative decoding (specdec) support in XQA kernels, which directly corresponds to the code modifications shown in the changeset—specifically, the introduction of conditional sliding-window masking logic in mha.cu with speculative decoding guards, and supporting updates to test infrastructure. While the title includes metadata (bug tracker URL and feature label) which adds some noise, the core technical content clearly and specifically conveys the primary change and would be understandable to teammates familiar with the codebase. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
/bot run --disable-fail-fast
PR_Github #22697 [ run ] triggered by Bot. Commit: 4a34055
PR_Github #22697 [ run ] completed with state FAILURE. Commit: 4a34055
/bot run --disable-fail-fast
PR_Github #22740 [ run ] triggered by Bot. Commit: c589e79
PR_Github #22740 [ run ] completed with state SUCCESS. Commit: c589e79
/LLM/main/L0_MergeRequest_PR pipeline #17146 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #22806 [ run ] triggered by Bot. Commit: ff66d85
PR_Github #22806 [ run ] completed with state SUCCESS. Commit: ff66d85
/LLM/main/L0_MergeRequest_PR pipeline #17201 completed with status: 'FAILURE'
Please make sure you locally tested special cases like multi-block mode.
Thanks @lowsfer, for Ampere XQA, the multi-block mode is not enabled yet in TRTLLM. But I did ran the XQA unit test. Some note is, there were some edge case that fails before I made my changes, those case are stayed failed (due to limited bandwidth 😅) But the overall accuracy ran by pipeline seemed good.
/bot run
PR_Github #22916 [ run ] triggered by Bot. Commit: c738411
PR_Github #22916 [ run ] completed with state FAILURE. Commit: c738411
/LLM/main/L0_MergeRequest_PR pipeline #17284 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #22921 [ run ] triggered by Bot. Commit: c738411
PR_Github #22921 [ run ] completed with state SUCCESS. Commit: c738411
/LLM/main/L0_MergeRequest_PR pipeline #17288 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #22935 [ run ] triggered by Bot. Commit: c738411
Please make sure you locally tested special cases like multi-block mode.
Thanks @lowsfer, for Ampere XQA, the multi-block mode is not enabled yet in TRTLLM. But I did ran the XQA unit test. Some note is, there were some edge case that fails before I made my changes, those case are stayed failed (due to limited bandwidth 😅) But the overall accuracy ran by pipeline seemed good.
Can you share some examples of these failing tests? Thanks!
PR_Github #22935 [ run ] completed with state SUCCESS. Commit: c738411
/LLM/main/L0_MergeRequest_PR pipeline #17295 completed with status: 'FAILURE'
/bot run --disable-fail-fast
PR_Github #23070 [ run ] triggered by Bot. Commit: 2ebcb52
hey @pengbowang-nv, @jhaotingc recently went OOO until mid november. If the CI passes, could we merge this PR?
Can you share some examples of these failing tests? Thanks!
I tested the accuracy on RTX6000 MMLU as well and only a 2% drop with spec-dec compared to baseline. I think spec-dec slight accuracy degradation is an on-going discussion. @mikeiovine may have more context.
PR_Github #23070 [ run ] completed with state SUCCESS. Commit: 2ebcb52
/LLM/main/L0_MergeRequest_PR pipeline #17396 completed with status: 'FAILURE'
/bot run
PR_Github #23672 [ run ] triggered by Bot. Commit: 5a5467f
PR_Github #23672 [ run ] completed with state SUCCESS. Commit: 5a5467f
/LLM/main/L0_MergeRequest_PR pipeline #17811 completed with status: 'FAILURE'
/bot run --test-backend "pytorch"
PR_Github #23766 [ run ] triggered by Bot. Commit: 5a5467f