[Feature] add sm120 hidden datatypes support (float8e3m4 / float4e0m3)#41
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Emit e3m4 (mma and cvt) through the e5m2 PTX encoding instead of e4m3, so the cubin patch targets E5M2 instructions only and can never rewrite an e4m3 scale cvt sharing the same cubin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # tests/test_mxmma.py
There was a problem hiding this comment.
Code Review
This pull request introduces support for hardware narrow-float formats (float8e3m4 and float4e0m3) not natively exposed by PTX, implementing a C++ cubin patcher (patch_cubin.cpp) and integrating it into the JIT compiler, runtime, and quantization kernels. The review feedback identifies several critical and medium-severity issues, including a copy-paste bug in humming/kernel/humming.py that selects the wrong patching mode, potential out-of-bounds reads during ELF parsing, unhandled failures for ftell and fwrite in the C++ patcher, a lack of error handling when g++ is missing during compilation, and potential undefined behavior in cubin_patch_buffer with null or empty inputs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| c_dtype=dtypes.DataType.from_str(c_dtype), | ||
| bs_dtype=dtypes.DataType.from_str(bs_dtype), | ||
| group_size=16, | ||
| ) |
There was a problem hiding this comment.
This path has a PTX ISA version requirement. The combination kind::mxf4nvf4 + scale_vec::4X + ue8m0 is not accepted by PTX ISA 8.8 . Support for this combination was added in PTX ISA 9.1
There was a problem hiding this comment.
Thank you for pointing that out. However, this issue also exists under the original e2m1, and the compatibility problem with different CUDA versions is not the target of this PR. We will address it in future work.
|
Credit to @im0qianqian for the original idea shared in https://zhuanlan.zhihu.com/p/2059376150565089368, which inspired this PR. |


This PR add sm120 hidden datatypes support (float8e3m4 / float4e0m3).
The sm120 devices supports float8e3m4 and float4e0m3 but PTX doesn't expose. We can patch the cubin to use those formats.
Technical Details
-7, -6, -5, ..., 5, 6, 7). The value range is equivalent to that of INT4 but without -8. Note that floating-point numbers with an exponent field of 0 are not actually defined by the specification. Humming simply chooses to make the data type that falls within this value range an E0M3.byte0 | ((byte1 & 0x0f) << 8)), can be used to identify the instruction class.OMMA (FP4 MMA)
0x47fOMMA.SF.16864.F32.E2M1.E2M1.UE4M3.4XOMMA.SF.16864.F32.E2M1.E2M1.E8.4XMXFP4 with groupsize=32 doesn't support E0M3.
QMMA (FP8 MMA)
0x47aQMMA.SF.16832.F32.E4M3.E4M3.E8QMMA.16832.F32.E4M3.E4M3Two independent 3-bit type fields:
000001010011100101110111CVT (F2FP)
0x23eF2FP.SATFINITE.<fmt>.F32.PACK_AB_MERGE_CF2FP.<f16>.<fmt>.UNPACK_BDown-convert format subfield = (bit87, bit86, bit85, bit76).
1,0,0,11,0,0,01,0,1,00,1,1,10,1,1,00,0,1,10,0,1,0Humming Implement
Humming developed kernels that use these two formats. Since these formats are not exposed in PTX, we use E5M2 and E2M1 as substitutes during compilation and then patch the resulting cubin file.
The current limitation is that mixed-precision multiplication between different formats with the same bit width is not supported (for example, A cannot be E4M3 while B is E3M4, nor can A be E2M1 while B is E0M3). This is supported in hardware, but has not yet been implemented in Humming.
performance
NVFP4-E0M3
MXFP8-E3M4
FP8-E3M4 (no-blocked, channelwise)
The patched cubin can utilize the device's peak TFLOPS.