Instantiate the wide one-shot all-reduce at WS=3 and add an all-gather on the
wide transport (ar_gather_3rank), with dispatch rows for world_size 3, so a
three-card box resolves 'all_reduce' and the vocab-parallel sampler's
'all_gather'. The two-shot is not instantiated at 3: it shards the message
world ways and the residual width does not divide. Selftest: 3-rank sum,
block-count sweep and both gather placements (skipped on fewer than 3 cards).
Local lab build on top of 1.0.3 (f487864); not submitted upstream.
(cherry picked from commit a76f2ab66500b9a7711b8f52abbf48eb88758359)
Throughput, prompt tokens by source, speculative decoding by draft
position, scheduler steps, latency, prefix cache and HTTP, from both
metric families. Plain PromQL, so the same JSON runs on Prometheus and on
VictoriaMetrics. Window ratios are counter ratios with the definitions of
the since-start gauges; conditional acceptance at position j in a window
is reached(j+1) / reached(j).
GUIDE: draft_position_acceptance_ratio is cumulative since start
(draft.h), and the dashboard is named under §6.3.
docker logs answered nothing about traffic: the only lines the server
wrote on a request were the kernel recordings, and a refusal left no
trace at all, so a client reporting "rejected" could not be matched to
anything. Two lines per request now, at info: one when it is admitted
(id, endpoint, peer, model, message and tool counts, prompt tokens, n,
max_tokens) and one from record() when it ends (finish reason, prompt
tokens and what the prefix cache spared, generated and reasoning
tokens, time to first token, decode rate, wall). Every refusal logs its
status, type and message with the peer -- 4xx at info, 5xx as a
warning. The debug level adds the last user message's opening, one
bounded line, so a log line can be matched to what was typed; the
daily's info level never prints prompt text.
HttpRequest carries the peer (httplib's remote_addr:port; empty
in-process), OaiRequest carries what the parse already walked past
(message and tool counts, the last user message) and the peer.
(cherry picked from commit 067facd47e2b0c0afeefe79166e77f01c33d588f)
- Wrong answers under concurrency on models with gated delta net layers (Qwen3.8-Flash-Next,
Qwen3.8-27B, Qwen3.6-35B-A3B). A conv state slot was one entry wider in the allocation than in
the state the kernels index, so clearing the slot a newly admitted request was given -- and a
prefix-cache checkpoint's save and restore -- reached into the next request's conv and n-gram
windows. A request decoding beside an admission then lost part of its recent context: a right
first token followed by a context-free continuation ("1. **Identify the numbers..." for "What
is 65 times 3?"), repeated or skipped digits. A single request was never affected. One
definition of the slot now, and the server refuses to start if the allocation and the kernels
ever disagree on it. Present since 1.0.0; reported with a strict concurrent sanity check.
- --num-speculative-tokens 0 no longer stops the engine at the first multi-sequence decode step:
an all-reduce argument struct's padding was uninitialised, and a recorded pass's audit read it
as a changed argument.
- The n-gram embedding table (Qwen3.8-Flash-Next's per-layer embedding) can be gathered on the
card. libr4d gains a row for embed_lookup_q whose output is the host gather's to the bit, and
--ngram-placement uses it: ram keeps a pinned copy in RAM that the cards read in place over the
link, so a step has no host work in it; vram puts the whole table on every card that holds it;
disk reads it from the container on the host, as before. auto takes the first of the three that
holds the table and prints why it passed over the others. Without a device kernel for the gather,
ram is the locked copy the host gather reads and vram is refused, as in 1.0.10.
- The pinned copy is not charged to RLIMIT_MEMLOCK; the host gather's locked copy still is, so
--ulimit memlock=-1 matters only on a run without the cards.
- The idea and a first kernel for the device gather came from Code000.
- Four-rank Qwen3.8-Flash-Next (PRs 14 and 16 by keptn42): the all-reduce runs fused with the
hyper-connection's write, and with the MoE gather in front of it, on decode and verify steps on
the exact wire. The routed experts are split in four classes, so every rank computes the same
share; moe_gemm_q_mod4 is the new grouped GEMM. The oracle now checks moe_gemm_q on w4nl and
w5nl containers.
- --embedding-placement and --ngram-placement, each auto | vram | ram | disk. The token embedding
can live in the pinned host pool, read in place over the link (from PR 17 by mechkbfan). An n-gram
table can be copied into locked RAM at load instead of read from the container (from PR 15 by
keptn42). auto takes the fastest tier with room once every other weight is placed, and startup
prints what it chose and why. A tier that cannot be honoured stops the start with the reason; the
embedding on disk and the n-gram table in VRAM are refused, since nothing can serve them.
- The expert_tiered placement no longer spends the pinned host pool twice when it falls back to
layer offload, and a lossy-wire request for a four-rank fused write is a selection miss rather
than a startup abort.
At --tp 4 each MoE connection ran moe_gather and the fused write as two
launches, three or four with the inverse table. ar_gather_hc_write_4rank
runs r4d_ar_gather_word as the prologue of ar_hc_write_4rank, with the
two-rank slot table and grid rule. The arithmetic is moe_gather's plus
ar_hc_write_4rank's, so the bytes are unchanged. One and two ranks unchanged.
At --tp 4 each gated-residual connection ran all_reduce and hc_write_bf16
as two launches. ar_hc_write_4rank fuses them: the wide exact one-shot,
reduced in place, with r4d_ar_hc_write_word as its epilogue. It takes the
steps the exact one-shot would (under 1 MiB, and under min_bytes on wht6);
larger and lossy messages keep the two launches. Two ranks unchanged.
embed_lookup_q reads the n-gram table through a row cache and direct reads,
and about half of a step's rows are first-seen, so steps wait on the drive.
--ngram-table ram (default disk, unchanged) copies the table into locked
huge pages in the background, checks the copy against the mapping and then
serves the gather from memory. MemAvailable, RLIMIT_MEMLOCK and the cgroup
limit are checked first; if any is short the table stays on disk. The flag
reaches the plugin as an optional `resident` parameter of embed_lookup_q.
The scale view of a w4nl64a8h, w4nl32a8h or w5nl64a8h expert is the E4M3 scale
plus its fixed second level, which enc_selection_logical could not read, and
libref described the weight scale on block fp8's grid for every dtype. So
RADIANCE_OP_ORACLE left every moe_gemm_q and moe_gemm_q_mod4 issue at those
formats NOT CHECKED. Both fixed; libref's arithmetic and serving unchanged.
The parity split gave ranks 0..3 30/30/20/20 % of the routed work. The extra
block of each five-block expert now goes round all four ranks by expert id
mod 4: rank r takes two blocks of class r and one of each other class, a
quarter each. The plain experts' extra tiles move to ranks 0 and 1 so they
do not stack on the shared expert's. One and two ranks declare as before.
moe_gemm_q over four tables instead of two: expert e is entry e / 4 of class
e % 4. A separate op, because the declaration divides a table op's weights
over its table operands by count. The arguments are repacked to fit four
classes in 256 bytes; moe_gemm_q's arithmetic is unchanged. Where weights
do not divide evenly over the tables, the first tables take one more each
(510 experts: 128/128/127/127). libref and libavx serve the op.
At four ranks the routed parity split leaves ranks 0 and 1 widest, and the
shared expert's extra block and the plain bf16 experts' extra tiles were cut
from rank 0 as well. Both remainders now go to the ranks the routed split
leaves narrowest. One and two ranks declare byte for byte as before.
The embedding table is the largest model-level weight a dense model has --
248320 x 5120 in bf16 is 1.18 GiB a card at --tp 2 -- and a step reads only
its rows: M of them, a few KiB at decode. On a 16 GiB card that is VRAM the
KV cache wants, and no strategy could move it: layer_offload spills whole
layers only, and the derived split charges every model-level weight to VRAM.
--host-weights NAMES places the named weights in the pinned host pool before
any strategy runs. The site is DeviceZeroCopy: the pool is mapped, so the
lookup kernel is handed its device-side address and reads the rows over the
link in place. The unit is never movable, and every assignment pass and VRAM
total skips it through one MoveUnit::preplaced(), as they skip the mapped
tier.
- weight_footprint() counts hosted units in their own bucket, so a derived
split leaves them out of the weight budget and the KV pool gets the room
without stating --vram-*-mib
- only a weight embedding lookups alone read is accepted: a GEMM operand
(the head) would stream its shard every step, and is refused
- names are parsed at config time (comma-separated, trimmed, a trailing '*'
a prefix); each one that matches nothing is warned about by name
- a weight the host pool cannot hold is refused with the plan filled in, and
the placement report gives host weights their own line beside the pool
- GUIDE.md §4.3 and the flags table; engine info carries host_weights
Measured on Qwen3.8-27B-FP8 with its MTP head, 2x RX 9070 XT (16 GiB),
--tp 2, two sequences, a 2560-token step, the split derived:
table in VRAM --host-weights token_embd.weight
KV pool (tokens) 70,976 144,576
decode, 500 tokens 115.8 tok/s 115.7 tok/s
prefill, 22K prompt 2773 tok/s 2798 tok/s
Tests: place_test covers the footprint bucket, the pinned zero-copy
placement, the refusal of a GEMM's weight and of a pool too small; ctest
-LE 'gpu|oot' passes.
- Pinned host memory is locked in pieces of at most 1 GiB (issue 13): an Intel VT-d host in
scalable mode that refuses any single pin above about 2.5 GiB now takes the host pool with IOMMU
translation, and peer-to-peer access, left on.
- Four-rank all-reduce (PR 11 by keptn42): the tiered-int8 wire serves in-place calls, so
--tp 4 --tp-wire wht6 runs. At four and eight ranks the exact all-reduce is one-shot up to
524288 elements and two-shot above, chosen by the selector, so the band report names the kernel
that runs. The docs and the startup warning describe the four-rank lossy wire; eight ranks have
none.
- A VRAM allocation the card cannot take is refused, saying what the card has left and which
processes hold memory on it. ROCm 7.2's runtime crashes on such an allocation once a queue has
been destroyed, which every startup does.
- rad-convert --changed FILE: with --reuse, converts only the weights that read a changed
checkpoint tensor and copies the rest.
The exact two-shot row needs hops=2, which the four-rank blocks never
state, so a 10 MiB prefill chunk went one-shot: 3N bytes a rank instead
of 1.5N. Above 1 MiB the one-shot entry now runs the two-shot kernel, in
place. Same fp32 fold order, bit-identical (KL vs tp 2 equal to the last
digit). Flash-Next tp 4 on 4x R9700: prefill +17% at 16k and 64k, decode
unchanged.
At four ranks every all_reduce is declared in place and without `hops`,
so `--tp 4 --tp-wire wht6` resolves all of them to ar_twoshot_4rank_ti8,
whose entry refused x == y: the first step failed and the engine stopped.
The entry now gates by `min_bytes` like the two-rank wht6 entry (exact
one-shot below) and accepts in place. Flash-Next tp 4 on 4x R9700: KL
vs tp 2 exact 0.062 / 0.070 (tp 4 exact: 0.061 / 0.068), prefill +27%
at 16k and 64k, decode unchanged.
- Qwen3.8-Flash-Next serves at --tp 4, contributed by goodman-b (PR 9). Rank pairs share each of
the model's two KV heads, every rank computes a slice of every expert's width, and four ranks
run the unfused all-reduce plus a new four-rank all-gather for the vocab-parallel sampler. Two
ranks declare and compute exactly as before. The README has a four-rank flag row; it pins
--host-pool-mib on every card, 48 GiB in all. At four ranks the expert shares are not equal:
ranks 0 and 1 compute three blocks of every even/odd pair of experts and ranks 2 and 3 two
(docs/ARCHITECTURES.md).
- The four- and eight-rank all-gathers require peer access between the cards, as every other
collective does since 1.0.7, and the kernel library's selftest now refuses any multi-rank kernel
that does not.
--debug-graph on the real container at --tp 4 was red on exactly one op: thirteen
device bands, all of them attn_paged_gate_quant, refused with 'gqa == 12, have 6'.
The row table registered the fused sparse-decode leg only at the two-rank ratio, so
at four ranks the block declared a fused op nothing served.
That was my reading of v1, and it was wrong in a way that is not neutral: the block
declares the fused op beside the unfused pair EITHER way, so an unregistered geometry
is not a quiet fallback, it is a device hole -- a band a request can land in whose
step then fails at issue rather than at declare.
The kernel already exists. r4d_attn_paged_gqa8.hip pastes the _gq entry points onto
R4D_ATTN_GQA, so the gqa6-bs4 unit has exported them since it was written; the
build's libr4d.so has r4d_rad_attn_decode_gq_h256_gqa6_fp8 and _bf16 in its symbol
table. Unlike all_gather, this leg needed a row registered, not a kernel written.
q_len <= 10 rather than <= 5 is the same q_len*gqa <= 64 at six queries a position;
the verify bound moves with the ratio and nothing else. TP2 cannot regress: the rows
carry C_EQ(gqa, 6) against a world-2 query that carries 12.
radiance: 'layer 34's plain experts are 384 wide, which 4 ranks cannot share in
64-wide tiles' -- on ranks 1 and 2 only. The protected experts are declared by a
second grouped GEMM over their own slice of the expert's width, and that width
was read off THIS RANK's parity slices (max ff_hi). At two ranks that is the
model's width; at four it is 384, 512, 640 depending on who asks. Ranks 0 and 3
passed the check, ranks 1 and 2 refused, so the all-reduce's rendezvous got two
of four ranks and the launch died -- the AR error was the cascade, not a bug.
The width is g.n_ff_all. And an even share of it is not available here: 640
columns are ten 64-wide output tiles, which four ranks take as 3, 3, 2, 2. An
uneven share is still whole tiles and every tile still has exactly one owner, so
the rank takes a span -- uniform across a layer's protected experts, because
their GEMM takes ONE table and every entry of a table has one geometry (unlike
the quantised experts, which alternate by parity precisely because they have two).
A rank count that divides the width keeps the old declaration verbatim, span
included: no span at all, the loader dividing the entry itself.
The old assertions pinned expert parallelism -- n_expert = 128, expert_base =
r*128 -- which is the design this replaces. What the four ranks divide is each
expert's width, so what the test pins is a span on every expert's down
projection, per parity, plus the property that actually matters: the four
ranks' slices of one parity TILE the width, each block claimed exactly once.
Neither unserved (a rank quietly dropping a fifth of every expert) nor twice
(the all-reduce then double-counts that block).
Read off the declared spans, not off the plugin's formula -- recomputing them
would only prove the test agrees with the code.
The real-container declare gate refused this container at layers 46-47: 'keeps
1 experts plain bf16 on this rank, which leaves 127 quantised'. Root cause:
protected-expert counts are per-rank, and the recipe protects IN PAIRS precisely
so that each rank's quantised count stays even. Expert parallelism broke that
property the parity tables rest on; fixing it properly would need unequal-length
weight tables, which the builder's equal-split rule refuses by design.
The width split was always the right answer above two ranks and serves more
ranks than the old code realised. Each parity's blocks are cut contiguously
across the ranks and the rank taking the odd block alternates with the parity:
at four ranks and five blocks, [0,2) [2,3) [3,4) [4,5), with the fat class
rotating between the two parities so no rank takes both. Every block of every
expert has exactly one owner, protected counts go back to the recipe's global
even numbers, and -- because every rank still computes a slice of every routed
expert -- the routing-balance cost the EP design carried disappears with it.
World 2 is byte-identical: base, extra and the parity rotation reduce to the
same expressions at g.world == 2. Worlds up to the block count now declare;
beyond it the refusal names the reason.
World 4 refused at declare on two counts and at boot on a third the audit
found; the fourth is unchanged by design.
- rad_arch.h: a world above the KV head count replicates the heads in rank
pairs instead of dividing them. Geom gains kv_off; each rank declares
n_head_kv 1 and gqa 6. A world that is not a multiple of the head count
is still refused, by name.
- rad_block_attn_gated_fp8.h: k/v pass the row span LinearFP8 already
takes, gated on world > n_head_kv_all so an even shard is untouched and
TP2 declares byte-identically.
- qwen4exp_fp8.cpp: above two ranks the ranks own whole experts (5 blocks
of 128 do not cut four ways); the parity tables stay two-rank and the
router stays replicated.
- libr4d: attn_{prefill,decode}_h256_gqa6_bs4 rows and their TU -- the
gqa8 body at ratio 6, page 4. No fused form is instantiated at this
geometry; the unfused pair is what resolves.
- libr4d: r4d_ar_gather_Nrank.hip. The vocab-parallel sampler declares an
all_gather at any world > 1 and libr4d shipped only the 2-rank row, so a
TP4 boot was refused by the reference-kernel gate rather than served
wrong. The wide one-shot all-reduce with the reduction removed.
- rad_block_attn_gated.h / rad_block_attn_fp8.h: refuse a world above the
KV head count. They read n_head_kv and declare no span, so they would
have booted and read half a KV head -- fluent wrong text.
- tests/arch_test.cpp: the four-rank declare test, and the fake records
the shard span the real builder stores.
- README, ARCHITECTURES: TP4 in the present tense, with the costs named
and the rate against TP2 left unmeasured.
- Chat responses report usage.completion_tokens_details.reasoning_tokens: how much of
completion_tokens was the reasoning block. A reply that ran out of max_tokens inside <think>
now reads as that, instead of as a model that answered nothing.
- thinking_token_budget (vLLM's name; thinking_budget is read as the same field) caps the
reasoning. At that many tokens the block is closed and the model answers from what it has
reasoned so far. It holds under speculative decoding and at any temperature.
--thinking-token-budget sets the default for clients that send none.
- Every completion response carries a `timings` object in llama.cpp's shape: prompt and generated
token counts, times and rates, and the speculative tokens drafted and accepted for that request.
It is on the buffered response, on each streamed choice's final chunk and on the usage chunk,
so a proxy such as llama-swap can read per-request speed. /metrics stays the aggregate.
- Peer-to-peer access between the cards is checked at launch. The all-reduce kernels need it; on
a machine where the cards cannot reach each other's memory, startup stops and names device.p2p
instead of the first all-reduce faulting or hanging. A kernel library can require it with a
constraint on the new "device." keys, which match the machine and not the op's parameters.
- A pool allocation the driver refuses says why, with the card's free VRAM at that moment and,
for the host pool, the pinned memory taken against the amdgpu limit (ttm.pages_limit). Every
rank pins its own --host-pool-mib, so --tp 2 pins it twice.
- A text prompt to /v1/completions reads the model's control tokens as tokens, as vLLM and
llama.cpp do. A client that renders its own chat template can send "<|im_start|>user ..." and
the model sees the turn markers; they used to reach it as plain text. /tokenize and
/v1/embeddings read a text prompt the same way, and a prompt that already opens with BOS gets
no second one.
- The VRAM budget counts the engine's own hardware queues, which the driver backs with about
33 MiB of VRAM each, and the KV tiers' copy staging. Both used to come out of
--gpu-headroom-mib: Qwen3.8-Flash-Next ran with 9 MiB free under load against the 96 MiB it
asked to keep, the room a kernel's first launch allocates from. The startup receipt has a
"hardware queues" line.
- Running the whole model on the CPU (RADIANCE_HOST_DOMAIN=1 with no GPU visible) no longer
repeats words or answers differently at temperature 0. A decode step could read its input
token before the copy that delivers it had landed.
- The README says to clone the repository before installing.
- Answers no longer stop partway through. A request without max_tokens got 512 tokens, and a
reasoning model can think for thousands before it answers, so the reply ended inside the
reasoning with finish_reason "length", which chat clients do not show. It now gets whatever
the context leaves after the prompt, as in vLLM. --default-max-tokens N sets a number, and
--max-tokens-cap bounds every request.
- Qwen3.8-Flash-Next in Docker without --security-opt seccomp=unconfined is refused at startup,
in about a second, with a message naming that option. It used to load the whole model and then
fail every request as "unsupported", and a restart policy reloaded it over and over. The
n-gram table is read through io_uring, which Docker's default seccomp profile refuses.
- A request the engine fails says what failed, in the 500 or the stream's error event. It read
"the engine failed this request: ok".
- Flash-Next no longer crashes at startup about one start in seven (a race between the
parallel declares that size the activation arena).
- rad-convert no longer needs io_uring, so it converts in a sandbox that forbids it.
- oh-my-pi works unmodified on every Qwen model. Its requests carry a top-level
preserve_thinking, which was refused as an unknown field; it now reaches the chat template the
way enable_thinking does. Its task tool's `model` parameter is the `not` of every JSON type,
which the 1.0.1 fix did not cover: any `not` that excludes every value is now an argument no
call writes, under every chat template and Flash-Next's declared format.
- Command-line defaults and bounds for what a request leaves out. A flag left unset changes
nothing; /server_info reports the values under request_defaults.
- Sampling: --typical-p, --presence-penalty, --frequency-penalty, --repetition-penalty,
--repeat-last-n, --dry-multiplier, --dry-base, --dry-allowed-length, --dry-penalty-last-n,
--dry-sequence-breakers, --xtc-probability, --xtc-threshold.
- Requests: --default-max-tokens N|auto, --max-tokens-cap, --max-n, --max-queued-requests,
--max-stop-strings, --max-stop-bytes.
- Chat template: --chat-template-kwargs JSON|@FILE sets template variables a request's own
chat_template_kwargs override; --reasoning-format auto|none.
- HTTP: --http-threads, --read-timeout, --write-timeout, --keep-alive-timeout, --max-body-mib,
--retry-after, --no-cors.
- Media: --image-min-pixels, --image-max-pixels, --video-min-pixels, --video-max-pixels,
--video-fps, --video-min-frames, --video-max-frames, --video-max-frame-tokens,
--max-source-pixels.
- Under --reasoning-effort none or minimal, a request that sets enable_thinking true now thinks
instead of having the deployment default override it.
- --temp, --top-p, --min-p and --top-k refuse a value that is not a number instead of reading
it as 0.
- A tool whose schema bounds a string or an array past 2000 (maxLength, minLength, maxItems,
minItems) no longer fails every request carrying it (issue #5). The bound is held exactly, up to
about 200,000; past that the request is refused with a 400 naming the tool's property and the
count. A bound past 2^31, such as Number.MAX_SAFE_INTEGER, is no bound.
- Compiling a grammar with a long bounded repetition is linear in the bound instead of quadratic:
maxLength 32000 compiles in 0.7 s instead of 2.1 s.
- Qwen3.8-Flash-Next serves with its container on btrfs (issue #3). The host gather of the n-gram
table needed the filesystem to report its direct-I/O alignment, which btrfs never does, and
refused every request. Where none is reported it now reads in units of the file's block size,
and one read of the table proves that before a row is served.
- docs/DOCKER.md says which filesystems the models directory can be on, and what btrfs compression
costs the n-gram reads.
- Up to 32 sequences a step on every model. The DSpark drafter (MiniCPM5) no longer rejects every
draft from the tenth sequence on, and the step batch's block tables and media staging are
charged to the VRAM budget instead of the headroom kernels load into.
- A tool parameter whose schema accepts no value ({"not": {}}, as TypeBox and Arktype export
`never`) is an argument no call writes, instead of failing the request. oh-my-pi's task tool
works.
- --served-model-name NAME and --override-chat-template PATH.
- The startup session count counts only the part of the KV pool that holds context.
- Compose files and README run --max-num-seqs 32 where it keeps a 200K-token request.