TFR tensor core with DSM drops an MXFP4/NVFP4 NaN block scale when its elements are masked
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
Research direction
Read hw/rtl/tcu/tfr/VX_tcu_tfr_mul_f4.sv at the two exception assignments identified in the issue, then compare the scale NaN handling in VX_tcu_tfr_mul_f8.sv. Reproduce with the listed tcu_fedp commands for --fmt=10 and --fmt=11; done means both return NaN for the masked NaN scale cases. Pull request #517 is already open for this issue.
Written by the indexing model from the issue text.
Description
Hi there,
With VX_CFG_TCU_DSM_ENABLE, a NaN block scale (E8M0 0xFF for MXFP4, UE4M3 0x7F for NVFP4) no longer makes the result NaN when every element it scales has a zero operand. MXFP8 and MXBF8 do return NaN in that case (the fp8 multiplier raises the scale NaN for masked lanes since #460), and so do builds without DSM, SimX and the TfrFedp reference.
The FEDP unit test shows it on master 2221ee286 with the MX configuration of run-tcu-unit; --sparsity=100 zeroes A and clears the valid bits the way DSM does:
make -C hw/unittest/tcu_fedp NUM_REGS=2 SF=1 CONFIGS="-DSIMULATION -DSV_DPI -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_TYPE_TFR -DUSE_FEDP -DVX_CFG_TCU_MX_ENABLE -DVX_CFG_TCU_FP8_ENABLE -DVX_CFG_TCU_FP4_ENABLE -DVX_CFG_TCU_MXFP4_ENABLE -DVX_CFG_TCU_NVFP4_ENABLE"
./hw/unittest/tcu_fedp/tcu_fedp --fmt=10 --W=25 --ulp=0 --sfa=255 --sparsity=100 --no-trace
./hw/unittest/tcu_fedp/tcu_fedp --fmt=11 --W=25 --ulp=0 --sfa=127 --sparsity=100 --no-trace
Both fail at test 0 with expected=nan (0x7fc00000), actual=3.08809e+09 (0x4f38108d), which is C. --fmt=8 and --fmt=9 with the same options pass. The same happens with LANE_MASK=0, the core's setting. In a full WMMA run on rtlsim (NT=8, TFR, DSM), an MXFP4 or NVFP4 row of A that is all zero under NaN scales gives 0 in that row of C; without DSM, and on SimX, the row is NaN.
The cause is in hw/rtl/tcu/tfr/VX_tcu_tfr_mul_f4.sv, lines 262 and 523, which gate the scale NaN with the lane's valid bits (term_on = vld_mask):
assign exceptions_mxfp4[i].is_nan = ((sf_a == 8'hFF) || (sf_b == 8'hFF)) && (|term_on);
assign exceptions_nvfp4[i].is_nan = sf_nan && (|term_on);
Suggested fix: drop && (|term_on) (and the then unused term_on), as was done for sf_nan in VX_tcu_tfr_mul_f8.sv. Without DSM the mask is all ones, so default builds do not change. A PR follows.
Thanks!
- Dominant language
- Verilog
- Stars
- 2.4k
- Forks
- 563
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 71
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vortexgpgpu/vortex
-
RV64 signed DIV/REM restores the sign from bit 31Possibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vortexgpgpu/vortex#501 · 1 comment ·
Maintainers usually reply within 1 day
-
fpu: sign-extend RV64 FCVT.WU positive overflow resultsPossibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vortexgpgpu/vortex#499 · 1 comment ·
Maintainers usually reply within 1 day
-
WGMMA: the next kernel can compute with the previous kernel's B row left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#558 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
vortexgpgpu/vortex#521 ·
Maintainers usually reply within 1 day
-
WGMMA: a block-major B tile can read K-major data left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#518 ·
Maintainers usually reply within 1 day