cutlass icon indicating copy to clipboard operation
cutlass copied to clipboard

[CuTe DSL] libs-base and libs-cu13 4.4.x ship divergent _cutlass_ir.so for the same path; libs-base emits malformed _mma PTX for SM120 mxf4nvf4 mma

Open alexbi29 opened this issue 7 months ago • 4 comments

Summary

The two PyPI wheels nvidia-cutlass-dsl-libs-base==4.4.x and nvidia-cutlass-dsl-libs-cu13==4.4.x both unpack into the same path but with divergent contents — both the binary _cutlass_ir.cpython-312-x86_64-linux-gnu.so and several .py files (_cute_ops_gen.py, _cute_nvgpu_ops_gen.py, …). When pip installs both, file conflicts are resolved by install order, which is non-deterministic across upgrade paths.

When libs-base's files win, any cute.nvgpu.warp.MmaMXF4NVF4Op kernel JIT-compiles to PTX containing the malformed opcode

_mma.block_scale.scale_vec::4X.m16n8k64.row.col.f32.e2m1.e2m1.f32.ue4m3

(leading underscore, missing .sync.aligned. qualifier, missing kind::mxf4nvf4 qualifier). PTXAS rejects it:

error: NVPTX compiler invocation failed, error log:
  ptxas application ptx input, line XXXX; error : Unexpected instruction types specified for '_mma'

When libs-cu13's files win, the same kernel compiles to the correct opcode

mma.sync.aligned.m16n8k64.row.col.kind::mxf4nvf4.block_scale.scale_vec::4X.f32.e2m1.e2m1.f32.ue4m3

which assembles cleanly. Tested-good PTX dump (full file): https://gist.github.com/alexbi29/81fe62fd3b53f09c0c18bbd93112a29f

Hardware caveat

Only validated on SM120a (NVIDIA RTX PRO 6000 Blackwell). The same divergent-binary mechanism exists for all CUDA-13 capable arches; whether SM100 / SM103 mxf4nvf4 paths are also affected is untested but plausible.

Confirming the divergence in 10 seconds

pip download --no-deps nvidia-cutlass-dsl-libs-base==4.4.1 nvidia-cutlass-dsl-libs-cu13==4.4.1 -d /tmp/dl
P=nvidia_cutlass_dsl/python_packages/cutlass/_mlir/_mlir_libs/_cutlass_ir.cpython-312-x86_64-linux-gnu.so
unzip -p /tmp/dl/nvidia_cutlass_dsl_libs_base-4.4.1*.whl  $P | sha256sum
unzip -p /tmp/dl/nvidia_cutlass_dsl_libs_cu13-4.4.1-cp312-cp312-manylinux_2_28_x86_64.whl $P | sha256sum

Yields two different SHA256 hashes for the same logical artifact at the same version.

Per-version SHA256 of _cutlass_ir.cpython-312-x86_64-linux-gnu.so

Wheel Version SHA256 (first 8) Behavior on SM120 mxf4nvf4 mma
libs-base 4.4.0 cdf0e9a0 BROKEN — emits _mma.* PTX
libs-base 4.4.1 abb02941 BROKEN
libs-base 4.4.2 55e62bcc BROKEN
libs-cu13 4.4.0 14a919ba CORRECT — emits mma.sync.aligned.kind::mxf4nvf4.*
libs-cu13 4.4.1 486168fe CORRECT
libs-cu13 4.4.2 b34cc2e8 CORRECT

Triggering both orderings explicitly

Pip's resolver may pick either file as the winner depending on prior install state. To pin the outcome:

# Order A — libs-base last → BROKEN _cutlass_ir.so on disk
pip install --no-deps --force-reinstall nvidia-cutlass-dsl-libs-cu13==4.4.1
pip install --no-deps --force-reinstall nvidia-cutlass-dsl-libs-base==4.4.1
sha256sum $(python -c "import nvidia_cutlass_dsl as p,os;print(os.path.dirname(p.__file__))")/python_packages/cutlass/_mlir/_mlir_libs/_cutlass_ir.cpython-312-x86_64-linux-gnu.so
# → abb02941...   (libs-base wins; broken)

# Order B — libs-cu13 last → CORRECT _cutlass_ir.so on disk
pip install --no-deps --force-reinstall nvidia-cutlass-dsl-libs-base==4.4.1
pip install --no-deps --force-reinstall nvidia-cutlass-dsl-libs-cu13==4.4.1
sha256sum ...
# → 486168fe...   (libs-cu13 wins; correct)

Standalone Python repro

A minimal b12x-based repro that triggers MmaMXF4NVF4Op JIT compile without needing a model checkpoint is at https://gist.github.com/alexbi29/b402fde6439501bb607e1147186016ee — about 50 lines, takes synthetic random tensors. Run on SM120a:

pip install b12x torch
mkdir -p /tmp/dump /tmp/cache
CUTE_DSL_CACHE_DIR=/tmp/cache CUTE_DSL_ARCH=sm_120a CUTE_DSL_KEEP_PTX=1 \
  CUTE_DSL_DUMP_DIR=/tmp/dump python repro_mma_bug.py
grep -c '_mma\.'           /tmp/dump/*.ptx   # broken: > 0
grep -c 'mma.sync.aligned' /tmp/dump/*.ptx   # working: > 0

(A pure-cute_dsl version without b12x would be ~200 lines because MmaMXF4NVF4Op only triggers NVVM lowering inside a fully-formed kernel with tiled_mma + smem layouts + fragment loads + epilogue — leveraging b12x's existing infrastructure keeps the repro short.)

Compounding issue: mixing binaries triggers cute.gemm operandSegmentSizes verification failure or import error

The .py files differ between the two wheels at the same version — they are tightly coupled to the corresponding .so. Mixing them produces either:

'cute.gemm' op operand count (5) does not match with the total size (0) specified in attribute 'operandSegmentSizes'

…or, when libs-cu13's .py files are paired with libs-base's .so:

ModuleNotFoundError: No module named 'cutlass._mlir._mlir_libs._cutlass_ir._lir';
'cutlass._mlir._mlir_libs._cutlass_ir' is not a package

So the fix is not "swap one .so" — the fix is "ensure ALL files come from one wheel."

Workaround

Force libs-cu13 to install LAST so its files win:

pip install --no-deps --force-reinstall 'nvidia-cutlass-dsl-libs-cu13==4.4.1'

Requested fix

One of:

  1. Restructure the wheels so they don't share file paths.
  2. Make both wheels' binaries equivalent so install order doesn't matter.
  3. At minimum, make libs-base 4.4.x's NVVM lowering for SM120 MmaMXF4NVF4Op emit the correct mma.sync.aligned.m16n8k64.row.col.kind::mxf4nvf4.block_scale.scale_vec::4X.f32.e2m1.e2m1.f32.ue4m3 opcode — matching libs-cu13.

Impact

  • Blocks the b12x NVFP4 MoE backend (vllm-project/vllm#39042) on SM120, ~15–20% throughput hit on Qwen3.5-122B / Nemotron-3-Super-120B serving when forced to fall back to flashinfer_cutlass.
  • Hard for users to diagnose: behavior depends on pip install order, not package version, so the bug appears intermittent across machines.

Environment

  • GPU: NVIDIA RTX PRO 6000 Blackwell (SM120a), driver 595, CUDA 13.2.
  • OS: Ubuntu 24.04 (manylinux_2_28).
  • Python 3.12.
  • Versions tested: nvidia-cutlass-dsl{,-libs-base,-libs-cu13} == 4.4.0 / 4.4.1 / 4.4.2.

alexbi29 avatar Apr 15 '26 22:04 alexbi29

Also seeing this

samodi-nv avatar Apr 24 '26 23:04 samodi-nv

Please refer to the detailed explanation here:

https://github.com/vllm-project/vllm/pull/40082#issuecomment-4349406309

AethoceSora avatar Apr 30 '26 03:04 AethoceSora

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar May 30 '26 05:05 github-actions[bot]

@alexbi29 @samodi-nv @AethoceSora this is now fixed in 4.6 release.

brandon-yujie-sun avatar Jul 02 '26 06:07 brandon-yujie-sun