Commit Graph
675 Commits
Author SHA1 Message Date
Boris Manojlovic fd40bb430c nomicbert: architecture plugin for nomic-embed-text-v2-moe
Post-norm encoder with fused Wqkv and biases, NeoX rotary, non-causal attention, a dense MLP on even layers and a top-2 of 8 expert MLP on odd layers, mean pooling into the pooled f32 buffer for /v1/embeddings. The checkpoint is f32; data/recipes/nomic-embed-v2-moe-bf16.recipe casts the linears, the token embedding and the token-type table to bf16 (the device kernels read bf16), norms and biases stay f32. The checkpoint's shared experts.bias is not applied: against a llama.cpp run of the same checkpoint at Q8_0 the variant without it matches best (cosine 0.9994; the others 0.9990 to 0.9993), and llama.cpp's own nomic-bert-moe does not carry it. Verified on a gfx1201 card and on libavx/libref against a pure-float32 torch reference: mean cosine 0.99995, min 0.99983 over 20 texts. Unit tests declare and lint a cut-down model. Not verified: inputs above 512 tokens against a reference on the device, other quantisations.
2026-10-27 20:58:47 +01:00
Boris Manojlovic 4853db97db checkpoint: nomic config key aliases, RAD_MAP_TRANSPOSE honouring src_index
meta_from_config_json reads the nomic spellings (n_layer, n_embd, n_head, n_inner, n_positions, moe_top_k, layer_norm_epsilon, rotary_emb_base) as fallbacks in the same chain as the usual keys; existing checkpoints parse as before. RAD_MAP_TRANSPOSE can first take one expert's sub-tensor of a stacked table: src_index[0] picks the dim-0 sub-tensor of a rank-3 stack, or, with src_rows[0] > 0, the row block of a rank-2 stack flattened over its rows. map_transpose_slice() declares it; map_slice() takes the same optional sub_rows. Tests in checkpoint_test cover the aliases, the [8,4,3] case, the flattened case and an out-of-range index.
2026-10-27 20:58:47 +01:00
Boris Manojlovic 157450a82b gemma4_bf16: per-layer MLP width for use_double_wide_mlp (Gemma 4 E2B), and the bf16 descriptor for unmodified Google E2B/E4B directories 2026-10-27 20:57:20 +01:00
mici81andClaude Opus 5.5 b74a6b2ece spechub: mtp_couple_verify walks the live candidates only (151 -> 31 us a launch)
The sampler's candidate plane is kSampleCandidates (1024) wide and at top_k 20 about 20 entries are live,
but the coupled verify ran its eligibility scan (global memory, one entry at a time) and its sums and
walks on one thread over all 1024: 92-151 us a launch at any row count, on the critical path of every
coupled step. The workgroup now checks validity and takes the maximum in parallel (order-free, exact),
compacts the live indices in ascending order into LDS, and the serial sums and walks run over that list
in the host reference's order, so the token is the same bit for bit.

vtime (n_cand 1024, 20 live, every row bound): 151.7 / 92.8 / 100.5 -> 31.3 / 32.2 / 35.9 us at 4 / 16 /
64 rows; device == host on every row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 18:37:28 +01:00
mici81andClaude Opus 5.5 ce79b12126 dflash2 coupled walk: Q at temperature 0.6 by default
Q's temperature (RADIANCE_DFLASH_Q_TEMP) only moves acceptance, never the
output law. Held-out tokens per verify step at request temperature 1, x4,
32 rows of the eval set, Qwen3.8-27B MXFP4 with a DFlash2 drafter fine-tuned on our traffic, our serving flags:
ordinary rule 3.52; coupled with Q at 1.0 3.71, 0.7 3.88, 0.5 3.85,
0.35 3.77. The walk's scores are flatter than the target's law, so a
sharper Q puts its mass where the target's is; 0.6 is the default now.

At 0.6, 3 interleaved rounds against the ordinary rule (64 held-out rows
at x4, and three requests at x1 and x4, 1500 tokens, T 1):
- tokens per step 3.53 -> 3.82 (+8.2 %), every round apart
  (3.50/3.49/3.61 vs 3.82/3.79/3.86); time-weighted decode +5.4 %;
- decode per stream: 0.7k prompt x1 174.1 -> 181.7 (+4.4 %), x4 144.6 -> 153.8
  (+6.4 %); 22k prompt x1 186.6 -> 191.0 (+2.3 %), x4 135.1 -> 146.2 (+8.2 %);
  41k prompt x1 186.9 -> 196.8 (+5.3 %), x4 125.8 -> 135.0 (+7.3 %);
  aggregate at x4 +5.3..+5.5 %.
Coupled at 0.6 against the ordinary rule, 5000-6000 samples of tokens 1-4
of two chat prompts: chi-square p 0.62..0.99.

The walk's kernel issues each candidate's successor slice and unary score
before the predecessor's codebook row (both are independent of it). This is
the build measured above; it moved the pass time within noise (91.3 -> 90.8
us at M 16, steps 7), and tokens, ids, x and status still match the host
oracle on all 40 random lattices (q by FP64 exp ulps, <= 4.3e-16).

ctest (the environment-only tests excluded) 105/105.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 18:37:28 +01:00
mici81andClaude Opus 5.5 cb0abe9ac7 dflash2: lossless coupled acceptance at T > 0 (--draft-coupling on)
DFlash2's drafts were the greedy walk over its candidate lattice, accepted
only when they equal the target's own sampled draw: P(y == x) instead of
rejection sampling's sum min(P, Q). --draft-coupling already did the latter
for a linear MTP head; this extends it to the block drafter.

- dflash_couple_propose (spechub plugin, device row + host oracle): after
  dflash_select, the same lattice walked again, sampled. Position l scores
  each candidate as dflash_select does (unary + low-rank edge from the
  previous token), Q_l = FP64 softmax of score / q_temp over the best eight
  in-vocabulary candidates, x_l ~ Q_l at (seed, base, KEY_DRAFT + l + 1),
  x_l is the next predecessor. Position l writes round l+1's state row, so
  the engine binds it and the sampler's mtp_couple_verify (maximal coupling,
  residual (P - Q)+) verifies it exactly as an MTP round. Q depends on the
  committed text and on x_0..x_{l-1}, never on the verify, and is stored
  exactly. Greedy requests keep dflash_select's tokens (status 0); a draw
  for another card or a Q that cannot be built takes the walk's argmax and
  the ordinary verify (status -1). The shared arithmetic is in
  abi/rad_spechub.h (rad_dflash_couple_step / _walk).
- The block driver stages one draw per drafting row before the query pass,
  reads the states back with the slots and binds them after the commit
  (Engine::bind_couple, shared with the serial driver).
- qwen35_fp8 declares the planes and the op under --draft-coupling;
  RADIANCE_DFLASH_Q_TEMP sets Q's temperature (default 1, exact at any).
- Default (flag off): no op, no plane, no change.

Gates:
- spechub_dflash_couple_test (CPU): emitted token vs P by chi-square over 3
  seeds each, Fisher-combined p 0.135..0.919, for Q = P, Q on fewer tokens
  than P, Q mostly outside P, top_k 20 + top_p 0.95, top_p 0.6, top_k 3 at
  T 0.7, peaked Q; acceptance = sum min(P, Q) within 5 sigma; the walk's
  stored Q equals the softmax of its scores (1e-5) and x follows it (p
  0.993); the whole draft/verify/bonus loop over 3 tokens matches the
  target's autoregressive law (combined p 0.62 at q_temp 1, 0.67 at 0.5,
  0.024 with every 2nd step on the ordinary verify).
- Device row vs host oracle, 40 random lattices at the production geometry
  (V 248320, K 16, R 256, steps 7/3, M 1..16): tokens, x, ids, status
  identical; q differs only by FP64 exp ulps (<= 4.3e-16 relative).
  91 us a launch at M 16, steps 7.
- Engine, Qwen3.8-27B MXFP4 TP2, our serving flags, 4-6 tokens of two chat
  prompts at T 1 / top_p 0.95 / top_k 20, 5000-11000 samples per arm:
  coupled vs ordinary speculation chi-square p 0.23..0.81 (tokens 1-4 and
  pair 1-2); both differ from no speculation on one prompt by the same
  amount (the verify-vs-decode logits, not the rule).
- Flag off, old build (up12 5dbb5dc) vs this: greedy top-5 logprob traces
  identical over 300 tokens (spec 7 and 0, two requests each), 6/6
  fixed-seed sampled texts identical.
- ctest (the environment-only tests excluded) 105/105.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 18:37:28 +01:00
baKon 72a58d0c0c core: --expert-stats FILE, the routed experts every layer selects, from the heat engine's histograms
Which experts a served model actually uses, per layer, is what deciding how to spend an expert's
bits needs, and the core already has it: every routed layer's counts come back to a host bank once
a pass, and the heat engine drains the landed banks once a step, one step behind. --expert-stats
FILE credits the same rows to a host tally and writes it as JSON every 30 s and at shutdown,
through a temporary and a rename (place/xstats.h). No device work, no copy, no synchronisation;
where the heat engine is off (every expert in VRAM, a static plan) the drain runs for the tally
alone, and at shutdown the streams are drained and the banks still in the ring are credited.

Counts are filed by step kind: prefill (no decode rows), decode, mixed (one histogram cannot split
it) and draft, which is every routed layer past the trunk (an MTP or DSpark head; its bank holds
the step's last draft pass). Each rank files its passes' kinds when it issues them.

A histogram row is the rank's own experts from zero, so under expert parallelism (deepseek41) it
is the rank's slice. The map from a rank's index to the model's expert id comes from the container:
index e is the unit declared with group expert e, and the directory entry of that unit's weight
names the expert. An expert several ranks hold (a width slice each) is counted on the lowest; a
rank that counts nothing does not drain for the tally. Without directory ids the map falls back to
the indices (one rank, or every rank holding the model's count) or to rank order.

The file carries the model, the routed layers, each layer's expert count and top_k, tokens and
steps issued by kind, histograms, passes, observed tokens and selections per kind and layer, the
per-rank drain counters (lost, unmapped, unclassified), and counts[kind][layer][expert].
/server_info names the file. Router weights are not summed: they stay on the card.

Tests: xstats_test (the map, the tally's kinds and merge, the file); config_test lists the flag
and checks it is off until it names a file.
2026-10-27 18:34:32 +01:00
Constantin fb8cb95b7e docs: verify non-target kernel dispatch 2026-10-27 18:28:46 +01:00
Constantin c2565369e9 docs: record BF16 W4 review follow-up 2026-10-27 18:28:46 +01:00
Constantin d947d7139e fix: preserve BF16 W4 CPU narrowing semantics 2026-10-27 18:28:46 +01:00
Constantin da8c95d4d9 docs: clarify shared R9700 power caps 2026-10-27 18:28:46 +01:00
Constantin fbffd33e22 docs: record third-card benchmark confirmation 2026-10-27 18:28:46 +01:00
Constantin 05ccf42964 docs: record cross-card HYV3 throughput check 2026-10-27 18:28:46 +01:00
Constantin 31ac68549b docs: record launcher compatibility smokes 2026-10-27 18:28:46 +01:00
Constantin 2c9d415166 docs: record full HYV3 validation and A/B results 2026-10-27 18:28:46 +01:00
Constantin 85b5388089 docs: record release-based GPU and inference smoke 2026-10-27 18:28:46 +01:00
Constantin c301f3315e docs: record release-tag PR build validation 2026-10-27 18:28:46 +01:00
Constantin edbdc44b8e docs: verify engine build on latest upstream 2026-10-27 18:28:46 +01:00
Constantin 87cb41b5fa docs: distinguish validation from final rebased base 2026-10-27 18:28:46 +01:00
Constantin 9d6ae971e8 docs: record local Qwen validation artifact hash 2026-10-27 18:28:46 +01:00
Constantin ad26c95675 docs: record rebased HYV3 validation results 2026-10-27 18:28:46 +01:00
Constantin 3a1706f1fa Document HYV3 optimization scope, measurements and validation
## Summary

Optimize HYV3 decode and the shared W4/W5 and signed-I4 expert paths:

- Compact the asymmetric W4/W5 one-row epilogue without changing its WMMA or split-K arithmetic.
- Pack per-128-scale I4 experts into `t16k64` fragments and load one routed row directly into registers; keep prefill compatible with the same packed weights. Subgroup-scaled codebooks retain their layout.
- Narrow BF16 activations to F16 inside the W4 decode GEMM, replacing the separate activation cast with the same rounding.
- Reuse fused Q/K normalization/RoPE/KV-store, residual norms, routing and the TP1 shared/routed gather in HYV3. TP2 retains separate arm reductions.
- Add cold-weight timing modes, canonical/byte/guard checks, independent nibble-address tests and an affected-path/measurement report.

## Validation

On merged `main` (`2d2f638`):

- `gfx1201` kernel library, selftest executable and all three HYV3 plugins: compiled.
- Release and ASan/UBSan/leak architecture suites: passed.
- Layout parity: 1,145 checks over 20 cases, including GPTQ, rotated experts and subgroup codebooks: passed.
- Reference arithmetic: 136,622 checks over 254 cases passed with two failing upstream inventory/sweep cases excluded; the same failures were reproduced using unchanged upstream test source.

A full engine/unit run is blocked by upstream's missing KV-stream headers. No GPU workload or serving-service changes were made during this validation pass.

## Measurements and readiness

Earlier TP1 HYV3 measurements reached 115.678 decode tokens/s versus 90.290 initially; the isolated expert-packing step measured 95.392 to 103.364. These used a highly repetitive 10,030-prompt/2,000-output `alpha` workload on an R9700. They are **historical, not measurements of this rebased PR**, and establish neither general throughput nor gains on other models.

Keep this PR in draft until current-base GPU numerical/guard checks and matched throughput/text/tool-quality measurements pass for HYV3 and the other affected W4/W5/I4 paths. The historical tool subset did not clear its earlier guard and needs an isolated rerun.

See [the optimization report](docs/benchmarks/hyv3-w4-decode.md) for affected models/encodings, historical results, validation details and remaining gates.
2026-10-27 18:28:46 +01:00
Constantin 9916dcace3 Fold HYV3 TP1 shared combination into the routed gather
Prepare a unity-gate plane once per step and use the existing gather at TP1 while preserving routed BF16 rounding before the shared add. Retain independent arm reductions and combination at TP2, with multi-pass graph and routing-rounding checks.
2026-10-27 18:28:46 +01:00
Constantin 36c39efdca Fold HYV3 residual adds into the following norms
Reuse the existing BF16-rounded add/norm fusion while retaining final output materialization and the original collective positions. Cover TP1, TP2 and multi-pass prefill without introducing calibration hooks.
2026-10-27 18:28:46 +01:00
Constantin d59cdce040 Use fused QK normalization RoPE and KV store in HYV3 decode
Wire the existing fused prologue into the private HYV3 attention helper for small BF16-KV batches. Retain the separate operations for other shapes and KV layouts, with graph coverage of both paths.
2026-10-27 18:28:46 +01:00
Constantin bb48b14005 Reuse BF16 add for HYV3 shared/routed combination
Replace the equivalent FP32 cast/add/cast chain with the existing BF16 add and enable the existing fused router for HYV3. Preserve separate tensor-parallel arm reductions and BF16 rounding boundaries; add the reference arithmetic check.
2026-10-27 18:28:46 +01:00
Constantin 492d33c470 Narrow BF16 activations inside asymmetric W4 decode GEMMs
Replace the separate BF16-to-F16 activation cast with the same nearest-even narrowing on load. Keep existing split-K and WMMA arithmetic. Test finite and raw-bit activations, canonical arithmetic, byte parity and output guards; provide BF16-input cold-weight timing sweeps.
2026-10-27 18:28:46 +01:00
Constantin aeedae4027 Pack per-128 I4 experts for coalesced one-token GEMMs
Change only the per-128-scale load-time expert layout to 16-column/64-K fragment tiles. Add the register-loaded one-row kernel, keep staged prefill compatible, and leave subgroup-scaled codebooks row-major.

Update the stored-layout hashes atomically with the layout and add independent canonical-nibble address checks.
2026-10-27 18:28:46 +01:00
Constantin 692ce7ed8b Measure routed-expert GEMMs with cold live-weight banks
Add the TP1 HYV3 expert geometry to the timing harness while keeping the Flash-Next mode. Rotate actively addressed codes and scales and check all output bytes across dispatch forms.
2026-10-27 18:28:46 +01:00
Constantin 9f90451599 Prune padded-row work from single-row asymmetric W4/W5 GEMMs
Keep WMMA, group and split arithmetic unchanged, but stage and reduce only the live row. Add byte parity, guard and canonical-arithmetic cases over legal launch geometries.
2026-10-27 18:28:46 +01:00
Constantin 2ef0536051 Expose a cold-weight asymmetric W4 GEMM timing sweep 2026-10-27 18:28:46 +01:00
Constantin 99edcc97e0 Cover head-128 BF16 fused QK normalization in existing kernels
Extend registry bounds for the existing qkv_norm_rope_kv_store implementation and exercise the head-128 GQA-8/16 shapes numerically. No HYV3 architecture hook is included in this kernel-only branch.
2026-10-27 18:28:46 +01:00
orca f69c9d8324 test(isa): the two parsers, on fixtures
isa_tools (fast tier) runs libr4d/isa/selftest.sh: no build tree, no card, no
ROCm. rows.awk at the nine 24-VGPR boundaries and at the wave64 quantum;
waterfall.awk on a forward branch after a movrel (not a loop), a real back-edge
(a loop), a movrel with no branch, and a kernel with no movrel after a kernel
that has one.

Against the code this replaces, five of the nine occupancy checks fail (97,
121, 145, 241, 256) and the forward-branch case counts a loop where there is
none. The rest pin behaviour that is right today: the movrel-with-no-branch row
and the empty kernel stay as they are, and the seen-flag reset in flush() has no
observable case in this tree -- waterfall.awk resets it per kernel so a later
edit cannot reintroduce one.
2026-10-27 18:24:13 +01:00
orca f406c4dafc fix(isa): fail closed, and count a back-edge, not any exec branch
Both instruments could report a clean tree after inspecting nothing.
res.sh and waterfall.sh skipped an object whose code object would not extract
(`|| continue`), skipped a disassembly that failed, and then printed a header
and a short table and exited 0. waterfall.sh additionally counted every
s_cbranch_exec* after a movrel -- a forward branch is not the loop that re-runs
the movrel -- and carried that flag across kernels, because flush() reset n and
loops but not seen.

Now: no .hip.o under BUILD, a code object that will not extract, a
llvm-readelf/llvm-objdump that fails, or not one kernel inspected all exit 1. A
HIP translation unit with no kernels carries no .hip_fatbin and is skipped, not
failed -- one exists in this tree (r4d_ar_entry), which is why "every object must
extract" was not an option. The parse is waterfall.awk, and a branch counts only
when its target label was already defined above it, i.e. is a back-edge.

Measured over every kernel this tree builds (761 movrels): 199 loops become 101,
19 rows change, and 12 of them are r4d_ar_twoshot_Nrank_exact reporting 7 where
it has no back-edge at all:

    r4d_ar_twoshot_Nrank_exact  7 -> 0   (x12)
    r4d_hc_bf16                 6 -> 1
    xprefetch                   4 -> 3
    r4d_ple_gate_bf16           3 -> 0
    r4d_ngram_ids               2 -> 1
    spechub                     9 -> 8, 2 -> 0
    r4d_encoder_bf16            1 -> 0
2026-10-27 18:23:49 +01:00
mici81andClaude Opus 5.5 74e701ea17 prefix cache: a snapshot at a head other prompts share
A model with snapshots (recurrent state, or a sliding window the cache does not index) resumes a
hit only at a snapshot, and those are taken on the checkpoint interval and at each prompt's tail.
A head every request starts with -- the same system prompt or instructions in front of a different
text, as a translation service sends its pieces -- is usually shorter than an interval, and each
tail is its own, so the head was computed again by every request.

The cache now counts the blocks published right after each block (Entry::n_children) and reports
where a lookup leaves a head that at least two cached prompts already left differently
(CacheHit::branch_at; one is not enough, the next prompt could be the same conversation going on).
When nothing resumes within kSharedHeadMin (256) tokens of that point, admission sets the request's
own checkpoint there (Request::checkpoint_at, which n > 1 already uses), and the requests after it
skip the head.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-27 18:17:21 +01:00
baKon 731a23a65a tools: rad-chatparse --request, one chat request rendered and read back as the server does
--request REQ.json --rad MODEL.rad renders an OpenAI request through parse_chat_request with the
server's own adapters (the container's vocabulary, --override-chat-template, --chat-template-kwargs,
the architecture plugin's declared reply format from --home or the template's analysis with
--no-plugin), and reads each --reply file as the model's tokens: stopped at end of generation,
detokenised with the request's preserved tokens, parsed whole (the non-streaming body) and through
the SSE emitter (reassembled as a client does), with the tool-call grammar run over the tokens as
the sampler masks them. --render-raw renders a template with any JSON context through the vendored
jinja engine, for message shapes a request cannot carry. One JSON object on stdout.

rad-chatparse is now a plugin host: rad_core whole-archive with exports, the legacy parser's sources
compiled in.
2026-10-27 18:17:06 +01:00
baKon fe27edb4da core/text: typed argument tags, a format whose argument tag says JSON or string
RadChatFormat/ChatFormat gain arg_json_value_prefix, a second value prefix written in place of
arg_value_prefix before a JSON value (DeepSeek-V4.1's DSML: string="false" before JSON,
string="true" before text). The tag the reply writes decides how its value is read, for declared
and undeclared names alike, and JSON that does not parse is kept as its text; the grammar writes
the tag each argument's schema calls for and either for an undeclared name. The field sits at the
end of the struct, so an older plugin's shorter struct reads as unset and nothing changes for it.
chat_format_check refuses a typed format without both prefixes, with prefixes not told apart, or
with string-typed other values.

Tests: reading, streaming at every truncation, grammar arms per schema, refusals, ABI tail.
2026-10-27 18:16:26 +01:00
baKon 70639f7ea2 core/text: a template that cannot render a conversation is refused at load, not thrown
ChatTemplate::load ran the thinking probe, the first full render, outside any handler; a template
that compiles but fails in the reply-format analysis (here llama.cpp's own DeepSeek-V4.1 template,
which calls dict()) threw out of load and ended the process. It is now RAD_E_FORMAT with the
template's words, as a failing render already is per request.
2026-10-27 18:15:58 +01:00
baKon fa8c746497 core/format: an imatrix entry is found under llama.cpp's spelling, .weight and all
llama.cpp names each imatrix entry by its tensor (blk.0.attn_q.weight.in_sum2); importance_for
stripped .weight from the weight's name and looked up only the bare stem, so --imatrix matched
no weight from a llama.cpp file: the codebook types that need it (iq1_s, iq2_xxs, iq2_xs) were
refused and every other type was quantised without its importances. Both spellings are found now,
per-expert rows included, and the row is read under the entry's own name.

Tests: format_test a_converter_weight_name_finds_llama_cpps_spelling (a dense and a stacked expert
entry spelled .weight.in_sum2, a missing expert, a wrong width) fails without the change and
passes with it; a_converter_weight_name_finds_its_imatrix_row (the bare spelling) is unchanged.
2026-10-27 18:15:44 +01:00
orca b56139a96a fix(isa): wave32 VGPRs allocate in 24s, not 8s
res.sh rounded the VGPR count up to a multiple of 8 before dividing the SIMD's
1536 registers, so 128 VGPRs reported 12 waves where the hardware allows 10, and
256 reported 6 where it allows 5. gfx1201 wave32 allocates in multiples of 24;
wave64 keeps the 8 the script used for both, which nothing measured says is
wrong.

gfx1201 Wave32, 1536 VGPRs/SIMD, measured over every kernel this tree builds
(3369 rows, ROCm 7.15 / clang 23, -O3) -- 755 rows change:

    6 -> 5   214 rows   (256 VGPRs)
    11 -> 10 119 rows
    14 -> 12 118 rows
    10 -> 9  112 rows
    13 -> 12  96 rows
    12 -> 10  96 rows

The parse moved into rows.awk so selftest.sh can check it at the boundaries
(96/97, 120/121, 144/145, 240/241) without a build tree. Five of those nine
boundary checks fail on the arithmetic this replaces.
2026-10-27 17:57:10 +01:00
orca 68468fc957 test(gemm): cover incomplete W4A8 prefill M tiles
The row was only ever run at M = 256, which is a whole number of tile heights,
so no test entered the guarded epilogue. Every tile height the prefill arms
dispatch (64, 96, 128, 256 -- tile_bmbn) now gets the rows just past its tile
and one row past that, which is the shape that reads Ascale[M].

Smoke coverage: the harness checks the return code and the stream sync, not the
numbers, so this catches a fault or a rejected launch, not a wrong tail.
2026-10-27 17:55:52 +01:00
orca 9d37941a44 fix(gemm): guard the W4A8 prefill tail scale read
The epilogue computed $v = acc * Ascale[m]$ before the store guard, so on the
last row tile of an M that is not a multiple of the tile height it named
Ascale[M] -- a row the caller does not own. The read is under the guard now.

inside is STFAST && (m0 + BM <= M), so it implies m < M for every row of the
tile, and n < N holds unconditionally because the launch rejects N % BN != 0.

No behaviour change is claimed: on gfx1201 at -O3 the compiler already
predicates the whole scale-and-store block (s_and_saveexec + s_cbranch_execz
around both the global_load_b32 of the scale and the store), so the published
binary does not issue the invalid load. This keeps the source honest for
compilers and ISA levels that do not.
2026-10-27 17:55:10 +01:00
Deadcode 6645337f69 radiance 1.13.0
New models:
- Tencent Hy-Memory (HYV3) from its BF16, FP8 and GGUF checkpoints, with its native tool calls
- M2XFP4: metadata-augmented MXFP4 weights for Qwen3.8-27B and its DFlash2 drafter (top-1 89.1% ->
  92.4% against plain MXFP4), its quantiser and recipe, and ParoQuant's M2XFP4 checkpoints
- Gemma 4 E2B/E4B audio input; NVIDIA-Nemotron-3.5-Bolt-E4B in int8 and 4-bit, on two cards by
  default; Ornith-1.5-122B compose files

Speed:
- Weight reads beside the decode all-reduces (qwen35_fp8, gemma3; --weight-prefetch, on by default):
  the 27B MXFP4 with DFlash2 61.2 -> 67.9 tok/s at c1, TranslateGemma 27B +13%
- Head-256 split-KV decode attention at 256 workgroups and without bank conflicts (27B: +3-5% a
  step at 25-41K context), and the prefill KV split for small launches (a short turn over a long
  context decodes the other sequences 27% faster in that step)
- MXFP4 decode gate_up, activation and fp8 quantiser in one launch (27B, Gemma 3 up to 64 rows:
  TranslateGemma +2-5% at 2-8 streams)
- ParoQuant int4/int5 tiled GEMMs 6-9% faster
- Speculation: a step's tokens are sent before the drafter's passes end, no step waits behind one
  that ends its requests, and the MTP head's first draft no longer collapses after short chats in
  the prefix cache

Features:
- --kv-resident N: KV streaming for a context bigger than VRAM (qwen4exp_fp8, GLM-5.3)
- MiniMax-H3: reference media and keyframe conditioning with the VAE encoders
- Krea 2 rebalance presets balanced, detail and subtle
- The dashboard's request history; a stall watch that reports a frozen step's thread and stack
- rad-tune at the served configuration, collectives measured as the exchange; Gemma 4 E2B/E4B's
  per-layer embeddings read ahead off the step path
- A GPTQ calibration tap and recipe for Gemma 4 31B's w4a8 container

Fixes:
- The two-rank all-reduce checks that a peer's push has landed before reducing it
- z-lab's DFlash drafter on Gemma 4 31B keeps drafting after a prefix-cache hit
- MiniMax-H3's modulation rows

Changes: Plugin ABI 31: out-of-tree plugins must be rebuilt. RADIANCE_PREFETCH_BESIDE is
--weight-prefetch now; RADIANCE_NO_HUGE_PAGES, RADIANCE_IDS_EARLY, RADIANCE_ATTN_BAND_SPLIT,
R4D_PREFILL_SPLITS, RAD_PLE_TIMING and RAD_PLE_CACHE_ROWS are gone.
2026-10-27 16:47:35 +01:00
hugypufyandClaude Opus 5.5 341cedfc2d data/recipes: q38-27b-paro-m2xfp4-df2.recipe -- a ParoQuant M2XFP4 Qwen3.8-27B with the DFlash2 drafter
q38-27b-paro-mxfp4-df2.recipe for a paroquant_m2xfp4 checkpoint: the trunk is imported as it
ships, rotations included, and the drafter's linears go to M2XFP4 as in q38-27b-m2xfp4-df2.recipe.
TOOLS.md names the import beside rad-convert's other imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 15:22:39 +01:00
hugypufyandClaude Opus 5.5 2c645333a1 core/format, arch/common, libr4d: the ParoQuant M2XFP4 import -- Import::ParoM2 reads a paroquant_m2xfp4 checkpoint's planes and rotations, served as rotated MXFP4 is
A paroquant_m2xfp4 checkpoint (format m2xfp4, groups of 32, subgroups of 8, rotation groups of
128) is imported as ParoQuant's MXFP4 is: the codes, exponents and weight_meta bytes become the
m2xfp4 scheme's three planes byte for byte, joined row by row, with the learned rotations beside
them as the givens tables. LinearFP8 declares the rotated form like the rotated MXFP4 one, through
givens_dense_quant into its own E4M3 pair, and libr4d's layout hook and both m2xfp4 rows accept
it, the rows running a fused projection's parts (pb1/pb2) one launch a part as the mxfp4a8 rows
do. libref accepts the rotated planes and runs the parts as its mxfp4a8 arm does; libavx serves
no M2XFP4. checkpoint_test covers the import, quant_m2xfp_test libref's parts and r4d_selftest
libr4d's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 15:22:39 +01:00
mici81andClaude Opus 5.5 b6ad757bfa gemma3: the gated gate_up fold up to 64 rows (RADIANCE_G3_FOLD_ROWS), and prefetch knobs
The gate_up GEMM + gelu_mul + quant_act_fp8 fold ran only up to 8 rows; at 2-8 concurrent translations with
speculation a step is 16-64 rows and the three kernels ran apart. gemm_mxfp4a8_gated_gemv_wide (9 <= M <= 64,
K >= 2688) is gemv_wide at two column tiles a block, the gate tile j and its up tile n/16 + j: each K-wave loads both
tiles' weights and reads the activation once; the wave partials are summed in gemv_wide's order and the narrow fold's
epilogue quantises, so codes and scales are byte-identical to the unfused path. No spill (96-196 VGPRs, RT 1-4).

RADIANCE_G3_FOLD_ROWS (0 = today's 8) sets the fold band; RADIANCE_G3_PF_ROWS / _PF_MIB / _PF_EARLY expose the
prefetch beside the all-reduces (measured: no gain, defaults unchanged). Unset knobs keep the pinned graph and steps.

Measured on 2x Radeon AI PRO R9700, TranslateGemma 27B (MXFP4 GPTQ, DFlash2 drafter, speculation 7), greedy held-out
translations, aggregate tok/s, 2 interleaved rounds:
| fold ceiling | x2 | x4 | x8 |
| 8 (today) | 289.9 | 521.2 | 686.3 |
| 16 | 298.6 (+3.0 %) | 521.0 (-0.0 %) | 686.9 (+0.1 %) |
| 32 | 296.9 (+2.4 %) | 541.6 (+3.9 %) | 682.7 (-0.5 %) |
| 64 | 297.8 (+2.7 %) | 549.0 (+5.3 %) | 700.0 (+2.0 %) |

Tests: r4d_selftest gated wide fold byte-for-byte against gemv_wide + gelu_mul + quant_act_fp8 (or gated_quant_fp8)
for TranslateGemma's 21504x5376 at M 9-64 and other shapes (156 ok, 0 FAIL on gfx1201); arch_test gemma3 16/16
(defaults keep the pinned graph and steps, knobs move only what they name).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-26 10:08:01 +01:00
mici81andClaude Opus 5.5 96bc0465b3 attn prefill h256: the small-launch KV split for every GQA geometry
The KV split of the head-256 / GQA-6 prefill kernel (few workgroups -> split the KV walk into segments,
f32 partials, the split-KV merge with a cu span) now serves every head-256 prefill row: GQA 12
(4-token pages: fp8, bf16, fp8_v4, k6_v4), GQA 6 with 4-token pages (the same four), GQA 8, GQA 4 and
GQA 2 (fp8, bf16). The fewer KV heads a rank holds, the more it matters: at TP 2 Qwen4-Exp (GQA 12) and
Qwen3.5-35B-A3B (GQA 8) keep one KV head per rank, so a 53-row tail runs 2 workgroups on 32 WGPs.

The host side (the law, the scratch sweep, the scratch-capped count, R4D_PREFILL_SPLITS, the merge
launch) moves into r4d_attn_prefill_split.h; each unit passes its own geometry (query rows per workgroup
= 24 * 16 / gqa, tile 48). The GQA-6 unit is refactored onto it with the same law (Qwen3.8-27B in the
engine: greedy top-5 logprobs bit-identical before and after at 300 positions after 25k and 41k prompts).

Left unsplit: GQA-2 launches with a sliding window (the partition has no window floor; a 1024 window
walks at most ~26 tiles), the lossy e4m3 legs, and the head-128 / head-64 legs sharing the bodies.

Split count, one sequence, N query rows -> S: GQA 12 with 1 KV head: 1-32 -> 32, 53 -> 16, 160 -> 6,
1024 -> 1; GQA 8 with 1 KV head: 53 -> 16, 345 -> 4; GQA 2 with 4 KV heads: up to 160 -> 8. Scratch at
declare at most 25.4 MB per row. Split vs unsplit: at most 0.000488 (fp8 KV) and 0.0039 (bf16, fp8_v4,
k6_v4; about 1 bf16 ulp).

Tests: the split tests generalised over geometry for all 18 split rows (query lengths 1-640 over 8k-20k
keys, empty segments, ragged batches, pipelined pieces, poisoned scratch, oracle rows at each tile edge,
declare-time scratch): 1782 ok; the mixed-step case over 9 geometry x cache pairs: 54 ok. Every kernel
that existed before is byte-identical (311 of 311).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-26 09:25:35 +01:00
hugypufyandClaude Opus 5.5 22df1c7264 arch/common, data/recipes: an M2XFP4 DFlash2 drafter -- DenseFP8 declares and issues an m2xfp4 weight, and q38-27b-m2xfp4-df2.recipe converts one
DenseFP8, the drafter's linear, reads a plain m2xfp4 encoding as LinearFP8 does: the weight view
takes the codes and meta planes together, the E8M0 plane is b_scale and b_ref, and gemm() issues
gemm_nt_q at dtype m2xfp4 over the same E4M3 pair. declare_slice stays block fp8 and clears the
flag. The DFlash2 block keeps an M2XFP4 gate_up off the fp8a8 gated fold, as it does an MXFP4 one.
The recipe is q38-27b-mxfp4-df2.recipe with its 4-bit trunk and drafter rules at m2xfp4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:24:01 +01:00
hugypufyandClaude Opus 5.5 1c6acaf84b arch/common: M2XFP4 linears in the qwen35_fp8 trunk -- LinearFP8 reads an m2xfp4 weight as the MXFP4 views with the meta plane riding the weight operand
LinearFP8 recognises a plain m2xfp4 encoding (codes, E8M0 exponent and one meta byte per group of
32, no transform) and declares gemm_nt_q at dtype m2xfp4 over the producer's E4M3 pair: the weight
view selects codes and meta together, the exponent plane is b_scale and b_ref as for MXFP4, and the
row-part, shape and column-shard rules are the MXFP4 ones. Like the other non-block-fp8 forms it
refuses a stored view. step() issues it in a block of its own with the MXFP4 GEMM's operands, and
MlpFP8 keeps it off the fp8a8 gated fold, so an M2XFP4 gate_up takes the GEMM and gated quantiser pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:24:01 +01:00
hugypufyandClaude Opus 5.5 dab34da373 libr4d: gemm_m2xfp4a8_decode and gemm_m2xfp4a8_tiled -- the MXFP4 x fp8 GEMMs with the m2xfp4 meta plane folded into the e4m3 staging table
Two gemm_nt_q rows at dtype m2xfp4: a split-K decode kernel that stages the weight through LDS,
and a tiled prefill kernel after the mxfp4a8 one. The relayout appends the [K/32][N] meta plane to
the fragment-order codes and r4d_m2xfp4.h's e4m3 staging table takes the subgroup multiplier as a
second index, so the WMMAs and the epilogue are the mxfp4 kernels'. The decode row keeps its own
per-output arrival counters, as mxd_out_ctr does. r4d_emu_m2xfp4 runs both kernels on the host,
and r4d_selftest and kbench (a 4e-2 tolerance for the k = 3 rounding) cover the rows. The raw
entry points are declared in r4d_m2xfp4.h, beside the table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 09:24:01 +01:00