Skip to content

[None][chore] AutoDeploy: Refactor finegrained FP8 scale sharding helpers#12999

Merged
galagam merged 2 commits into
NVIDIA:mainfrom
nv-auto-deploy:gagam-minor-refactor
Apr 26, 2026
Merged

[None][chore] AutoDeploy: Refactor finegrained FP8 scale sharding helpers#12999
galagam merged 2 commits into
NVIDIA:mainfrom
nv-auto-deploy:gagam-minor-refactor

Conversation

@galagam

@galagam galagam commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

@CodeRabbit description

Description

Technical debt PR:

  • Minor refactor, follow up on [AutoDeploy]: DeepSeek R1 onboarding + initial perf analysis #12593: Single public wrapper for compute_shard_bounds + expand_scale_per_row.
  • Added TestNemotronSuperV3::test_functional_small - a single-GPU smoke test that loads a layer-reduced (16-layer) Super V3 FP8 model using reduced_model_kwargs(), a reusable helper that truncates both num_hidden_layers and layers_block_type to fit large hybrid models on one device. Added to l0_b200.yml for pre-merge coverage.

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

  • 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.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@galagam
galagam requested a review from a team as a code owner April 13, 2026 13:03
@galagam

galagam commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43042 [ run ] triggered by Bot. Commit: 0be96a1 Link to invocation

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Refactored FineGrained FP8 weight sharding logic by extracting a centralized _get_sharded_scale() method in sharding.py to compute shard bounds and scale expansion. Updated existing methods and MoE TP scale sharding to use the new centralized approach. Corresponding test updated to verify the refactored logic.

Changes

Cohort / File(s) Summary
FineGrained FP8 Sharding Refactoring
tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py
Extracted _get_sharded_scale() method to centralize weight_scale_inv sharding computation. Updated shard_scales(), shard_load_hook(), and _tp_shard_moe_scale() to use the new centralized method. Added explicit return type annotation for _compute_shard_bounds().
Test Update
tests/unittest/auto_deploy/multigpu/transformations/library/test_tp_sharding.py
Renamed test from test_finegrained_fp8_expand_scale_per_row to test_finegrained_fp8_get_sharded_scale. Updated test to verify the new _get_sharded_scale() method instead of directly testing _compute_shard_bounds() and _expand_scale_per_row(). Adjusted assertions to match refactored behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive PR description addresses key requirements but Test Coverage section is incomplete with only a comment placeholder and no actual test details listed. Expand Test Coverage section to clearly list the specific tests that validate the refactoring changes, including the renamed test_finegrained_fp8_get_sharded_scale test and any other relevant test coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: a refactor of finegrained FP8 scale sharding helpers in AutoDeploy, which aligns with the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

🧹 Nitpick comments (1)
tests/unittest/auto_deploy/multigpu/transformations/library/test_tp_sharding.py (1)

128-177: Please add a dim=1 / MoE regression case.

This test only exercises dim=0, but the refactor also routes _tp_shard_moe_scale() through _get_sharded_scale() for row-sharded w_down experts. A bug in the dim=1 branch would still pass this suite.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tests/unittest/auto_deploy/multigpu/transformations/library/test_tp_sharding.py`
around lines 128 - 177, Add a new test variant invoking
FineGrainedFP8WeightShardingInfo._get_sharded_scale with dim=1 to cover
MoE/w_down expert row-sharded paths: reuse the existing test logic but transpose
the role of rows/columns (or create weight_original_m analog) and assert both
aligned (compact) and non-aligned (per-item expansion) behaviors, and include
the edge case where size is not divisible by block_n (clamping to last scale
row); also add a specific case that routes through _tp_shard_moe_scale by
constructing inputs that mimic row-sharded w_down experts so any bug in the
dim=1 branch fails the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@tests/unittest/auto_deploy/multigpu/transformations/library/test_tp_sharding.py`:
- Around line 128-177: Add a new test variant invoking
FineGrainedFP8WeightShardingInfo._get_sharded_scale with dim=1 to cover
MoE/w_down expert row-sharded paths: reuse the existing test logic but transpose
the role of rows/columns (or create weight_original_m analog) and assert both
aligned (compact) and non-aligned (per-item expansion) behaviors, and include
the edge case where size is not divisible by block_n (clamping to last scale
row); also add a specific case that routes through _tp_shard_moe_scale by
constructing inputs that mimic row-sharded w_down experts so any bug in the
dim=1 branch fails the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ca7f5a1b-ba62-4449-a596-66267562a05d

📥 Commits

Reviewing files that changed from the base of the PR and between 68a1be1 and 0be96a1.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/auto_deploy/transform/library/sharding.py
  • tests/unittest/auto_deploy/multigpu/transformations/library/test_tp_sharding.py

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #43042 [ run ] completed with state SUCCESS. Commit: 0be96a1
/LLM/main/L0_MergeRequest_PR pipeline #33688 (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

Link to invocation

@galagam

galagam commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44167 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44167 [ run ] completed with state SUCCESS. Commit: 1e552c2
/LLM/main/L0_MergeRequest_PR pipeline #34594 (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

Link to invocation

@galagam

galagam commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --extra-stage "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44215 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44215 [ run ] completed with state SUCCESS. Commit: 1e552c2
/LLM/main/L0_MergeRequest_PR pipeline #34638 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

Link to invocation

@galagam

galagam commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44317 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44317 [ run ] completed with state FAILURE. Commit: 1e552c2
/LLM/main/L0_MergeRequest_PR pipeline #34738 (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

Link to invocation

@galagam

galagam commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44395 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44395 [ run ] completed with state FAILURE. Commit: 1e552c2
/LLM/main/L0_MergeRequest_PR pipeline #34810 (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

Link to invocation

@galagam

galagam commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44449 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44449 [ run ] completed with state SUCCESS. Commit: 1e552c2
/LLM/main/L0_MergeRequest_PR pipeline #34853 (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

Link to invocation

@galagam

galagam commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #44480 [ run ] triggered by Bot. Commit: 1e552c2 Link to invocation

@galagam galagam added the gagam-slack-watch Label for getting slack notifications via GitHub Slack app label Apr 20, 2026
@galagam

galagam commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45089 [ run ] triggered by Bot. Commit: 75b1a71 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45089 [ run ] completed with state SUCCESS. Commit: 75b1a71
/LLM/main/L0_MergeRequest_PR pipeline #35387 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

Link to invocation

@galagam

galagam commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45173 [ run ] triggered by Bot. Commit: 75b1a71 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45173 [ run ] completed with state FAILURE. Commit: 75b1a71
/LLM/main/L0_MergeRequest_PR pipeline #35450 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

Link to invocation

@galagam

galagam commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

/bot kill

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45228 [ kill ] triggered by Bot. Commit: 75b1a71 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45228 [ kill ] completed with state SUCCESS. Commit: 75b1a71
Successfully killed previous jobs for commit 75b1a71

Link to invocation

galagam added 2 commits April 23, 2026 10:20
Minor refactor, follow up on NVIDIA#12593

Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
Add test_functional_small to TestNemotronSuperV3 which overrides
num_hidden_layers (and layers_block_type) via model_kwargs to fit the
model on a single GPU. This provides pre-merge coverage for large models
that otherwise only run in multi-GPU CI.

Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
@galagam
galagam force-pushed the gagam-minor-refactor branch from 75b1a71 to 2cb3001 Compare April 23, 2026 17:41
@galagam

galagam commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "DGX_B200-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-1, DGX_H100-4_GPUs-AutoDeploy-Post-Merge-1,DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45235 [ run ] triggered by Bot. Commit: 2cb3001 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45235 [ run ] completed with state SUCCESS. Commit: 2cb3001
/LLM/main/L0_MergeRequest_PR pipeline #35496 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@galagam

galagam commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45379 [ run ] triggered by Bot. Commit: 2cb3001 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45379 [ run ] completed with state SUCCESS. Commit: 2cb3001
/LLM/main/L0_MergeRequest_PR pipeline #35620 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

Link to invocation

@galagam

galagam commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45441 [ run ] triggered by Bot. Commit: 2cb3001 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45441 [ run ] completed with state SUCCESS. Commit: 2cb3001
/LLM/main/L0_MergeRequest_PR pipeline #35673 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

Link to invocation

@galagam

galagam commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45554 [ run ] triggered by Bot. Commit: 2cb3001 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45554 [ run ] completed with state SUCCESS. Commit: 2cb3001
/LLM/main/L0_MergeRequest_PR pipeline #35772 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

Link to invocation

@galagam

galagam commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45592 [ run ] triggered by Bot. Commit: 2cb3001 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #45592 [ run ] completed with state SUCCESS. Commit: 2cb3001
/LLM/main/L0_MergeRequest_PR pipeline #35808 completed with status: 'SUCCESS'

CI Report

Link to invocation

@galagam
galagam merged commit db01f01 into NVIDIA:main Apr 26, 2026
5 checks passed
yufeiwu-nv pushed a commit to yufeiwu-nv/TensorRT-LLM that referenced this pull request May 19, 2026
…pers (NVIDIA#12999)

Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gagam-slack-watch Label for getting slack notifications via GitHub Slack app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants