Skip to content

Integrate Miles fused NVFP4 fake-QAT QDQ - #91

Open
zianglih wants to merge 1 commit into
radixark:miles-mainfrom
zianglih:agent/nvfp4-qdq-miles-integration
Open

Integrate Miles fused NVFP4 fake-QAT QDQ#91
zianglih wants to merge 1 commit into
radixark:miles-mainfrom
zianglih:agent/nvfp4-qdq-miles-integration

Conversation

@zianglih

@zianglih zianglih commented Sep 1, 2026

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

What does this PR do?

@HumansAnd

Adds the minimal Megatron side of a paired Miles/Megatron split for fused NVFP4 fake-QAT QDQ.

  • Scope: four lines in TEGroupedLinear._get_weight_tensors() gate on
    OPEN_TRAINING_NVFP4_FAKE_QAT_FLAG=1, lazily import the Miles-owned adapter, and transform
    TE's existing discrete weight list before the current INT4-QAT hook.
  • Disabled path: Megatron does not import Miles or CuTe DSL when the flag is off.
  • Ownership: the CuTe kernel, FP32 amax/STE wrapper, full numerical matrix, real grouped-linear
    forward/backward test, and benchmark live in the paired Miles PR. This PR adds no duplicate
    kernel or unit-test files.
  • Recipe premise: the enabled recipe targets TE 2.17+ discrete rank-2 weights. It deliberately
    carries no pre-2.17 fallback or runtime support validator; recipe compatibility is configured by
    the caller.
  • History: preserves draft Fuse NVFP4 fake-QAT quantize-dequantize with CuTe DSL #88 unchanged as the complete single-repository implementation and
    re-expresses it as a cleaner ownership split. This remains a follow-up to [WIP] Add NVFP4 fake QAT for grouped experts #75.

Paired Miles kernel/test PR:
radixark/miles#2864

Issue tracking

Linked issue: N/A (paired fork refactor of draft #88; related to #75)

Validation

  • Megatron commit: 65940a7197427997bbfd411b3944849f68c1aaf0
  • Megatron base: c160f0717e40f052de740026cf62739340e7b970 (miles-main)
  • Paired Miles head: ca0c3425f2c5b5f8ec97fc4af6e8fd976d32f704
  • C2 validation/benchmark commit: ffa7dc4ac3741c1e4f2c896aa78273730c418fe4
    (the head differs only by restoring the pre-existing CI registration metadata)
  • Image: radixark/miles:dev-202609010119
    (sha256:3ee2af22223ee8f0d0b0bf19340fc06bf8da6ddb26a36c76136f8f5e5c462728 on amd64/B300)
  • Hardware/runtime: C2, 8x NVIDIA B300 SXM6 AC (SM103); PyTorch 2.13.0+cu130, CUDA 13.0,
    Transformer Engine 2.17.0, Cutlass DSL 4.6.2

The Miles Blackwell file includes the real TEGroupedLinear hook, three discrete weights,
bit-exact TE QDQ comparison, forward, and identity-STE backward. The full run uses two visible GPUs
so the non-current-device restoration case executes rather than skips.

cd /hai-workspace/nvfp4-qdq-split/miles
CUDA_VISIBLE_DEVICES=0,1 PYTHONWARNINGS=ignore \
PYTHONPATH=/hai-workspace/nvfp4-qdq-split/miles:/hai-workspace/nvfp4-qdq-split/Megatron-LM \
pytest -q -o addopts= tests/fast-gpu/test_nvfp4_quantizer.py
........................................................................ [  4%]
........................................................................ [  9%]
........................................................................ [ 13%]
........................................................................ [ 18%]
........................................................................ [ 22%]
........................................................................ [ 27%]
........................................................................ [ 31%]
........................................................................ [ 36%]
........................................................................ [ 41%]
........................................................................ [ 45%]
........................................................................ [ 50%]
........................................................................ [ 54%]
........................................................................ [ 59%]
........................................................................ [ 63%]
........................................................................ [ 68%]
........................................................................ [ 73%]
........................................................................ [ 77%]
........................................................................ [ 82%]
........................................................................ [ 86%]
........................................................................ [ 91%]
........................................................................ [ 95%]
................................................................         [100%]
1576 passed in 20.68s

Local Megatron checks:

isort: passed
Black: 1 file left unchanged
pylint: 10.00/10
Ruff: All checks passed
compileall: passed
git diff --check: passed

tools/autoformat.sh was invoked but its fetch step cannot resolve the fork-only miles-main
branch on its hardcoded NVIDIA remote. The equivalent isort, Black, pylint, and Ruff commands were
run individually against the changed file and produced the results above; this was an
infrastructure/setup failure rather than a formatter failure.

The paired eight-weight [4096,6144] benchmark reports 1.623x overall geomean speedup versus
native TE quantize-dequantize (1.635x BF16, 1.611x FP16); complete raw timing is owned by the
Miles PR.

Contribution process

Pre-checks

  • I have added relevant unit tests (in the paired Miles Blackwell test)
  • I have added relevant functional tests (real paired grouped-linear forward/backward)
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh checks on my PR

Code review

Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!

All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.

Step 1: Mark PR as "Ready for Review"

  1. When the PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on the changes.

⚠️ Only mark as ready once merge conflicts are resolved and CI is passing.

Step 2: Final Review

For changes under megatron/core, expert approvals lead to the Final Review label and final review.

Step 3: Approved

The Approved label is applied automatically after the required reviews.

Merge

Any member of mcore-engineers can merge the PR.

Signed-off-by: Ziang Li <ziangli@umich.edu>
@zianglih
zianglih marked this pull request as ready for review September 1, 2026 19:22
@zianglih
zianglih marked this pull request as draft September 1, 2026 20:28
@zianglih
zianglih marked this pull request as ready for review September 1, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant