DSP tensor core: fp16 subnormal inputs are used at four times their value
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 1/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- computer-graphics
Research direction
Read hw/rtl/tcu/dsp/VX_tcu_fedp_dsp.sv at fp16_to_fp32, where the issue identifies the exponent calculation for subnormal inputs. Reproduce with the provided sgemm_tcu input change in tests/regression/sgemm_tcu/main.cpp and the ci/blackbox.sh rtlsim command; completion is shown when all 2046 subnormal codes convert correctly and the run passes. Pull request #512 is already open for this issue.
Written by the indexing model from the issue text.
Description
Hi there,
With VX_CFG_TCU_TYPE_DSP, every fp16 subnormal operand of the tensor core is multiplied as if it were four times larger.
On master 2221ee286, give sgemm_tcu subnormals in row 0 of A, for example with this change to tests/regression/sgemm_tcu/main.cpp (after the loops that fill h_A and h_B):
for (uint32_t k = 0; k < K; ++k)
h_A[k] = uint16_t(1 + (k * 97) % 0x3ff); // fp16 subnormals, ITYPE=fp16 only
and run
CONFIGS="-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_TYPE_DSP -DITYPE=fp16 -DOTYPE=fp32" ./ci/blackbox.sh --driver=rtlsim --app=sgemm_tcu
rtlsim reports Found 64 / 4096 errors!, all of row 0 of C, e.g. expected=0.000873, actual=0.003491. simx passes, and so do the TFR and DPI types on rtlsim with the same data. A single product shows it directly: A = 0x0001 (2^-24) times B = 1.0 gives 0x34800000 (2^-22) instead of 0x33800000, and 0x03ff gives 2.44e-4, which is larger than the smallest normal 0x0400 (6.10e-5, converted correctly).
The cause is fp16_to_fp32 in hw/rtl/tcu/dsp/VX_tcu_fedp_dsp.sv:60:
is_denormal ? 8'd127 - 8'd14 - {3'b0, leading_zeros} + 8'd1 :
A subnormal 0.f x 2^-14 equals 1.f' x 2^(-15 - leading_zeros), so its biased fp32 exponent is 112 - leading_zeros; the code gives 114 - leading_zeros. The mantissa bits are already right. bf16 and the integer formats do not use this converter. On an FPGA build the converted value is a normal fp32 number, so the flush-to-zero of the vendor floating-point cores does not hide it.
Suggested fix: is_denormal ? 8'd112 - {3'b0, leading_zeros} :. With it, all 2046 fp16 subnormal codes convert exactly and the run above passes. 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
All issues in vortexgpgpu/vortex
Similar issues
-
difficulty:easy func:viewer prio:normal type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NatronGitHub/Natron#2300 ·
Maintainers usually reply within 1 day
-
bug CImg difficulty:easy prio:low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NatronGitHub/openfx-misc#497 ·
Maintainers usually reply within 1 day
-
bugfix
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
storytold/designcraft#3485 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MrNeRF/LichtFeld-Studio#4319 ·
Maintainers usually reply within 1 day
-
prio:low scope:world
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
OliverRomhagen/vrigstad-joyride#849 ·
Maintainers usually reply within 1 day