Skip to content

[PyTorch] Quantize grouped current-scaling splits independently - #3907

Open
ZenAlexa wants to merge 8 commits into
NVIDIA:mainfrom
ZenAlexa:contrib/grouped-current-scaling-split-quantize-v2
Open

ZenAlexa wants to merge 8 commits into
NVIDIA:mainfrom
ZenAlexa:contrib/grouped-current-scaling-split-quantize-v2

Conversation

@ZenAlexa

@ZenAlexa ZenAlexa commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

This changes FP8 current scaling on the split-quantize path of grouped linear layers. Megatron's unfused expert path passes host-side split sizes when the grouped-tensor backend is disabled. Eligible splits use grouped kernels to compute their maxima, derive one scale per split and cast the input. The outputs retain their per-split tensor interface.

Distributed amax reduction keeps the existing per-split path so every rank issues the same collectives. The existing fused path selected by use_grouped_tensor=True is unchanged.

Type of change

Non-breaking optimization of an existing FP8 quantization path.

Changes

The fast path batches compatible current-scaling quantizers. Ineligible splits continue to use separate casts.

Validation

The regression compares FP8 output bytes (treating signed zeros as equal), inverse scales for nonempty splits and dequantized values against separate casts. It covers equal and uneven splits, empty experts, BF16 and FP32 inputs, and both rowwise-only and rowwise-plus-columnwise usage.

The remaining comparison needs a GPU that supports both backends. Please compare forward outputs, gradients and full-layer time for the baseline split path, the candidate split path and the existing grouped-tensor path with the same weights and expert split sizes. There are no same-hardware layer timings for this change yet.

The available native extension lacks get_cublasLt_build_version and does not include the candidate split implementation. Runs against that build do not validate this revision.

Checklist

  • The PR includes a grouped-versus-per-split regression.
  • Run the regression with the native extension built from this revision.
  • Compare all three layer paths on the same GPU.

Signed-off-by: ZenAlexa <zimingwang945@gmail.com>
…th in the test

Signed-off-by: ZenAlexa <zimingwang945@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 18:44

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Nov 20, 2026
@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge, with no actionable issues found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge, with no actionable issues found.

Summary

This PR batches compatible FP8 current-scaling splits while keeping separate output tensors and one scale per split.

  • Compatible FP8 splits share one grouped quantization pass.
  • CPU-offloaded grouped linear splits keep separate buffers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Split quantization request] --> B{Compatible quantizers and layout?}
  B -- No --> C[Separate casts]
  B -- Yes --> D{Bulk allocation enabled?}
  D -- No --> C
  D -- Yes --> E[Grouped maxima and per-split scales]
  E --> F[Grouped cast]
  F --> G[Separate tensor views]
Loading

Reviews (7) · Last reviewed commit: "Merge main into contrib/grouped-current-..." · Reviewed by Greptile

ZenAlexa and others added 3 commits November 21, 2026 23:31
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@pggPL

pggPL commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Have you considered using te.GroupedLinear(..., use_grouped_tensor=True) ? It is the newest API and supports fused quantization for current scaling.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
@ZenAlexa

Copy link
Copy Markdown
Contributor Author

Yes, I'd use use_grouped_tensor=True when the grouped-tensor backend is available. Megatron's unfused MoE path also accepts host-side split sizes with that backend disabled, which is the path this PR changes. I'd compare the two split implementations and the existing fused path on the same GPU for forward outputs, gradients and full-layer time.

Signed-off-by: Ziming Wang <zimingwang945@gmail.com>
Signed-off-by: Ziming Wang <zimingwang945@gmail.com>

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

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants