Skip to content

feat(refit): expose mutable MXFP8 destinations - #6826

Merged
wdykas merged 7 commits into
NVIDIA:mainfrom
wdykas:simplify-mxfp8-refit
Aug 26, 2026
Merged

wdykas merged 7 commits into
NVIDIA:mainfrom
wdykas:simplify-mxfp8-refit

Conversation

@wdykas

@wdykas wdykas commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

Enables in-place refitting of MXFP8 inference weights while preserving their underlying data and scale storage.

This is needed by external refit workflows such as Megatron Bridge and NeMo-RL, which copy updated BF16 weights into an already-quantized Megatron inference model.
Preserving storage addresses is important because those buffers may already be captured by CUDA graphs.

  • Adds logical shape, device, and dtype metadata to MXFP8Tensor.
  • Adds MXFP8Tensor.quantize_() and copy_() for updating an existing MXFP8 destination from a logical tensor.
  • Preserves the existing MXFP8 data and scale allocations during updates.
  • Reuses the in-place update API in MXFP8 quantization and resharding paths.
  • Exposes refresh_module_caches() as a public resharding utility.
  • Supports refreshing caches for a single model or a list/tuple of model chunks, including PP/VPP layouts.

The cache refresh API allows refit integrations that update weights outside execute_reshard_plan() to refresh parameter-derived state before inference resumes.

Why is this needed?

Without an in-place MXFP8 update API, refitting creates replacement quantized tensors and changes their device pointers. This can invalidate CUDA graph captures.

Additionally, some modules maintain values derived from model parameters. External refit paths need a supported way to refresh those caches after copying new weights.

Test coverage

  • Verifies that MXFP8 updates preserve data and scale storage addresses.
  • Verifies logical tensor metadata and updated quantized contents.
  • Covers both Triton and FlashInfer MXFP8 backends when available.
  • Verifies cache refresh for model lists and the existing reshard execution path.

Related work

@copy-pr-bot

copy-pr-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@wdykas

wdykas commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 75c6e44

@wdykas

wdykas commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

/claude strict-review

Comment thread megatron/core/inference/quantization/mxfp8_tensor.py
Comment thread tests/unit_tests/inference/test_mxfp8_utils.py
@claude

This comment was marked as resolved.

Comment thread megatron/core/resharding/execution.py
Comment thread megatron/core/inference/quantization/mxfp8_tensor.py Outdated
@wdykas

wdykas commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

/claude strict-review

@wdykas
wdykas marked this pull request as ready for review August 25, 2026 17:28
@wdykas
wdykas requested review from a team as code owners August 25, 2026 17:28
Comment thread megatron/core/inference/quantization/mxfp8_tensor.py
Comment thread megatron/core/inference/quantization/mxfp8_tensor.py
Comment thread megatron/core/transformer/moe/experts.py Outdated
Comment thread megatron/core/inference/quantization/mxfp8_tensor.py
Comment thread megatron/core/resharding/execution.py
Comment thread tests/unit_tests/inference/test_mxfp8_utils.py
Comment thread megatron/core/inference/quantization/mxfp8_tensor.py
wdykas added 3 commits August 25, 2026 13:03
Signed-off-by: wdykas <wdykas@nvidia.com>
Signed-off-by: wdykas <wdykas@nvidia.com>
Signed-off-by: wdykas <wdykas@nvidia.com>
@wdykas
wdykas enabled auto-merge August 25, 2026 20:52
Signed-off-by: wdykas <wdykas@nvidia.com>
@wdykas
wdykas force-pushed the simplify-mxfp8-refit branch from bae2a0b to f8c9186 Compare August 25, 2026 20:55
@wdykas

wdykas commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f8c9186

Comment thread megatron/core/transformer/moe/experts.py Outdated
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Approved All necessary approvals have been made label Aug 26, 2026
Signed-off-by: wdykas <wdykas@nvidia.com>
@wdykas

wdykas commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 096b22f

@nemo-automation-bot

Copy link
Copy Markdown

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/32923552756

Merged via the queue into NVIDIA:main with commit 68b28af Aug 26, 2026
93 checks passed
@wdykas
wdykas deleted the simplify-mxfp8-refit branch August 26, 2026 04:00
@wdykas wdykas mentioned this pull request Aug 26, 2026
5 of 6 tasks
ksivaman pushed a commit to ksivaman/Megatron-LM that referenced this pull request Sep 1, 2026
Signed-off-by: wdykas <wdykas@nvidia.com>

This branch was previously deployed

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

Labels

Approved All necessary approvals have been made complexity: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants