Skip to content

Conversation

@danielvegamyhre
Copy link
Contributor

@danielvegamyhre danielvegamyhre commented Jan 2, 2026

Stacked PRs:


Summary

Tests

  • pytest test/prototype/mx_formats/test_mx_linear.py

Benchmarks (e2e linear sigmoid fwd + bwd)

Command: python benchmarks/float8/float8_roofline.py --mx_recipe_name="mxfp8_cublas_rceil" --outfile "outfile.csv"

Before:

   fwd_M  fwd_K  fwd_N  r_bf16_gemm_s  r_fp8_gemm_s  r_fp8_ovhd_s  ...  b_fp8_gemm_s  b_bf16_e2e_s  b_fp8_e2e_s  b_fp8_e2e_spdp  rb_bf16_gemm_ratio  rb_fp8_gemm_ratio
0   1024   1024   1024       6.00e-06      6.00e-06      1.20e-05  ...      1.77e-05      1.49e-05     4.87e-05            0.31                0.41               0.34
1   2048   2048   2048       2.94e-05      1.47e-05      1.20e-05  ...      3.52e-05      4.56e-05     9.29e-05            0.49                0.65               0.42
2   4096   4096   4096       2.35e-04      1.17e-04      4.10e-05  ...      1.37e-04      2.80e-04     3.12e-04            0.90                0.82               0.85
3   8192   8192   8192       1.88e-03      9.40e-04      1.64e-04  ...      8.34e-04      1.92e-03     1.56e-03            1.23                0.97               1.13
4  16384  16384  16384       1.50e-02      7.52e-03      6.56e-04  ...      9.34e-03      1.65e-02     1.30e-02            1.27                0.96               0.81

After:

fwd_M  fwd_K  fwd_N  r_bf16_gemm_s  r_fp8_gemm_s  r_fp8_ovhd_s  ...  b_fp8_gemm_s  b_bf16_e2e_s  b_fp8_e2e_s  b_fp8_e2e_spdp  rb_bf16_gemm_ratio  rb_fp8_gemm_ratio
0   1024   1024   1024       6.00e-06      6.00e-06      1.20e-05  ...      1.75e-05      1.49e-05     4.49e-05            0.33                0.41               0.34
1   2048   2048   2048       2.94e-05      1.47e-05      1.20e-05  ...      3.53e-05      4.54e-05     7.55e-05            0.60                0.65               0.42
2   4096   4096   4096       2.35e-04      1.17e-04      4.10e-05  ...      1.37e-04      2.79e-04     2.44e-04            1.14                0.82               0.86
3   8192   8192   8192       1.88e-03      9.40e-04      1.64e-04  ...      8.35e-04      1.91e-03     1.29e-03            1.48                0.97               1.13
4  16384  16384  16384       1.50e-02      7.52e-03      6.56e-04  ...      9.22e-03      1.72e-02     1.19e-02            1.45                0.98               0.82

Kernel microbenchmarks

@danielvegamyhre danielvegamyhre force-pushed the danielvegamyhre/stack/101 branch from a2504fe to 89e73d2 Compare January 2, 2026 07:24
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 2, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures

As of commit cf0acd8 with merge base 8d47813 (image):

NEW FAILURES - The following jobs have failed:

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

danielvegamyhre added a commit that referenced this pull request Jan 2, 2026
stack-info: PR: #3568, branch: danielvegamyhre/stack/101
@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 Jan 2, 2026
@danielvegamyhre danielvegamyhre changed the title [mxfp8 training] use triton kernel for dim0 scaling with RCEIL rounding [mxfp8 dense training] use triton kernel for dim0 scaling with RCEIL rounding Jan 2, 2026
@danielvegamyhre danielvegamyhre added mx topic: not user facing Use this tag if you don't want this PR to show up in release notes topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) topic: performance Use this tag if this PR improves the performance of a feature labels Jan 2, 2026
@vkuzo
Copy link
Contributor

vkuzo commented Jan 2, 2026

what do benchmarks look like

stack-info: PR: #3568, branch: danielvegamyhre/stack/101
@danielvegamyhre danielvegamyhre marked this pull request as draft January 2, 2026 22:40
@danielvegamyhre danielvegamyhre force-pushed the danielvegamyhre/stack/101 branch from 89e73d2 to cf0acd8 Compare January 2, 2026 22:40
@danielvegamyhre danielvegamyhre changed the title [mxfp8 dense training] use triton kernel for dim0 scaling with RCEIL rounding [mxfp8 training] use triton kernel for dim0 scaling with RCEIL rounding Jan 2, 2026
@danielvegamyhre danielvegamyhre marked this pull request as ready for review January 2, 2026 22:40
@danielvegamyhre
Copy link
Contributor Author

what do benchmarks look like

Updated PR description with benchmarks, they are better

@danielvegamyhre danielvegamyhre marked this pull request as draft January 2, 2026 22:43
@danielvegamyhre danielvegamyhre marked this pull request as ready for review January 2, 2026 22:44
@vkuzo
Copy link
Contributor

vkuzo commented Jan 3, 2026

Updated PR description with benchmarks, they are better

that looks good for no-fusion, do we have metrics on what this looks like with layer fusion? The script has a flag to enable it, or you could use LLaMa 3 8B in torchtitan.

input_hp_r = input_hp.reshape(-1, input_orig_shape[-1])

input_mx_r_dim0 = MXTensor.to_mx(
input_mx_r_dim0 = _to_mxfp8_dim0(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should ensure the codebase stays consistent with how the various config flags are used. Before this PR, mxfp8_cast_kernel_choice controls the dim1 cast. I think good options are:

  1. make mxfp8_cast_kernel_choice control dim1 and dim0 casts (update names/docs as needed)
  2. or, make a separate mxfp8_cast_kernel_choice thing for dim0, update names as needed
  3. or, just delete all the configs and make the logic use custom kernels

The current PR is a bit confusing given the rest of the feature because it leaves the dim1 config as is but defaults the dim0 logic to a custom kernel.

I don't really like Option 3 because we should be able to quickly test compile, so Option 1 or Option 2 would sound good to me.

Uses Triton kernel for RCEIL scaling mode for better performance, otherwise
falls back to MXTensor.to_mx().
"""
if scale_calculation_mode == ScaleCalculationMode.RCEIL:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't how the dim1 config works, let's make sure all of these flags operate in a consistent way. You can change the dim1 logic if needed (everything is prototype).

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. mx topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) topic: not user facing Use this tag if you don't want this PR to show up in release notes topic: performance Use this tag if this PR improves the performance of a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants