Skip to content

[https://nvbugs/6892151][fix] Add __syncthreads() after the shared-memory init in both kernels; make the… - #20104

Open
trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6892151
Open

trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6892151

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: Two defects. (1) Warp 0 zeroes the shared-memory buffers with no barrier before the other warps write their partial sums into them, so those sums can be overwritten and outputs come out inflated. (2) When the large-batch kernel launches a single warp (inputs ≤256 elements for bf16/fp16, ≤128 for fp32), the warp_idx==1 step never runs, so input 1 is never normalised (each output is x·sum(x²)·w).
  • Fix: Add __syncthreads() after the shared-memory init in both kernels; make the large-batch init loop step by blockDim.y so one warp clears both rows; when blockDim.y==1, warp 0 also reduces input 1 and writes its rsqrt. Launch configuration, heuristic and kernel selection are unchanged. The tests add the [256,256] one-warp shape and a 100-call repeated-calls test.
  • Original test: bash .repair-bot/run_repro.sh
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Reproduction comparison

  • Failed commit: skipped_on_failed_commit
    Not run: the NVBug report states the failure ToT reproduced (=== REP_END )
  • ToT: repro_on_tot at 4393129
    Signature: === REP_END
  • Signature relation: same (NVBug report vs. ToT signature; failed leg not run)

Dev Engineer Review

The kernels add a block-wide barrier after shared-memory initialization. The large-batch kernel now initializes all shared-memory rows and normalizes input 1 when it launches one warp. The reported launch configuration, heuristic, and kernel selection remain unchanged.

QA Engineer Review

tests/unittest/_torch/modules/test_group_rmn_norm.py adds the [256, 256] large-batch case and test_group_rms_norm_repeated_calls. The repeated-call test exercises the base, large-batch, and heuristic operators 100 times across four configurations and compares results with an RMSNorm reference. This unit-test file does not require an integration test-list entry. Coverage verdict: sufficient for the reported defects. Test execution results were not supplied.

Per-File QA Perspective

  • cpp/tensorrt_llm/kernels/groupRmsNormKernels/groupRmsNormKernels.cu: Verify that the new synchronization prevents shared-memory initialization races and that the single-warp path normalizes input 1.
  • tests/unittest/_torch/modules/test_group_rmn_norm.py: Covers the single-warp shape and repeated calls across three operators. It is a unit-test file, so integration-list membership does not apply.

…e and one-warp large-batch path

GroupRMSNormBaseKernel and GroupRMSNormKernelLargeBatch initialize shared
memory in some warps while lane 0 of other warps writes partial sums to the
same slots, with no barrier in between, so warp contributions are lost and
outputs are inflated. Add a __syncthreads() after the initialization; the
sm < 900 __syncwarp() that only ordered lanes within a warp is now redundant.

When every input fits in one warp (<= 256 fp16/bf16 or <= 128 fp32
elements), the large batch kernel launches a single warp, so the warp 1
branch that converts input 1's sum of squares into its rsqrt never runs and
input 1 is scaled by its raw sum of squares. Let warp 0 initialize every row
and also reduce input 1 in that case, leaving the launch configuration and
the kernel-selection heuristic unchanged.

Add one-warp large-batch shapes and a repeated-call test for all three ops.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ff6812a and b7dae02.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Group RMSNorm kernels change shared-memory initialization and large-batch reduction behavior. Tests add a hidden-dimension case and repeated-call comparisons for the base, large-batch, and heuristic operators.

Changes

Group RMSNorm kernel updates

Layer / File(s) Summary
Base kernel shared-memory synchronization
cpp/tensorrt_llm/kernels/groupRmsNormKernels/groupRmsNormKernels.cu
The base kernel adds a block-wide barrier after shared-memory initialization and removes a conditional warp synchronization before shared-memory writes.
Large-batch initialization, reduction, and tests
cpp/tensorrt_llm/kernels/groupRmsNormKernels/groupRmsNormKernels.cu, tests/unittest/_torch/modules/test_group_rmn_norm.py
The large-batch kernel initializes every shared-memory row and handles input 1 reduction when only one warp is launched. Tests add the [256, 256] hidden-dimension case and compare operator outputs with reference outputs over 100 calls for each of four configurations.

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

Change: Bug fix

Suggested reviewers: bowenfu

Merge Risk: Minimal · previous review ff681

The targeted test covers the reported one-warp regression, and no actionable merge-blocking risk remains after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)

Check name Status Explanation
Title check Passed The title identifies the NVBugs issue, fix type, and primary shared-memory synchronization change. It is related and concise, although the displayed ending is truncated.
Description check Passed The description explains the root causes, fixes, test coverage, reproduction status, and related bug. It does not use the template's exact "Description" and "Test Coverage" headings and omits the chec…
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

🧪 Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 0b2caa1d-3ef7-42bb-b89b-4aa6469c9c3f
📥 Commits

Reviewing files that changed from the base of the PR and between 4393129 and ff6812a.

📒 Files selected for processing (2)

  • cpp/tensorrt_llm/kernels/groupRmsNormKernels/groupRmsNormKernels.cu
  • tests/unittest/_torch/modules/test_group_rmn_norm.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.

@mikeiovine mikeiovine 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.

Stamp on behalf of runtime devs, delegating proper review to @NVIDIA/trt-llm-kernels-devs; please ping me if you think this is not accurate

@BowenFu

BowenFu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Bug engineer ownership

@karljang, as the engineer assigned to the linked bug, you are responsible for driving this bot PR to resolution. Please coordinate review, address feedback and required code changes, get CI passing, and verify the original failure before driving it to merge. If the PR is obsolete or superseded, close it with a reason. Keep this PR updated with blockers and the next step.

@karljang

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80196 [ run ] triggered by Bot. Commit: ff6812a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@github-actions

Copy link
Copy Markdown

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.

@karljang

karljang commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81930 [ run ] triggered by Bot. Commit: ff6812a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@BowenFu

BowenFu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82448 [ run ] triggered by Bot. Commit: ff6812a Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82448 [ run ] completed with state SUCCESS. Commit: ff6812a
/LLM/main/L0_MergeRequest_PR pipeline #68058 completed with status: 'SUCCESS'

CI Report

Link to invocation

@BowenFu BowenFu closed this Nov 5, 2026
@BowenFu BowenFu reopened this Nov 5, 2026
@BowenFu

BowenFu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

/bot run

Signed-off-by: Bowen Fu <5812640+BowenFu@users.noreply.github.com>
@BowenFu

BowenFu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82766 [ run ] triggered by Bot. Commit: b7dae02 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82770 [ reuse-pipeline ] triggered by Bot. Commit: b7dae02 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82766 [ run ] completed with state ABORTED. Commit: b7dae02

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82771 [ run ] triggered by Bot. Commit: b7dae02 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82770 [ reuse-pipeline ] completed with state ABORTED. Commit: b7dae02
Can't reuse PR_Github #0 with status: UNKNOWN

Link to invocation

@BowenFu

BowenFu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

/bot run

@BowenFu
BowenFu enabled auto-merge (squash) November 5, 2026 11:44
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82795 [ run ] triggered by Bot. Commit: b7dae02 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82771 [ run ] completed with state ABORTED. Commit: b7dae02

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@BowenFu

BowenFu commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84430 [ run ] triggered by Bot. Commit: b7dae02 Link to invocation

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.

6 participants