Skip to content

HRX WMMA cores accumulate in f16: K x small-weight sums drift (+17% at K=2816) #284

Closed

Description

@bong-water-water-bong

The code is in our llama.cpp fork (1bit-MONSTER/llama.cpp, branch 1bit/hrx-vulkan-patched, ggml/src/ggml-hrx), which has issues disabled.

ggml_mul_mat_id_f32_f32_wmma (core motifs/mul_mat_id_f32_f32_wmma_core.loom) accumulates in vector<8xf16> WMMA fragments. With many small products, the sum drifts upward once it passes about 32.

Setup:

  • iree-test-loom (hrx-system 244cd38), --device=amdgpu --sanitizer=access, on strixhalo (gfx1151).
  • 1 token, 1 route, expert 1 of 2, output_size 96.
  • MXFP4 weights: every byte 0x77 (e = 119, code 7), so each weight is exactly 12 × 2^-9 = 0.0234375. All inputs 1.0.
  • Every product and every exact partial sum is representable in f16, so the exact result is K × 0.0234375.
K exact unchanged kernel (1bit/hrx-vulkan-patched) kernel with input sizes in multiples of 32
1152 27.0 (needs the change) 27.0
1440 33.75 (needs the change) 34.3125
2048 48.0 53.3125 53.3125
2304 54.0 61.3125 61.3125
2816 66.0 77.3125 (+17%) 77.3125
2880 67.5 (needs the change) 79.3125

Pattern:

  • Results are exact up to about 32.
  • Above that, every 16-wide WMMA step (16 × 0.0234375 = 0.375) adds 0.5. That's 2.0 extra per 256 inputs, which fits every row above.
  • It looks like the accumulation keeps only about 8 mantissa bits there, rounding 32.375 up to 32.5 rather than keeping f16's 0.03125 spacing.
  • The change to input sizes in multiples of 32 gives identical values at 2048/2304/2816, so this predates it.

Possibly the same root cause: bcloud-1b bisected a UD-IQ3_S NaN to common.mul_mat.f32_f32_wmma and common.mul_mat_swiglu.f32_f32_wmma. Both also stage and accumulate in f16; overflow is their working hypothesis.

Not measured yet: the model-level effect, for example KLD of MoE prefill with long K on these kernels. On gpt-oss-20b with the experts on the CPU, KLD vs CPU is 0.031; it has not yet been measured with the experts on HRX.

Repro: ~/lb/calib.sh on strixhalo (cases in ~/lb/calib_cases.loom, linked into ~/lb/calib_{base,g32}.loom).

🤖 Generated with Claude Code

Activity

  1. bong-water-water-bong commented on Oct 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Status 2026-10-04:

  2. bong-water-water-bong commented on Oct 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fork #81 is merged into 1bit/hrx-vulkan-patched (d1691f40a). All four f32_f32 WMMA cores now accumulate in f32: known-answer 84/84 exact (28/84 before), gpt-oss KLD vs CPU 0.0293 -> 0.0269. The cost is gpt-oss pp512 -4.8% on the Loom MoE core (27B +3.3%, Coder unchanged). This issue closes when an engine pin includes it.

  3. bong-water-water-bong commented on Oct 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fixed: the f32_f32 WMMA cores accumulate in f32 (fork #81, 85f5983), in the engine since llama.cpp pin e57beb97 (#311, main 4aa4ac2). Verified on strixhalo: 0.6B serve_e2e PASS and bit-identical greedy output at the pin; the drift measurement was reproduced and closed in the fork PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions