Commit Graph
891 Commits
Author SHA1 Message Date
claudeandClaude Opus 5.5 bfb1ebd1dd libxe2: the fused gdn epilogue's output gate on a float exp, libref's chain near a bf16 tie
63.0 us a call from 71.4 (unitrace, decode at depth 5); greedy 8/8 and the 2234-token
continuation identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:51:07 +01:00
claudeandClaude Opus 5.5 9d6eb9fba1 arch/common: GdnFP8 leaves the out projection's codes unwritten when a 4-bit one reads x
Under Geom::plain_norm the ssm_out projection is probed; when it reads no codes, the recurrent
epilogue gets no code pair (its fp8 group and the re-read of o drop out) and the prefill
quantiser is not declared. Greedy 8/8 and the 2234-token continuation identical; 1902 -> 1854
declared ops; 2234-token prompt 1039 -> 1054 tok/s; decode proxy 83.1 -> 83.6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:44:47 +01:00
claudeandClaude Opus 5.5 8bc5366045 libxe2: w4a8i8 accumulators start at -zero * asum
The DPAS now leaves sum - zero * asum directly (int16 operands, |zero * asum| <= 15*127*128),
so the epilogue is a convert and the two scalings: no zero-init move, no f32 multiply and
subtract an element. The same integer, so the same output (2234-token continuation and greedy
8/8 identical).

Probe at M = 2048: gate_up 83 -> 91, inz 81 -> 88, qg 80 -> 87, out 80 -> 86 int8 TOPS.
2234-token prompt 1001 -> 1039 tok/s. (A blocked work-group order and an L1 prefetch of the
codes were tried: neither helps; down at K = 17408 stays at ~66.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:30:16 +01:00
claudeandClaude Opus 5.5 531fda7313 libxe2: silu_mul, add, mul and sigmoid eight bf16 values a work-item; sigmoid's float exp
The scalar elementwise kernels spent their prefill time in int64 divides and generic
accessors (silu_mul ~0.7 ms a call). bf16 rows now take a 2-D range of eight columns a
work-item with 16-byte loads and stores, the same per-element arithmetic. sigmoid with a bf16
output takes the float exp, libref's double chain again only near a bf16 tie (as silu does).

kbench add/mul/sigmoid bit-exact; greedy 8/8 and the 2234-token prompt's continuation
identical. 2234-token prompt 960 -> 1001 tok/s; decode proxy 82.5 -> 83.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:20:05 +01:00
claudeandClaude Opus 5.5 e6f4862c7e libxe2: gdn_conv_prep's convolution eight channels a work-item
The (token, channel) form spent ~1.8 ms a 2048-token chunk in int64 divides and per-channel
branches. A work-item now takes eight channels of one head in 32-bit index math with 16-byte
loads and one 16-byte store, each output computed tap for tap as before; the scalar form
remains for other layouts (XE2_GDN_SCALAR_CONV=1 forces it).

2234-token prompt 877 -> 960 tok/s, its 96-token greedy continuation identical to the scalar
form's; greedy set 8/8 identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:08:52 +01:00
claudeandClaude Opus 5.5 49d7d0b238 libxe2: w4a8i8 prefill epilogue in f32 against scalar row factors
The stall samples put ~75% of the prefill GEMM in its per-group epilogue (128-wide broadcast
copies and int32 multiplies), not the DPAS. sum, zero * asum and their difference are integers
under 2^24, so forming them in f32 a row at a time gives the same values: byte-identical output
(kbench 2676/2676, greedy 8/8 identical).

Probe at M=2048: gate_up 76 -> 83, inz 75 -> 81, qg 74 -> 80 int8 TOPS. BetterBench prefill
@2000 931 -> 957 tok/s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 04:00:41 +01:00
claudeandClaude Opus 5.5 4511822138 libxe2: add_rmsnorm (schema and row); arch/common: the plain norm and the attention gate without unread work
- libxe2 serves `add_rmsnorm` (device-only; libxe2 now publishes its schema, libr4d's spelling):
  x += a then rmsnorm of the x written in one pass, at rmsnorm's own bf16 partition, so both
  outputs are byte-identical to the pair here. NormQuantFP8's plain form takes it where it
  resolves (one launch instead of `add` + `rmsnorm`, ~150 a round).
- AttnGatedFP8: under the plain norm an out projection that reads no codes skips the
  quantiser after the gate's sigmoid + mul.

Greedy output 8/8 identical to the previous commit; decode proxy 81.2 -> 82.5 tok/s; declared
ops 2046 -> 1902.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 03:17:05 +01:00
claudeandClaude Opus 5.5 f26eec2633 libxe2, arch/common: silu_mul for 4-bit down projections, float exp at the tie rule; head-row norms vectorized; attention SLM by gqa
- Under Geom::plain_norm a down projection that reads the bf16 plane and no codes (w4a16 /
  w4a8i8 quantise their own activation) takes `silu_mul` instead of gated_quant_fp8 (the E4M3
  pass nobody read: 17 us a call, 64 a round).
- silu_mul: float exp, libref's double chain again only near a bf16 tie (near_bf16_tie, as the
  gdn activations): op oracle 300/300 bit-identical at tolerance 0.
- rmsnorm's bf16 head rows (n = 128..512): a lane its contiguous slice by 16-byte loads (16 us ->
  a few us a q / k norm call). rad-kbench rmsnorm 240/240.
- the flash kernel's staged queries sized for gqa <= 8 (24 of 64 KiB a work-group).

Greedy decode proxy (depth 5, mtp4, draft vocab 131072): 74.3 -> 81.2 tok/s. KL against the
exact reference 0.00231 (was 0.00239), top-1 96.70%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 02:32:05 +01:00
claudeandClaude Opus 5.5 2d2356ad4b libxe2: decode / verify attention on DPAS, the keys split 32 ways
attn_paged_fast's single-sequence calls under 16 rows took the SIMT kernel (a lane a key, full
256-wide dots: ~137 us a verify call at ~400 tokens). The flash kernel now has a split form: a
work-group a (row block, kv head, partition), partitions past the context exit at once, each
partition's unnormalised (m, l, O) to scratch and a merge pass a sub-group a (row, head).
XE2_ATTN_DEC_SIMT=1 keeps the SIMT kernel. rad-kbench -m mtp4 --op attn_paged: 240/240; greedy
against SIMT 5/8 identical, the others diverge late at near-ties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 01:52:01 +01:00
claudeandClaude Opus 5.5 726e532114 libxe2, arch/common: the 28 Oct pending set, the bf16 cast fused, the vectorized norm, a draft-vocab prefix
- gdn_kkt_solve on DPAS (~0.4 ms at 2048 tokens against 7.7), the int8 head's DPAS forms at 9-16
  rows (verify past depth 7), the plain block norm (RadBuildCtx::plain_norm, set on the SYCL
  backend: `add` + `rmsnorm` where no reader takes the E4M3 codes) with the fast rmsnorm rows.
- rmsnorm's bf16 rows up to 8192 wide: a work-item eight elements by one 16-byte load (the generic
  form walked 20 dependent loads a work-item): 24.7 -> 3.3 us a decode norm, ~3.5 ms a round.
- w4a16: a bf16 activation narrowed to fp16 at the kernel's own load (the separate cast launch
  before every GEMM is gone), bit for bit the same.
- RADIANCE_MTP_DRAFT_VOCAB=N: the 2-bit draft head over the vocabulary's first N ids (a prefix
  shortlist, GRIMOIRE's idea); the u2 layout hook takes an op N below the weight's rows. 131072:
  greedy acceptance identical on the decode proxy, draft head 650 -> 351 us a pass.

KL against the exact-kernel reference (2002 positions): 0.002386, top-1 97.30% (was 0.002376 /
96.80%). Decode proxy (greedy, depth 5, mtp4): 72.0 -> 74.3 tok/s with the prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 01:52:01 +01:00
claudeandClaude Opus 5.5 7580ec3d17 Merge upstream main (v1.12 -> v1.15.1, 408 commits) into the SYCL port
Conflicts from the old m2xfp branch take upstream's version. Two libxe2 fixes the merge needs:
- rad_plugin_abi_layout: the plugin now exports the ABI layout hash the loader checks.
- gemm_nt_q_w4a16: upstream 492d33c sends bf16 activations to the w4a16 GEMM (the separate cast
  is gone); the fast kernel took only f16, so every call fell back to the exact path (decode
  ~2.5 tok/s). A bf16 activation is narrowed to f16 (round to nearest even) into a workspace first,
  the dropped cast bit for bit; decode back to ~57 tok/s on one request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 00:25:57 +01:00
keptn42 cfa6a668f6 deploy/compose, README: Gemma 4 31B w5 on two cards 2026-11-01 21:00:22 +01:00
keptn42 7892524801 gemma4_bf16: fused junctions and the prefill overlap on the i8a8, a4 and w5 grids
The residual junctions take the `_i8g` twins where the linear after them reads quant_act_i8g's
pair, so the prefill overlap runs on these trunks too. An a4 or w5 linear reads an f16 copy of
its input up to 64 rows: in such a step its junction also writes the bf16 norm output into the
linear's input row, where the unfused norm would, and the cast and w4a16_asym / w5a16 run as
before; the feed-forward keeps gelu_mul there. At four ranks the all-reduce is issued apart.

arch_test: the 31B on the three grids at one, two and four ranks -- the junctions, the decode
band's bf16 row, the same GEMMs and casts as the unfused step, the slices against the whole
step, codes and scales of every int8 pair on the same rows -- and the E4B form.
2026-11-01 21:00:22 +01:00
keptn42 b55791b398 libr4d: rmsnorm_quant_i8g, gelu_mul_quant_i8g and ar_rmsnorm_quant_i8g -- the junctions at quant_act_i8g's grid
The norm junction (post-norm, residual add, scalar, norm), the gelu product and the two-rank
all-reduce junction with quant_act_i8g's quantiser in place of quant_act_i8's: row-major int8
codes and an f32 scale per (row, 128 columns), what gemm_nt_q reads at i8a8, w4a8i8_asym and
w5a8i8. The kernels are rmsnorm_quant_i8's and gelu_mul_quant_i8's; only the epilogue over the
staged bf16 row differs (r4d_q8.h, q8_row_i8g: quant_act_i8g's mapping and rule), so each is
byte-identical to its chain ending in quant_act_i8g. out_bf16 may be x's own buffer. No
four-rank form: a four-rank caller finds no row and issues the all-reduce apart.

r4d_selftest: rmsnorm_quant_i8g, gelu_mul_quant_i8g and ar_rmsnorm_quant_i8g (two cards) against
their chains, the junction also with out_bf16 over x.
2026-11-01 21:00:22 +01:00
keptn42 141212dd88 gemma4_bf16: asymmetric int5 linears (w5a8i8 and w5a16 over a scale per 128)
a4 at five bits: u5 codes, a u8 zero point (0..31) and an f16 scale per [1 x 128] (libquant
`codes=u5 zero=u8 group=128 scale=f16`), ParoQuant int5's grid with no rotation. Read by w5a8i8
over quant_act_i8g's per-(row, 128) int8 activation above 64 rows and by w5a16 over the input cast
to f16 up to 64, as a4 reads w4a8i8_asym and w4a16_asym; q|k|v stay one GEMM. The views, row parts
and column cuts are a4's.

arch_test: the 31B form on both asymmetric grids at one and two ranks.
2026-11-01 21:00:22 +01:00
Constantin b264e9bd0c Scale the prefill softmax by row, not by wave
The h256 prefill online-softmax branch must remain wave-uniform, but the
previous branch let one row's growth vote make every row update its reference
maximum. A row's rounding could therefore depend on which other rows shared
the launch.

Keep the branch uniform and make each row update only when its own cross-half
maximum exceeds its own `m_ref + PGROW`. Rows below threshold retain `m_ref`.
This fixes row-coupled rescaling; it does not claim full-model bitwise
invariance across chunk sizes, since other shape-dependent paths remain.

The dedicated regression selector is `--case attn_prefill_rows` (exact match;
`--case rows` is not recognized). The older kernel-name selector runs the
regression only for that named GQA row; rerunning it for GQA4 also passes the
row checks. Three launch pairs run on six BF16 head-256 rows: GQA 2/4/6/8/12
and GQA6 with 4-token pages (18 assertions).
Against v1.15.1, 17/18 assertions failed; with this change 18/18 pass
bit-identically. For Spark GQA4, the baseline 58/128 pair differs in
588/118,784 elements (max abs 0.00195). Although this implementation file is
named `gqa6`, the parameterized body is included by the other head-256 GQA
wrappers too.

Controlled 917-token Spark BF16 rerun (same prompt, binary, model, TP1, BF16
KV, no prefix cache; only libr4d changed): chunk 128 vs 1024 kept top token 198
and all 20 candidates in common before and after. Maximum shared top-20
log-probability delta was 0.23717 on v1.15.1 and 0.28474 with this patch.
This example does not improve; it is included to avoid claiming general chunk
invariance. The earlier raw full-vocabulary pre-fix result (131,070/131,072
logits changed, max abs 0.46925) has no matching post-fix capture; the paired
API top-20 comparison is the comparable result.

On a separate 32-document, 31,391-position BF16 evaluation, chunk-1024 vs
chunk-128 reference achieved 99.49% top-1 agreement (31,231/31,391): 160
positions still choose a different top token between chunk shapes, not against
external ground truth. Mean KL was 0.000879, median 1.29e-5, p99 0.00462,
p99.9 0.10119, max 3.2961. The pre-fix result on this exact set was not
measured. At the separately
investigated scored row 461 (document 20, token position 477), prefix replay's
recorded top token 62594 was replaced by 2561 before the fix; after it, token
62594 was restored with a 0.184-nat top-token log-probability gap. That
0.184 is not a full-set KL, and the 3.296 maximum comes from the separate
31,391-position evaluation.

Fast CTest: 141/141. Full card selftest still has one unrelated
`hc_read_e4m3` prefill-tile failure, reproducible on untouched v1.15.1. No
throughput improvement is claimed or measured.
2026-11-01 20:59:44 +01:00
mici81andClaude Opus 5.5 55da38afbd libr4d: the norms' lane sum issues its reads eight at a time
1.15's kR4dSumLanes partition folds a row's sum of squares over 256 lanes
whatever the block width, so a 1024-thread decode block reads it back with a
quarter of its threads, one read at a time: a Gemma 3 sandwich norm re-reads
the 5376-wide row it has just written twice, 21 dependent loads a lane each.
TranslateGemma 27B lost 5 % of its decode (four streams 225.0 / 227.2 tok/s a
stream against 238.2 / 239.7 on 1.14; ar_rmsnorm_post_quant_fp8 3.1 -> 5.1 ms
a step under --profile-ops).

r4d_lanes_sumsq (r4d_common.h) keeps the partition and the order of the adds
and only batches the reads, eight before their adds; libr4d is built
-ffp-contract=off, so every bit stays the same (greedy Qwen 300/300 x2 and
TranslateGemma 6/6 identical to the merge without it). Used by both
lanes_sumsq copies and rmsnorm_body's two loops. TranslateGemma back to
238.9 / 239.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 20:57:42 +01:00
keptn42 b34b1ac844 deploy/compose, README: Gemma 4 31B i8g and heretic-ara-i8g 2026-11-01 20:56:46 +01:00
Asim Siddiqui 34c52ebe96 libr3d: the RDNA3 (gfx11) wave-matrix kernel plugin
A self-contained HIP kernel plugin for gfx11 (RDNA3) that exposes the
libref-declared ops as device rows the engine can tune and dispatch:

  * GEMMs (bf16, f16, int8-activation, vocab) retiled to 16x128 on the
    wave-matrix (WMMA) builtins. The retile removes the 8x wave
    redundancy of the naive tile and stages the activation once per
    16x128 block; the 16-row and 64-row forms share the stage. The k-walk
    double-buffers the 128-deep tile (the next tile stages while the
    current one multiplies), on the m64 and tiled forms.
  * Quantised GEMMs: fp8-e4m3 x e4m3 (tiled and ALU), mxfp4 x a8, w2a8,
    w4a16, w5a16, w8a8 (the prefill heights 17..127 on the wave matrix),
    and the gated (swiglu) form. E4M3 decodes exactly to f16 through a
    256-entry LDS table; the WMMA fragments bit-cast the staged halfs
    (a uint16-to-_Float16 assignment is a value conversion, not a
    reinterpret).
  * Half-precision-accumulate arms (acc = 1) on the m64 wave matrix:
    the f16/bf16 16x16x16 builtins with the compile-time opsel half
    select.
  * Grouped MoE GEMMs (bf16, e4m3 with F32 block scales, mxfp4a8, w4a8),
    retiled the same way, over the run-walk / gather structure.
  * Normalisation (layernorm / rmsnorm) and the quantisation ops.
  * GDN linear-attention, the QSA/KV state ops, and the MoE
    router/scatter/gather family (router_topk_scatter, router_sigmoid_topk
    with the correction bias, moe_gather, moe_gather_inv; the top-k
    router runs to n_expert 512).

Every row implements an op libref declares; the selector (tune) picks
the implementation and the NOTUNE rows carry the untuned default.
Selftest-clean (121 rows, schema + finiteness); values verified against
CPU references per op.
2026-11-01 20:56:25 +01:00
Deadcode 203064b487 radiance 1.15.1
Fixed:
- A preempted prefill no longer parks the engine: once its wait is overdue the scheduler
  reclaims prefix-cache blocks over several rounds, returns leaked state slots when nothing is
  running, preempts only decoding requests it is ahead of (never one still building its prompt),
  and fails a recompute an empty pool cannot hold instead of waiting forever. Before, concurrent
  long requests that filled the KV pool could preempt every runner and leave all of them waiting
  with nothing running while /health answered 200 (#360)
- A scored request's candidate list is capped at 4096 ids, and a step whose pinned scored rows
  cannot be allocated cancels those requests instead of stopping the engine
- qwen4exp: the pinned copy of the window bounds is freed when a rank's model is re-declared

Server hardening:
- Keyless loopback-only routes need a loopback socket, a matching Origin and a Host naming the
  loopback or --allow-host; a TLS proxy on loopback no longer makes every client local
- --trusted-proxy CIDR (repeatable): X-Forwarded-For from a vouched network names the caller in
  the logs; authority still reads the socket
- A 401 closes the connection; drains of unread bodies are bounded; multipart form fields and
  buffered Anthropic tool-call arguments are parsed under the same size and depth gates as JSON
- 500s carry a generic message on the wire (the reason stays in the log), client text in log lines
  is sanitised, and a security-relevant header sent twice is refused
- An empty --api-key value stays a startup error (now pinned by a test)
- hfget.sh vets a repo listing's file names before fetching and hashes each LFS download against
  its oid
- cpp-httplib v0.64.0; vendor/SHA256SUMS pins every vendored file (ctest vendor_sums), and
  .woodpecker.yml runs the host suite on every push

Thanks to @baKon (#360) and @fl0l0u.
2026-10-31 09:28:19 +01:00
fl0l0u b6acbd69e4 server: name the caller a vouched proxy carried, without arming the guard
An operator running radiance behind a reverse proxy sees one address in
every log line: the proxy's. --trusted-proxy CIDR (repeatable) vouches
for the networks whose sockets may say who they carried. An
X-Forwarded-For from inside a vouched network is walked from the right:
vouched hops are skipped, the first address no vouched CIDR covers is
the caller, a chain of only vouched hops ends at its leftmost, and
anything else falls back to the socket. From an unvouched socket the
header names no one, because it has not been vouched for.

Attribution is not authority, and the split that keeps them apart is
mechanical. HttpRequest carries `peer`, the attributed caller, sanitized
where it is built because a named address arrives in a header and the
log keeps no client text otherwise -- and `raw_peer`, the socket as the
kernel saw it, which is now the only address peer_is_loopback() reads.
A proxy on loopback therefore hands the keyless loopback-only routes to
none of its clients; it only names them where the proxy used to stand.
transport_test pins both halves: the walk at the unit level, and over a
real socket that a vouched proxy plus X-Forwarded-For leaves the
loopback guard answering 200 and the cross-origin 403 untouched.

httplib's own set_trusted_proxies -- new this side of the vendor bump --
is deliberately unarmed. It rewrites req.remote_addr, the very field the
guards would read as the socket peer, so one over-broad vouched network
would move the guard rather than the log line. Radiance reads the header
itself, and ip_in_cidr refuses across families: a vouched ::ffff:0:0/96
vouches for no IPv4 socket. Config rejects anything but a numeric
network with a prefix at startup, because a typo there would silently
unvouch a proxy; the refusals the transport answers before the router
log the attributed caller too, so the audit trail stays one line per
request whoever the socket belongs to.
2026-10-31 07:50:43 +01:00
fl0l0u 40e1b3073b vendor: cpp-httplib v0.46.1 -> v0.64.0 -- the drain patch retires to one line
Eighteen upstream releases, taken the way the lift was taken: the
split pair llama.cpp now carries (1ab23c33b), against the cpp-httplib
v0.64.0 tag. The vendored pair before this commit was byte-identical
to the old base plus patch 0022 -- re-checked against the pinned lift
commit, not taken on faith.

0022 was written because upstream's keep-alive drain could be paced
one byte per socket timeout forever, and because a refused request's
unread body had no reason to be drained at all. v0.64.0 does both of
those itself: every 4xx/5xx response now carries Connection: close,
a scope_exit in write_response closes the socket when it sees that
option, the drain is skipped for any response committed to close, and
a drain that does run is bounded by a 256 KB cap, the connection's
read timeout as a total, and an immediate close for a part-read body.
The old patch applied nowhere, and mostly needed to be nothing.

What one line is still owed: the library bounds the drain's time only
by the connection's read timeout -- the same knob that bounds a whole
request's reads, uploads included, so lowering it would cap uploads
too. The reworked patch gives the drain a five-second budget of its
own. transport_test's cases for the refusal and the stalled drain are
unchanged: they pin the behavior, whoever in the tree implements it.

Also new in this window and watched with interest: set_trusted_proxies
arrives with real IP matching -- the seam a coming commit wires.
Manifest regenerated; vendor_sums green.
2026-10-31 07:50:43 +01:00
fl0l0u 3decb3ca13 qwen4exp: the pinned window copy survives its model's reset
declare() resets the rank's Model with Model{} on every re-declare --
every rebuild, every sizing probe, every test case -- and the reset
drops pipe_cu_h, the once-made pinned copy of the window bounds, on the
floor: the pointer is overwritten and the pin leaks. arch_test flags it
under the asan tier (qsa_a_widened_step...: 8 bytes, calloc,
pipe_bounds), and the leak grows one pin per re-declare of a rank.

Free the copy where it is dropped. The copy is read only by a widened
step's memcpys, and no step runs across a declare.
2026-10-31 07:50:43 +01:00
fl0l0u 8e65e1a302 ci+vendor: pin the lifted tree by hash, and run the suite on every push
Two standing gaps in how this tree is guarded.

vendor/ records what every lifted file is and what we changed, in prose
-- prose nothing enforces. vendor/SHA256SUMS is the mechanical half:
all 73 files under vendor/, the lifts, the patch series and the record
itself, hashed; tests/vendor_sums.sh recomputes both directions -- a
file whose content drifted from its record, and a file that arrived
without being recorded -- and fails the suite (ctest: vendor_sums, in
the fast tier). An unrecorded change to a lifted dependency now has to
survive being a committed manifest update to ship, instead of slipping
through a rebase the way 33108e4's silent reverts did through this
branch's history.

And no CI ran the suite at all. .woodpecker.yml (Codeberg CI) builds
CPU-only with the media codecs present and runs the host preset --
everything but the gpu and oot tiers. The runner is the current Ubuntu
LTS deliberately: the mp4 writer binds FFmpeg's >= 7 AVIO callbacks and
24.04's 6.1 does not compile it.

Rehearsed on a native Ubuntu 26.04 box -- the same gcc 15.2 the image
carries -- the host preset fails eight cases on this branch, and the
same eight on plain upstream/main: arch, chatparse, engine_e2e, two
gbnf shards, place, quant_ggml and avx_check. Pre-existing under gcc
15, partly machine-dependent (avx_check compares kernels op by op on
the CPU it finds, and the gbnf shards flip under load); this branch
adds none of them. CI's first red is upstream's to see.
2026-10-31 07:50:43 +01:00
fl0l0u 1577854d00 hfget+deploy: fetch a repo on verified claims, and run with a key argv cannot show
The --model repo-id path trusts the hub with the machine's filesystem and
the container runs with the kernel's door off. Both stop here.

hfget.sh trusted a listing's file names to be names: an absolute path or
a .. segment wrote wherever the destination's owner could write, and a
name shadowing .hfget-manifest taught the next run whatever it liked. A
listing is now vetted whole before anything is fetched -- absolute
paths, .. segments, control characters (a tab splices one entry into two
fields), names of hfget's own manifest -- and a child refuses a path
that would escape anyway. Silent skipping was the alternative, and it
leaves a directory that reads as complete and is not.

And the content key was the hub's claim, never checked: an LFS file was
kept for its size and its claimed oid recorded without ever hashing the
download, so a swapped file of equal length -- or a spliced resume at
any length -- passed forever after. The download is hashed on arrival
and kept only when it matches the claimed sha256; a mismatch deletes the
file, and the manifest now certifies verified content.

--model-revision REV fetches at a branch, tag, sha or refs/pr/N instead
of the moving main: without it a restart can serve weights nobody
reviewed, and the guide now says to name one.

--api-key-env NAME reads the key from the environment, where only the
process and root can reach it, not the command line where every process
on the host reads it in ps; an unset or empty variable refuses startup
exactly like an empty --api-key. The compose files carry the key
through environment: now -- the fail-closed :? guard moves with it --
across all 52 model files.

And the containers' seccomp=unconfined has a way out: Docker's default
profile, plus exactly the calls that forced the escape -- io_uring for
the n-gram table, mbind/set_mempolicy/get_mempolicy for ROCm's NUMA
binding -- is shipped as seccomp-radiance.json and selected through
RADIANCE_SECCOMP; the default stays unconfined until each operator
audits their own card stack. Verified: under the profile io_uring_setup
and set_mempolicy behave as under unconfined and a non-listed syscall
earns EPERM.

hf_model_test: the escape-listing refusal, the oid verify (bad rejected
and deleted, good certified), the pinned revision fetched -- against a
fake curl for a hub. config_test: --api-key-env fails closed unset,
reads the key set. ASan+UBSan: config/diag/hf_model/server/transport/
wire/lifecycle, 8/8.
2026-10-31 07:50:43 +01:00
fl0l0u ad3f03dbc6 server: no internals on the wire, no client text in the log, no paths for strangers
Four ways the server told more about itself than the caller earned.

The exception handler logged e.what() sanitized and then put the raw
string on the wire: a 500 whose message echoes request text is a
reflection point, and one that quotes how a handler broke names the
server's internals to whoever prodded it. The wire gets the generic
sentence now; the reason stays in the log. The realtime and speech
sockets caught their session's exception the same way -- raw what() to
the log and onto the client's error event -- and follow. Their WebSocket
wrapper logged e.what() and the request path unsanitized: the path is
fully client text, and a client that can put CRLF and an escape sequence
into a log line can forge the next one.

A security-relevant header sent twice is a request built to be read two
ways: this server reads the first copy, a proxy in front may read the
last or join them, and whichever copy the disagreement lands on, the
attacker picked it. Host, Authorization, X-Api-Key and Origin are
refused whole at 400 before either reader -- the key gate included --
even when every copy carries a valid key. The lookup is
case-insensitive, so an Authorization beside an authorization counts.

And the model card's `root` is a path on this machine, served to anyone
/v1/models admits. Keyless, it now belongs to the local operator, the
rule /diagnostics and the LoRA admin already follow; with a key it
travels with the key.

server_test: the_models_root_path_follows_the_key. transport_test:
a_duplicated_security_header_is_refused. ASan+UBSan: server/transport/
wire/stream/speech/speech_stream/dashboard, 7/7.
2026-10-31 07:50:43 +01:00
fl0l0u 1c967b2f14 sched+engine: keep a scored request's size from reaching the pinned pool
A scored request asks the engine for the logits of chosen candidate ids
at its prompt's last position (Request::token_scores). Three places
where that readout's memory was someone else's decision:

The candidate list was bounded by value, never by count, and the count
is what a scored step pays for: the step stages the union of every
staged request's candidates as hidden and table rows in one pinned host
buffer, before anything is admitted or accounted. One request naming a
million ids -- any caller of the raw request seam -- is a multi-gigabyte
pinned allocation the box either loses or dies on. add_locked caps the
list at 4096, orders above what a decision request names (its prompt's
written answers, a few dozen), and says so in the refusal.

And when the pinned allocation is lost anyway -- the cap bounds one
request's rows, not the batch's union, and the pool can be low for
reasons of its own -- stage_scored_rows returned E_NOMEM into the step
loop's fail path: the whole engine stopped, every connection with it.
It cancels the scored requests instead, on the step loop's existing
deferred-cancel vector the sampler's grammar failures already use: a
request whose scores the box cannot hold is that request's failure. No
alloc-failure seam exists to test the branch directly; its cancel path
is the sampler stage's, applied at the same join.

And declare_scores now refuses a head table shorter than the
vocabulary: the scored readout indexes it by token id, the scheduler
bounds candidate ids by meta.n_vocab, and a table a few thousand rows
short turns the last block of the vocabulary into a read off the end of
a weight -- a device fault, not a refusal. Padding past the vocabulary
reads fine and stays fine.

sched_test: a_scored_request_names_at_most_the_candidate_cap.
build_test: declare_scores_wants_a_table_that_covers_the_vocabulary.
ASan+UBSan: sched/build/server/systemone/config/diag, 6/6.
2026-10-31 07:50:43 +01:00
fl0l0u 5f7244da4d server: bound what an unauthenticated socket can make the transport hold
Three ways a client spent the server's patience or memory without ever
being admitted:

The gate's 401 answers before any handler sees the request, so its body
sits unread on a keep-alive socket, and httplib's anti-smuggling drain
will wait for it: one byte per read timeout paces a whole worker, at the
pacing client's chosen rate. The refusal now closes the connection
instead, says so on the response, and buries the body with the socket --
which is also what makes draining a refusal pointless.

A drain that does have a purpose -- a framed body on a request the
router answered without reading it -- inherits the stream's 30 s read
wait per packet gap and no total bound at all. It keeps both waits now:
five seconds per gap (the stream's own set_read_timeout, the same knob
the WebSocket upgrade uses) and five in total (a deadline the discard
provider checks), then the connection dies and the timeout is restored
for whatever the connection still has coming.

And bodies. The per-request cap bounds one body and no sum, every byte
of a body is buffered before parse, admission or any accounting sees
it, and a few hundred concurrent large POSTs is an OOM that reaches the
engine before any refusal does. read_and_bridge now holds every buffered
byte against a transport-wide budget and answers 429 with Retry-After to
the newcomer the budget has no room for; the reservation releases on
every exit, including the peer vanishing mid-body. The budget defaults
to eight bodies at the per-request cap and moves through
ServerOptions::max_inflight_body_bytes.

Vendor: the two httplib hunks are recorded as patches/0022, and
UPSTREAM's "no file content differs" for the pair is replaced with what
the split actually is and what is now edited in it.

transport_test: a_refusal_closes_the_connection,
a_stalled_drain_dies_on_its_deadline, the_inflight_body_budget. ASan+UBSan:
transport/wire/lifecycle/server/config/diag/dashboard, 7/7.
2026-10-31 07:50:43 +01:00
fl0l0u ec53bce5dc server: stop treating the loopback socket as identity
Three guards read a loopback peer plus a matching Origin as "this is
the machine's operator". Two real topologies forge exactly that:

DNS rebinding hands a hostile page its victim's own browser, so the
peer IS loopback, and the page is same-origin with the server, so the
Origin/Host compare stays silent. Only the Host still says which name
the client asked for, and the attacker's domain cannot be made to read
as the loopback.

The documented TLS-proxy topology puts every remote client behind a
loopback socket, and a non-browser client sends no Origin at all; the
proxy passes the public Host, which the new check refuses.

Server::local_operator now guards the keyless routes: the socket, the
Origin, and a Host naming the loopback, --allow-host, or a concrete
bind address. GET /admin/control-vector takes the guard POST already
had, placed before the 404-that-means-no-vector so a remote page can
probe neither; keyless DELETE /sessions and /reset_prefix_cache --
which destroy other clients' cached conversations -- answer the
machine only. --allow-host (repeatable) admits names an operator
reaches the box by from the box itself.

A local user at the console stays admitted; nothing about a key-set
server changes. GUIDE 6.6 states the new posture.
2026-10-31 07:50:43 +01:00
fl0l0u d54f3b9e6e server: bound the last unbounded parses of untrusted text
Three ways in, each ending in a parse that bounds neither what it
builds nor how deep it nests:

videos.cpp read its multipart form fields with the raw parser, so a
512 MiB field of brackets died at the tree's teardown; the same file's
JSON path was bounded, so the form path now shares its gate, and a
field over budget or over depth reads as a bad parse (a form test pins
both refusals and a well-formed field).

Anthropic's buffered body parsed the model's tool-call arguments
directly; the streaming path already scans them with json_complete,
whose depth cap keeps a cooperating model from stack-killing the
worker, and the buffered body now passes the same gate, reading too
deep as an empty input.

The image decoders checked the container header's dimensions against
the pixel cap but converted whatever the bitstream actually decoded;
a container whose SPS disagrees with its header slipped through. Both
now re-check the decoded frame, as the video path already does. The
re-check is inside RAD_HAVE_FFMPEG and compiles with every FFmpeg
build; the media-less container proves the two server changes.
2026-10-31 07:50:43 +01:00
fl0l0u 546f0c2047 config: pin the empty --api-key refusal with a test
d773992 restored the refusal 33108e4 had silently taken back, so the
behavior is main's again. What no branch carried was a test. The hunk
was written once, merged, and deleted by a stale rebase with nothing
noticing until an audit read the parser; an empty --api-key value --
a unit file whose $RADIANCE_API_KEY was never set -- must stay a
startup error, so a config_test case says so, and the next silent
overwrite trips a test instead of an audit.
2026-10-31 07:50:43 +01:00
baKon 9560780bfa sched: a preempted prefill reclaims cache and leaked state slots before it waits
The whole-recompute gate refused a preempted request forever when the pool held only cache entries, and an empty running set left a leaked state slot unreclaimed. Reclaim the cache over several rounds, release idle state slots when nothing is running, and admit the overdue waiter if it can ever fit. A prefill is never a victim while a decoder is running; tests cover the deadlock, the leaked slot, and the lost KV sequence.
2026-10-30 21:32:03 -05:00
Deadcode 9ed3ef7a7b radiance 1.15.0
New models and formats:
- IQR for Qwen3.8-27B: weights on the int8 grid under GPTQ, a trellis down each GPTQ column
  (IQR-V2), and IQR-V3, a computed trellis code under one scale a row, kept at its codes' width in
  VRAM and decoded in the GEMM; 15 IQR-V3 recipes from ~2 to ~7 bits a weight
  (data/recipes/q38-27b-*-v3.recipe, docs/IQR.md)
- libhalo: a kernel library for Strix Halo (gfx1151), preferred there over libr3d
- Nemotron 3.5 Embed 1B and 8B (nemotron35_embed): text and image embeddings through a Pixtral
  tower, on the card and on the CPU
- Nemotron 3.5 Rerank 8B
- /v1/systemone: Cloudflare's clef and clef-flash, Convai Innovations' Laya and Mica beside
  LiquidAI d1; scored steps read the candidates' logits from the head table with no lm_head pass
- LFM2's 8-bit trunk: block-fp8 or int8 linears with the fused producers, and the d1-3B recipe
- DeepSeek-V4.1's reply format with DSML tool calls and typed argument tags

Weights on the drive:
- The file tier reads only the experts the pass routes rows to; the draft head's weights stay in
  the host pool
- A hot VRAM cache for routed experts read off the drive, reads deposited straight into free host
  pool slots, and copyless evictions; the file tier's counters are now ssd_*
- GLM-5 Next shards its routed experts by expert, not by width, so they can live on the drive
- The stall watch counts drive reads as progress, and the DMA lane's room check reads the lane's
  own completion fence

Quantisation tooling:
- --calib-corpus, --calib-dir and --calib-layers record each linear's input Hessian; beside
  --kld-record the reference's own run records them
- --kld-top N records a sparse KL reference (the N most likely tokens and the tail's mass)
- GPTQ in a third of the time with the same codes, trellis GPTQ on the card, vector codebooks
  with coordinate descent, and rad-convert --reuse repeated, each container supplying what the
  earlier ones lack

Speculation:
- Prompt lookup alone (--spec-ngram K, --spec-ngram-min/-max): each sequence keeps an index of its
  n-grams, and a proposal is verified only when its measured step cost says it pays;
  --draft-window adaptive follows it

Speed:
- IQR decode: the narrow tile splits K for four times the int8 tile's waves and folds each 128-K
  block once; at 8 tokens down and the output projections run in 0.61-0.82x and 0.70-0.92x FP8's
  time (2-6 bits); IQ6R-S-V3 with its DFlash2 drafter steps in 26.3 ms at TP2, against 29.4 ms
  before and FP8's 27.3
- Qwen MXFP4 feed-forward: the gated fold up to 16 rows, not 8
- libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and
  rope; KLATE again for the head-256 gqa6 paged prefill; gram_accum on the matrix cores

Features:
- /health, /v1/health and /ping answer 503 with "status": "stuck" once the device has advanced
  nothing for a minute or a queue has faulted, so a supervisor can restart a wedged server (#356)
- --image-gen-max-pixels and --image-gen-max-refs size an image generator's buffers (#344)
- The startup report lists only the options not at their default, with a count; -v lists all
  (#250)
- --preempt-wait-ms bounds how long a preempted prefill waits for its whole-recompute room
- --placement layer_offload spills dense layers so one --max-model-len sequence fits
- Startup refuses amdgpu with CWSR off and says how to fix it;
  --proceed-with-incompatible-configuration starts anyway under an UNSUPPORTED banner

Fixes:
- The n-gram read-ahead hands each row to the reader once and reads only as far ahead as the row
  cache holds, and pauses while decode reads: about one drive read a row instead of two (#355)
- A file-tier window reads each of its runs once, not once a run per run
- The decode split law's verify floor is bounded by the batch's workgroups: max_seqs 256 no longer
  declares 64x the scratch (#342)
- A prefetch DMA list's mark stays out of the signal pool until the engine has read it, and a
  prefill stage copies only the blocks its own tables name (#343)
- The split-KV row sum is read with fetch-inactive (#328)
- LFM2 on the host backend: libref and libavx serve the row-form ops it declares (#348)
- The preempted-prefill gate skips a KV group that holds no blocks (#352)
- Every request entry point bounded, gated and sanitised (JSON depth, invalid UTF-8, control bytes
  in the log, the dashboard's CSP, cross-origin browsers on the loopback-only routes); a prompt id
  outside the vocabulary refused at admission; --api-key "" refused at startup
- The telemetry the HTTP thread reads is atomic
- An RMS norm row no longer depends on how many rows its launch carries; prefill attention's
  rescale is decided by live rows only
- A --kld-record prefill chunk that finishes no sequence gets its logits on a tied-head model
- A kernel's lazily made counter block is zeroed outside the lock other ranks take (a TP2 first-step
  hang)

Changes: Plugin ABI 32. Every plugin exports a layout fingerprint of the ABI structs and the loader
refuses a plugin without it or with another (#302), so out-of-tree plugins must be rebuilt.
Appended: RadBuildCtx calib_* and gen_max_*, RadArchProbe gen_max_*, RadBatch score_only and
plugin_words, RadDeviceProps::unified, RadChatFormat arg_json_value_prefix.
2026-10-30 22:01:01 +01:00
overchop 8da043c246 place: the caching layer -- hot VRAM cache, deposits, copyless relabels
Routing-aware reads leave a routed expert's bytes on the drive when the
pass routes nothing to it, but the reads that DO happen still have two
wasteful fates: they land in a per-pass buffer thrown away at the next
layer, and they cross the link even when the same bytes already sit in a
host pool slot that just went cold. This commit gives both bytes
somewhere to stay.

The hot VRAM cache: a routed expert whose read heat ranks past the
admission bar lands in a shadow slab slot and stays there. The slot is
its address from then on, until heat evicts it -- eviction is a copyless
relabel (back to Tier::SSD, publish null); the container is ground
truth. The planner budgets the shadow slots for it (per-class on_disk
count); the mover admits (Kind::Admit), evicts, and retires the
admissions.

Deposits: a free pool slot takes the O_DIRECT read directly -- the
read's destination IS the slot -- and the unit becomes a pool unit the
GEMM reads zero-copy, with heat promoting it at PCIe speed later. Its
demotion is a copyless drop (the slot still holds the bytes). A full
pool evicts its coldest unrouted unit by relabel, copyless, and the
freed slot feeds the next deposit.

The counters follow the traffic: the file stager's family is renamed
file_* -> ssd_* (ssd_layers, ssd_units, ssd_read_bytes, ssd_preads,
ssd_read_ns, ssd_wait_ns) beside the existing ssd_reads/ssd_bytes, and
the new legs are counted (ssd_staging_bytes, ssd_promotions and
ssd_promoted_bytes, ssd_deposits and ssd_deposit_bytes, pool_evictions).
The dashboard's expert plane gains the matching staging, promotions and
deposits rows, and --weights-disk-tier's help text names the tier.

Measured on GLM-5.3-Flash TP2 (2x Radeon R9700), 250-token essay at
temp 0: 5.49 tok/s at ~104 GiB of SSD reads per run, against main's
2.05 tok/s at ~378 GiB.

Assisted-by: GLM-5.3-Flash
2026-10-30 15:02:09 +01:00
overchop 9efdd00c4c place: routing-aware file-tier reads
The file tier read every file-tier unit of a routed layer whether or not
the router sent rows to it. A deep layer keeps whole experts on the drive
(288 per world), but a pass routes rows to a handful of them: the read
volume was ~18x what the router justified, and the engine streamed
~378 GiB from the SSD per run at 2.05 tok/s (GLM-5.3-Flash, TP2).

The layer's router has run by the time the stager triggers -- the
trigger is the layer's first expert op -- so the pass's route counts are
already on the device. Ctx::route_counts_device exposes them; the file
stager hands them to Mover::stage_file_units, and an expert counted
zero, which has no sorted rows and no GEMM run naming it, is left on the
drive: its weights are not read at all. Its table entries are published
at a valid dummy address (the calm region) for the pass and nulled again
with the staged units, because the kernels still issue the layer's table
and a null entry fails the step. Published even when EVERY unit of the
layer is skipped -- a decode step can route nothing to a layer.

The drafter's own weights (the "mtp." namespace) run on every draft pass
of every decode step, more often than anything a profile could rank, so
the planner pins them in the host pool ahead of everything ranked
(MoveUnit::draft_head) instead of letting the expert fill push them to
the file tier every step.

Read extents are also clamped to the container file's size, so a
truncated container fails a read loudly instead of reading past EOF.

Measured on GLM-5.3-Flash TP2 (2x Radeon R9700), 250-token essay at
temp 0: 3.4-3.6 tok/s where main gives 1.42 on the same prompt.

Assisted-by: GLM-5.3-Flash
2026-10-30 15:02:09 +01:00
overchop 9647b84ee0 glm5next: expert parallelism -- experts become file-direct
Main's glm5next width-shards the routed experts unconditionally
(GlmTp::expert_width, ff_lo/ff_hi): an expert's stored form is a shard
across ranks, so --weights-disk-tier refuses it and a 151 GiB expert set
cannot leave VRAM at any pool size. The helper's expert-parallel
declaration (expert_base windows, RAD_SHARD_NONE, no ff spans) already
exists upstream -- qwen4exp uses it -- so this retargets glm5next onto it:
each rank owns 288/world whole experts, the routed arm's buffers
full-width (FE), the shared expert still width-sharded, world 1 unchanged,
and a shape probe's rank >= world clamps to rank 0's window.

Fixes the 24.78 GiB "no eligible tier" startup OOM on 2-card hosts; the
world-8 graph pin is re-recorded from the test's own pin: printout.

Assisted-by: GLM-5.3-Flash
2026-10-30 15:02:09 +01:00
overchop 6f6b5c3f78 aql: the stall watchdog is progress-aware; the DMA lane's ring completion is fenced
Main's stall watchdog samples only the queues' read indices, and the DMA
lane trusts the SDMA queue's written-back read pointer for its room check.
Both stall wrongly: a drive-paced prefill parks every queue for seconds
(one rank spins at the all-reduce while the other reads its layer off the
drive -- spurious dumps), and the SDMA engine's written-back read pointer
can stop moving while the engine runs on -- a full ring then waits forever,
wedging the startup pool fill above ~32 GiB/rank.

pread_exact counts the bytes it returns (rad::dio_progress); every O_DIRECT
read funnels through it, and read_progress adds that to the queues' read
indices: a wait that moves nothing anywhere is a hang however slow the
drives are, so the threshold is a flat 5 s and every stall report is
genuine. The main DMA lane names its lists the way the xp queue already
does -- each list ends by writing its number to a word the engine keeps
advancing (fin/ends) -- and dma_read takes the further of that fence and
the read pointer, so the room check can no longer mistake a stalled
writeback for a stalled engine. dump_dma_lanes reports the finished-list
count.

Verified on the wedge reproducer: GLM startup with a 36000 MiB pool fill,
decode with promotions, and a 13300-word drive-paced prefill -- zero
spurious dumps, the ring live throughout.

Assisted-by: GLM-5.3-Flash
2026-10-30 15:02:09 +01:00
Gaspa79 74e7fddd79 nemotron 3.5 rerank 8b implementation 2026-10-30 09:47:42 -03:00
DeadcodeandClaude Opus 5.5 d773992abc [FIX] restore the prompt vocabulary check, the empty --api-key refusal and scored steps' issue-ahead rule
33108e48 (the preempted-prefill gate's wait bound) was cut from an older main and, landing, took
back three changes that had merged before it:

- a28221eb: a prompt id outside the vocabulary is refused at admission (Scheduler::add_locked),
  never staged into a pass where the embedding gather faults the device and stops the engine; and
  its test, a_prompt_names_real_vocabulary_rows.
- b9c685a9: --api-key "" is a startup error, not a server that looks guarded and answers every
  keyless request; and the guide's lines on it and on the loopback-only routes.
- ed1e5caf: a scored row the step in flight finishes gets no step issued ahead; and its two tests,
  the non-scored one with a token left after the step in flight so that a step ahead exists (#349).

The wait bound itself, the lookup index and the rest of 33108e48 are unchanged. sched_test 176,
config_test 62 and server_test 177 cases pass.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qthwau4zwWgAaD8vZrycp1
2026-10-30 12:18:29 +01:00
mici81andClaude Opus 5.5 8df9240d65 sched: the preempted-prefill gate skips a KV group that holds no blocks
Every program carries a sentinel KV group at index 0. KVGeom reads its decl.kind 0 as RAD_KV_FULL
with block size 1, while the manager's plan for it pages nothing and owns no block. The gate
(e668d49) walked every group KVGeom calls paged, so for the sentinel it wanted the whole prompt,
one block a token, out of a pool of none: a preempted request was never readmitted. The bound on
the wait (33108e4) cannot help, since preempting running requests frees nothing in that group.
engine_e2e_test's qwen35_preemption_by_recompute_changes_no_logit hung on it (the KL recording of a
small pool: one preempted document, nothing left running); with the group skipped it passes in
0.9 s. It may also be the live request in #346 that waited 710 s with gen=0.

The gate now skips a group with no blocks (total_blocks 0), as KVManager::ensure skips a group its
plan does not page.

sched_test: a_preempted_prefill_ignores_a_kv_group_that_holds_no_blocks (a group the scheduler sees
as full and the manager as empty; the preempted request stayed Preempted after the pool emptied
before the fix). 173 cases pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 12:11:13 +01:00
mici81andClaude Opus 5.5 167595a9b4 libr4d: the split-KV row sum read with fetch-inactive (#328)
The prefill KV split (6a7824a) stores each segment's row sum under `if (h == 0)`, so only half the
wave consumes `l_i += swap16(l_i)`. A compiler may sink the exchange into that half, where
v_permlanex16 with fi = 0 reads the lane's own value for the inactive partner, and the stored sum is
then twice one half's instead of the pair's: the merge normalises by the wrong total. The decode
kernel's f32-partial path has the same shape (lrow read under `if (h == 0)` only).

swap16_fi sets fetch-inactive, so the partner's half is read whatever exec says. With every lane
active it is the same exchange. Found by sabi-noema and posted by mordae in #328; this is their
helper and prefill change, plus the decode path.

The compilers I have do not sink it: in this tree's build (ROCm 10.1) and in the published 1.14.0
libr4d.so, every split instance of the h256/gqa6 prefill kernel exchanges before the `h == 0` mask.
So the fix changes the code (op_sel:[1,0] on those exchanges, a register shuffle around them) but
not the results here, and no test here can fail without it. r4d_selftest: the h256/gqa6 prefill and
decode rows, every cache layout, 453 checks, 0 failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:39:08 +01:00
baKon 9cf8d3dad8 arch/common: DeepSeek-V4.1's reply format, DSML tool calls with typed argument tags
The checkpoint's own encoder writes an assistant turn as reasoning followed by a sectioned DSML call block, with each argument tag naming string or JSON. The template analysis cannot state those typed tags, so the format is declared as data and chatparse_test reads it back. Split from #266; no model plugin or kernels.
2026-10-30 10:23:09 +01:00
Gaspa79 94c90b17ad nemotron 3.5 implementation 2026-10-30 10:22:53 +01:00
baKon 33108e488b sched: a bound on the preempted-prefill gate's wait 2026-10-30 10:21:57 +01:00
mici81andClaude Opus 5.5 0792d86375 libr4d: the paged prefill attention h256 gqa6 asks for KLATE again
75b4c92 brought the kernel side of KLATE (tile t+1 K fetched once tile t has its scores) and set
P_OPT to (3954187 | O_KLATE) in this launcher; a later merge restored the old P_OPT line, so the
kernel code is there but Qwen3.8 prefill no longer takes it. This puts the bit back. Load order
only: the bytes are the same.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 10:21:34 +01:00
mici81andClaude Opus 5.5 f8e69c4825 libr4d decode split law: bound the three-wave verify floor by workgroups (#342)
49ca5ff made a three-wave verify past 16k keep at least 64 segments a sequence. The declared scratch
is the worst over every sequence count up to max_seqs, so at 256 sequences it became 64x the law's:
h256/gqa12 at max_ctx 200000 went from 7.62 to 487.5 MiB a card, and the KV pool lost that (#342:
5-8 % prefill on an expert-tiered MoE).

The floor is now min(64, 1024 / units), units = KV heads x sequences. Up to eight sequences of two
KV heads it stays 64; at 16 it is 32, at 256 two, and the declared region stays at what eight
sequences need.

Measured on 2x R9700, Qwen3.8-27B MXFP4 TP2, k6_v4, speculation 7 without the short block (every
step an 8-row verify), forced segment counts, ms a decode step:
  45k x8  64: 41.24, 32: 41.20, 16: 42.29
  45k x12 64: 57.42, 32: 57.38, 16: 59.39
  45k x16 64: 74.83, 32: 74.68, 16: 74.79
  90k x8  64: 51.79, 32: 52.02, 16: 54.42
Up to 64 segments past eight sequences changes nothing; the new floor gives x12 42 and x16 32.

r4d_selftest's split-law case pins the region at 16 sequences (100k and 32k: 32 segments) and at
256 (2); it read 64 for all three before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 09:16:16 +01:00
Brandon Bertelsen ec243c2a7d Merge main into laya-arch-plugin 2026-10-29 13:45:18 -04:00
Code000andPi 8df39472b6 lfm2: the 8-bit trunk -- block-fp8 linears, the fused producers, and the d1-3B recipe
Every linear of the trunk is a LinearFP8, so the container's encoding decides the
GEMM: bf16 stays `gemm_nt` exactly as before, a recipe's block E4M3 is gemm_nt_q at
fp8a8 over an activation quantised once per producer, and int8 is gemm_nt_q at
i8a8. The format is read off layer 0's first linear; a trunk mixing formats is
refused by name. The convolution, the norms and attention stay bf16.

On a block-fp8 trunk the fused producers run: rmsnorm_quant_fp8 with a fold for
each mixer's norm (the previous block's residual add included) and MlpFP8 for the
feed-forward, whose gate|up GEMM applies SiLU(gate) * up and quantises in its
epilogue. The convolution's C * conv(B * x) and the codes its out projection reads
become one gate_quant_fp8 at act none. `gemm_nt_q_gated_wide` puts whole prompts
through the fold instead of falling back to the pair past 64 rows; k and v ask
for `gemm_nt_q_short`; the head norms and rope ask for `rmsnorm_rows` and
`rope_rows`. Each of those is the model's own declaration, so no other
architecture's path moves.

The lm_head is read at its stored codes (bf16, or E4M3/int8 where a recipe made
it so, logits_gemm_fp8/_i8). A tied head also declares the final-normed rows and
the embedding table to the core (rad_declare_scores), so a scored step needs no
head read at all.

data/recipes/d1-3b-fp8.recipe: all 30 layers' linears to E4M3 with a bf16 scale a
128x128 block; the tied head to int8 per row per 128 columns.

Co-Authored-By: Pi <pi@localhost>
2026-10-29 16:23:28 +01:00
Code000andPi b8cd1c950a libr4d: the gated prefill fold, the short-prompt split row, and the rows forms of rmsnorm and rope
Four rows of our own, each declared only by a model that asks for it, so every
other caller keeps the row and the bits it had:

  gemm_nt_q_gated_wide   gemm_nt_q_gated at every M: the narrow tile to 64 rows
                         and, past them, the gated prefill tile (128 gate and
                         128 up rows against 64 activation rows a block), whose
                         accumulators are the unfused prefill GEMM's. The
                         narrow row keeps its M <= 64 ceiling and kernel.
  gemm_nt_q_short        the narrow fp8 row with the short-prompt split rule:
                         N <= 512, K <= 5120 and 41..64 rows run unsplit, where
                         the split's per-slice floors dominate. Its scratch hook
                         makes the same choice, so the arena matches the launch.
  rmsnorm_rows           the same norm; at n <= 256 and 1024 or more rows a wave
                         a row, its sums in rmsnorm_kernel's wave order.
  rope_rows              the same rotation; at 64 or more rows and 4 or more
                         heads one angle a (token, pair), every head turned with
                         it, byte-identical to rope.

gate_quant_fp8 gains act none: the plain product (`mul` then the quantiser) in
one pass, rounded once as mul_bf16 rounds it. Its `mode` stays 1 by default, so
the sigmoid producer every other model issues is unchanged.

r4d_selftest: the act-none chain against mul + quant_act_fp8 at M 1, 8 and 65 with
strided sources and without out_bf16; gemm_nt_q_gated_wide against the tiled
GEMM + gated_quant_fp8 at 65 and 129 rows; and the RDNA4 device phase accepts
gfx1200 beside gfx1201, where the card this was measured on lives.

docs/OPS.md carries the four rows ops_doc checks.

Co-Authored-By: Pi <pi@localhost>
2026-10-29 16:23:28 +01:00
Code000andPi ed1e5caf9d core, abi: scored steps -- rad_declare_scores, RadBatch::score_only, and /v1/systemone's model
A scored request (Request::token_scores, what /v1/systemone asks: the raw logits
at a few candidate ids) does not need the half-gigabyte lm_head read the sampler
would consume. A plugin whose head is the bf16 embedding table declares the
final-normed hidden rows and that table (rad_declare_scores); on a step whose
sampled rows are all scored rows and whose program declared both, the core sets
RadBatch::score_only, the plugin issues everything but the head, and the core
reads the hidden rows and the candidates' table rows back and takes the dot
products in f64 on the host. RadBatch gains one trailing int32 (score_only, 360),
which the pass key mixes; an older plugin never sees it set.

The scheduler issues no step ahead of one that brings a scored row to
max_tokens: that forward pass reads nothing and a max_tokens=1 question would
pay a decode step after its prefill. Scored rows only -- every other decode keeps
the step of overlap it had.

/v1/systemone reports which model answered.

Co-Authored-By: Pi <pi@localhost>
2026-10-29 16:23:28 +01:00