Skip to content

Fix RoundingModeKind incompatible with nvidia-cutlass-dsl 4.6.0+ - #4765

Merged
andrewor14 merged 1 commit into
mainfrom
cutlass-rounding-mode
Aug 21, 2026
Merged

andrewor14 merged 1 commit into
mainfrom
cutlass-rounding-mode

Conversation

@andrewor14

Copy link
Copy Markdown
Contributor

Summary: nvidia-cutlass-dsl 4.6.0 renamed RoundingModeKind -> FPRoundingMode, while both existed in 4.5.0. #4725 recently added references to the old name, resulting in the following error. This breaks compatibility with vllm nightly, which currently depends on 4.6.2:

AttributeError: module 'cutlass._mlir.dialects.nvvm' has no attribute
'RoundingModeKind'
  at cute_utils.py:246, in compute_scale_rceil

Claude summary:

Rename the three uses to `FPRoundingMode`, which is correct on every released
version:

  - Values are identical for the members used here:
      RoundingModeKind: NONE=0 RN=1 RM=2 RP=3 RZ=4
      FPRoundingMode:   NONE=0 RN=1 RM=2 RP=3 RZ=4 RNA=5   (strict superset)
  - Both register attribute builders with the same body, emitting a signless
    i32 IntegerAttr from int(x), so the enum class does not affect the attribute.
  - From 4.6.0 the generated op requests 'FPRoundingModeAttr' (22 uses, 0 of
    'RoundingModeKindAttr'), so this is the expected API there, not a shim.
  - FPRoundingMode is present in 4.4.2, 4.5.0, 4.6.0, 4.6.2 and 4.7.0, so the
    unconditional rename keeps older versions working.

nvidia-cutlass-dsl 4.6.0 renamed RoundingModeKind -> FPRoundingMode,
while both existed in 4.5.0. #4725 recently added references to the
old name, resulting in the following error. This breaks compatibility
with vllm nightly, which currently depends on 4.6.2:

```
AttributeError: module 'cutlass._mlir.dialects.nvvm' has no attribute
'RoundingModeKind'
  at cute_utils.py:246, in compute_scale_rceil
```

According to claude:
```
Rename the three uses to `FPRoundingMode`, which is correct on every released
version:

  - Values are identical for the members used here:
      RoundingModeKind: NONE=0 RN=1 RM=2 RP=3 RZ=4
      FPRoundingMode:   NONE=0 RN=1 RM=2 RP=3 RZ=4 RNA=5   (strict superset)
  - Both register attribute builders with the same body, emitting a signless
    i32 IntegerAttr from int(x), so the enum class does not affect the attribute.
  - From 4.6.0 the generated op requests 'FPRoundingModeAttr' (22 uses, 0 of
    'RoundingModeKindAttr'), so this is the expected API there, not a shim.
  - FPRoundingMode is present in 4.4.2, 4.5.0, 4.6.0, 4.6.2 and 4.7.0, so the
    unconditional rename keeps older versions working.
```
@pytorch-bot

pytorch-bot Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit b5f5875 with merge base f10e69b (image):
💚 Looks good so far! There are no failures yet. 💚

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 Aug 17, 2026
@andrewor14
andrewor14 marked this pull request as draft August 17, 2026 19:12
@andrewor14
andrewor14 marked this pull request as ready for review August 17, 2026 19:18
@andrewor14 andrewor14 added the topic: bug fix Use this tag for PRs that fix bugs label Aug 17, 2026
@vkuzo

vkuzo commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@claude review, and make sure to check vs the cutedsl docs

@claude

claude Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Claude finished @vkuzo's task in 2m 21s —— View job


Review: PR #4765 — RoundingModeKind → FPRoundingMode

  • Read the changed file (cute_utils.py)
  • Review the diff vs origin/main
  • Check FPRoundingMode vs the CuTeDSL docs (see caveat below)
  • Post review feedback

Verdict: LGTM. The change is correct, minimal, and complete.

What the diff does

Renames all three nvvm.RoundingModeKind.* references to nvvm.FPRoundingMode.*:

Line Function Mode
cute_utils.py:204 _cvt_ue8m0_to_f32 .RN (round-to-nearest)
cute_utils.py:246 compute_scale_rceil .RP (round-up / ceil)
cute_utils.py:260 compute_scale_floor .RZ (round-toward-zero / floor)

Verified in-repo

  • ✅ Complete — a repo-wide grep for RoundingModeKind returns zero remaining hits; all three sites are converted.
  • ✅ Consistent — on origin/main the file used RoundingModeKind for all three (introduced in Refine MXFP8 CUDA quantization semantics #4725, commit f10e69b's successor). There's no mixed usage left, and no other file in the repo references either enum.
  • ✅ Semantics preserved — the modes map 1:1 to the same intent: .RP still backs the round-up path in compute_scale_rceil and .RZ still backs the floor path in compute_scale_floor, matching each function's docstring. The rename doesn't touch CVTPackFloatKind or SaturationModeKind, which is right.

On the "check vs the cutedsl docs" request

⚠️ Transparency: I could not reach the live CuTeDSL docs from the CI sandbox — WebFetch is not permitted here and outbound gh api/network calls are blocked. The nvvm dialect enums are also code-generated into the nvidia-cutlass-dsl wheel rather than committed to the public NVIDIA/cutlass git tree, so they can't be inspected from the repo either. If you want an independent doc cross-check, it's a one-liner against an installed wheel:

from cutlass._mlir.dialects import nvvm
print([m for m in dir(nvvm.FPRoundingMode) if not m.startswith("_")])
# expect: NONE RN RM RP RZ (RNA on 4.6+)

The PR description's evidence is internally consistent with the fix: FPRoundingMode is a strict superset of RoundingModeKind for the members used here (RN=1, RP=3, RZ=4), both enums feed the same signless-i32 IntegerAttr builder, and from 4.6.0 the generated op requests FPRoundingModeAttr exclusively. That matches the reported runtime error (nvvm has no attribute 'RoundingModeKind' on 4.6.2) and the claim that FPRoundingMode exists on 4.4.2 → 4.7.0.

Suggestion (non-blocking)

Since the whole motivation is a version-compat break, it would be worth confirming the fix on the actual pinned version (vllm nightly's nvidia-cutlass-dsl==4.6.2) — the GPU CI job exercising cute_utils is the real signal here. The RoundingModeKind→FPRoundingMode rename landed in 4.6.0, so a green run on 4.6.2 fully closes this out. (The current CI failure is just the unrelated module: label check, not a code failure.)
· branch cutlass-rounding-mode

andrewor14 added a commit that referenced this pull request Aug 17, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales.
@andrewor14 andrewor14 added module: training quantize_ api training flow and removed topic: bug fix Use this tag for PRs that fix bugs labels Aug 17, 2026
andrewor14 added a commit that referenced this pull request Aug 17, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales.
andrewor14 added a commit that referenced this pull request Aug 17, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales.
@andrewor14
andrewor14 merged commit 36027d8 into main Aug 21, 2026
28 of 31 checks passed
andrewor14 added a commit that referenced this pull request Aug 21, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales.
andrewor14 added a commit that referenced this pull request Aug 21, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales. Same fix for `fmax`.
andrewor14 added a commit that referenced this pull request Sep 3, 2026
`nvidia-cutlass-dsl` 4.6.0 removed a leading argument in
`cvt_packfloat_f32` and `cvt_packfloat`. The current callsite in torchao
(introduced in #4725) still includes this leading argument, resulting
in the following error:

```
TypeError: cvt_packfloat_f32() takes 4 positional arguments but 5 were given
```

```
\# 4.5.x
nvvm.cvt_packfloat_f32(T.i32(), src_a, src_b, src_c, to, rnd=..., sat=...)
\# 4.6.0+
nvvm.cvt_packfloat_f32(src_a, src_b, src_c, to, rnd=..., sat=...)
```

Repro on 4.6.0 (needs #4765 to run):

```
import torch
from torchao.prototype.moe_training.kernels.mxfp8 import (
    mxfp8_quantize_2d_1x32_cutedsl,
)

x = torch.randn(128, 2048, device="cuda", dtype=torch.bfloat16)
offs = torch.tensor([128], device="cuda", dtype=torch.int32)
mxfp8_quantize_2d_1x32_cutedsl(x, scaling_mode="rceil", offs=offs)
```

Verified on 4.6.0 that the output is bitwise identical to
`triton_to_mxfp8_dim0` for qdata and scales. Same fix for `fmax`.
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