Archived
radiance 1.0.10
- 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.
This commit is contained in:
1 parent
2f56e3c477
commit
e466fa07e2
56 files changed
+1804
-761
No files matched your search
+14
-11
@@ -334,17 +334,20 @@ time.
|
||||
|
||||
**The fused all-reduce forms are two-rank, except the exact write.** At four ranks `ar_hc_write`
|
||||
exists on the exact wire only (`ar_hc_write_4rank`, the 4-rank one-shot with the write as its
|
||||
epilogue, on the plain all-reduce's buffers), and so does `ar_gather_hc_write`
|
||||
(`ar_gather_hc_write_4rank`, the same with `moe_gather` as its prologue), which the MoE
|
||||
connections take wherever the step is one MoE pass. A step takes either where the standalone
|
||||
`all_reduce` would have been the exact one-shot: under 1 MiB, and with `--tp-wire wht6` also
|
||||
under `--tp-wire-min-kb`. Larger messages, and every lossy one, keep the standalone sequence —
|
||||
`moe_gather` on the MoE connections, `all_reduce` (4-rank two-shot or ti8), then
|
||||
`hc_write_bf16`. The unfused sequence is declared beside the fused one, so nothing is unresolved
|
||||
at boot. The
|
||||
attention's own fusion is not a collective and does carry over: the sparse decode with the output
|
||||
gate and the quantiser in its merge (`attn_paged_gate_quant`) has gqa-6, page-4 rows. The per-step cost against tp2 on the
|
||||
same cards is unmeasured.
|
||||
epilogue), and so does `ar_gather_hc_write` (`ar_gather_hc_write_4rank`, the same with
|
||||
`moe_gather` as its prologue), which the MoE connections take wherever the step is one MoE pass.
|
||||
Both are declared over the rows of a decode or verify step — `--max-num-seqs` × (1 +
|
||||
`--num-speculative-tokens`) — because a one-shot is for those messages, and a step within that
|
||||
bound takes them wherever its message goes out exact: always with `--tp-wire exact`, and with
|
||||
`--tp-wire wht6` under `--tp-wire-min-kb`. They run on an all-reduce instance keyed by that bound,
|
||||
not on the standalone all-reduce's unless the two bounds agree; the wide family's flag, sequence
|
||||
and slot discipline is what makes either safe on one stream. A prefill chunk, and every message
|
||||
that goes out lossy, keeps the standalone sequence — `moe_gather` on the MoE connections,
|
||||
`all_reduce` (whose size bands pick the 4-rank one-shot or two-shot, or ti8 on the lossy wire),
|
||||
then `hc_write_bf16`. The unfused sequence is declared beside the fused one, so nothing is
|
||||
unresolved at boot. The attention's own fusion is not a collective and does carry over: the sparse
|
||||
decode with the output gate and the quantiser in its merge (`attn_paged_gate_quant`) has gqa-6,
|
||||
page-4 rows. The per-step cost against tp2 on the same cards is unmeasured.
|
||||
|
||||
**One collective does generalise, because it has to.** The lm_head is vocab-sharded, so the sampler
|
||||
gathers the ranks' candidate sets rather than their logits (`core/sample/sampler.cpp`) and an
|
||||
|
||||
+4
-5
@@ -88,14 +88,13 @@ Every one of these options is needed:
|
||||
without this the model cannot serve. The profile also refuses the NUMA binding calls the ROCm
|
||||
runtime makes for host memory.
|
||||
- **`--init`**: the engine is not PID 1. It finishes its step and releases the cards on SIGTERM.
|
||||
- **`--ulimit memlock=-1`**: `--ngram-placement ram` locks a copy of the n-gram table in RAM
|
||||
(47.7 GiB for Qwen3.8-Flash-Next), far past Docker's default memlock limit. Without it `auto`
|
||||
reads the table from the container and `ram` refuses the start. `deploy/compose/common.yaml`
|
||||
sets it.
|
||||
- **`--network host`**: the server binds the host's addresses directly, IPv4 and IPv6, with no
|
||||
NAT in front of it.
|
||||
|
||||
And one more for `--ngram-table ram`: **`--ulimit memlock=-1`**. The copy of the n-gram table is
|
||||
locked in RAM, and Docker's default memlock limit is far below its 47.7 GiB; without it the server
|
||||
says so at the first request and reads the table from the container as it does by default.
|
||||
`deploy/compose/common.yaml` sets it.
|
||||
|
||||
The image sets `GPU_MAX_ALLOC_PERCENT=100` and `GPU_MAX_HEAP_SIZE=100`. The HIP runtime's defaults
|
||||
cap one allocation, and the heap, below what the placement plan hands out.
|
||||
|
||||
|
||||
+44
-16
@@ -468,23 +468,47 @@ Related flags:
|
||||
--gpu-headroom-mib 96 # VRAM left unclaimed on every card
|
||||
--kv-cache-dtype fp8 # halve what a token of context costs (a real quantisation)
|
||||
--host-pool-mib 8192 # pinned host tier for weights
|
||||
--host-weights token_embd.weight # the embedding table off the card (below)
|
||||
--embedding-placement ram # the token embedding off the card (below)
|
||||
--ngram-placement ram # an n-gram table in locked RAM instead of read from disk (below)
|
||||
--weights-disk-tier # stream what fits neither from the container; needs O_DIRECT
|
||||
```
|
||||
|
||||
**`--host-weights` takes the embedding table off the card.** It 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. Named here, it is placed in the pinned host pool before any
|
||||
strategy runs and the lookup kernel reads it over the link in place, so it costs no VRAM and the
|
||||
KV pool gets its share. On Qwen3.8-27B at two 16 GiB cards decode and prefill measured within noise
|
||||
of the table on the card, against ~73K more tokens of context. The pool must hold it
|
||||
(`--host-pool-mib`, every rank its own shard), a derived split leaves it out of the weight budget,
|
||||
and a name any other op reads -- a head, a GEMM operand -- is refused: it would stream every step.
|
||||
**Two lookup tables have a placement of their own**, because a step reads only M of their rows and
|
||||
never the whole table, so a tier below the card serves them at little or no cost:
|
||||
|
||||
| | `vram` | `ram` | `disk` |
|
||||
|---|---|---|---|
|
||||
| `--embedding-placement` | on the card, with the other weights | the pinned host pool, read over the link in place | refused |
|
||||
| `--ngram-placement` | refused | a locked copy in RAM, made at load | read from the container through a row cache |
|
||||
|
||||
Both default to `auto`, the fastest tier that has room once every other weight is placed. Startup
|
||||
prints what each resolved to and why. A tier the flag names that cannot be honoured stops the
|
||||
server with the reason; nothing falls back quietly.
|
||||
|
||||
**The token embedding** is the largest model-level weight a dense model has -- 248320 x 5120 in bf16
|
||||
is 1.18 GiB a card at `--tp 2`. With `ram` it is placed in the pinned host pool before any strategy
|
||||
runs and the lookup reads it over the link in place, so it costs no VRAM and the KV pool gets its
|
||||
share. The pool must hold it (`--host-pool-mib`, every rank its own shard). `auto` keeps it on the
|
||||
card unless the card cannot hold the other weights with it, or a derived KV pool could then not
|
||||
hold one `--max-model-len` sequence; then it takes `ram` if the host pool can hold it. The table is
|
||||
found by what reads it: a model-level weight only `embed_lookup` reads. A head tied to it is read by
|
||||
a GEMM too and is never moved, since it would stream whole every step. `disk` is refused: the lookup
|
||||
writes activations the card reads, and a host kernel reading the container cannot write them.
|
||||
|
||||
```sh
|
||||
radiance --model m.rad --tp 2 --host-pool-mib 1280 --host-weights token_embd.weight
|
||||
radiance --model m.rad --tp 2 --host-pool-mib 1280 --embedding-placement ram
|
||||
```
|
||||
|
||||
**An n-gram table** (Qwen3.8-Flash-Next's is 47.7 GiB) is read by a host kernel only, so it is never
|
||||
on the card. `disk` reads its rows from the container through a row cache and direct reads; about
|
||||
half of a step's rows are first-seen, so steps wait on the drive. `ram` copies the whole table into
|
||||
locked huge pages at load -- 12 to 40 s more startup, depending on the page cache -- and every gather
|
||||
reads memory. It needs the table's size in memory after the pinned host pools and the prefix
|
||||
cache's host tier, with 4 GiB to spare, a memlock limit that large (`--ulimit memlock=-1` in Docker,
|
||||
`LimitMEMLOCK=infinity` under systemd), and room under every memory cgroup the process sits in.
|
||||
`ram` short of any of them refuses the start and names which; `auto` takes `ram` when all of them
|
||||
allow it and `disk` otherwise.
|
||||
|
||||
**A model larger than the card and the host pool together still serves with
|
||||
`--weights-disk-tier`** -- and every step is then paced by the drive, which is the trade the flag
|
||||
names. A routed expert that fits neither VRAM nor the pinned pool lives in the container and
|
||||
@@ -695,10 +719,14 @@ eight ranks is one-shot up to 1 MiB a message and two-shot above it, which sends
|
||||
bits.
|
||||
|
||||
On a model with a gated residual (Qwen3.8-Flash-Next) the all-reduce rides inside the residual's
|
||||
write, with the MoE gather in front of it, on either wire: the rotated forms of `ar_hc_write` and
|
||||
`ar_gather_hc_write` produce the same bytes as the unfused chain on the same wire. There `wht6` is
|
||||
worth +5.6–6.3% of prefill at a 2048-token chunk (20K prompt 5556 → 5908 tok/s; a 23K extension at
|
||||
81K depth 4998 → 5278) and −1.3% of the eight-stream decode step; one-stream decode stays exact.
|
||||
write, with the MoE gather in front of it. At two ranks that holds on either wire: the rotated
|
||||
forms of `ar_hc_write` and `ar_gather_hc_write` produce the same bytes as the unfused chain on the
|
||||
same wire. There `wht6` is worth +5.6–6.3% of prefill at a 2048-token chunk (20K prompt 5556 →
|
||||
5908 tok/s; a 23K extension at 81K depth 4998 → 5278) and −1.3% of the eight-stream decode step;
|
||||
one-stream decode stays exact. At four ranks only the exact wire has a fused form, and it takes
|
||||
the decode and verify steps — up to `--max-num-seqs` × (1 + `--num-speculative-tokens`) rows. A
|
||||
prefill chunk, and a message that goes out on the tiered-int8 wire, runs the unfused chain, where
|
||||
the all-reduce's own size choice between one-shot and two-shot applies.
|
||||
|
||||
**The cards must reach each other's memory directly** (peer to peer, P2P). The all-reduce
|
||||
kernels push into the other card's memory. At launch radiance asks the driver, for every pair of
|
||||
@@ -864,9 +892,9 @@ one line naming each one the command line moved.
|
||||
| `--vram-kv-mib N` | derive | the paged KV pool |
|
||||
| `--kv-cache-dtype T` | bf16 | `bf16` or `fp8` |
|
||||
| `--host-pool-mib N` | 0 | pinned host tier (weights) |
|
||||
| `--host-weights NAMES` | none | embedding tables kept in the pinned host pool and read in place over the link (comma-separated, a trailing `*` matches a prefix); charged to `--host-pool-mib`, and only a weight embedding lookups alone read is accepted. See §4.3 |
|
||||
| `--embedding-placement WHERE` | auto | `auto`, `vram` or `ram`: the token embedding on the card or in the pinned host pool, read in place; `disk` is refused. See §4.3 |
|
||||
| `--ngram-placement WHERE` | auto | `auto`, `ram` or `disk`: an n-gram table as a locked copy in RAM made at load, or read from the container; `vram` is refused. See §4.3 |
|
||||
| `--weights-disk-tier` | off | read weights that fit neither VRAM nor the host pool from the container (O_DIRECT); routed experts a layer at a time |
|
||||
| `--ngram-table MODE` | disk | where the n-gram embedding's host gather reads its rows: `disk` from the container through a row cache, `ram` from a copy of the whole table in locked host memory (Qwen3.8-Flash-Next: 47.7 GiB), made in the background from the first request. `ram` needs the memory and a memlock limit that large (`--ulimit memlock=-1` in Docker); short of either it says so and stays on `disk` |
|
||||
|
||||
**Idle session tiers**
|
||||
|
||||
|
||||
@@ -365,6 +365,10 @@ typo'd directory is a message, not a silent quality regression.
|
||||
|
||||
- `r4d_selftest --case moe_gemm_w4a8` -- the kernel against an independent host decode of the same
|
||||
planes, both M bands, through the relayout the loader runs.
|
||||
- `r4d_selftest --case moe_gemm_w4a8_mod4` -- the four-class op against the two-class one byte for
|
||||
byte, and against a host decode with every class at its own geometry and one of classes 1 to 3
|
||||
the only wide one, as ranks 1 to 3 of four hold them; `--case moe_gemm_fp8a8_mod4` is the same
|
||||
host decode at block fp8.
|
||||
- `quant_test` -- **GPTQ against the objective it minimises**. The metric is
|
||||
`||X (W - W')^T||^2 = sum over rows of e H e^T` and *not* rel_l2 on the weight: error feedback
|
||||
makes the weight worse in the plain sense, deliberately. The control is no Hessian at all, under
|
||||
|
||||
+9
-11
@@ -130,9 +130,11 @@ the codes and the scale planes of its even experts and of its odd ones. Whatever
|
||||
is split EVENLY across the table positions, in declaration order, and where it does not come out
|
||||
whole the first positions take one more each: `moe_gemm_q_mod4`'s first `n_expert % 4` classes hold
|
||||
one expert more than the rest, and their codes and scales are its first table positions. A list too
|
||||
short to give every table an entry is refused at declare, and a run that is not one contiguous,
|
||||
same-shaped table is refused at issue. That is exactly right for the case tables exist for: every
|
||||
table of one MoE op takes one weight per expert of its class.
|
||||
short to give every table an entry is refused at declare. A table whose declared run is not
|
||||
contiguous is refused when the tables are bound, before the first step; one whose entries disagree
|
||||
about their shape, or an issue naming a run other than the declared one, is refused at issue. That
|
||||
is exactly right for the case tables exist for: every table of one MoE op takes one weight per
|
||||
expert of its class.
|
||||
|
||||
## What the loader enforces
|
||||
|
||||
@@ -772,7 +774,9 @@ and the input, and the reduced sum lands in it.
|
||||
output feeds a gated residual rather than a norm. `y` is INOUT for the same reason `x` is above.
|
||||
It serves both wires, one op a wire: a caller declares the rotated form beside the exact one and
|
||||
issues whichever the step's message goes out on, and a `wire` of 6 is 6 at every size. At four
|
||||
ranks only the exact form exists.
|
||||
ranks only the exact form exists. A caller states `wire` 0 on the exact form rather than leaving it
|
||||
out: a row that serves one wire only says so with a constraint on `wire`, and a constraint on an
|
||||
absent key does not hold.
|
||||
|
||||
`ar_gather_hc_write` is `moe_gather` followed by `ar_hc_write`: the gather's output IS the
|
||||
message, so `y` is written by the gather half before it is reduced in place, and the five gather
|
||||
@@ -785,7 +789,7 @@ form exists, as for `ar_hc_write`.
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `embed_lookup` | `M`(range) `n_embd` `n_vocab` `dtype` `vocab_offset`/opt `wscale`:f64/opt | `tokens`, `wte`w → `x` |
|
||||
| `embed_lookup_q` | `M`(range) `n_embd` `n_vocab` `dtype` `vocab_offset`/opt `wscale`:f64/opt `resident`/opt | `tokens`, `wte`w, `scale`w? → `x`, `ahead`? |
|
||||
| `embed_lookup_q` | `M`(range) `n_embd` `n_vocab` `dtype` `vocab_offset`/opt `wscale`:f64/opt | `tokens`, `wte`w, `scale`w? → `x`, `ahead`? |
|
||||
| `logits_gemm` | `M`(range) `n_vocab` `n_embd` `dtype` | `x`, `lm_head`w → `logits` |
|
||||
| `ngram_ids` | `M`(range) `heads` `ngram` `eos` | `tok`, `state`:inout, `cu`, `mult`w, `vocab_sizes`w, `offsets`w, `cache_idx`?, `has_init`?, `num_accepted`? → `ids`, `ahead_ids`? |
|
||||
| `ple_gate` | `M`(range) `n` `hc` `eps`:f64 `dtype` `wadd`:f64/opt `gate_eps`:f64/opt | `k`, `q`, `v`, `w_key`w, `w_query`w, `w_conv`w → `gv`, `gvn` |
|
||||
@@ -893,12 +897,6 @@ the alignment the filesystem reports for direct I/O, or its block size where it
|
||||
btrfs does; one read of the table proves it before the first row is served. A filesystem with no
|
||||
direct I/O at all cannot hold a container with this table.
|
||||
|
||||
**`resident` keeps the table in RAM instead**, for a deployment that has the memory: libavx copies
|
||||
it once into locked huge pages, in the background from the first gather that carries it, and reads
|
||||
the copy from then on; until the copy is in place, and wherever the process cannot lock that much,
|
||||
the rows come from the file as above. The result is the same either way. An architecture sets it
|
||||
from `RadBuildCtx::ngram_table_ram` (`--ngram-table ram`).
|
||||
|
||||
The placement planner runs an op on the host when **every weight operand of it** is `Site::Host`,
|
||||
which is why the table must be a weight operand at all: `gather_rows` takes a plain `IN` operand and
|
||||
would never trigger it. And the host kernel has to live in a production plugin — libavx, the host
|
||||
|
||||
Reference in new issue
Block a user