radiance 1.1.0

- The VRAM split has no ratio: --expert-vs-cache-ratio is gone (now an unknown option). The
  experts keep what the pinned host pool cannot hold, the KV cache takes the rest and lends idle
  blocks to the experts. Flash-Next at tp2: 7.9 GiB of KV a card, up from 4.7. Startup, /stats,
  /metrics and the dashboard report the most the cache can hold.
- Linear-state snapshots live in pinned host memory, not VRAM (--checkpoint-slots sizes the
  store). Prefix-cache misses on agent sessions fixed; a published conversation is no longer
  trimmed away.
- Any world size from the shipped container (baKon): --tp 3 on Flash-Next with no padded
  checkpoint -- the attention world, uneven delta-net heads, the fill op.
- Kernels (keptn42): moe_gemm_q decode loads and one-trip run search, hc_read's prefill form
  (+3.7% prefill at 18K), hc_up row groups up to eight, the fused router launch. Each is the rule
  where it was measured faster; no environment switches.
- Tool calls: a typed argument is always JSON (Python True/None no longer leak into arguments --
  Codeberg #21); nine further reply-parser fixes; the reply path inside a call is ~12x cheaper on
  the host.
- The kernel changes: prefill +2-3% and decode -2% a step on 2x R9700 at tp2, identical text.
This commit is contained in:
Deadcode committed 2026-10-06 14:04:49 +02:00
1 parent 9f5feb24ee
commit 82b5835c02
101 files changed
+5105 -3767

No files matched your search

+43 -44
View File
@@ -409,39 +409,38 @@ outright:
radiance --model m.rad --vram-weights-mib 24000 --vram-kv-mib 6000
```
or let the engine derive it from the card and tell it only the ratio:
or leave both unset and let the engine derive it from the card. The non-expert weights come off
the top of what is claimed. The rest — the `elastic` line of the startup receipt — is shared by
the expert slab and the KV cache, and no flag divides it:
```sh
radiance --model m.rad --expert-vs-cache-ratio 0.82
```
- **The cache lends** under `--placement auto` or `expert_tiered`, without `--deterministic`, on a
device with virtual memory management. The experts keep on the card exactly what the pinned host
pool (`--host-pool-mib`) cannot hold, plus one expert unit of packing slack; they have nowhere
else to be. The cache takes everything else, up to what it could ever address
(`--max-num-seqs` x `--max-model-len`), and every block no live request holds is lent back to the
expert slab in place. The prefill staging region comes out of the cache's side.
- **Without a lender** — `--deterministic`, a stated `--placement all_vram` or `layer_offload`, or
no virtual memory management — a block the cache does not use would sit empty, so the experts
come first and the cache keeps one `--max-model-len` sequence.
`--expert-vs-cache-ratio` is the **weights** share of what is claimed. 0.75 (the default) gives
three quarters to weights and a quarter to KV.
The cache never gets less than one `--max-model-len` sequence, and when both sides fit, both are
whole. With a lending cache, `--host-pool-mib` is what moves the split: a larger pool takes experts
off the card and gives the cache more.
**This flag decides whether multi-turn works, which is more than the split it names.** The KV side
is not only concurrency: prefix caching holds a finished sequence's blocks so the next turn can
reuse them. When the pool cannot hold the *live sessions*, the cache drops prefixes the next turn
wanted and that turn re-prefills its whole context. At long contexts that is two orders of magnitude
of time-to-first-token, bought back for a fraction of a percent of the decode step.
Measured on Qwen3.8-Flash-Next at a 200K context, two ~184K-token sessions, byte-identical text:
| ratio | turn 1 | turn 2 | prefix hit |
|---|---|---|---|
| 0.87 | 207.4 s | 173.0 s | 0.0% |
| 0.82 | 227.7 s | **3.0 s** | 99.0% |
Same model, same prompts. The only difference is whether the pool could hold both sessions. 57x on
the second turn, paid for with ~10% on the cold first turn and ~1.4% of the decode step — experts
lose 5% of the elastic pool and the MoE GEMM is residency-bound.
The cliff is sharp and it is worth knowing where: at this shape 0.84 is **not** enough (49.7% hit,
one of the two sessions), and watching `kv_util` finds it — between 0.75 and 0.81 of the pool the
hit rate falls from 80.7% to 49.4%.
**The cache's size decides whether multi-turn works.** The KV side is not only concurrency: prefix
caching holds a finished sequence's blocks so the next turn can reuse them. When the pool cannot
hold the *live sessions*, the cache drops prefixes the next turn wanted and that turn re-prefills
its whole context. At long contexts that is two orders of magnitude of time-to-first-token.
Measured on Qwen3.8-Flash-Next at a 200K context with two ~184K-token sessions and byte-identical
text, the second turn took 173.0 s at a 0.0% prefix hit with a pool that could not hold both
sessions, and 3.0 s at 99.0% with one that could. The fall-off is sharp, and `kv_util` shows a
pool approaching it.
To size it yourself: work out what a token of context costs across **all** paged groups for your
model (the startup log prints this), multiply by the context you actually serve, multiply by the
sessions you want live at once, and give the KV side at least that.
sessions you want live at once, and compare that with the cache the receipt reports. The cache
already has everything the experts can do without; a larger `--host-pool-mib` (RAM permitting) or
`--kv-cache-dtype fp8` gives it more.
Worked, on Qwen3.8-Flash-Next: two paged groups share one token axis — `kv_attn` at 26.00 KiB and
`kv_qsa_bkey` at 3.25 KiB per 4-token block — so a token of context costs **7.32 KiB**, and a
@@ -564,8 +563,7 @@ holds at that price.
### 4.4 Long context
```sh
radiance --model m.rad --max-model-len 200000 --kv-cache-dtype fp8 \
--expert-vs-cache-ratio 0.82 --max-num-seqs 8
radiance --model m.rad --max-model-len 200000 --kv-cache-dtype fp8 --max-num-seqs 8
```
`--max-model-len` does not reserve anything per request — it sets the worst case the pool is sized
@@ -584,11 +582,10 @@ per sequence whether it is used or not:
- **Recurrent state.** On a hybrid model every sequence owns its delta-net state, and with
speculation two copies of it. Qwen3.8-Flash-Next keeps 54 MiB a copy on each card, so 32
sequences take 3.4 GiB of the cache share before a single token is cached. At
`--expert-vs-cache-ratio 0.82` the attention cache then holds about 116K tokens, less than one
200K request, and startup warns that a longer one would be refused; 0.78 brings it back, and the
experts it moves off the card cost single-stream decode about 15%. The 27B in bf16 lands at
117K the same way. The 27B in FP8 holds 2.8 full-length sessions at 32, the 35B-A3B ten.
sequences take 3.4 GiB of the cache share before a single token is cached. The 27B in bf16,
with no experts to give way, then holds about 117K tokens of attention cache, less than one 200K
request, and startup warns that a longer one would be refused. The 27B in FP8 holds 2.8
full-length sessions at 32, the 35B-A3B ten.
- **Block tables.** The step batch's tables are carved for every sequence at the full context.
They are charged to the VRAM budget (`step staging` in the startup receipt), so they come out of
the cache share and not out of `--gpu-headroom-mib`.
@@ -763,18 +760,21 @@ radiance --model m.rad \
--prefix-cache-disk-mib 65536 --prefix-cache-dir /var/cache/radiance
```
- `--prefix-cache-host-mib N` — **this is the switch.** Without a size, nothing is copied. Part of
it goes to linear-state snapshots on a hybrid model; startup says how many. Size it for the
conversations you expect to come back: one that does not fit comes back from disk instead.
- `--prefix-cache-host-mib N` — **this is the switch.** Without a size, nothing is copied. It holds
attention blocks only; a hybrid model's linear-state snapshots are in host memory already, in the
`--checkpoint-slots` store. Size it for the conversations you expect to come back: one that does
not fit comes back from disk instead.
- `--prefix-cache-disk-mib N` — the disk tier's size. Everything that reaches host memory is
written here too, so it sees the same bytes the host tier does.
written here too, snapshots included, so a full snapshot store detaches its least recently used
snapshot instead of losing it.
- `--prefix-cache-dir DIR` — where the disk tier lives. **Not `--weights-disk-tier`**, which is about
*weights*. The disk tier holds conversation content unencrypted.
- Recovering a 200K-token turn costs a copy over PCIe; recomputing it costs minutes.
On a hybrid model this includes the recurrent state, not just the attention blocks — restoring the
On a hybrid model the recurrent state matters as much as the attention blocks — restoring the
blocks alone leaves the session re-running every linear layer over its whole transcript, which
every hit-rate counter reports as a hit. `/sessions` shows what is stored, where, and whether the
every hit-rate counter reports as a hit. The snapshots never take VRAM: each is copied to host
memory after the step that produced it and back before the step that resumes from it. `/sessions` shows what is stored, where, and whether the
linear half is being served.
### 4.9 What a request that leaves a field out gets
@@ -891,7 +891,6 @@ one line naming each one the command line moved.
| flag | default | |
|---|---|---|
| `--gpu-headroom-mib N` | 96 | VRAM left unclaimed on every card |
| `--expert-vs-cache-ratio R` | 0.75 | weights share of what is claimed |
| `--vram-weights-mib N` | derive | the resident weight slab |
| `--vram-kv-mib N` | derive | the paged KV pool |
| `--kv-cache-dtype T` | bf16 | `bf16` or `fp8` |
@@ -915,7 +914,7 @@ one line naming each one the command line moved.
| `--placement MODE` | auto | `all_vram`, `layer_offload`, `expert_tiered`, `auto` |
| `--deterministic` | off | pin placement to the loader's plan, so the resident set cannot change under the heat engine |
| `--checkpoint-interval N` | 2048 | linear-attention state checkpoint interval, in tokens |
| `--checkpoint-slots N` | 8 | linear-state snapshots the server may hold at once, **in total**, not per sequence. A cap, not a charge: slots are backed as they are taken, so unused ones cost no VRAM. Raising it trades addressable context, since the range comes out of the KV pool |
| `--checkpoint-slots N` | 8 | linear-state snapshots the server may hold at once, **in total**, not per sequence. They live in pinned host memory, not VRAM: one slot is a snapshot of every rank's shard (113 MB on Flash-Next at `--tp 2`), allocated at startup. A snapshot is copied off the card after the step that produced it and back before the step that resumes from it. With a disk tier a full store detaches its least recently used snapshot to disk instead of losing it |
| `--checkpoint-policy NAME` | geometric-backoff | also `tip-only`, `keep-all` |
| `--no-prefix-cache` | — | disable prefix caching |
@@ -1480,10 +1479,10 @@ released until it does.
| What you see | What it means | What to do |
|---|---|---|
| `N declared op(s) resolve to libref` and the engine exits | No kernel library covers those ops on this card. Serving from the reference implementation would be orders of magnitude slow with nothing to say so | Install a library that covers them, or accept the cost with `--debug-accept-reference-kernels`. The named ops are exactly what a new library must implement |
| `did not fit` at load, naming a weight class or a KV group | The split left one side too little. A routed expert cannot be served from the file tier, so it has nowhere else to go | If **weights** did not fit: **raise** `--expert-vs-cache-ratio`, lower `--max-model-len` or `--max-num-seqs`, or add `--host-pool-mib`. If a **KV group** did not fit: lower the ratio, or `--kv-cache-dtype fp8`. The plan report names which, by class, with the shortfall |
| `did not fit` at load, naming a weight class or a KV group | The split left one side too little. A routed expert cannot be served from the file tier, so it has nowhere else to go | If **weights** did not fit: add or raise `--host-pool-mib`, or lower `--max-model-len` or `--max-num-seqs`. If a **KV group** did not fit: `--kv-cache-dtype fp8`, or a larger `--host-pool-mib` (RAM permitting), which takes experts off the card. The plan report names which, by class, with the shortfall |
| `chat is 501` in the startup line | The container carries no chat template | Re-convert with `--tokenizer`, and check that a `chat_template.jinja` sits beside `tokenizer_config.json` in the checkpoint. Meanwhile use `/v1/completions` |
| `does not read '<weight>' encoded <encoding>` at startup | No loaded kernel takes that weight's encoding for the op that reads it | Convert with a recipe that writes an encoding a loaded kernel reads, or load the library that reads it |
| Prefix hit rate 0% and every turn re-prefills | The KV pool cannot hold the live sessions, so the cache evicts what the next turn wanted | Lower `--expert-vs-cache-ratio` (more to KV), or `--kv-cache-dtype fp8`, or fewer/shorter sessions. See §4.3 |
| Prefix hit rate 0% and every turn re-prefills | The KV pool cannot hold the live sessions, so the cache evicts what the next turn wanted | The cache already has everything the experts can do without: a larger `--host-pool-mib` (RAM permitting), `--kv-cache-dtype fp8`, or fewer/shorter sessions. See §4.3 |
| The server dies with no log line, on a request it had been serving fine | A kernel whose code object had never been loaded could not be: the card has no room left. HIP faults inside the launch rather than returning an error, so there is nothing to print | A card that never met `--gpu-headroom-mib` — see §4.3. Raise the headroom past the shortfall startup names. `coredumpctl info` names the kernel; `AMD_LOG_LEVEL=1` prints `HSA_STATUS_ERROR_OUT_OF_RESOURCES` just above the fault |
| KV in VRAM stays high with one session and nothing moves | The idle tiers are **off** — they are sized, and with no size nothing is copied | Pass `--prefix-cache-host-mib N` |
| `out of memory` / `the carve reserved N of address space and the card would not back it` | Something else is holding VRAM | Check with `rocm-smi`; stop the other process. The budget is stated before allocation, so the log says what it asked for |
+4 -5
View File
@@ -66,9 +66,8 @@ LDS lookup a byte), more protected bf16 experts (+4% bytes for 7% less error), a
(13% less error energy for +13-18% on the expert GEMMs).
**Further quality levers**, in order: five bits on both projections of layers
16-31 (the same +8% as the down projections, ~0.066 expected); fewer layers at five bits for a
smaller prefill cost; and `--expert-vs-cache-ratio`, which buys the residency back with KV
capacity. The formats, the kernel and a layer's own choice of form are all in the tree.
16-31 (the same +8% as the down projections, ~0.066 expected), and fewer layers at five bits for a
smaller prefill cost. The formats, the kernel and a layer's own choice of form are all in the tree.
## The stored plane
@@ -244,8 +243,8 @@ its Hessians in the model's own domain; a rotated recipe's GPTQ reads them rotat
Whole experts per rank, which a calibration run wants anyway. A step reads about 100 GiB a rank from
the drive and grows only slowly with what it carries -- 50 s at ~32K tokens, 59 s at ~55K -- so
drive it with large prefill steps: `--max-num-batched-tokens 65536 --max-num-seqs 64`, about 96
requests in flight, and `--expert-vs-cache-ratio 0.5` so the cache share holds 64 sequences'
recurrent state. That records ~930 tokens a second, ten million tokens in three hours.
requests in flight, with a KV pool that holds 64 sequences' recurrent state (`--vram-kv-mib`
states it outright). That records ~930 tokens a second, ten million tokens in three hours.
**The corpus is what the Hessian is of, so it has to look like the traffic.** A few thousand
tokens of one repeated sentence gives a Gram whose energy sits in a handful of directions, and GPTQ
+13 -5
View File
@@ -544,11 +544,19 @@ gets a refusal, not a silent change of cost.
`router_topk_scatter` over those logits. With `gate_b` [1, K] and `gate` [M, 1] present it is
also the shared expert's one-column `gemm_nt` over the same `a`; the two come together or not at
all. The selection needs every logit of a row, so it runs in the workgroup that finishes the GEMM
last (an arrival counter, self-resetting, one a stream and logits buffer). It is byte-identical to
the launches it stands in for: an element of the skinny bf16 GEMM depends only on its split-K
count, which this op takes from the same law at the same N, and the selection and sort are the
same code. Decode only, `M <= 64` -- past that the router is the tiled GEMM -- and bounded like the
pair. The logits stay an output.
last (an arrival counter, self-resetting, one an op instance: libr4d takes it in the row's `init`,
so it is in the VRAM budget, and refuses a launch without one). It is byte-identical to the
launches it stands in for: an element of the skinny bf16 GEMM depends only on its split-K count,
which this op takes from the same law at the same N, and the selection and sort are the same code.
Decode only, `M <= 64` -- past that the router is the tiled GEMM -- and bounded like the pair. The
logits stay an output.
**The router GEMM inside it is NOTUNE.** It always takes the split the untuned law picks, which is
what makes it byte-identical to the unfused GEMM as an untuned install runs it. A tune-cache entry
for the unfused router's `gemm_nt` does not reach this op, so on a tuned install the two forms may
differ in the last bit; no shipped configuration tunes these GEMMs. An architecture asks for this op
wherever it declares the pair and issues the router and the pair itself where it does not resolve
or a pass is past its rows.
`moe_scatter`'s output is what `rad_route_report` hands the heat engine. The histogram is read
back asynchronously and consumed on the next step; nothing here blocks the compute stream
+3 -3
View File
@@ -534,19 +534,19 @@ deliberately disconnects clients from it, which is not the same promise.
| | knobs |
|---|---|
| `mcserve.sh` | MiniCPM5-2B + DSpark drafter (`minicpm5-2b-dspark.v2.rad`), left running. `P` `TP` `MLEN` `SEQS` `M` `KVD` `HR` `MNBT` `EXTRA` `EXTRA_ENV` |
| `fnserve.sh` | Qwen3.8-Flash-Next, the production container `w4nl64-i8lm.rad`, same contract. `P` `TP` `MLEN` `SEQS` `M` `RATIO` `NS` `HOSTPOOL` `KVD` `HR` `MNBT` `WIRE` `KVHOST` `KVDIR` `KVDISK` `EXTRA` `EXTRA_ENV` |
| `fnserve.sh` | Qwen3.8-Flash-Next, the production container `w4nl64-i8lm.rad`, same contract. `P` `TP` `MLEN` `SEQS` `M` `NS` `HOSTPOOL` `KVD` `HR` `MNBT` `WIRE` `KVHOST` `KVDIR` `KVDISK` `EXTRA` `EXTRA_ENV` |
| `fnstop.sh` | stops whichever is running and **waits for the process to go** |
| `convdspark.sh`, `convfn.sh` | rebuild the containers those two serve. The conversions of record. `convfn.sh` needs `CALIB=<dir>`: the production recipe's expert rule runs GPTQ against the calibration Grams there |
| `hfget.sh` | fetch a checkpoint from Hugging Face with `curl` and `jq`. Resumable |
```sh
scripts/fnserve.sh # defaults: port 8100, tp 2, 200K ctx, ratio 0.82
scripts/fnserve.sh # defaults: port 8100, tp 2, 200K ctx
P=8100 MLEN=131072 SEQS=4 scripts/fnserve.sh # override
scripts/fnstop.sh
```
Both print the endpoints and exit with the server still up. Read their headers — `fnserve.sh` in
particular carries the whole `--expert-vs-cache-ratio` argument with the measurements behind it.
particular records why each production flag is what it is.
### Measuring a server that is already up
+74 -64
View File
@@ -2,66 +2,60 @@
Radiance shards by dividing: `n_head`, `n_head_kv`, the delta-net head counts and the vocabulary
each split across the world, and a count that does not divide is **refused at declare, by name**
(`share.cpp`, `rad_arch.h`). Four ranks got through for Qwen3.8-Flash-Next by replicating the two
KV heads in rank pairs (1.0.7); three did not: 24 query heads, 2 KV heads, 16 GDN K heads and 48
GDN V heads have no even share in 3, and replication needs a world that is a multiple of the head
count. 1.0.12 served three ranks by **padding the checkpoint** offline (`tools/pad_tp.py`, the
regime of tcclaviger's `vllm/config/tp_padding.py`): zero heads appended so that 36 / 3 / 18 / 54
divide, and a container converted from that. It worked, exactly, and it cost a second 115 GiB
container for every model and 1/3 of the attention and 2 of 18 delta-net heads computing zeros.
(`share.cpp`, `rad_arch.h`). Four ranks get through for Qwen3.8-Flash-Next by replicating the two
KV heads in rank pairs; three did not: 24 query heads, 2 KV heads, 16 GDN K heads and 48 GDN V
heads have no even share in 3, and replication needs a world that is a multiple of the head count.
Padding the checkpoint offline (`tools/pad_tp.py`: zero heads appended so that 36 / 3 / 18 / 54
divide) served three ranks exactly, at the cost of a second 115 GiB container for every model and
a third of the attention and 2 of 18 delta-net heads computing zeros.
This document describes what replaced it: **the shipped container serves at any world size**, with
no tool and no second file. Two rules, both built from machinery the engine already had.
## 1. The attention world
`rad_arch.h` `geom_from` already handled a world *above* the KV head count by replication, when
the world is a multiple of the count. It now handles a world that is **neither a divisor nor a
multiple** of it:
`rad_arch.h` `geom_from` handles a world *above* the KV head count by replication, when the world
is a multiple of the count. For a plugin that asks for it (`attn_world_ok`; qwen4exp does) it also
handles a world that is **neither a divisor nor a multiple** of it:
> attention is served on the largest multiple of the KV head count under the world -- the
> **attention world** -- and the ranks past it are **attention-zero**.
Three ranks over two KV heads: the attention world is 2. Ranks 0 and 1 split the heads exactly as
the two-rank serve does -- 12 query heads, one KV head, gqa 12, the same kernels -- and rank 2
declares **the same shapes** and reads **nothing** for them: `rad_weight_shard_zero` tells the
loader that this rank's share of `attn_qg`, `attn_k`, `attn_v` and `attn_output` is zeros. Its
attention computes zeros from zeros and its output projection adds exactly nothing to the reduce.
Five ranks over two: attention world 4 (two replicated pairs), rank 4 attention-zero. Six: three
pairs, no zero rank.
**computes no attention**: `rad_block_attn_gated_fp8.h` declares no projections, no attention and
no cache store on it, and writes the block's output wire to zero with one `fill` (`docs/OPS.md`).
The all-reduce and the residual after it see what they always saw, and the zero adds exactly
nothing to the reduce. Five ranks over two: attention world 4 (two replicated pairs), rank 4
attention-zero. Six: three pairs, no zero rank. A plugin that does not ask is refused at a world
like these, by name, as before.
**The zeros are written, not assumed.** A zero share has no bytes in the container, so the sweep
over the file never reaches it; the loader hands it to the relayout workers itself, before the
sweep, and its fill writes the slot. The pool refuses to finish with any staged weight nothing
delivered. This matters because a card whose freed VRAM the driver wipes hands fresh allocations
back as zeros, and a slot nothing wrote serves correctly there by luck -- until the card has been
through a reset ("VRAM is lost") and the same slot is garbage. The test that sees it on any card:
RADIANCE_POISON_ALLOC=255 radiance --model stock.rad --tp 3 ...
fills every fresh device allocation with 0xFF (NaN in every float width) before it is handed out;
the serve must answer exactly as without it. `RADIANCE_POISON_RANGE=lo:hi` narrows the fill to a
thread's allocation ordinals for a bisect (`core/device/dispatch.cpp`).
Why the same shapes rather than no attention on that rank: the scheduler sees **one program**
(`core/sched/batch.cpp` indexes `kv_groups[i]` by position), so every rank declares every op and
every KV group in the same order. An attention-zero rank's KV group is as large as its peers'; the
cost is one KV head of cache on that rank, the same bytes the padded container spent on its dummy
head, and nothing is read from disk for its projections.
**The KV groups stay in the same order on every rank.** The scheduler sees one program
(`core/sched/batch.cpp` indexes `kv_groups[i]` by position) and one block table serves every rank,
so an attention-zero rank declares its attention group like its peers and marks it
`rad_kv_group_zero`: it carves nothing for it, holds the shared table's block count, lends none of
it, and the tiers skip it when they move an entry. Every rank carves the same block count -- each
is planned, asked what it could page (`KVManager::paged_tokens`; a rank whose only paged groups are
zero limits nobody) and capped at the least before any carves.
Under a smaller attention world the plain even shard over `world` is the wrong cut for every
attention projection, so `rad_block_attn_gated_fp8.h` declares **spans** (`rad_weight_shard_span`,
the same call the KV replication already used for k/v): q|gate rows and output columns
`[attn_rank * n_head, +n_head)` heads, k/v rows at `kv_off`. When the attention world is the world
-- every TP2 and TP4 deployment -- no span is declared and the block declares as it always did.
attention projection, so the attention ranks declare **spans** (`rad_weight_shard_span`, the same
call the KV replication uses for k/v): q|gate rows and output columns `[attn_rank * n_head,
+n_head)` heads, k/v rows at `kv_off`. When the attention world is the world -- every TP2 and TP4
deployment -- no span is declared and the block declares as it always did.
## 2. Uneven delta-net heads
The delta net has no KV-head constraint: its kernels are bound on head *widths* (`head_k`,
`head_v`, the chunk) and take any head count. So 16 K heads over three ranks are **6, 5 and 5**,
each rank's V heads the same multiple of its K heads (48 / 16 = 3: 18, 15, 15), every rank real
heads, nothing padded. `qwen4exp` computes the split (`base + (rank < rem)`) and
`rad_block_gdn_fp8.h` declares it as spans of the container's rows.
`head_v`, the chunk) and take any head count. So 16 K heads over three ranks are **5, 5 and 6**,
each rank's V heads the same multiple of its K heads (48 / 16 = 3: 15, 15, 18), every rank real
heads, nothing padded. The extra head goes to the rank without attention (`remainder_place` in
`rad_arch.h`): it has the time, and the rank that would otherwise hold the extra head AND attention
is the step's slowest. The experts' extra block stays on the parity rotation (`qwen4exp_fp8.cpp`
says why). `qwen4exp` computes the split and `rad_block_gdn_fp8.h` declares it as spans of the
container's rows. Each rank's recurrent state is its own size, so a fresh slot is cleared, a
snapshot taken and a tier entry laid out by each rank's own plan: a slot of the snapshot store or
the tiers is the sum of the ranks' shares, each rank's where the ones before it end.
That needed one thing the span call could not say. `in_proj_qkv|z` is four projections stacked
along dim 0 -- q 2048, k 2048, v 6144, z 6144 rows -- and `rad_weight_shard_span` takes one
@@ -73,46 +67,62 @@ columns take the same rank's heads. The even split, when the counts divide, is u
## 3. What this is built from
- `rad_weight_shard_zero(b, w)` -- this rank's share is zeros; `weight_share` returns the
declaration's extents with no rectangles, the loader stages the weight with a worker that writes
zeros (the route a checkpoint weight takes) and reads nothing.
- `rad_weight_shard_span_parts(b, w, lo, hi, total, n)` -- a span per stacked part.
- `Geom::attn_world / attn_rank / attn_zero`, set by `geom_from`; `GdnFP8::Config::k_first /
v_first`, set by the plugin.
- Both exports are additive: `RAD_ABI_VERSION` does not move, and a plugin that does not call them
declares as before. `tests/share_test.cpp` holds the per-part cut and the zero share.
- `rad_kv_group_zero(b, g)` -- this rank keeps no cache for a paged group.
- the `fill` op -- libr4d's `fill_bf16`, libref's `ref_fill`.
- `Geom::attn_world / attn_rank / attn_zero`, set by `geom_from` under `attn_world_ok`;
`GdnFP8::Config::k_first / v_first`, set by the plugin.
- The exports are additive: `RAD_ABI_VERSION` does not move, and a plugin that does not call them
declares as before. `tests/share_test.cpp` holds the per-part cut, `tests/arch_test.cpp` the
three-rank declaration, `tests/mem_test.cpp` the capped carve, the zero group and a tier entry
moved across ranks with unequal shares.
**A load check that came with it.** The relayout pool refuses to finish when any staged weight was
never delivered: a slot nothing wrote holds whatever the card had there -- zeros on a card whose
freed memory the driver wipes, garbage after a reset ("VRAM is lost"). The instrument that shows
such a read on any card:
RADIANCE_DEBUG_POISON_ALLOC=255 radiance --model stock.rad --tp 3 ...
fills every fresh device allocation with 0xFF (NaN in every float width) before it is handed out;
the serve must answer exactly as without it. `RADIANCE_DEBUG_POISON_RANGE=lo:hi` narrows the fill
to a thread's allocation ordinals for a bisect (`core/device/dispatch.cpp`).
## 4. Serving
```sh
radiance --model qwen3.8-next-flash-fp8-iq4r-moe.rad --tp 3 --tp-wire exact --max-num-seqs 8 \
--max-model-len 262144 --placement expert_tiered --host-pool-mib 8192 \
--gpu-headroom-mib 96 --expert-vs-cache-ratio 0.82 --kv-cache-dtype fp8 \
--gpu-headroom-mib 96 --kv-cache-dtype fp8 \
--num-speculative-tokens 3 --max-num-batched-tokens 2048
```
The log says what the geometry did:
```
radiance: world_size = 3 over n_head_kv = 2: attention on 2 rank(s), rank(s) 2..2 carry zero attention weights and the delta net and experts of a full rank
radiance: qwen4exp: rank 0 takes delta-net K heads [0, 6) of 16 and V heads [0, 18) of 48
radiance: qwen4exp: rank 1 takes delta-net K heads [6, 11) of 16 and V heads [18, 33) of 48
radiance: qwen4exp: rank 2 takes delta-net K heads [11, 16) of 16 and V heads [33, 48) of 48
radiance: world_size = 3 over n_head_kv = 2: attention on 2 rank(s), rank(s) 2..2 carry no attention and take the delta net's remainder first
radiance: qwen4exp: rank 0 takes delta-net K heads [6, 11) of 16 and V heads [18, 33) of 48
radiance: qwen4exp: rank 1 takes delta-net K heads [11, 16) of 16 and V heads [33, 48) of 48
radiance: qwen4exp: rank 2 takes delta-net K heads [0, 6) of 16 and V heads [0, 18) of 48
```
Measured on three Radeon AI PRO R9700 (gfx1201, PCIe Gen5 x16, Threadripper PRO 9955WX) with the
same container served at two and three ranks -- the one comparison where only the world changes:
Measured by the contributor on three Radeon AI PRO R9700 (gfx1201, PCIe Gen5 x16) at an earlier
state of this design -- the attention-zero rank then ran its projections on zero weights, and the
extra delta-net head sat on rank 0 -- with the uncensored Flash-Next fine-tune. Hot = 1 / 4 / 8
streams, 8 K prompt, 1 K generated, aggregate tok/s; crowd = 4 streams at 100 K context, per
stream; HumanEval 164 and a 200-question GSM8K subset at temperature 0:
| | two ranks | three ranks |
|---|---|---|
| READY from cold | | |
| 1 / 4 / 8 streams, aggregate t/s | | |
| 4 streams at 100 K context, per stream | | |
| HumanEval / GSM8K | | |
| container | `--tp` | hot c1 / c4 / c8 | crowd | HE | GSM8K |
|---|---|---|---|---|---|
| unpadded | 3 | 191 / 309 / 353 | 42.7 | 0.878 | 0.925 |
| unpadded, the same file | 2 | 177 / 308 / 377 | 33.8 | 0.884 | 0.915 |
| padded offline | 3 | 182 / 288 / 395 | 43.5 | 0.848 | 0.935 |
The three-rank text is the three-rank text of the padded container, token for token, at temperature
0 on the prompt set -- the two computations are the same arithmetic with the zeros in a different
place.
Three ranks buy the single stream and the long-context crowd, not the eight-stream aggregate. The
quality rows are within a rerun of each other (HumanEval moves by about 3 of 164 between runs of one
container); unpadded and padded at three ranks gave the same answers on 40 prompts at temperature
0, bit-identical on one -- the head regroup changes the order the all-reduce sums in, and near-ties
flip.
`tools/pad_tp.py` and `tools/pad_verify.py` remain in the tree: they are how a checkpoint is padded
for an engine that has no attention world, and how a pad is verified, and nothing here needs them.