Skip to content

ggml-hrx: int4-activation SwiGLU prefill is opt-in (27B KLD 0.0019 -> 0.000003, speed -0..0.7%) - #121

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-i4-prefill-opt-in
Oct 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-i4-prefill-opt-in

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

common.mul_mat_swiglu_q5_projection.symmetric_i4_q8_plane quantizes the gate/up activations of
the Q5_K/IQ4_XS SwiGLU layers to symmetric int4 in every prompt batch of up to 2048 tokens (its
2048-token cap is why -ub 4096 measured a different answer, engine #390). New file
dispatch-i4-prefill-opt-in.{h,cpp} (ours); one early return in its matcher; the exact f16 path
(the HIP dense SwiGLU) takes those layers instead.

Measured on strixhalo gfx1151, performance mode, Qwen3.8-27B UD-Q4_K_XL:

  • llama-perplexity -c 4096 --chunks 2 -ub 2048 against the -ub 4096 logits (which never took
    this path): default 0.001949 mean KLD (same top 97.9%) -> 0.000003, PPL 6.7183 -> 6.7097;
    GGML_HRX_SYMMETRIC_I4_PREFILL=1 reproduces 0.001949. At -c 512 -ub 512 the KLD against the
    previous default is 0.002222, PPL 6.6835 -> 6.6381.
  • Speed with the matcher off (interleaved llama-bench x3, medians): pp512 645.8 -> 645.7 at ub
    512 and 645.2 -> 640.8 at ub 2048, pp2048 617.0 -> 615.8 / 594.2 -> 592.9, pp4096 603.2 ->
    600.5 / 573.1 -> 571.1 (-0.0..-0.7%).

🤖 Generated with Claude Code

…C_I4_PREFILL=1)

common.mul_mat_swiglu_q5_projection.symmetric_i4_q8_plane quantizes the gate/up activations of
the Q5_K/IQ4_XS SwiGLU layers to symmetric int4 in every prompt batch of up to 2048 tokens (its
2048-token cap is why -ub 4096 measured a different answer, engine #390). New file
dispatch-i4-prefill-opt-in.{h,cpp} (ours); one early return in its matcher; the exact f16 path
(the HIP dense SwiGLU) takes those layers instead.

Measured on strixhalo gfx1151, performance mode, Qwen3.8-27B UD-Q4_K_XL:
- llama-perplexity -c 4096 --chunks 2 -ub 2048 against the -ub 4096 logits (which never took
  this path): default 0.001949 mean KLD (same top 97.9%) -> 0.000003, PPL 6.7183 -> 6.7097;
  GGML_HRX_SYMMETRIC_I4_PREFILL=1 reproduces 0.001949. At -c 512 -ub 512 the KLD against the
  previous default is 0.002222, PPL 6.6835 -> 6.6381.
- Speed with the matcher off (interleaved llama-bench x3, medians): pp512 645.8 -> 645.7 at ub
  512 and 645.2 -> 640.8 at ub 2048, pp2048 617.0 -> 615.8 / 594.2 -> 592.9, pp4096 603.2 ->
  600.5 / 573.1 -> 571.1 (-0.0..-0.7%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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