Archived
radiance 1.0.11
- 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.
This commit is contained in:
1 parent
e466fa07e2
commit
469441d90f
24 files changed
+848
-247
No files matched your search
+5
-4
@@ -88,10 +88,11 @@ 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.
|
||||
- **`--ulimit memlock=-1`**: where no device kernel gathers the n-gram table (a run on the host
|
||||
backend), `--ngram-placement ram` locks a copy of it in RAM -- 47.7 GiB for
|
||||
Qwen3.8-Flash-Next, far past Docker's default memlock limit -- and without the limit raised
|
||||
`auto` reads it from the container and `ram` refuses the start. On the cards the copy is pinned
|
||||
memory the cards read, which the limit does not count. `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.
|
||||
|
||||
|
||||
+16
-12
@@ -469,7 +469,7 @@ Related flags:
|
||||
--kv-cache-dtype fp8 # halve what a token of context costs (a real quantisation)
|
||||
--host-pool-mib 8192 # pinned host tier for weights
|
||||
--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)
|
||||
--ngram-placement ram # an n-gram table in RAM instead of read from disk (below)
|
||||
--weights-disk-tier # stream what fits neither from the container; needs O_DIRECT
|
||||
```
|
||||
|
||||
@@ -479,7 +479,7 @@ 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 |
|
||||
| `--ngram-placement` | on the card, every card holding all of it | a copy in RAM made at load, read by the card over the link | 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
|
||||
@@ -499,15 +499,19 @@ writes activations the card reads, and a host kernel reading the container canno
|
||||
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.
|
||||
**An n-gram table** (Qwen3.8-Flash-Next's is 47.7 GiB) is read a few rows a token, which is why it
|
||||
can live off the card at all. `disk` reads its rows from the container through a row cache and
|
||||
direct reads on the host; about half of a step's rows are first-seen, so steps wait on the drive.
|
||||
`ram` copies the whole table into host memory at load -- 12 to 40 s more startup, depending on the
|
||||
page cache -- and every gather reads memory: the card's own gather kernel reads a pinned copy over
|
||||
the link, so a step has no host work in it at all. `vram` puts it on the card, every card holding
|
||||
all of it, which needs a card that large. `ram` needs the table's size in memory after the pinned
|
||||
host pools and the prefix cache's host tier, with 4 GiB to spare, and room under every memory cgroup
|
||||
the process sits in; it refuses the start short of either and names which. `auto` takes the first
|
||||
of `vram`, `ram` and `disk` that holds the table. Without a device kernel for the gather (a build
|
||||
with no libr4d), the table is read on the host: `vram` is refused, and `ram` is a copy in locked
|
||||
huge pages, which also needs a memlock limit that large (`--ulimit memlock=-1` in Docker,
|
||||
`LimitMEMLOCK=infinity` under systemd).
|
||||
|
||||
**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
|
||||
@@ -893,7 +897,7 @@ one line naming each one the command line moved.
|
||||
| `--kv-cache-dtype T` | bf16 | `bf16` or `fp8` |
|
||||
| `--host-pool-mib N` | 0 | pinned host tier (weights) |
|
||||
| `--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 |
|
||||
| `--ngram-placement WHERE` | auto | `auto`, `vram`, `ram` or `disk`: an n-gram table on the card, as a copy in RAM made at load and read by the card, or read from the container. 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 |
|
||||
|
||||
**Idle session tiers**
|
||||
|
||||
+37
-18
@@ -868,11 +868,12 @@ holds only where the rank holds the WHOLE vocabulary -- `world_size` 1, not mere
|
||||
on most steps, so a check keyed on the offset alone refuses correct calls. Bounding ids is the
|
||||
caller's, and the tokeniser and the sampler both already are.
|
||||
|
||||
### `embed_lookup_q`, the host gather
|
||||
### `embed_lookup_q`, the n-gram gather
|
||||
|
||||
**A gather from a table quantised with ONE scale for all of it**: `x[m] = wte[id] * scale[0]`.
|
||||
Padding and bounds behave exactly as `embed_lookup`'s — a negative id writes a zero row, an id past
|
||||
the table fails the launch.
|
||||
the table fails the launch in the host kernels and writes a zero row in the device one, which
|
||||
cannot read its ids before it runs (libr4d's divergence note).
|
||||
|
||||
**Why one scale is enough**, measured on the bf16 original: E4M3 carries its own exponent, a row's
|
||||
dynamic range in this table is only 2.3×, and the scale sits on a **three-octave plateau** where
|
||||
@@ -886,21 +887,38 @@ different kernels. It is `gemm_nt_q`'s argument against being a `dtype` on `gemm
|
||||
scale to `embed_lookup` as an optional operand would also have moved `x` from slot 2 to slot 3 for
|
||||
every caller in the tree.
|
||||
|
||||
**It runs on the HOST, served by libavx; no device library has a row for it.** The table it
|
||||
gathers from is 51.2 GB and cannot go anywhere else: staging a whole movement unit to use 5 KB is
|
||||
the wrong shape, pinning it for zero-copy needs all 51.2 GB pinned in host RAM, and
|
||||
`hipHostRegister` on the container's mapping would force all of it resident. The container is
|
||||
mmapped, so the table is at a host address on open. libavx keeps the rows a gather
|
||||
has touched in a row cache of its own and reads a miss straight from the file with O_DIRECT
|
||||
(`libavx/avx_ngram.cpp`): the page cache would map a 4 KiB page per 160-byte row. The reads keep
|
||||
the alignment the filesystem reports for direct I/O, or its block size where it reports none, as
|
||||
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.
|
||||
**Where it runs is where `--ngram-placement` puts the table**, because the planner runs an op on
|
||||
the host when **every weight operand of it** is `Site::Host` and takes that from the table's
|
||||
placement. The table is 51.2 GB and is never staged a unit at a time — moving a whole unit to use
|
||||
5 KB is the wrong shape — so it is read where it lies:
|
||||
|
||||
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
|
||||
kernel library — because `rad_gate_reference_kernels` refuses to serve on libref by design.
|
||||
| placement | the table | the gather |
|
||||
|---|---|---|
|
||||
| `disk` | the container's mapping | libavx's host kernel |
|
||||
| `ram`, libr4d loaded | a pinned copy every card maps at its host address | libr4d's device kernel, over the link |
|
||||
| `ram`, no device kernel | a locked copy (`core/format/table_copy.h`) | libavx's host kernel |
|
||||
| `vram` | the card, every rank holding all of it | libr4d's device kernel |
|
||||
|
||||
`hipHostRegister` on the container's mapping is not one of them: it would force all of the file
|
||||
resident.
|
||||
|
||||
**The host gather keeps its own row cache.** The container is mmapped, so the table is at a host
|
||||
address on open. libavx keeps the rows a gather has touched in a row cache of its own and reads a
|
||||
miss straight from the file with O_DIRECT (`libavx/avx_ngram.cpp`): the page cache would map a
|
||||
4 KiB page per 160-byte row. The reads keep the alignment the filesystem reports for direct I/O, or
|
||||
its block size where it reports none, as 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
|
||||
on `disk`.
|
||||
|
||||
**The device gather is libr4d's `embed_lookup_q_bf16`**: four entries a thread, each E4M3 code
|
||||
decoded exactly, multiplied by the scale in f32 and rounded to nearest even — the value libavx's
|
||||
lookup table holds, to the bit. It reads the ids and writes `e` in the host arena, where the
|
||||
architecture declares them for the host gather, so the step has no host op left in it.
|
||||
|
||||
The table has to be a weight operand at all for the host site to be reachable: `gather_rows` takes
|
||||
a plain `IN` operand and would never be placed there. And the host kernel has to live in a
|
||||
production plugin — libavx, the host kernel library — because `rad_gate_reference_kernels`
|
||||
refuses to serve on libref by design.
|
||||
|
||||
### `ngram_ids`, and the gather that is not an op
|
||||
|
||||
@@ -937,8 +955,9 @@ derives the read cursor for it.
|
||||
operand of it is `Site::Host`, and `gather_rows` takes a plain `IN` operand.
|
||||
|
||||
**`ahead_ids` and `ahead`: the next chunk's rows, a step early.** A prefill chunk gathers `heads`
|
||||
rows a token and, on text the row cache has not seen, most of them are random reads of the
|
||||
container file — ~30 ms a 2048-token chunk on an NVMe, with the card idle behind the host-site op.
|
||||
rows a token and, with the table on `disk` and text the row cache has not seen, most of them are
|
||||
random reads of the container file — ~30 ms a 2048-token chunk on an NVMe, with the card idle behind
|
||||
the host-site op.
|
||||
The next chunk of the prompt is already known (`RadBatch::n_ahead`, which stores it in `token_ids`
|
||||
after the step's own tokens), so:
|
||||
|
||||
|
||||
Reference in new issue
Block a user