Skip to content

feat(rocm): class-axis loss + fpquant/nvfp4 lanes — completes the ROCm loss/quant mirror - #172

Merged
gstoner merged 1 commit into
mainfrom
s2/rocm-class-loss-fpquant
Jun 28, 2026
Merged

gstoner merged 1 commit into
mainfrom
s2/rocm-class-loss-fpquant

Conversation

@gstoner

@gstoner gstoner commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Final ROCm-mirror PR for the loss/quant families — closes the cross-device pair for the S11 class-axis losses and the S9 quantize ops (x86 in #167/#168/#169).

class-axis loss (rocm_class_loss_compiled, pure composition — no new C++)

cross_entropy / kl / js / focal / label_smoothed_cross_entropy / z_loss; exp/log run on the rocm unary lane (gfx1151), class-axis max/sum/gather/one-hot on the host (same pattern as the x86 class-loss + ROCm attention/gemm-family lanes).

fpquant + nvfp4 (new GenerateROCMFpQuantKernel.cpp)

tessera_rocm.fpquant — flat 1-operand float-grid mantissa-snap (ax=min(|x|,max); e=max(floor(log2 ax),min_exp); ulp=2^(e−mant); roundeven; sign + NaN-propagate), via math.log2/floor/exp2/roundeven→ROCDL, parameterized for fp8 e4m3/e5m2, fp6 e2m3/e3m2, fp4 e2m1. rocm_fpquant_compiled (per-tensor scale) + rocm_nvfp4_compiled (per-block fp8-E4M3 scale + E2M1 codes, host block structure).

Validation (gfx1151)

test_rocm_class_loss_compiled.py + test_rocm_fpquant_compiled.py15 passed vs tessera.losses/tessera.ops (class-loss 2e-4; fpquant/nvfp4 2e-3 — the GPU log2/roundeven grid matches the reference on random data) + codegen gate. ruff/mypy clean; consistency green (88 passed).

Wiring

runtime executors + _rocm_fpgrid / _rocm_unary_t / _rocm_log_softmax helpers + executor table; execution_matrix catalog + 3 rows; backend_manifest _ROCM_COMPILED (6+6+2 ops) + _NUMERICAL_FIXTURES; dashboards regenerated.

With this, loss (29) + rl_loss (4) + quantize (8) all run on both gfx1151 and AVX-512 — three of the four "0/0" categories are now fully cross-device. Only spectral remains.

🤖 Generated with Claude Code

…m loss/quant mirror

Final ROCm-mirror PR for the loss/quant families — closes the cross-device pair
for the S11 class-axis losses and the S9 quantize ops (x86 in #167/#168/#169).

class-axis loss (rocm_class_loss_compiled, pure composition — no new C++):
cross_entropy / kl / js / focal / label_smoothed_cross_entropy / z_loss; exp/log
run on the rocm unary lane (gfx1151), class-axis max/sum/gather/one-hot on the
host (same pattern as the x86 class-loss + ROCm attention/gemm-family lanes).

fpquant + nvfp4 (new GenerateROCMFpQuantKernel.cpp): tessera_rocm.fpquant — flat
1-operand float-grid mantissa-snap (ax=min(|x|,max); e=max(floor(log2 ax),
min_exp); ulp=2^(e-mant); roundeven; sign+NaN-propagate), log2/floor/exp2/
roundeven via math->ROCDL, parameterized for fp8 e4m3/e5m2, fp6 e2m3/e3m2,
fp4 e2m1. rocm_fpquant_compiled (per-tensor scale) + rocm_nvfp4_compiled
(per-block fp8-E4M3 scale + E2M1 codes, host block structure).

Validation (gfx1151):
- tessera-opt codegen + ROCDL lowering verified.
- test_rocm_class_loss_compiled.py + test_rocm_fpquant_compiled.py — 15 passed
  vs tessera.losses/tessera.ops (class-loss 2e-4; fpquant/nvfp4 2e-3 — the GPU
  log2/roundeven grid matches the reference on random data).

Wiring: runtime executors (class-loss / fpquant / nvfp4) + `_rocm_fpgrid` /
`_rocm_unary_t` / `_rocm_log_softmax` helpers + executor table; execution_matrix
catalog + 3 rows; backend_manifest _ROCM_COMPILED (6+6+2 ops) +
_NUMERICAL_FIXTURES; dashboards regenerated.

With this, loss (29) + rl_loss (4) + quantize (8) all run on BOTH gfx1151 and
AVX-512 — three of the four "0/0" categories fully cross-device. Only spectral
remains.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gstoner
gstoner merged commit 66cc130 into main Jun 28, 2026
14 checks passed
@gstoner
gstoner deleted the s2/rocm-class-loss-fpquant branch June 28, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant