DSP tensor core: fp16 subnormal inputs are used at four times their value

Aperta
#510 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@youzi27 ci sta già lavorando.

Dal 27/11/2026.

  • #512 di @youzi27 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
1/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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!

Lingua principale
Verilog
Stelle
2.4k
Fork
563
Merge medio
1g 7h
PR unite (30g)
71

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vortexgpgpu/vortex

Tutte le issue di vortexgpgpu/vortex

Issue simili

Altre issue su Computer Graphics

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.