Skip to content

Wire MoE and MXFP8Linear training paths to CuTeDSL by default - #4620

Closed
alexsamardzic wants to merge 2 commits into
gh/alexsamardzic/5/basefrom
gh/alexsamardzic/5/head
Closed

alexsamardzic wants to merge 2 commits into
gh/alexsamardzic/5/basefrom
gh/alexsamardzic/5/head

Conversation

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4620

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 5 Unrelated Failures

As of commit 864b33b with merge base 3818749 (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 27, 2026
@alexsamardzic alexsamardzic added the module: training quantize_ api training flow label Jul 27, 2026
@alexsamardzic alexsamardzic changed the title Wire MXFP8 training paths to CuTeDSL by default Wire MoE and MXFP8Linear training paths to CuTeDSL by default Jul 27, 2026
alexsamardzic added a commit that referenced this pull request Jul 27, 2026
@alexsamardzic

Copy link
Copy Markdown
Collaborator Author

This PR wires the MXFP8 MoE grouped-mm and MXFP8Linear training paths to use the CuTeDSL backend by default, while keeping the legacy CUDA/Triton backend selectable for validation and benchmarking. It adds end-to-end correctness tests for grouped-mm, padded grouped-mm, prequantized MXTensor grouped-mm, and MXFP8Linear fwd/bwd, plus benchmark support for comparing CuTeDSL against the legacy backend. This prepares the next PR to delete torchao._C_mxfp8 and the now-obsolete legacy CUDA/Triton paths.


To run tests:

pytest -q \
    test/prototype/moe_training/test_mxfp8_grouped_mm.py::test_mxfp8_grouped_gemm_backend_fwd_bwd \
    test/prototype/moe_training/test_mxfp8_grouped_mm.py::test_mxfp8_grouped_gemm_padded_backend_fwd_bwd \
    test/prototype/moe_training/test_mxfp8_grouped_mm.py::test_mxfp8_grouped_gemm_mxtensor_backend_forward \
    test/prototype/moe_training/test_mxfp8_grouped_mm.py::test_mxfp8_grouped_gemm_with_dq_fwd_bwd \
    test/prototype/moe_training/test_mxfp8_linear.py::test_mxfp8_linear_fwd_bwd_sqnr

To run MoE grouped-mm fwd/bwd recipe benchmark:

python benchmarks/prototype/moe_training/mxfp8/roofline_unified.py \
    --backend=both --K=4096 --N=4096 --G=8 --breakdown_M=16384 \
    --outfile_speedup=roofline_speedup_K4096_N4096.csv \
    --outfile_quant_2d=roofline_quant_2d_K4096_N4096.csv \
    --outfile_quant_3d=roofline_quant_3d_K4096_N4096.csv \
    --plot_file=roofline_K4096_N4096.png

Results of benchmark above:
roofline_K4096_N4096


To run MXFP8Linear fwd/bwd recipe benchmark:

python scripts/validate_mxfp8_linear_cutedsl.py \
    --M 4096 --N 4096 --K 2048 \
    --cuda-graph-bench --graph-iters 100

Would be good to run on multi-GPU machine:

torchrun --nproc-per-node=2 --local-ranks-filter=0 \
    benchmarks/prototype/moe_training/mxfp8/bench_ep_pipeline.py --backend=legacy

torchrun --nproc-per-node=2 --local-ranks-filter=0 \
    benchmarks/prototype/moe_training/mxfp8/bench_ep_pipeline.py --backend=cutedsl

[ghstack-poisoned]
alexsamardzic added a commit that referenced this pull request Jul 29, 2026
@alexsamardzic

Copy link
Copy Markdown
Collaborator Author

Added --calibrate_roofline option to roofline_unified.py. When turned on, the script measures achievable copy bandwidth plus BF16/FP8 GEMM throughput on the current GPU and uses those calibrated values for the roofline model, instead of relying only on the hard-coded B200 assumptions. The output and plot labels now refer to these values as achievable roofline ceilings.

@andrewor14

Copy link
Copy Markdown
Contributor

Hi @alexsamardzic, is this the PR that's incorrectly wired? Should we close it then?

@alexsamardzic

Copy link
Copy Markdown
Collaborator Author

Replaced by #4705.

@alexsamardzic

alexsamardzic commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hi @alexsamardzic, is this the PR that's incorrectly wired? Should we close it then?

All five on the stack were wrong, I used plain ghstack command to create them. I had to close all of them, and replaced them with another stack, created through ghstack --direct, #4705 is replacement for this one, and the rest is in the same new stack. I apologize for the mess - previously I was creating proper branches for my PRs here, and in this case I used ghstakh out of habit from mostly working with PyTorch repo.

Btw: All five of these PRs are reasonably simple, I've stated test plans, and also benchmarking results showing that the perfomance is unchanged, or better - so I hope we could merge them quickly. The top one, #4705, is the only one to be careful about, as this one switches the default to new CuTeDSL kernels. After we merge this, and then if we see for couple weeks that there are no issues, I'll post another PR to delete legacy kernels and the C++ extension.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: training quantize_ api training flow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants