Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
+34
-34
@@ -1,54 +1,54 @@
|
||||
# scripts/
|
||||
|
||||
Shell harnesses that drive a **running** engine: bring a model up, measure it, and assert on what
|
||||
comes back over the wire. They are versioned with the engine because a measurement is only
|
||||
reproducible if the thing that took it is, and because what each one encodes is an argument — why
|
||||
a window is sampled the way it is, which counter is the honest one — that is expensive to
|
||||
reconstruct from the number alone.
|
||||
Harnesses that drive a running engine: bring a model up, measure it, and assert on what comes back
|
||||
over the wire. They are versioned with the engine so measurements stay reproducible, and each
|
||||
header records its method (why a window is sampled the way it is, which counter to trust), which is
|
||||
hard to reconstruct from the number alone.
|
||||
|
||||
The scripts that start a server or a conversion expect the build at
|
||||
`$HOME/workspace/radiance/build` and the containers under `$HOME/models/rad/`; every default is
|
||||
an environment override (`M=` for the container, `P=` for the port, and so on — each script's
|
||||
header lists its own). The ones that only attach to a live server need nothing but `curl` and
|
||||
`jq`. Scripts resolve each other by `$(dirname "$0")`.
|
||||
Scripts that start a server or a conversion run the build at `$BUILD`, by default `build/` in the
|
||||
checkout the script is in, and default to containers under `$HOME/models/rad/` and checkpoints under
|
||||
`$HOME/models/<org>/<name>`. A script that starts a server first stops any `radiance` already
|
||||
running (`oracle.sh` only the one on its own port) and logs to `$HOME/<script>.log`. Most defaults
|
||||
are environment overrides (`M=` for the container, `P=` for the port, and so on); each script's
|
||||
header lists its own. Scripts that only attach to a live server need `curl` and `jq`; `cardclock.py`
|
||||
needs `python3`. Scripts find each other through `$(dirname "$0")`.
|
||||
|
||||
## Bringing a model up
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `mcserve.sh` | MiniCPM5-2B with its DSpark drafter (`minicpm5-2b-dspark.v2.rad`), left running on :8100. Records why `--max-model-len` is the container's `n_ctx_train` and why a dense model of this size needs no explicit VRAM split. |
|
||||
| `fnserve.sh` | Qwen3.8-Flash-Next, the production container `w4nl64-i8lm.rad`, same contract. Records the production flags and why: the 200K context and how the expert/cache split sizes the prefix cache at it, the 2048-token chunk, the prefix-cache tiers and the lossy `wht6` cross-rank wire. |
|
||||
| `fnstop.sh` | Stops whichever is running and waits for the process to go. |
|
||||
| `convdspark.sh` | Rebuilds the container `mcserve.sh` serves, with the drafter merged. The conversion of record. |
|
||||
| `convfn.sh` | Rebuilds the container `fnserve.sh` serves from `data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe`. Needs `CALIB=<dir>`: the recipe's expert rule runs GPTQ against the calibration Grams there (`docs/MOE-W4.md`). |
|
||||
| `hfget.sh` | Fetches a checkpoint from Hugging Face with `curl` and `jq`. Resumable, and it leaves behind the duplicate weight formats a large repo often carries beside its safetensors. |
|
||||
| `mcserve.sh` | MiniCPM5-2B with its DSpark drafter (`minicpm5-2b-dspark.v2.rad`), left running on :8100. Records why `--max-model-len` is the checkpoint's `n_ctx_train` (131072) and what a token of KV costs. |
|
||||
| `fnserve.sh` | Qwen3.8-Flash-Next, the production container `w4nl64-i8lm.rad`, left running on :8100. Records the production flags and their reasons: the 200K context and how the expert/cache split sizes the pool for it, the 2048-token chunk, the host prefix-cache tier and the lossy `wht6` cross-rank wire. |
|
||||
| `fnstop.sh` | Stops whichever server is running and waits for the process to exit. |
|
||||
| `convdspark.sh` | Rebuilds the container `mcserve.sh` serves, with the drafter merged, as `minicpm5-2b-dspark.new.rad` beside it. The checkpoint and drafter paths are fixed; `RECIPE=` overrides the recipe. |
|
||||
| `convfn.sh` | Rebuilds the container `fnserve.sh` serves, as `w4nl64-i8lm.new.rad` beside it, from `data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe`. Needs `CALIB=<dir>`: the recipe's expert rule runs GPTQ against the calibration Grams there (`docs/MOE-W4.md`). |
|
||||
| `hfget.sh` | Fetches a Hugging Face repo with `curl` and `jq`. Resumable, and skips the duplicate weight formats a repo often carries beside its safetensors. `radiance --model <repo id>` runs it. |
|
||||
|
||||
## Measuring
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `cstep2.sh` | Steady-state decode ms/step at a given concurrency, against a live server. Waits until exactly C sequences are running before sampling and re-checks at the end: a window whose edges carry fewer than C describes no concurrency at all. Model-agnostic (`P=` picks the port). |
|
||||
| `dprofd.sh` | Per-op device timing (`--profile-ops`) at depth and concurrency, on the 27B dense model with its DFlash2 drafter (`q38-27b-fp8-df2.v2.rad`). The counters are cumulative and a run starts with prefill, so a single dump is a mixture of two populations — difference two dumps taken after prefill has ended. |
|
||||
| `fnpf.sh` | Prefill throughput of whatever server is on `$P`, over the repository's own prose, with a fresh nonce a rep so the prefix cache cannot make a rep free. Prints card temperature and clock beside every rep. |
|
||||
| `fnconc.sh` | What a long prefill costs the decoders running beside it, and the prefill's own time, on one clock: alone, then contended, with a warm pass discarded. |
|
||||
| `fntrace.sh` | A Flash-Next prefill under `rocprofv3`, with the link counters from `/stats` across the same request, so the streamed-read rate of the MoE GEMM can be computed. |
|
||||
| `mctrace.sh` | A MiniCPM5-2B decode trace under `rocprofv3`, formatted for `libr4d/isa/tsum.sh`. The `blocks` column is what the trace is for. |
|
||||
| `ident.sh` | Run-to-run reproducibility at a fixed configuration: one hash per (temperature, question), to compare against another run of the same configuration. A speculative run is not expected to match a non-speculative one byte for byte — the split-K count is chosen from M, so the two take different reduction orders and can flip a near-tie late in a long answer — but a divergence within the first sentence or two is a defect. |
|
||||
| `cardclock.py` | What holds each card's clock under a sustained load, and which card a tensor-parallel step waits for. The step ends when its slowest rank finishes, and under a sustained load the firmware picks that rank's clock: the power limit, a temperature or current limit, or the top of its voltage/frequency curve. Reads every AMD card's `gpu_metrics` table ten times a second and counts a throttler bit only when the clock is lower while it is set (some firmware keeps a bit on at idle). The engine's own step counters sit beside it per window, so a slow window is told apart first: slower steps, fewer tokens per step (the text), or host time between steps. Drives its own greedy load, or with `--watch` only samples a server that real traffic is driving. `--compare` puts two saved runs side by side. Read-only on the cards. |
|
||||
| `oracle.sh` | Every op compared against libref on the operands the model actually issued, which is the gap rad-kbench cannot close: its operands are its own, dense and rank-2, and an engine's are slices of arenas and weights off a file. Reads for two things — a MISMATCH, and the NOT CHECKED lines that name the rows whose weight layout has no published inverse and therefore cannot be compared at all. |
|
||||
| `cstep2.sh` | Steady-state decode ms/step at each concurrency, against a live server. Waits until exactly C sequences are running before sampling and re-checks at the end, since a window with fewer than C at either edge measures no single concurrency. Model-agnostic (`P=` picks the port). |
|
||||
| `dprofd.sh` | Per-op device timing (`--profile-ops`) at depth and concurrency on the 27B dense model with its DFlash2 drafter (`qwen3.8-27b-fp8.rad`); starts its own server on :8129 and needs a ~16K-token prompt (`PROMPT=<file>`). The counters are cumulative and a run starts with prefill, so one dump mixes prefill and decode; difference two dumps taken after prefill has ended. |
|
||||
| `fnpf.sh` | Prefill throughput of the server on `$P`, over the repository's own markdown, with a fresh nonce per rep so the prefix cache cannot serve it. Prints card temperature and clock beside every rep. |
|
||||
| `fnconc.sh` | What a long prefill costs the decoders running beside it, and the prefill's own time, measured together: alone, then contended, with a warm pass discarded. |
|
||||
| `fntrace.sh` | A Flash-Next prefill under `rocprofv3`, on its own server, with the `/stats` link counters across the same request, giving the MoE GEMM's streamed-read rate. |
|
||||
| `mctrace.sh` | A MiniCPM5-2B decode trace under `rocprofv3`, on its own server, formatted for `libr4d/isa/tsum.sh`, mainly for its `blocks` column. |
|
||||
| `ident.sh` | Run-to-run reproducibility at a fixed configuration: one hash per (temperature, question), to compare against another run of the same configuration. A speculative run need not match a non-speculative one byte for byte (the split-K count is chosen from M, so reduction orders differ and a near-tie can flip late in a long answer), but a divergence within the first sentence or two is a defect. |
|
||||
| `cardclock.py` | What holds each card's clock under sustained load, and which card a tensor-parallel step waits for (the slowest rank ends the step). Reads every AMD card's `gpu_metrics` table ten times a second and counts a throttler bit only when the clock is lower while it is set (some firmware keeps a bit on at idle). Shows the engine's step counters per window, so a slow window is attributed to slower steps, fewer tokens per step or host time between steps. Drives its own greedy load, or with `--watch` only samples a server under real traffic; `--compare` shows two saved runs side by side. Read-only on the cards. |
|
||||
| `oracle.sh` | Every op compared against libref on the operands the model issued, which rad-kbench cannot do: its operands are its own (dense, rank 2), while the engine's are arena slices and weights loaded from a file. Starts its own server on :8302. Read it for `MISMATCH` lines, and for `NOT CHECKED` lines naming rows whose weight layout has no published inverse and so cannot be compared. |
|
||||
|
||||
## Regression checks against a live server
|
||||
|
||||
These cover what `tests/chat_test.cpp` structurally cannot: the server, the wire format, and a
|
||||
real model's output.
|
||||
These cover what `tests/chat_test.cpp` cannot: the server, the wire format, and a real model's
|
||||
output. `mcagent.sh` and `mcdecl.sh` start their own MiniCPM5-2B server through `mcserve.sh`.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `apikeys.sh` | Every request key on the lists in `core/server/oai.cpp`: a rejected key must be refused by name, an inert one accepted and ignored, an accepted one honoured — and a key the deployment cannot satisfy (`logprobs`, `grammar` on chat) refused rather than answered without it. |
|
||||
| `fndrop.sh` | Clients that disconnect mid-request, at points derived from a timed full request: the server must stay up and keep answering a reference question identically. |
|
||||
| `tierident.sh` | Whether a session that left VRAM comes back byte for byte, both halves of it. The VRAM repeat is the control: without it a differing hash proves nothing, because a cache hit could have been tie-divergent. A run where nothing moved is a failure, not a pass. On a hybrid model the linear-state checks are COUNTERS and not hashes — a lost snapshot is invisible in the text, because the engine replays from further back and produces the same answer. |
|
||||
| `tiercross.sh` | The same question with TWO sessions in flight, which is the only way to see one being served the other's context or state — with a single conversation in the server there is no other conversation's bytes to be served. Compares each restore against that session's DEVICE-HIT run rather than its cold one, because a hybrid session's reuse is clamped to the last reachable checkpoint and a cold run reuses nothing by definition. |
|
||||
| `mctools.sh` | The tool-call shapes that are hardest to parse — an array argument, two calls in one reply, prose before a call, plain chat with tools available. Asserts `finish_reason` and that no `<function`/`<param`/CDATA marker reaches content. |
|
||||
| `mcstream.sh` | Tool-call replies **streamed**, asserting on raw SSE fragments rather than on the assembled message. Content cannot be retracted once sent, so a repair applied at the end is not a fix; this is the check that sees the difference. |
|
||||
| `mcagent.sh` | What speculation is worth on an agentic workload — `/v1/chat/completions` with tools, which is a constrained decode. Speculation on and off alternate across restarts because the speculation depth is a server-level setting. |
|
||||
| `mcdecl.sh` | How often the drafter actually proposes. `draft_acceptance_ratio` is conditional on having drafted, so it reads healthy while tokens-per-step collapses; blocks-per-step is the quantity that separates the two. |
|
||||
| `tierident.sh` | Whether a session that left VRAM comes back byte for byte, attention blocks and recurrent state both. The repeat from VRAM is the control: without it a differing hash proves nothing, since a cache hit could be tie-divergent. A run where nothing moved is a failure. On a hybrid model the linear-state checks are counters, not hashes: a lost snapshot does not show in the text, because the engine replays from further back and produces the same answer. Needs a server started with `--prefix-cache-mib 512`. |
|
||||
| `tiercross.sh` | The same check with two sessions in flight, the only way to catch one being served the other's context or state. Compares each restore against that session's device-hit run rather than its cold one, because a hybrid session's reuse is clamped to the last reachable checkpoint and a cold run reuses nothing. |
|
||||
| `mctools.sh` | The tool-call shapes hardest to parse: an array argument, two calls in one reply, prose before a call, plain chat with tools available. Asserts `finish_reason` and that no `<function`/`<param`/CDATA marker reaches content. |
|
||||
| `mcstream.sh` | Tool-call replies streamed, asserting on raw SSE fragments rather than the assembled message. Streamed content cannot be retracted, so a repair applied at the end is not a fix. |
|
||||
| `mcagent.sh` | What speculation is worth on an agentic workload: `/v1/chat/completions` with tools, a constrained decode. Speculation on and off alternate across restarts because the speculation depth is a server-level setting. |
|
||||
| `mcdecl.sh` | How often the drafter proposes, by context length. `draft_acceptance_ratio` is conditional on having drafted, so it can look healthy while tokens per step collapse; blocks per step separates the two. |
|
||||
@@ -1,153 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Does this server actually do what it says about request keys, against one that is ALREADY UP?
|
||||
#
|
||||
# The rule the whole API rests on is that A REQUEST THAT RETURNS 200 MEANS EVERY FIELD OF IT WAS
|
||||
# HONOURED: a parameter this engine does not implement is REFUSED, not quietly dropped. That rule
|
||||
# is only worth anything if it is true of every key on the list, and the list lives in
|
||||
# core/server/oai.cpp in three parts -- accepted, inert, rejected-with-a-reason. This checks the
|
||||
# running server against it.
|
||||
#
|
||||
# THE TWO FAILURES THAT MATTER POINT IN OPPOSITE DIRECTIONS:
|
||||
#
|
||||
# a REJECTED key that returns 200 is the rule broken -- the caller asked for a sampler the
|
||||
# device does not have and got a plausible answer computed without it;
|
||||
#
|
||||
# an INERT key that returns 400 breaks the official SDKs, which send `user`, `store` and
|
||||
# friends unprompted and cannot be told not to.
|
||||
#
|
||||
# A rejected key is refused on its NAME, so the value it carries does not matter and every case
|
||||
# below sends 1. An accepted key is not checked here: it would need a valid value per key, and a
|
||||
# 400 would then be ambiguous between "refused the key" and "disliked the value".
|
||||
#
|
||||
# P=8100 scripts/apikeys.sh
|
||||
P="${P:-8100}"
|
||||
H="${H:-127.0.0.1}"
|
||||
U="http://$H:$P"
|
||||
pass=0; fail=0
|
||||
|
||||
# code and blamed parameter for a chat request carrying one extra key
|
||||
probe() { # $1 = key, $2 = json value
|
||||
jq -n --arg k "$1" --argjson v "$2" \
|
||||
'{messages:[{role:"user",content:"hi"}],max_tokens:4,temperature:0} + {($k): $v}' \
|
||||
> "$WORK/q.json"
|
||||
code=$(curl -s -o "$WORK/r.json" -w '%{http_code}' -m 120 -X POST "$U/v1/chat/completions" \
|
||||
-H 'Content-Type: application/json' --data @"$WORK/q.json")
|
||||
param=$(jq -r '.error.param // ""' < "$WORK/r.json" 2>/dev/null)
|
||||
printf '%s %s' "$code" "$param"
|
||||
}
|
||||
|
||||
want_refused() { # $1 = key
|
||||
set -- "$1" $(probe "$1" 1)
|
||||
if [ "$2" = "400" ] && [ "$3" = "$1" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
fail=$((fail + 1)); printf ' FAIL %-24s expected 400 naming it, got %s %s\n' "$1" "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
want_accepted() { # $1 = key, $2 = json value
|
||||
set -- "$1" $(probe "$1" "$2")
|
||||
if [ "$2" = "200" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
fail=$((fail + 1)); printf ' FAIL %-24s expected 200, got %s (param %s)\n' "$1" "$2" "$3"
|
||||
fi
|
||||
}
|
||||
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/apikeys.XXXXXX"); trap 'rm -rf "$WORK"' EXIT INT TERM
|
||||
echo "checking $U against the key lists in core/server/oai.cpp"
|
||||
|
||||
echo " rejected keys must be refused, by name:"
|
||||
for k in logit_bias functions function_call best_of suffix \
|
||||
mirostat mirostat_tau mirostat_eta top_n_sigma \
|
||||
dynatemp_range dynatemp_exponent lora modalities audio prediction \
|
||||
continue_final_message cache_prompt; do
|
||||
want_refused "$k"
|
||||
done
|
||||
|
||||
echo " inert keys must be accepted and ignored:"
|
||||
for k in user metadata store service_tier safety_identifier prompt_cache_key; do
|
||||
want_accepted "$k" '"x"'
|
||||
done
|
||||
|
||||
# AN ACCEPTED KEY NEEDS A VALID VALUE, or a 400 is ambiguous between "refused the key" and
|
||||
# "disliked the value" -- so each of these carries one the schema actually allows, and the ones
|
||||
# that only make sense together are sent together.
|
||||
merge() { # $1 = label, $2 = json object to merge into a minimal chat request
|
||||
jq -n --argjson o "$2" \
|
||||
'{messages:[{role:"user",content:"hi"}],max_tokens:4,temperature:0} + $o' > "$WORK/q.json"
|
||||
code=$(curl -s -o "$WORK/r.json" -w '%{http_code}' -m 120 -X POST "$U/v1/chat/completions" \
|
||||
-H 'Content-Type: application/json' --data @"$WORK/q.json")
|
||||
if [ "$code" = "200" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
fail=$((fail + 1))
|
||||
printf ' FAIL %-24s expected 200, got %s: %s\n' "$1" "$code" \
|
||||
"$(jq -r '.error.message // ""' < "$WORK/r.json" | head -c 90)"
|
||||
fi
|
||||
}
|
||||
|
||||
echo " accepted keys must be honoured, not refused:"
|
||||
merge model '{"model":"m"}'
|
||||
merge n '{"n":1}'
|
||||
merge seed '{"seed":1}'
|
||||
merge stop '{"stop":["\n\n"]}'
|
||||
merge temperature '{"temperature":0.7}'
|
||||
merge top_p '{"top_p":0.9}'
|
||||
merge top_k '{"top_k":20}'
|
||||
merge min_p '{"min_p":0.05}'
|
||||
merge typical_p '{"typical_p":0.95}'
|
||||
merge presence_penalty '{"presence_penalty":0.1}'
|
||||
merge frequency_penalty '{"frequency_penalty":0.1}'
|
||||
merge repetition_penalty '{"repetition_penalty":1.05}'
|
||||
merge repeat_last_n '{"repeat_last_n":64}'
|
||||
merge xtc '{"xtc_probability":0.1,"xtc_threshold":0.15}'
|
||||
merge dry '{"dry_multiplier":0.5,"dry_base":1.75,"dry_allowed_length":2,"dry_penalty_last_n":64,"dry_sequence_breakers":["\n"]}'
|
||||
merge priority '{"priority":0}'
|
||||
merge ignore_eos '{"ignore_eos":false}'
|
||||
|
||||
merge response_format '{"response_format":{"type":"text"}}'
|
||||
merge tools '{"tools":[{"type":"function","function":{"name":"f","description":"d","parameters":{"type":"object","properties":{}}}}],"tool_choice":"auto","parallel_tool_calls":true}'
|
||||
merge add_generation_prompt '{"add_generation_prompt":true}'
|
||||
merge max_completion_tokens '{"max_completion_tokens":4}'
|
||||
merge chat_template_kwargs '{"chat_template_kwargs":{"enable_thinking":false}}'
|
||||
merge reasoning_effort '{"reasoning_effort":"low"}'
|
||||
merge enable_thinking '{"enable_thinking":false}'
|
||||
merge stream '{"stream":true,"stream_options":{"include_usage":true}}'
|
||||
|
||||
# AND TWO ACCEPTED KEYS ARE REFUSED BY CAPABILITY RATHER THAN BY VETTING, which is the rule
|
||||
# working and not a hole in it: being on the accepted list means the engine UNDERSTANDS the key,
|
||||
# not that every deployment can satisfy it. What matters is that it refuses instead of answering
|
||||
# unconstrained, so what is asserted here is the refusal, with the key named.
|
||||
#
|
||||
# logprobs -- `supports_logprobs` is initialised false and set true nowhere in the tree, so this
|
||||
# engine never returns per-token probabilities. /server_info reports `logprobs: false`, which is
|
||||
# where a client should look before asking.
|
||||
#
|
||||
# grammar and response_format ON CHAT -- both pass through the chat template, which may rewrite
|
||||
# or drop them. A template that returns no grammar for a request that asked for one leaves the
|
||||
# caller parsing free prose against a schema they were told was enforced, so it is a refusal.
|
||||
# On /v1/completions there is no template in the way and the same grammar works.
|
||||
want_capability_refusal() { # $1 = label, $2 = object, $3 = key that must be blamed
|
||||
jq -n --argjson o "$2" \
|
||||
'{messages:[{role:"user",content:"hi"}],max_tokens:4,temperature:0} + $o' > "$WORK/q.json"
|
||||
code=$(curl -s -o "$WORK/r.json" -w '%{http_code}' -m 120 -X POST "$U/v1/chat/completions" \
|
||||
-H 'Content-Type: application/json' --data @"$WORK/q.json")
|
||||
param=$(jq -r '.error.param // ""' < "$WORK/r.json" 2>/dev/null)
|
||||
if [ "$code" != "200" ] && [ "$param" = "$3" ]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
fail=$((fail + 1))
|
||||
printf ' FAIL %-24s expected a refusal naming %s, got %s %s\n' "$1" "$3" "$code" "$param"
|
||||
fi
|
||||
}
|
||||
|
||||
echo " and two accepted keys this deployment cannot satisfy must REFUSE, not answer anyway:"
|
||||
want_capability_refusal logprobs '{"logprobs":true,"top_logprobs":1}' logprobs
|
||||
want_capability_refusal "grammar (chat)" '{"grammar":"root ::= \"ok\""}' grammar
|
||||
|
||||
echo " and a key on no list at all must be refused, naming it:"
|
||||
want_refused "no_such_parameter_at_all"
|
||||
|
||||
printf '\n %d passed, %d failed\n' "$pass" "$fail"
|
||||
[ "$fail" -eq 0 ] || exit 1
|
||||
+27
-32
@@ -1,43 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# cardclock.py -- what holds each card's clock under a sustained load, and which card sets the step.
|
||||
#
|
||||
# A tensor-parallel step ends when its slowest rank finishes: every rank waits for the others in the
|
||||
# all-reduce. So the clock that decides decode speed is the LOWEST of the cards', and on a
|
||||
# workstation card under a sustained load the firmware -- not the engine -- picks that clock: the
|
||||
# power limit (PPT), a temperature limit, a current limit. The same image then reads several percent
|
||||
# apart from one boot to the next, depending on which card heats first and how hard its power limit
|
||||
# bites. This puts a number on that:
|
||||
# A tensor-parallel step ends when the slowest rank finishes the all-reduce, so decode speed follows
|
||||
# the lowest card clock. Under sustained load the firmware picks that clock (power limit PPT,
|
||||
# temperature or current limits), so the same image can differ by several percent between boots
|
||||
# depending on which card heats first. This script:
|
||||
#
|
||||
# * drives a sustained greedy load at --conc against a live server (or, with --watch, only samples
|
||||
# while something else drives it -- real traffic on a deployment), and reports tok/s per --window
|
||||
# seconds;
|
||||
# * beside it, the engine's own step counters per window (/metrics): step ms, tokens per decode step,
|
||||
# draft acceptance, busy share and host gap per step -- so a slow window is attributed to slower
|
||||
# steps, to the text (fewer tokens a step), or to the host, before anyone blames a clock. The
|
||||
# engine's tok/s counts every request the server ran in the window, the load's only this script's:
|
||||
# a gap between the two is someone else's traffic;
|
||||
# while other traffic drives it) and reports tok/s per --window seconds;
|
||||
# * reports the engine's step counters per window from /metrics (step ms, tokens per decode step,
|
||||
# draft acceptance, busy share, host gap per step), so a slow window is attributed to slower
|
||||
# steps, the text (fewer tokens per step) or the host. The engine's tok/s counts every request
|
||||
# the server ran, the load's only this script's; a difference is other traffic;
|
||||
# * reads every AMD card's SMU metrics table (/sys/class/drm/card*/device/gpu_metrics) ten times a
|
||||
# second: clocks, temperatures (edge, hotspot, memory, the GFX/SOC/MEM voltage regulators), power,
|
||||
# fan, and the throttler bits the firmware itself sets -- READ-ONLY, no root needed;
|
||||
# * names the card the step waits for and what holds it, and the setting that addresses that;
|
||||
# * --json saves a run; --compare puts two of them side by side (before / after a setting change).
|
||||
# second: clocks, temperatures (edge, hotspot, memory, GFX/SOC/MEM voltage regulators), power,
|
||||
# fan and the firmware's throttler bits. Read-only, no root needed;
|
||||
# * names the card the step waits for, what holds it, and the setting that addresses it;
|
||||
# * --json saves a run; --compare shows two runs side by side (before / after a setting change).
|
||||
#
|
||||
# scripts/cardclock.py [--port 8100] [--conc 8] [--seconds 180] [--gen 1024] [--json run.json]
|
||||
# scripts/cardclock.py --watch [--seconds 300] [--json run.json]
|
||||
# scripts/cardclock.py --compare before.json after.json
|
||||
#
|
||||
# Reading the throttler bits: a bit counts only when it is set under load AND the card's clock is
|
||||
# lower while it is set. Some firmware keeps a bit set all the time -- on Radeon AI PRO R9700
|
||||
# (gfx1201) TEMP_HOTSPOT reads set at idle and at 45 C with no effect on the clock -- so a bit that
|
||||
# the idle baseline also shows is listed and ignored.
|
||||
# Throttler bits: a bit counts only when it is set under load and the clock is lower while it is
|
||||
# set. Some firmware keeps a bit set permanently (on the Radeon AI PRO R9700, gfx1201, TEMP_HOTSPOT
|
||||
# is set at idle and at 45 C with no effect on the clock), so a bit the idle baseline also shows is
|
||||
# listed and ignored.
|
||||
#
|
||||
# Changing a setting this points at (power1_cap, fan target, voltage offset) is a write to the SMU:
|
||||
# do it ONLY while no process holds /dev/kfd -- stop the server first. On a gfx1201 box such a write
|
||||
# under load has reset the machine. Check with `sudo find /proc/[0-9]*/fd -lname /dev/kfd`, not
|
||||
# `lsof /dev/kfd`: lsof on the host does not see a containerised server's handle (the container's
|
||||
# /dev/kfd is its own node). None of these settings survive a reboot. Undervolts in
|
||||
# particular must be proven under a SUSTAINED hot load, not a short test: an offset that passes a
|
||||
# minute-long selftest can wedge a card twenty minutes into real traffic once it runs at 90 C.
|
||||
# Changing a suggested setting (power1_cap, fan target, voltage offset) writes to the SMU: do it
|
||||
# only while no process holds /dev/kfd. On gfx1201 such a write under load can reset the machine.
|
||||
# Check with `sudo find /proc/[0-9]*/fd -lname /dev/kfd`; host lsof does not see a containerised
|
||||
# server's handle (the container's /dev/kfd is its own node). None of these settings survive a
|
||||
# reboot. Prove an undervolt under a sustained hot load: an offset that passes a minute-long
|
||||
# selftest can wedge a card after twenty minutes at 90 C.
|
||||
#
|
||||
# Needs Linux amdgpu with a gpu_metrics v1.3 table (RDNA3 / RDNA4 discrete cards); a card with any
|
||||
# other layout is skipped rather than misread.
|
||||
@@ -108,8 +103,8 @@ def find_cards():
|
||||
if not re.fullmatch(r"card\d+", dev.split("/")[-2]): continue
|
||||
if rd(dev + "/vendor") != "0x1002" or not os.path.exists(dev + "/gpu_metrics"): continue
|
||||
c = Card(dev)
|
||||
# ANOTHER LAYOUT IS ANOTHER KIND OF PART, not a reason to stop: an APU's integrated graphics
|
||||
# beside the discrete cards reports a v2.x table, and the engine does not serve on it.
|
||||
# Skip, do not stop, on another layout: an APU's integrated graphics reports a v2.x table and
|
||||
# the engine does not serve on it.
|
||||
try:
|
||||
size, fr, cr = struct.unpack_from("<HBB", open(dev + "/gpu_metrics", "rb").read(4))
|
||||
if (fr, cr) != (1, 3) or size != 120:
|
||||
@@ -184,8 +179,8 @@ def engine_windows(snaps, t0, t1, w):
|
||||
def load(a, base, model):
|
||||
done, stop, stall = [], threading.Event(), {}
|
||||
def worker(i):
|
||||
# --seed: every run sends the same prompts in the same order per stream (the text drives speculation, so a
|
||||
# run-to-run A/B wants it fixed); without it, a fresh mix each run
|
||||
# --seed fixes each stream's prompt sequence across runs (the text drives speculation, so A/B runs need it
|
||||
# fixed); without it, each run gets a fresh mix
|
||||
rnd = random.Random(i * 7919 + (a.seed if a.seed is not None else int(time.time())))
|
||||
while not stop.is_set():
|
||||
t0 = time.time(); tag, topic = rnd.getrandbits(48), rnd.randrange(len(TOPICS))
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
#!/bin/sh
|
||||
# Rebuild the DSpark container for MiniCPM5-2B that scripts/mcserve.sh serves
|
||||
# (minicpm5-2b-dspark.v2.rad): the bf16 checkpoint with the drafter merged in, every linear made
|
||||
# block fp8 by data/recipes/minicpm5-2b-dspark.recipe, served by arch/llama_dense_fp8. It writes
|
||||
# a .new.rad beside it, because the output is removed before the conversion starts.
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
RECIPE=${RECIPE:-$HOME/workspace/radiance/data/recipes/minicpm5-2b-dspark.recipe}
|
||||
# block fp8 by data/recipes/minicpm5-2b-dspark.recipe, served by arch/llama_dense_fp8. The output
|
||||
# is removed before conversion starts, so it is a .new.rad beside the served container.
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
RECIPE=${RECIPE:-$ROOT/data/recipes/minicpm5-2b-dspark.recipe}
|
||||
SRC=$HOME/models/openbmb/MiniCPM5-2B
|
||||
DRAFT=$HOME/models/openbmb/MiniCPM5-2B-DSpark
|
||||
OUT=$HOME/models/rad/minicpm5-2b-dspark.new.rad
|
||||
[ -d "$DRAFT" ] || { echo "no drafter checkpoint at $DRAFT"; exit 1; }
|
||||
rm -f "$OUT"
|
||||
./bin/rad-convert "$SRC" -o "$OUT" \
|
||||
--home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--home radiance_home \
|
||||
--tokenizer "$SRC/tokenizer.json" \
|
||||
--draft-model "$DRAFT" \
|
||||
--recipe "$RECIPE" \
|
||||
|
||||
+20
-19
@@ -1,31 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Rebuild the Qwen3.8-Flash-Next container `fnserve.sh` serves. THE CONVERSION OF RECORD.
|
||||
# Rebuild the Qwen3.8-Flash-Next container `fnserve.sh` serves; the canonical conversion.
|
||||
#
|
||||
# The recipe is the whole format decision: it names what each weight is quantised to, and the
|
||||
# container records it (rad-info --recipe), so the engine serves the file in the format it was
|
||||
# packed in and nothing else. The default, data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe, builds the
|
||||
# production container w4nl64-i8lm.rad; its header says what each weight becomes and what that
|
||||
# measures.
|
||||
# The recipe names what each weight is quantised to and the container records it (rad-info
|
||||
# --recipe), so the engine serves the file in the format it was packed in. The default,
|
||||
# data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe, builds the production container w4nl64-i8lm.rad;
|
||||
# its header describes each weight's format.
|
||||
#
|
||||
# CALIB=<dir> IS REQUIRED BY THAT RECIPE. Its routed-expert rule runs GPTQ against `calib=$CALIB`,
|
||||
# and the converter refuses a recipe that names an unset variable. The directory holds each
|
||||
# layer's pooled Grams and each expert's own down Gram, recorded from the bf16 model over THIS
|
||||
# checkpoint (docs/MOE-W4.md, "Calibration"): Grams taken from another checkpoint are not
|
||||
# transferable, and a layer with no file is packed without error feedback.
|
||||
# That recipe requires CALIB=<dir>: its routed-expert rule runs GPTQ against `calib=$CALIB`, and
|
||||
# the converter refuses a recipe that names an unset variable. The directory holds each layer's
|
||||
# pooled Grams and each expert's down Gram, recorded from the bf16 model of this checkpoint
|
||||
# (docs/MOE-W4.md, "Calibration"). Grams from another checkpoint do not transfer, and a layer with
|
||||
# no file is packed without error feedback.
|
||||
#
|
||||
# A recipe whose rules do not name $CALIB (RECIPE=data/recipes/qwen4exp-w4.recipe, say) rounds its
|
||||
# experts to nearest with absmax scales; CALIB=<dir> then puts them through int4 GPTQ instead, by
|
||||
# the --quant rule that recipe's header names, which goes ahead of the recipe's own.
|
||||
# A recipe that does not name $CALIB (e.g. RECIPE=data/recipes/qwen4exp-w4.recipe) rounds experts
|
||||
# to nearest with absmax scales; setting CALIB=<dir> then applies int4 GPTQ through the --quant
|
||||
# rule that recipe's header names, which takes precedence over the recipe's own rule.
|
||||
#
|
||||
# OUT is removed before the conversion starts, so its default is a .new.rad beside the served
|
||||
# container rather than the served container itself.
|
||||
# OUT is removed before conversion starts, so it defaults to a .new.rad beside the served
|
||||
# container.
|
||||
#
|
||||
# CALIB=<dir> [SRC=<checkpoint dir>] [OUT=<container>] [RECIPE=<file>] scripts/convfn.sh
|
||||
set -e
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
SRC=${SRC:-$HOME/models/Qwen/Qwen3.8-Flash-Next}
|
||||
OUT=${OUT:-$HOME/models/rad/w4nl64-i8lm.new.rad}
|
||||
RECIPE=${RECIPE:-$HOME/workspace/radiance/data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe}
|
||||
RECIPE=${RECIPE:-$ROOT/data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe}
|
||||
[ -d "$SRC" ] || { echo "no checkpoint at $SRC"; exit 1; }
|
||||
[ -f "$SRC/tokenizer.json" ] || { echo "no tokenizer.json in $SRC"; exit 1; }
|
||||
[ -f "$RECIPE" ] || { echo "no recipe at $RECIPE"; exit 1; }
|
||||
@@ -42,7 +43,7 @@ else
|
||||
fi
|
||||
rm -f "$OUT"
|
||||
./bin/rad-convert "$SRC" -o "$OUT" \
|
||||
--home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--home radiance_home \
|
||||
--tokenizer "$SRC/tokenizer.json" \
|
||||
--recipe "$RECIPE" "$@" \
|
||||
-v 2>&1 | tail -30
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
#!/bin/sh
|
||||
# STEADY-STATE decode step time at concurrency, against a LIVE server (no restart).
|
||||
# Steady-state decode step time at each concurrency, against a running server.
|
||||
#
|
||||
# ignore_eos pins every sequence to the same length so none retires mid-window; we wait until
|
||||
# exactly C are RUNNING, sample the counters across a window in the middle, and re-check the
|
||||
# count at the end -- a window whose edges carry fewer than C sequences reports a step time that
|
||||
# is not any concurrency's. Model-agnostic: P= picks the port.
|
||||
# ignore_eos fixes every sequence's length so none retires mid-window. The script waits until
|
||||
# exactly C are running, samples the counters over a window in the middle and re-checks the count
|
||||
# at the end; a window with fewer than C sequences at either edge measures no single concurrency.
|
||||
# Model-agnostic; P= picks the port.
|
||||
P=${P:-8100}
|
||||
U="http://127.0.0.1:$P"
|
||||
LEVELS="${LEVELS:-1 2 3 4 5 6 8}"
|
||||
|
||||
+13
-13
@@ -1,24 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Per-op device timing (--profile-ops) AT DEPTH and AT CONCURRENCY, on the 27B dense model with
|
||||
# its DFlash2 drafter: C requests of a ~16K-token prompt (PROMPT=<file>), so every
|
||||
# context-scaling op (attn_paged above all) shows the weight it carries at a real KV depth rather
|
||||
# than at a few dozen tokens.
|
||||
# Per-op device timing (--profile-ops) at depth and concurrency on the 27B dense model with its
|
||||
# DFlash2 drafter: C requests of a ~16K-token prompt (PROMPT=<file>), so context-scaling ops
|
||||
# (above all attn_paged) are timed at a realistic KV depth.
|
||||
#
|
||||
# THE COUNTERS ARE CUMULATIVE AND THE RUN STARTS WITH PREFILL, so a single table is a mixture:
|
||||
# ~30 chunked-prefill steps at 4096 tokens sit under every decode step that follows. This dumps
|
||||
# every EVERY steps (RADIANCE_PROFILE_EVERY) and leaves them all in the log; differencing two dumps
|
||||
# that are both after prefill ended is the only way to get a decode-only table out of it.
|
||||
# The counters are cumulative and the run starts with prefill (~30 chunked steps of 4096 tokens),
|
||||
# so one table mixes prefill and decode. The server dumps every EVERY steps
|
||||
# (RADIANCE_PROFILE_EVERY) into the log; difference two dumps taken after prefill ended to get a
|
||||
# decode-only table.
|
||||
P=8129
|
||||
C="${C:-8}"
|
||||
EVERY="${EVERY:-20}"
|
||||
MT="${MT:-400}"
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
pkill -f "bin/radianc[e]"; while pgrep -f "bin/radianc[e]" >/dev/null; do sleep 1; done; sleep 3
|
||||
: > "$HOME/dprofd.log"
|
||||
[ -n "$KVFP8" ] && export RADIANCE_QWEN35_KV_FP8=1 # read by nothing: the KV width is --kv-cache-dtype
|
||||
GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 RADIANCE_PROFILE_EVERY="$EVERY" \
|
||||
./bin/radiance --model "${M:-$HOME/models/rad/q38-27b-fp8-df2.v2.rad}" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
./bin/radiance --model "${M:-$HOME/models/rad/qwen3.8-27b-fp8.rad}" \
|
||||
--radiance-home radiance_home \
|
||||
--max-num-seqs 8 --max-model-len 24000 --checkpoint-slots 0 --no-prefix-cache \
|
||||
--tp 2 --tp-wire wht6 --tp-wire-min-kb 128 \
|
||||
--max-num-batched-tokens 4096 --num-speculative-tokens ${DEPTH:-auto} \
|
||||
@@ -35,7 +35,7 @@ while [ $i -lt $C ]; do
|
||||
PIDS="$PIDS $!"; i=$((i+1))
|
||||
done
|
||||
wait $PIDS
|
||||
echo "C=$C kvfp8=${KVFP8:-0} completion_tokens $(jq -r '.usage.completion_tokens' /tmp/dpd_0.out)"
|
||||
echo "C=$C completion_tokens $(jq -r '.usage.completion_tokens' /tmp/dpd_0.out)"
|
||||
sleep 2
|
||||
pkill -f "bin/radianc[e]"; while pgrep -f "bin/radianc[e]" >/dev/null; do sleep 1; done
|
||||
grep -c "per-op device timing, rank 0" "$HOME/dprofd.log" | sed 's/^/dumps: /'
|
||||
|
||||
+13
-16
@@ -1,19 +1,16 @@
|
||||
#!/bin/sh
|
||||
# What a long prefill costs the requests already running beside it, and what the prefill chunk
|
||||
# does to both halves of that trade.
|
||||
# What a long prefill costs the decoders running beside it.
|
||||
#
|
||||
# WHY IT CANNOT BE MEASURED ALONE. A bigger prefill chunk holds the device for longer in one
|
||||
# go, so every decode step queued behind it waits that much longer. Run by itself a long prompt
|
||||
# only shows the good half -- the chunk is worth tens of percent of prefill -- and the bill
|
||||
# arrives on other people's sequences. Both halves have to be on the same clock.
|
||||
# A bigger prefill chunk speeds up prefill by tens of percent but holds the device longer, so
|
||||
# every decode step queued behind it waits longer. A long prompt run alone shows only the gain;
|
||||
# both sides must be measured together.
|
||||
#
|
||||
# WARM FIRST. `expert_tiered` faults its tier in on the first requests, so a cold first pass
|
||||
# charges the whole cold tier to the alone arm and comes back with contention making the decoders
|
||||
# FASTER. The first pass ("warm") is discarded; each later pass runs both arms back to back.
|
||||
# `expert_tiered` faults its tier in on the first requests, so a cold first pass charges the cold
|
||||
# tier to the alone arm and makes contention look like a speedup. The first pass ("warm") is
|
||||
# discarded; each later pass runs both arms back to back.
|
||||
#
|
||||
# THE DECODERS USE ignore_eos SO THEIR LENGTH IS FIXED. A decoder that stops early leaves the
|
||||
# contended window measuring fewer streams than the alone window did, which reads as contention
|
||||
# being free.
|
||||
# Decoders use ignore_eos so their length is fixed: one that stopped early would leave the
|
||||
# contended window with fewer streams than the alone window, hiding the cost.
|
||||
#
|
||||
# P=8100 C=4 DEC=300 PROMPT=24000 scripts/fnconc.sh
|
||||
#
|
||||
@@ -29,8 +26,8 @@ ROOT="${ROOT:-$(dirname "$0")/..}"
|
||||
URL="http://$H:$P"
|
||||
CORPUS=/dev/shm/fnconc-corpus.txt
|
||||
|
||||
# Grown when a later run wants more than the last one did: `head -c` on a corpus that is too
|
||||
# short returns what there is rather than failing, so the arm would time a prompt it did not send.
|
||||
# Grow the corpus when a run needs more: `head -c` on a short corpus silently returns less, so
|
||||
# the arm would time a shorter prompt than intended.
|
||||
want=$((PROMPT * BPT + 4096))
|
||||
if [ "$(wc -c < "$CORPUS" 2>/dev/null || echo 0)" -lt "$want" ]; then
|
||||
: > "$CORPUS"
|
||||
@@ -55,8 +52,8 @@ long_request() {
|
||||
awk -v a="$t0" -v b="$t1" 'BEGIN { printf "%.2f", b - a }'
|
||||
}
|
||||
|
||||
# C decoders, timed. `wait` would also wait on anything else this shell started, so the pids are
|
||||
# collected and waited on by name.
|
||||
# C decoders, timed. A bare `wait` would also wait on anything else this shell started, so the
|
||||
# pids are waited on individually.
|
||||
decoders_wall() {
|
||||
t0=$(date +%s.%N); pids=
|
||||
i=0; while [ "$i" -lt "$C" ]; do decoder "d$1$i" & pids="$pids $!"; i=$((i + 1)); done
|
||||
|
||||
+14
-23
@@ -1,31 +1,22 @@
|
||||
#!/bin/sh
|
||||
# What happens when a client goes away mid-request, against a server that is ALREADY RUNNING.
|
||||
# Client disconnects mid-request, against a running server.
|
||||
#
|
||||
# WHY THIS EXISTS. A disconnect calls the scheduler's reap at an arbitrary point in the step loop,
|
||||
# so anything that holds a raw Request* across that point -- the step plan's entry, a drafter's
|
||||
# snapshot -- is a use-after-free that takes the whole server down. Every other harness in this
|
||||
# tree waits for its requests, so none of them can see that.
|
||||
# A disconnect runs the scheduler's reap at an arbitrary point in the step loop, so anything holding
|
||||
# a raw Request* across that point (a step plan entry, a drafter snapshot) is a use-after-free.
|
||||
# Other harnesses wait for their requests and never exercise this.
|
||||
#
|
||||
# SURVIVING IS NOT THE TEST. A server that stays up and then answers differently has a freed slot
|
||||
# feeding a live sequence, which is the same defect wearing a quieter shirt. So a reference answer
|
||||
# is taken first, the drops happen, and the same question is asked again: the hashes have to match.
|
||||
# Staying up is not enough: a freed slot feeding a live sequence shows as a changed answer. A
|
||||
# reference answer is taken first and the same question is asked after each drop; the hashes must
|
||||
# match. Every observation counts toward the verdict, since a transient divergence right after a
|
||||
# burst is the interesting case and a final re-check would hide it.
|
||||
#
|
||||
# THE DROP POINTS ARE DERIVED, NOT WRITTEN DOWN. One full request is timed first and the drops are
|
||||
# placed at fractions of it, because a drop point past the end of the request is not a drop at all
|
||||
# -- it is curl waiting for a response that already arrived, and it reports PASS having exercised
|
||||
# nothing.
|
||||
# Drop points are fractions of a timed full request; a drop past the end of the request exercises
|
||||
# nothing. `--max-time` is the disconnect (curl closes the socket); `running` returning to zero
|
||||
# well before the request would have finished confirms it.
|
||||
#
|
||||
# `--max-time` is the disconnect: curl closes the socket where it lands. A drop is confirmed by
|
||||
# `running` falling back to zero well before the request would have finished on its own.
|
||||
#
|
||||
# EVERY OBSERVATION COUNTS, NOT THE LAST ONE. A transient divergence right after a burst is the
|
||||
# interesting case and a final re-check hides it: ask again and the answer is right, so the run
|
||||
# reports clean. The verdict below is over all of them.
|
||||
#
|
||||
# AND ONE DIVERGENCE IS NOT A FINDING HERE. A single completion hash can diverge on an unchanged
|
||||
# binary -- concurrency decides batch composition and greedy decoding differs at a tie -- so a
|
||||
# diverged row means RUN IT AGAIN, several times, before believing it. The reference question
|
||||
# itself is stable against an idle server; it is the contended path that can tie-flip.
|
||||
# One divergence is not a finding: concurrency changes batch composition, and greedy decoding can
|
||||
# flip at a tie even on an unchanged binary. Rerun several times before believing a diverged row.
|
||||
# The reference question is stable against an idle server; only the contended path can tie-flip.
|
||||
#
|
||||
# P=8100 scripts/fndrop.sh
|
||||
P="${P:-8100}"
|
||||
|
||||
+17
-26
@@ -1,33 +1,25 @@
|
||||
#!/bin/sh
|
||||
# Prefill throughput against a server that is ALREADY RUNNING, and nothing else.
|
||||
# Prefill throughput of the server already running on $P.
|
||||
#
|
||||
# WHY IT IS NOT A SERVE HARNESS. Prefill speed is a property of the deployment's flags -- the
|
||||
# chunk, the tensor-parallel width, the expert/cache split -- so a harness that brings its own
|
||||
# server measures the flags it chose rather than the ones in use. This one attaches to whatever is
|
||||
# on $P and reports what that server does; use scripts/fnserve.sh to put one there.
|
||||
# Prefill speed depends on the deployment's flags (chunk, tensor-parallel width, expert/cache
|
||||
# split), so this attaches to a running server instead of starting its own; scripts/fnserve.sh
|
||||
# starts one.
|
||||
#
|
||||
# THE PROMPT IS PROSE, NOT RANDOM WORDS. A generated word of random letters is three tokens rather
|
||||
# than one, so a token target computed from a word count is off by a factor of three -- and, worse,
|
||||
# a stream of tokens the model has never seen together routes differently through a mixture of
|
||||
# experts than text does, which is the thing a prefill measurement is mostly measuring. The corpus
|
||||
# is the repository's own markdown, repeated to length.
|
||||
# The prompt is the repository's markdown, repeated to length. Random-letter words tokenize at
|
||||
# about three tokens each and route through the experts differently from real text, which skews a
|
||||
# MoE prefill measurement.
|
||||
#
|
||||
# THE PREFIX CACHE MAKES A SECOND REP FREE, so every rep opens with a different nonce. A cache
|
||||
# matches from the START of the prompt, so a leading nonce invalidates the whole match while a
|
||||
# trailing one would leave every block but the last a hit -- and the run would report a prefill
|
||||
# rate for work that was never done. `cached_tokens` is printed so that this is visible rather
|
||||
# than assumed.
|
||||
# Every rep starts with a different nonce so the prefix cache cannot serve it: the cache matches
|
||||
# from the start of the prompt, so a trailing nonce would leave all but the last block a hit.
|
||||
# `cached_tokens` is printed to show this.
|
||||
#
|
||||
# THE CARD'S CLOCK IS PART OF THE MEASUREMENT. Prefill drifts downward over a sustained run as the
|
||||
# part heats, monotonically and across runs as well as within them, so a single number is not
|
||||
# comparable across runs taken at different times. Temperature and sclk are printed beside every
|
||||
# rep for the same reason a bench prints its build id: without them a thermostat reads as a
|
||||
# regression.
|
||||
# Prefill slows as the card heats, within and across runs, so temperature and sclk are printed
|
||||
# beside every rep; a number without them is not comparable across runs.
|
||||
#
|
||||
# P=8100 N=8000 REPS=3 scripts/fnpf.sh
|
||||
#
|
||||
# N is a token TARGET reached through an assumed bytes-per-token; the rate is computed from the
|
||||
# `prompt_tokens` the server reports, so the approximation does not enter the answer.
|
||||
# N is a token target reached through an assumed bytes-per-token; the rate uses the server's
|
||||
# reported `prompt_tokens`, so the approximation does not affect it.
|
||||
P="${P:-8100}"
|
||||
H="${H:-127.0.0.1}"
|
||||
N="${N:-8000}"
|
||||
@@ -37,10 +29,9 @@ ROOT="${ROOT:-$(dirname "$0")/..}"
|
||||
URL="http://$H:$P"
|
||||
CORPUS="${CORPUS:-/dev/shm/fnpf-corpus.txt}"
|
||||
|
||||
# One corpus, built once and reused, so successive runs prefill the same bytes. GROWN when a
|
||||
# later run wants more than the last one did: `head -c` on a corpus that is too short silently
|
||||
# returns what there is, so a sweep that raised N would report a rate for a prompt it did not
|
||||
# send -- and the prompt_tokens column makes that visible only to a reader who was looking.
|
||||
# One corpus, built once and reused, so successive runs prefill the same bytes. It is grown when a
|
||||
# run needs more: `head -c` on a short corpus silently returns less, and the run would report a
|
||||
# rate for a shorter prompt than intended.
|
||||
want=$((N * BPT + 4096))
|
||||
if [ "$(wc -c < "$CORPUS" 2>/dev/null || echo 0)" -lt "$want" ]; then
|
||||
: > "$CORPUS"
|
||||
|
||||
+58
-68
@@ -1,92 +1,82 @@
|
||||
#!/bin/sh
|
||||
# Bring up Qwen3.8-Flash-Next as a long-lived server and LEAVE IT RUNNING: start it, wait for
|
||||
# /health, print the endpoints and exit with the server still up. The default container is the
|
||||
# production one, w4nl64-i8lm.rad, built by data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe
|
||||
# (scripts/convfn.sh).
|
||||
# Start Qwen3.8-Flash-Next as a long-lived server: wait for /health, print the endpoints and exit
|
||||
# with the server still up. The default container is the production w4nl64-i8lm.rad, built by
|
||||
# data/recipes/qwen4exp-w4nl64-i8-hc8m.recipe (scripts/convfn.sh).
|
||||
#
|
||||
# 200K CONTEXT. --max-model-len reserves nothing per request; it sets the WORST CASE the paged
|
||||
# pool is sized against. Under expert_tiered the cache lends: the routed experts keep on the card
|
||||
# exactly what the host pool cannot hold, and the cache takes the rest of the elastic pool, up to
|
||||
# --max-num-seqs x --max-model-len, lending every block no live request holds back to the expert
|
||||
# slab. --host-pool-mib is what moves that split: a larger pool takes experts off the card and
|
||||
# gives the cache more, in pinned host RAM.
|
||||
# Context: --max-model-len reserves nothing per request; it sets the worst case the paged pool is
|
||||
# sized against. Under expert_tiered the routed experts keep on the card what the host pool cannot
|
||||
# hold, the cache takes the rest of the elastic pool (up to --max-num-seqs x --max-model-len), and
|
||||
# blocks no live request holds are lent back to the expert slab. --host-pool-mib moves that split:
|
||||
# a larger pool moves experts to pinned host RAM and gives the cache more VRAM.
|
||||
#
|
||||
# The pool is a CAPACITY, not a per-request cap. A token costs 7.31 KiB across the two paged
|
||||
# The pool is a capacity, not a per-request cap. A token costs 7.31 KiB across the two paged
|
||||
# groups (kv_attn 26.00 KiB and kv_qsa_bkey 3.25 KiB per 4-token block), so one 200K sequence is
|
||||
# 1.43 GiB. A one-shot request needs its own context; a multi-turn one needs more: with prefix
|
||||
# caching a finished sequence's blocks stay HELD so the next turn can reuse them, so the demand is
|
||||
# the live SESSIONS, and a context of T tokens occupies about 1.8 x T pool tokens. When the pool
|
||||
# cannot hold the live sessions, the cache evicts exactly what the next turn asks for, and every
|
||||
# turn re-prefills its whole context (0% prefix hit; minutes per turn instead of seconds). Watch
|
||||
# kv_util: the hit rate falls off a cliff as the pool fills.
|
||||
# 1.43 GiB. With prefix caching a finished sequence's blocks stay held for the next turn, so demand
|
||||
# is the live sessions: a context of T tokens occupies about 1.8 x T pool tokens. If the pool
|
||||
# cannot hold them, the cache evicts what the next turn needs and every turn re-prefills its whole
|
||||
# context (0% prefix hit, minutes per turn). Watch kv_util; the hit rate drops sharply as the pool
|
||||
# fills.
|
||||
#
|
||||
# Defaults are the production shape (gpu-headroom-mib 96, kv-cache-dtype fp8,
|
||||
# max-num-batched-tokens 2048, tp 2, speculation depth 3), with the prefix cache on and
|
||||
# --checkpoint-slots at its default, because multi-turn chat wants both.
|
||||
# --checkpoint-slots at its default, as multi-turn chat needs both.
|
||||
#
|
||||
# THE CHUNK IS 2048. `--max-num-batched-tokens` is the prefill chunk when checkpoints are off, and
|
||||
# it sets how many routed rows the MoE GEMM sees at once. Part of the expert weight is not in
|
||||
# VRAM (it is pinned host memory, read over the link inside the kernel), so a smaller chunk
|
||||
# re-reads every expert's weight for fewer tokens: 2048 prefills about 55% faster than 512.
|
||||
#
|
||||
# - 4096 IS NOT A 4096 CHUNK: plan_chunk splits at --checkpoint-interval (2048) before the
|
||||
# budget applies, so it runs 2048 chunks while the activation arena, which grows with the
|
||||
# BUDGET and is charged before the expert/KV split, takes resident experts for a chunk it never
|
||||
# gets. Startup names which of the two bound the chunk. A real 4096 chunk (with
|
||||
# --checkpoint-interval 4096) is no faster either: the larger arena costs more resident experts
|
||||
# Chunk 2048: `--max-num-batched-tokens` is the prefill chunk when checkpoints are off and sets how
|
||||
# many routed rows the MoE GEMM sees at once. Part of the expert weight is pinned host memory read
|
||||
# over the link inside the kernel, so a smaller chunk re-reads every expert for fewer tokens; 2048
|
||||
# prefills about 55% faster than 512.
|
||||
# - 4096 does not give a 4096 chunk: plan_chunk splits at --checkpoint-interval (2048) first,
|
||||
# while the activation arena grows with the budget and is charged before the expert/KV split,
|
||||
# costing resident experts for nothing. Startup names which limit bound the chunk. A real 4096
|
||||
# chunk (--checkpoint-interval 4096) is no faster: the larger arena costs more resident experts
|
||||
# than the amortisation returns.
|
||||
# - It does not cost co-running decoders: queued behind a prefill that finishes sooner, they
|
||||
# finish sooner at 2048 than at 512 (scripts/fnconc.sh measures both halves).
|
||||
# - It does not cost the prefix cache: the KV pool loses about 3% to the larger arena and two
|
||||
# ~180K sessions still hit 99% with no evictions.
|
||||
# - It costs about 0.6% of decode step time at one stream (scripts/cstep2.sh), from the resident
|
||||
# experts the arena takes; at eight streams the difference is below what the harness resolves.
|
||||
# - It changes the text. A different chunk is a different batch shape, so a prefill sums in a
|
||||
# different order and a tie can land on a different token; each chunk size is stable on its
|
||||
# own. Pin the chunk before recording anything to compare against later.
|
||||
# - Co-running decoders queued behind a prefill finish sooner at 2048 than at 512, since the
|
||||
# prefill does (scripts/fnconc.sh).
|
||||
# - The KV pool loses about 3% to the larger arena; two ~180K sessions still hit 99% with no
|
||||
# evictions.
|
||||
# - Decode step time rises about 0.6% at one stream (scripts/cstep2.sh) from the experts the
|
||||
# arena displaces; at eight streams the difference is below the harness's resolution.
|
||||
# - The chunk changes the text: a different batch shape sums prefill in a different order, so a
|
||||
# tie can resolve differently. Each chunk size is stable on its own; pin it before recording a
|
||||
# reference.
|
||||
#
|
||||
# THE PREFIX CACHE IS TIERED, AND THE ENGINE LEAVES THE HOST TIER OFF BY DEFAULT.
|
||||
# --prefix-cache-mib is zero unless asked for, so a server started without it drops a conversation's
|
||||
# context the moment the pool needs the blocks. This deployment keeps finished turns in host memory,
|
||||
# where they cost the card nothing, for an hour of disuse (--prefix-cache-ttl's default).
|
||||
#
|
||||
# The ELASTIC half needs no flag and cannot be turned off: the pool holds the blocks it is using
|
||||
# plus a buffer derived from the chunk, and the expert slab takes the VRAM it releases. That leans
|
||||
# on --gpu-headroom-mib, which is why the 96 above matters -- startup names any shortfall and holds
|
||||
# it back on top of the reserve.
|
||||
# Prefix cache: the engine's host tier is off by default (--prefix-cache-mib 0), so a conversation
|
||||
# is dropped as soon as the pool needs its blocks. This deployment keeps finished turns in host
|
||||
# memory for an hour of disuse (--prefix-cache-ttl's default). The elastic VRAM half needs no flag
|
||||
# and cannot be turned off: the pool holds the blocks in use plus a buffer derived from the chunk,
|
||||
# and the expert slab takes the VRAM it releases. That relies on --gpu-headroom-mib (96 above);
|
||||
# startup names any shortfall and holds it back on top of the reserve.
|
||||
#
|
||||
# --prefix-cache-mib finished conversations are copied here at once and their VRAM goes to the
|
||||
# expert slab; a return restores instead of re-prefilling, and a full tier
|
||||
# drops its least recently used. It holds attention blocks only: the
|
||||
# linear-state snapshots are in the --checkpoint-slots store, 113 MiB each on
|
||||
# this model and counted for the whole server, not per sequence.
|
||||
# evicts least recently used. It holds attention blocks only: linear-state
|
||||
# snapshots live in the --checkpoint-slots store (113 MiB each on this model,
|
||||
# counted for the whole server, not per sequence).
|
||||
#
|
||||
# THE HOST NUMBER IS DELIBERATELY SMALL BECAUSE OF THE N-GRAM TABLE. The tier's arena is PINNED,
|
||||
# and the 47.68 GiB n-gram (PLE) table is read through the container's own mmap, so it lives in
|
||||
# the page cache -- and pinned bytes come out of the same host RAM. Taking too much here turns a
|
||||
# decode step's minor faults into major ones, a far worse trade than a smaller host tier.
|
||||
# Watch /proc/<pid>/stat majflt across a prefill before raising it.
|
||||
# The host tier is kept small because of the n-gram table: the tier's arena is pinned, and the
|
||||
# 47.68 GiB n-gram (PLE) table is read through the container's mmap, so both draw on the same host
|
||||
# RAM. Too large a tier turns a decode step's minor faults into major ones. Watch
|
||||
# /proc/<pid>/stat majflt across a prefill before raising it.
|
||||
#
|
||||
# THE CROSS-RANK WIRE IS THE ROTATED 6-BIT ONE (--tp-wire wht6). An all-reduce at or above
|
||||
# --tp-wire-min-kb (128 KiB: every prefill chunk, and decode from seven streams up) carries a
|
||||
# Walsh-Hadamard-rotated 6-bit payload instead of bf16 -- 2.6x fewer bytes over PCIe -- inside the
|
||||
# gated residual's fused writes. Against the exact wire at a 2048-token chunk it prefills about 6%
|
||||
# faster and decodes about 1% faster at eight streams; at one stream nothing changes, because its
|
||||
# messages stay under the floor and go exact.
|
||||
# --tp-wire wht6: an all-reduce at or above --tp-wire-min-kb (128 KiB: every prefill chunk, and
|
||||
# decode from seven streams up) carries a Walsh-Hadamard-rotated 6-bit payload instead of bf16,
|
||||
# 2.6x fewer bytes over PCIe, inside the gated residual's fused writes. Against the exact wire at
|
||||
# a 2048-token chunk it prefills about 6% faster and decodes about 1% faster at eight streams; one
|
||||
# stream stays under the floor and is exact. It is lossy: over greedy continuations of 160 code and
|
||||
# prose prompts, wht6 agrees with the exact wire at 91.4% of positions, the same as the E4M3
|
||||
# hyper-connection matrices the container already carries versus bf16 (91.3%). WIRE=exact serves
|
||||
# the exact wire.
|
||||
#
|
||||
# IT IS LOSSY, by about as much as a trade this model already makes. Over greedy continuations of
|
||||
# 160 code and prose prompts, compared at every position while the two prefixes still agree, wht6
|
||||
# agrees with the exact wire at 91.4% of positions -- the same as E4M3 hyper-connection matrices
|
||||
# against bf16 ones (91.3%), which the container already carries. WIRE=exact serves the exact wire.
|
||||
#
|
||||
# Binds 0.0.0.0 so a client on another host can reach it. Stop it with scripts/fnstop.sh.
|
||||
# Binds 0.0.0.0 so other hosts can reach it. Stop it with scripts/fnstop.sh.
|
||||
P="${P:-8100}"
|
||||
M="${M:-$HOME/models/rad/w4nl64-i8lm.rad}"
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
pkill -f "bin/radianc[e]"; while pgrep -f "bin/radianc[e]" >/dev/null; do sleep 1; done; sleep 2
|
||||
env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 $EXTRA_ENV \
|
||||
nohup ./bin/radiance --model "$M" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--radiance-home radiance_home \
|
||||
--host 0.0.0.0 --port "$P" \
|
||||
--max-num-seqs ${SEQS:-8} --max-model-len ${MLEN:-200000} \
|
||||
--tp ${TP:-2} --placement expert_tiered --host-pool-mib ${HOSTPOOL:-12288} \
|
||||
|
||||
+13
-19
@@ -1,19 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Qwen3.8-Flash-Next PREFILL under rocprofv3 kernel tracing, and the link counters beside it.
|
||||
# Qwen3.8-Flash-Next prefill under rocprofv3 kernel tracing, with the link counters beside it.
|
||||
#
|
||||
# WHAT IT ANSWERS. `moe_gemm_q` is the largest item in a prefill step and most of what it waits on
|
||||
# is expert weight that is not resident, read where it lies -- which for a host-pooled unit means
|
||||
# crossing the link inside the kernel. Neither half of that is visible alone: a trace says how long
|
||||
# the GEMM ran and says nothing about bytes, and /stats says how many bytes were streamed and
|
||||
# nothing about when. Taking both across the same run gives the rate the streamed read actually
|
||||
# achieves, which is the only number that says whether the kernel is at the link's ceiling or
|
||||
# leaving it idle.
|
||||
# `moe_gemm_q` is the largest item in a prefill step, and it mostly waits on non-resident expert
|
||||
# weight, which for a host-pooled unit is read across the link inside the kernel. The trace gives
|
||||
# the GEMM's time and /stats the bytes streamed; together they give the achieved streaming rate,
|
||||
# which shows whether the kernel reaches the link's ceiling.
|
||||
#
|
||||
# PREFILL ONLY, AND THAT IS WHY tsum's WINDOW IS NOT USED. tsum.sh keys its steady-state window on
|
||||
# a marker that fires once per DECODE step; with max_tokens 1 there is no such run, so it falls
|
||||
# back to summing the whole trace and every number is per RUN. That is what isolation wants here --
|
||||
# the run IS the prefill -- but it does mean the model load's own kernels are in the total, so the
|
||||
# prompt has to be long enough that they are noise.
|
||||
# tsum.sh keys its steady-state window on a once-per-decode-step marker; with max_tokens 1 there is
|
||||
# none, so it sums the whole trace and every number is per run. The model load's kernels are in the
|
||||
# total, so the prompt must be long enough to make them negligible.
|
||||
#
|
||||
# N=20000 OUT=<trace dir> scripts/fntrace.sh
|
||||
#
|
||||
@@ -25,7 +20,8 @@ BPT="${BPT:-4}"
|
||||
OUT="${OUT:-$HOME/traces/fnpf}"
|
||||
ROOT="${ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
|
||||
CORPUS=/dev/shm/fntrace-corpus.txt
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
|
||||
want=$((N * BPT + 4096))
|
||||
if [ "$(wc -c < "$CORPUS" 2>/dev/null || echo 0)" -lt "$want" ]; then
|
||||
@@ -40,7 +36,7 @@ rm -rf "$OUT"; mkdir -p "$OUT"
|
||||
env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 $EXTRA_ENV \
|
||||
"$ROOT/libr4d/isa/trace.sh" "$OUT" -- \
|
||||
./bin/radiance --model "$M" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--radiance-home radiance_home \
|
||||
--host 127.0.0.1 --port "$P" \
|
||||
--max-num-seqs ${SEQS:-8} --max-model-len ${MLEN:-200000} \
|
||||
--tp ${TP:-2} --placement expert_tiered --host-pool-mib ${HOSTPOOL:-12288} \
|
||||
@@ -66,10 +62,8 @@ t1=$(date +%s.%N)
|
||||
s1=$(st stream_bytes); a1=$(st ar_bytes); h1=$(st h2d_bytes)
|
||||
pt=$(printf '%s' "$out" | jq -r '.usage.prompt_tokens // 0')
|
||||
|
||||
# UNDER rocprofv3 THE SERVER CAN REFUSE TO DIE ON SIGTERM. The profiler chains its own handler
|
||||
# onto the signal and the process then sits in finalisation indefinitely -- so an unbounded wait
|
||||
# here loses the run, and the trace CSV is already on disk by that point. Escalate rather than
|
||||
# spin.
|
||||
# Under rocprofv3 the server can hang in finalisation after SIGTERM (the profiler chains its own
|
||||
# handler). The trace CSV is already on disk by then, so escalate to SIGKILL after a bounded wait.
|
||||
pkill -f "bin/radianc[e]"
|
||||
i=0; while pgrep -f "bin/radianc[e]" >/dev/null && [ $i -lt 30 ]; do sleep 1; i=$((i + 1)); done
|
||||
pgrep -f "bin/radianc[e]" >/dev/null && { echo "did not exit on TERM under the profiler, killing"; pkill -9 -f "bin/radianc[e]"; sleep 2; }
|
||||
|
||||
+25
-32
@@ -1,40 +1,35 @@
|
||||
#!/bin/sh
|
||||
# hfget.sh -- fetch a Hugging Face repo with curl and jq, and nothing else.
|
||||
# hfget.sh -- fetch a Hugging Face repo with only curl and jq.
|
||||
#
|
||||
# The engine and its tooling do not depend on Python, so `huggingface-cli` is not assumed. The API
|
||||
# gives a file listing as JSON and every file has a stable resolve/ URL, which is all a downloader
|
||||
# needs.
|
||||
# returns a JSON file listing and every file has a stable resolve/ URL.
|
||||
#
|
||||
# scripts/hfget.sh <repo-id> [dest-dir] [revision]
|
||||
#
|
||||
# Set HF_TOKEN for a gated or private repo. Re-running resumes: a file whose local size already
|
||||
# matches the listing is skipped and a short one is continued with `curl -C -`, so an interrupted
|
||||
# transfer of a 300 GB checkpoint costs only what it had not finished.
|
||||
# Set HF_TOKEN for a gated or private repo. Re-running resumes: a file whose local size matches the
|
||||
# listing is skipped and a short one is continued with `curl -C -`.
|
||||
#
|
||||
# A CHANGED FILE IS FETCHED AGAIN even at the same size. A complete run records each file's content
|
||||
# A changed file is fetched again even at the same size. A complete run records each file's content
|
||||
# key (the LFS sha256, or the size for a small file) in <dest>/.hfget-manifest, and a later run
|
||||
# compares the listing against it. The manifest is written only when every file arrived, so its
|
||||
# presence means the directory is a complete copy of some revision.
|
||||
#
|
||||
# Exit status: 0 complete; 3 nothing on disk was changed (the listing could not be read, or what is
|
||||
# still to fetch does not fit), so a complete earlier copy is intact; anything else, a transfer
|
||||
# failed and a file may be partial -- re-run to resume. `radiance --model <repo-id>` serves the
|
||||
# failed and a file may be partial (re-run to resume). `radiance --model <repo-id>` serves the
|
||||
# earlier copy on 3 and refuses on the rest.
|
||||
#
|
||||
# WEIGHT DUPLICATES ARE SKIPPED. Many repos carry the same tensors several times over -- safetensors
|
||||
# beside the older pickle .bin, an ONNX export, a GGUF conversion -- and on a large checkpoint each
|
||||
# copy is hundreds of gigabytes of the same numbers. When the listing holds any .safetensors, every
|
||||
# other weight format is left behind.
|
||||
# Duplicate weight formats are skipped: when the listing holds any .safetensors, other weight
|
||||
# formats (pickle .bin, ONNX, GGUF, ...) are not fetched.
|
||||
#
|
||||
# HFGET_JOBS concurrent transfers, default 4. These are long sequential reads: a few streams
|
||||
# saturate the link and more only makes the destination seek.
|
||||
# saturate the link and more only make the destination seek.
|
||||
set -e
|
||||
|
||||
# ---- child mode: one file, named by "<size><tab><oid><tab><path>" in $1, everything else inherited.
|
||||
# Size first: a non-LFS file has no oid, and busybox `xargs -I` strips the leading blanks of a line,
|
||||
# so a line that began with its empty oid field would reach the child one tab short.
|
||||
# sh cannot export a function, so parallelism is one re-entry of this script per file under
|
||||
# `xargs -P` rather than a worker pool.
|
||||
# Size comes first because a non-LFS file has no oid and busybox `xargs -I` strips leading blanks,
|
||||
# so a line starting with an empty oid field would arrive one tab short.
|
||||
# sh cannot export a function, so each file is a re-entry of this script under `xargs -P`.
|
||||
if [ -n "$HFGET_CHILD" ]; then
|
||||
size=${1%% *}; rest=${1#* }; oid=${rest%% *}; path=${rest#* }
|
||||
key=${oid:-$size} # LFS: sha256, non-LFS: size
|
||||
@@ -47,7 +42,7 @@ if [ -n "$HFGET_CHILD" ]; then
|
||||
printf '%s\t%s\n' "$key" "$path" >> "$HFGET_MAN_OUT"
|
||||
exit 0
|
||||
fi
|
||||
rm -f "$out" # SAME SIZE, NEW CONTENT: resume is size-based and useless -> fresh
|
||||
rm -f "$out" # same size, new content: resume is size-based, so start fresh
|
||||
echo " ~ $path (same size, new content)"
|
||||
elif [ -f "$out" ]; then
|
||||
echo " + $path (resuming at $(wc -c < "$out") of $size)"
|
||||
@@ -79,18 +74,16 @@ command -v jq >/dev/null || { echo "hfget: jq is required" >&2; exit 2; }
|
||||
command -v curl >/dev/null || { echo "hfget: curl is required" >&2; exit 2; }
|
||||
|
||||
echo "hfget: listing $repo@$rev"
|
||||
# THE LISTING IS PAGINATED AND THE PAGE SIZE IS SMALL. A large checkpoint runs to a hundred-odd
|
||||
# shards and the API returns fifty entries with a `Link: ...; rel="next"` header. Taking only the
|
||||
# first page is the worst possible failure here: every file it did fetch is the right length, so
|
||||
# the size check passes and the converter is handed a checkpoint missing two thirds of its
|
||||
# tensors. Follow the cursor until there is no next link.
|
||||
# The listing is paginated (fifty entries per page, next page in a `Link: ...; rel="next"`
|
||||
# header). Reading only the first page would silently yield an incomplete checkpoint whose files
|
||||
# all pass the size check, so follow the cursor until there is no next link.
|
||||
api="https://huggingface.co/api/models/$repo/tree/$rev?recursive=true&expand=true"
|
||||
listing='[]'
|
||||
page=0
|
||||
while [ -n "$api" ]; do
|
||||
hdr=$(mktemp "${TMPDIR:-/tmp}/hfhdr.XXXXXX")
|
||||
# A failed request is reported here rather than by set -e, which would exit with curl's status
|
||||
# and say nothing; and with 3, since nothing has been written yet.
|
||||
# Report a failed request here rather than letting set -e exit silently with curl's status;
|
||||
# exit 3, since nothing has been written yet.
|
||||
st=0
|
||||
if [ -n "$HF_TOKEN" ]; then
|
||||
body=$(curl -sSL --fail-with-body -D "$hdr" -H "Authorization: Bearer $HF_TOKEN" "$api") \
|
||||
@@ -125,12 +118,12 @@ n=$(wc -l < "$list")
|
||||
need=$(awk -F'\t' '{s += $1} END {printf "%.1f", s / 1073741824}' "$list")
|
||||
mkdir -p "$dest"
|
||||
: > "$dest/.hfget-manifest.tmp"
|
||||
# WHAT IS STILL TO FETCH, not the repo's size: a warm cache of a model larger than the free space
|
||||
# left beside it must not read as a download that does not fit. A file is counted from its local
|
||||
# length, and whole when the manifest says its content changed.
|
||||
# Count what is still to fetch, not the repo's size, so a mostly complete copy larger than the free
|
||||
# space does not read as a download that does not fit. A file counts from its local length, or in
|
||||
# full when the manifest says its content changed.
|
||||
todo=0
|
||||
# Split by expansion, as the child does: a tab is IFS whitespace, so `read` would merge the empty
|
||||
# key of a non-LFS file into the next field.
|
||||
# Split by expansion, as the child does: a tab is IFS whitespace, so `read` would merge a non-LFS
|
||||
# file's empty key into the next field.
|
||||
while IFS= read -r line; do
|
||||
size=${line%% *}; rest=${line#* }; oid=${rest%% *}; path=${rest#* }
|
||||
cur=0
|
||||
@@ -141,8 +134,8 @@ while IFS= read -r line; do
|
||||
fi
|
||||
if [ "$cur" -lt "$size" ]; then todo=$((todo + size - cur)); fi
|
||||
done < "$list"
|
||||
# Free space in KiB from POSIX `df -Pk` (one line per filesystem, 1024-byte blocks): GNU's
|
||||
# `-BG --output=avail` is not in busybox, which is the df the container image has.
|
||||
# Free space in KiB from POSIX `df -Pk` (1024-byte blocks); the container image's busybox df lacks
|
||||
# GNU's `-BG --output=avail`.
|
||||
free=$(df -Pk "$dest" | awk 'NR == 2 { print $4 }')
|
||||
echo "hfget: $n file(s), $need GiB -> $dest"
|
||||
[ "$have_st" -gt 0 ] && echo "hfget: safetensors present, pickle weight formats skipped"
|
||||
|
||||
+15
-18
@@ -1,25 +1,22 @@
|
||||
#!/bin/sh
|
||||
# ident.sh -- is this server reproducible? One hash per (temperature, question), so a run can be
|
||||
# compared against another run of the SAME configuration.
|
||||
# ident.sh -- server reproducibility check. Prints one hash per (temperature, question) for
|
||||
# comparison against another run of the same configuration.
|
||||
#
|
||||
# WHAT IT PROVES: run-to-run determinism at a fixed configuration, across restarts. On
|
||||
# Qwen3.8-Flash-Next at tp2 with the MTP head at depth 3, two servers started from scratch give
|
||||
# the same six hashes: temperature 0, 0.7 and 1.0, both questions.
|
||||
# It tests run-to-run determinism at a fixed configuration, across restarts: on
|
||||
# Qwen3.8-Flash-Next at tp2 with the MTP head at depth 3, two fresh servers give the same six
|
||||
# hashes (temperature 0, 0.7 and 1.0, both questions).
|
||||
#
|
||||
# WHAT IT DOES NOT PROVE: that a SPECULATIVE run matches a NON-SPECULATIVE one byte for byte.
|
||||
# `narrow_ksplit` chooses the split count of the fp8 GEMM's finisher from M, so the same row
|
||||
# computed at M=1 (one token at a time) and at M=8 (a verify block) is not bit-identical, and a
|
||||
# long answer can flip a near-tie somewhere past its first few hundred characters, both
|
||||
# continuations equally good. `--deterministic` does not change that -- it pins placement and
|
||||
# never reaches a kernel.
|
||||
# It does not test that a speculative run matches a non-speculative one byte for byte.
|
||||
# `narrow_ksplit` picks the fp8 GEMM finisher's split count from M, so a row computed at M=1 and
|
||||
# at M=8 (a verify block) is not bit-identical, and a long answer can flip a near-tie past its
|
||||
# first few hundred characters. `--deterministic` pins placement only and does not affect kernels.
|
||||
#
|
||||
# BUT A SHORT COMMON PREFIX IS A DEFECT, NOT A TIE. On Qwen3.8-Flash-Next at tp2, depth 3 against
|
||||
# --num-speculative-tokens 0 gives the same six hashes here, and over longer answers the two agree
|
||||
# for hundreds of characters before any flip. A speculative run that leaves the non-speculative
|
||||
# text within the first sentence or two is computing something different after a rejected draft --
|
||||
# rolling state read from a rejected token is exactly that shape -- and is worth bisecting. If
|
||||
# byte-identity across that boundary is ever required everywhere, the work is plumbing a pinned
|
||||
# split count into the fp8 GEMM, and it costs throughput at one M or the other.
|
||||
# A short common prefix is a defect, not a tie. On Qwen3.8-Flash-Next at tp2, depth 3 and
|
||||
# --num-speculative-tokens 0 give the same six hashes, and longer answers agree for hundreds of
|
||||
# characters. A speculative run that departs within the first sentence or two is computing
|
||||
# something different after a rejected draft (e.g. rolling state read from a rejected token) and
|
||||
# is worth bisecting. Byte identity across that boundary would need a pinned split count in the
|
||||
# fp8 GEMM, at a throughput cost for one M or the other.
|
||||
#
|
||||
# P=8100 scripts/ident.sh # against a server already up
|
||||
P=${P:-8100}
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
#!/bin/sh
|
||||
# What speculation is worth on the AGENT's OWN WORKLOAD: /v1/chat/completions with tools, which
|
||||
# is a constrained decode. Arms alternate across server restarts because n_spec is a server-level
|
||||
# setting and cannot be varied inside one process.
|
||||
# What speculation is worth on an agent workload: /v1/chat/completions with tools, a constrained
|
||||
# decode. Arms alternate across server restarts because n_spec is a server-level setting.
|
||||
T='[{"type":"function","function":{"name":"write","description":"write a file","parameters":{"type":"object","properties":{"path":{"type":"string"},"content":{"type":"string"}},"required":["path","content"]}}},{"type":"function","function":{"name":"bash","description":"run a shell command","parameters":{"type":"object","properties":{"cmd":{"type":"string"}},"required":["cmd"]}}},{"type":"function","function":{"name":"read","description":"read a file","parameters":{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}}}]'
|
||||
Q="Write a long, heavily commented C implementation of a chess board representation with FEN parsing, then explain every design decision in detail."
|
||||
U="http://127.0.0.1:8111"
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
# HOW OFTEN DOES THE DRAFTER ACTUALLY PROPOSE? draft_tokens_total/depth is the number of draft
|
||||
# BLOCKS; over decode steps that is the fraction of steps that speculated at all. accept% is
|
||||
# conditional on having drafted, so a high accept% with tok/step ~1.2 can only mean most steps
|
||||
# never drafted. The server log says the drafter may DECLINE ("prompt lookup fills in").
|
||||
# How often the drafter proposes, by context length. draft_tokens_total/depth is the number of
|
||||
# draft blocks; divided by decode steps it is the fraction of steps that speculated. accept% is
|
||||
# conditional on drafting, so a high accept% with tok/step ~1.2 means most steps never drafted.
|
||||
# The drafter may decline (the server log says "prompt lookup fills in").
|
||||
P=8112; U="http://127.0.0.1:$P"
|
||||
pad() { i=0; W=""; while [ $i -lt "$1" ]; do
|
||||
W="$W static int eval_piece_$1_$i(const Board *b, int sq) { return b->squares[sq] * 100 + $i; }"
|
||||
|
||||
+9
-10
@@ -1,22 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Bring up MiniCPM5-2B (fp8) as a long-lived server and LEAVE IT RUNNING.
|
||||
# Start MiniCPM5-2B (fp8) as a long-lived server, like scripts/fnserve.sh: wait for /health, print
|
||||
# the endpoints and exit with the server still up. Stop it with scripts/fnstop.sh.
|
||||
#
|
||||
# The sibling of scripts/fnserve.sh, for the small dense model. Same contract: start it, wait for
|
||||
# /health, print the endpoints, exit with the server still up. Stop it with scripts/fnstop.sh.
|
||||
#
|
||||
# WHY 131072 AND NOT 200000. n_ctx_train is 131072 for this checkpoint; the 200K context
|
||||
# scripts/fnserve.sh serves is a property of the Flash-Next model, which a 2B model cannot honour.
|
||||
# Context is 131072, this checkpoint's n_ctx_train (the 200K of fnserve.sh is Flash-Next's).
|
||||
#
|
||||
# KV is 21.0 KiB a token at fp8 (42 layers x 2 kv heads x 128 x 2 planes), halved per rank at
|
||||
# tp 2, so a full-length sequence costs 1.38 GiB a rank and 8 of them do not fit -- the pool is
|
||||
# a capacity, not a per-request reservation, and it backs however many the cache can hold.
|
||||
# tp 2, so a full-length sequence costs 1.38 GiB a rank and 8 of them do not fit. The pool is a
|
||||
# capacity, not a per-request reservation.
|
||||
P="${P:-8100}"
|
||||
M="${M:-$HOME/models/rad/minicpm5-2b-dspark.v2.rad}"
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
pkill -f "bin/radianc[e]"; while pgrep -f "bin/radianc[e]" >/dev/null; do sleep 1; done; sleep 2
|
||||
env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 $EXTRA_ENV \
|
||||
nohup ./bin/radiance --model "$M" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--radiance-home radiance_home \
|
||||
--host 0.0.0.0 --port "$P" \
|
||||
--max-num-seqs ${SEQS:-8} --max-model-len ${MLEN:-131072} \
|
||||
--tp ${TP:-2} \
|
||||
|
||||
+4
-6
@@ -1,10 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Tool-call replies STREAMED, which is how an agent client talks to this server: content is sent
|
||||
# as it grows and cannot be retracted, so a tool call repaired only at the end would leave the
|
||||
# client showing the raw XML AND the call. Asserts on the RAW SSE bytes, not on the assembled
|
||||
# message.
|
||||
# The port is an override (P=, default 8100): this harness attaches to a server that is already
|
||||
# up rather than starting one.
|
||||
# Streamed tool-call replies, as agent clients use them. Streamed content cannot be retracted, so a
|
||||
# tool call repaired only at the end would leave the client showing both the raw XML and the call.
|
||||
# Asserts on the raw SSE bytes, not the assembled message.
|
||||
# Attaches to a running server on P= (default 8100).
|
||||
P=${P:-8100}
|
||||
WORK=$(mktemp -d "${TMPDIR:-/tmp}/mcstream.XXXXXX"); trap 'rm -rf "$WORK"' EXIT INT TERM
|
||||
T='[{"type":"function","function":{"name":"bash","description":"run a shell command","parameters":{"type":"object","properties":{"cmd":{"type":"string"}},"required":["cmd"]}}},{"type":"function","function":{"name":"write","description":"write a file","parameters":{"type":"object","properties":{"path":{"type":"string"},"content":{"type":"string"}},"required":["path","content"]}}}]'
|
||||
|
||||
+6
-7
@@ -1,11 +1,10 @@
|
||||
#!/bin/sh
|
||||
# The four tool-call shapes that are hardest to parse -- an array argument, two calls in one
|
||||
# reply, prose before a call, plain chat with tools available -- against a speculating container
|
||||
# such as the DSpark one (scripts/mcserve.sh): speculation must not disturb the XML tool grammar.
|
||||
# finish_reason tool_calls is the proof the SERVER parsed them; a call that comes back as prose in
|
||||
# `content` is a call the parser did not close.
|
||||
# The port is an override (P=, default 8100): this harness attaches to a server that is already
|
||||
# up rather than starting one.
|
||||
# The four hardest tool-call shapes to parse (an array argument, two calls in one reply, prose
|
||||
# before a call, plain chat with tools available) against a speculating container such as the
|
||||
# DSpark one (scripts/mcserve.sh); speculation must not disturb the XML tool grammar.
|
||||
# finish_reason tool_calls shows the server parsed the calls; a call returned as prose in
|
||||
# `content` is one the parser did not close.
|
||||
# Attaches to a running server on P= (default 8100).
|
||||
P=${P:-8100}
|
||||
T='[{"type":"function","function":{"name":"edit","description":"edit a file","parameters":{"type":"object","properties":{"path":{"type":"string"},"edits":{"type":"array","items":{"type":"object","properties":{"oldText":{"type":"string"},"newText":{"type":"string"}}}}},"required":["path","edits"]}}},{"type":"function","function":{"name":"bash","description":"run a shell command","parameters":{"type":"object","properties":{"cmd":{"type":"string"}},"required":["cmd"]}}},{"type":"function","function":{"name":"write","description":"write a file","parameters":{"type":"object","properties":{"path":{"type":"string"},"content":{"type":"string"}},"required":["path","content"]}}}]'
|
||||
ask() { # $1 label $2 user message
|
||||
|
||||
+8
-6
@@ -1,19 +1,21 @@
|
||||
#!/bin/sh
|
||||
# MiniCPM5-2B decode under rocprofv3 kernel tracing. The BLOCKS column is what this is for:
|
||||
# a 2B dense model at tp2 has tiny N per rank, so every decode GEMM is a candidate for grid
|
||||
# collapse -- 2048/tile_n workgroups on a 64-CU card leave most of it idle.
|
||||
# MiniCPM5-2B decode under rocprofv3 kernel tracing, mainly for the BLOCKS column: a 2B dense
|
||||
# model at tp2 has small N per rank, so a decode GEMM may launch too few workgroups (2048/tile_n
|
||||
# on a 64-CU card leaves most of it idle).
|
||||
# N=<decode tokens> OUT=<trace dir> scripts/mctrace.sh
|
||||
P=8102
|
||||
M="${M:-$HOME/models/rad/minicpm5-2b-dspark.v2.rad}"
|
||||
N="${N:-140}"
|
||||
OUT="${OUT:-$HOME/traces/mc}"
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
pkill -f "bin/radianc[e]"; while pgrep -f "bin/radianc[e]" >/dev/null; do sleep 1; done; sleep 2
|
||||
rm -rf "$OUT"; mkdir -p "$OUT"
|
||||
env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 $EXTRA_ENV \
|
||||
"$HOME/workspace/radiance/libr4d/isa/trace.sh" "$OUT" -- \
|
||||
"$ROOT/libr4d/isa/trace.sh" "$OUT" -- \
|
||||
./bin/radiance --model "$M" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--radiance-home radiance_home \
|
||||
--max-num-seqs 8 --max-model-len 16384 --tp 2 \
|
||||
--gpu-headroom-mib 160 --kv-cache-dtype fp8 --max-num-batched-tokens 512 \
|
||||
$EXTRA --port $P > "$HOME/mctrace.log" 2>&1 &
|
||||
|
||||
+60
-82
@@ -1,95 +1,71 @@
|
||||
#!/bin/sh
|
||||
# Every matching op compared against libref ON THE OPERANDS THE DEVICE KERNEL WAS HANDED.
|
||||
# Compare every matching op against libref on the operands the device kernel was handed.
|
||||
#
|
||||
# rad-kbench falsifies one op at a time on operands IT invented: dense, rank-2, freshly filled. The
|
||||
# engine's are row slices of a max_tok buffer, column slices of a fused projection, rank-3 views a
|
||||
# scan kernel required, and weights that came off a file. A kernel can be correct at every shape
|
||||
# rad-kbench knows and wrong at the one the model issues, so this runs the host row beside the
|
||||
# device one on the real thing, every issue, and reports per operand.
|
||||
# rad-kbench tests one op at a time on operands it invents (dense, rank 2, freshly filled). The
|
||||
# engine's operands are row slices of a max_tok buffer, column slices of a fused projection, rank-3
|
||||
# views and weights loaded from a file; a kernel can be right at every kbench shape and wrong at
|
||||
# the one the model issues. This runs the host row beside the device one on every issue and
|
||||
# reports per operand.
|
||||
#
|
||||
# IT IS NOT A MEASUREMENT OF ANYTHING. Two device-to-host copies of every operand -- a fused
|
||||
# gate_up weight is 170 MiB -- a host synchronisation per issue on every lane, and a reference
|
||||
# kernel that is not trying to be fast. Keep MAXN small and the prompt short.
|
||||
# Cost: two device-to-host copies of every operand (a fused gate_up weight is 170 MiB), a host
|
||||
# synchronisation per issue on every lane and a slow reference kernel. Not a performance
|
||||
# measurement; keep MAXN small and the prompt short. A routed expert GEMM is the most expensive:
|
||||
# its weight operand is the layer's whole expert table, snapshotted twice plus the inverted copy,
|
||||
# some gigabytes per issue, so MAXN=2 is a sensible sweep there.
|
||||
#
|
||||
# ON A LARGE CONTAINER IT CAN STILL BE OOM-KILLED PART WAY THROUGH AND THAT IS THE HOST, NOT A
|
||||
# DEFECT. A 166 GiB container with a 12 GiB host pool leaves little room for two copies of every
|
||||
# operand of every issue; the run prints the verdicts it reached before it died, and those are as
|
||||
# good as any others. Lower HOSTPOOL, or window the sweep with FROM/TO, to reach further in.
|
||||
# Large containers: a 166 GiB container with a 12 GiB host pool can be OOM-killed part way
|
||||
# through. That is a host limit, not a defect; the verdicts printed before it died are valid.
|
||||
# Lower HOSTPOOL or window the sweep with FROM/TO. An operand over RADIANCE_OP_ORACLE_MAXBYTES
|
||||
# (4 GiB), such as Flash-Next's 47.68 GiB PLE n-gram table, is reported NOT CHECKED with its name
|
||||
# and size and the sweep continues; raise the cap if the host can hold three copies.
|
||||
#
|
||||
# ONE OPERAND CAN DO IT ON ITS OWN, AND THAT ONE IS NAMED RATHER THAN FATAL. The Flash-Next PLE
|
||||
# gather reads a 47.68 GiB n-gram table, which no snapshot can hold on a host of ordinary size.
|
||||
# An operand over RADIANCE_OP_ORACLE_MAXBYTES (4 GiB) is a NOT CHECKED line naming the operand and
|
||||
# its size, so the sweep goes on; raise the cap to include it if the host can take three copies.
|
||||
# Relayouted weights: a kernel that claims a weight may relayout its canonical planes at load (e.g.
|
||||
# libr4d's fp8a8 weights in WMMA fragment order). The oracle maps them back through the device
|
||||
# row's RadUnrelayoutFn and decodes them before comparing; a row that relayouts without publishing
|
||||
# an inverse is reported NOT CHECKED by name, which is a coverage gap, not a pass. The fp8 rows,
|
||||
# the int8 (i8a8) block rows, the MoE 4-bit expert plane and its E4M3 scale views (both grouped
|
||||
# GEMMs, every class) and the dense w4 rows are checked; the w8a16, w8a8, w2a8 and mxfp4 rows are
|
||||
# not.
|
||||
#
|
||||
# WHAT A DISAGREEMENT DOES NOT MEAN. The kernel that claims a weight relayouts its canonical
|
||||
# planes at load, and libr4d's fp8a8 weights are held in WMMA fragment order -- the same bytes,
|
||||
# permuted. The oracle puts those back through the device row's own RadUnrelayoutFn to the planes
|
||||
# and decodes them before it compares; a row that relayouts a weight and publishes no inverse is
|
||||
# NOT CHECKED and says so by name. Read those lines: they are coverage this instrument does not
|
||||
# have. The fp8 rows, the int8 (i8a8) block rows, the MoE 4-bit expert plane and its E4M3 scale
|
||||
# views (both grouped GEMMs, every class) and the dense w4 rows answer; the w8a16, w8a8, w2a8 and
|
||||
# mxfp4 rows do not.
|
||||
# `gemm_w2a8_nt` (the 2-bit draft head on every speculating container: mtp.draft_head.weight,
|
||||
# dspark.draft_head.weight, dflash.draft_head.weight) is a missing zero point, not a missing
|
||||
# inverse. It uses an unsigned asymmetric grid, value = (code - zero) * scale per (row, group of
|
||||
# 128), and the zero plane lives in `b_scale` beside the scale (r4d.w2a8.sz.g128, a packed pair a
|
||||
# dword). The reference reads `b` as codes and `b_scale` as a symmetric scale, so closing this
|
||||
# needs a zero point in `gemm_nt_q`'s schema and an asymmetric reader in libref. r4d_selftest's
|
||||
# gemm_w2a8_nt case covers it against a host decode of the canonical planes, and since the draft
|
||||
# head only proposes tokens the target verifies, an error here costs acceptance, never output.
|
||||
#
|
||||
# NOT EVERY GAP IS AN INVERSE SOMEBODY HAS NOT WRITTEN, AND THIS ONE IS A MISSING ZERO POINT.
|
||||
# `gemm_w2a8_nt` -- the 2-bit draft head, live on EVERY speculating container, and the same gap
|
||||
# under all three drafters (mtp.draft_head.weight, dspark.draft_head.weight,
|
||||
# dflash.draft_head.weight) -- is stored on an UNSIGNED ASYMMETRIC grid, value = (code - zero) *
|
||||
# scale per (row, group of 128).
|
||||
#
|
||||
# An inverse for the WEIGHT operand alone cannot close it, and not because the permutation is hard:
|
||||
# undoing the fragment order to a plane of unsigned codes is the same work the fp8 rows already do.
|
||||
# The obstruction is that `zero` is not in that operand. The weight's zero plane is taken by
|
||||
# `b_scale` beside its scale plane (r4d.w2a8.sz.g128, a packed pair a dword), and the reference
|
||||
# reads `b` as codes and `b_scale` as a symmetric scale -- it has no zero point to apply.
|
||||
#
|
||||
# What would close it is a zero point in `gemm_nt_q`'s schema and an asymmetric reader in libref,
|
||||
# which is a FEATURE and not a missing hook. The row is covered instead by r4d_selftest's own
|
||||
# gemm_w2a8_nt case, against a host decode of the canonical planes -- and what the draft
|
||||
# head produces is a PROPOSAL the target verifies with its own head, so an error here costs
|
||||
# acceptance and cannot change a token the model emits.
|
||||
#
|
||||
# A COLLECTIVE IS CHECKED ONLY WHERE BOTH RANKS ARM ON THE SAME ISSUE, AND AN OPS FILTER IS WHAT
|
||||
# BREAKS THAT. libref's all_reduce is a RENDEZVOUS: it parks on a barrier until every rank has
|
||||
# handed in its message. The oracle arms each rank on that rank's OWN issue counter and spends
|
||||
# that rank's OWN budget, so the two sides have to arrive together. Unfiltered they mostly do --
|
||||
# about one collective in ten is refused over a tp2 decode. A NARROW ops list is what pulls
|
||||
# them apart -- the budget is then spent only on the named ops, the ranks do not issue the same
|
||||
# ones (an expert-parallel split alone sees to that), and one rank reaches the collective armed
|
||||
# while the other does not. What comes back then is
|
||||
# Collectives are checked only when both ranks arm on the same issue. libref's all_reduce is a
|
||||
# rendezvous: it waits on a barrier for every rank's message. Each rank arms on its own issue
|
||||
# counter and spends its own budget, so the ranks must arrive together. Unfiltered, about one
|
||||
# collective in ten is refused over a tp2 decode. A narrow OPS list makes it worse: the ranks do
|
||||
# not issue the same named ops (an expert-parallel split alone ensures that), so one rank arrives
|
||||
# armed and the other does not, giving
|
||||
#
|
||||
# oracle #609 op 'all_reduce': the host kernel REFUSED ... with device error
|
||||
# oracle #620 op 'all_reduce': the host kernel REFUSED ... with shape this kernel does not serve
|
||||
#
|
||||
# which are the 30-second barrier timeout and, on the next attempt, the peer's stale message
|
||||
# length. Neither is a finding about all_reduce. Sweep collectives with OPS=*, or at TP=1 where
|
||||
# world_size is 1 and the reference answers in place; the two-rank wire also has its own tests
|
||||
# (tests/wire_test.cpp and the tp2 determinism gate).
|
||||
# (the 30-second barrier timeout, then the peer's stale message length). Neither is a finding about
|
||||
# all_reduce. Sweep collectives with OPS=*, or at TP=1 where world_size is 1 and the reference
|
||||
# answers in place; the two-rank wire has its own tests (tests/wire_test.cpp and the tp2
|
||||
# determinism gate).
|
||||
#
|
||||
# A ROUTED EXPERT GEMM IS THE EXPENSIVE ONE. Its weight operand is a table of the layer's whole
|
||||
# expert set and the snapshot materialises all of it, twice, plus the inverted copy -- some
|
||||
# gigabytes an issue. MAXN=2 is a sweep, not a limitation of the instrument.
|
||||
# Ops with no libref row report "0 op(s) checked, N skipped for want of a reference kernel": the five
|
||||
# QSA ops (qsa_block_key, qsa_score, qsa_select, qsa_work, qsa_tail_store), dflash_conv,
|
||||
# gate_quant_fp8, router_topk_scatter, qk_norm_rope_gate and ar_rmsnorm_quant_fp8. Each has a
|
||||
# numeric case in r4d_selftest (the QSA ops against f64 evaluations of their formulae, a host sort
|
||||
# and a host walk; the four fusions byte-identical against the unfused pair they replace). What is
|
||||
# missing is only the check on the engine's own operands.
|
||||
#
|
||||
# WHAT HAS NO HOST KERNEL AT ALL, on top of the inverses above. Ten ops the architectures declare
|
||||
# have no libref row, so naming one reports "0 op(s) checked, N skipped for want of a host kernel":
|
||||
# the five QSA ops (qsa_block_key, qsa_score, qsa_select, qsa_work, qsa_tail_store), dflash_conv,
|
||||
# gate_quant_fp8, router_topk_scatter, qk_norm_rope_gate and ar_rmsnorm_quant_fp8.
|
||||
# Coverage across Flash-Next (four-bit MoE, QSA, PLE), Qwen3.6-35B-A3B (fp8 MoE), the 27B dense
|
||||
# with the DFlash2 drafter and MiniCPM5-2B with DSpark: 42 distinct op types, every comparison
|
||||
# made agrees. Every speculating container leaves NOT CHECKED only `gdn_recurrent_update` under
|
||||
# the anchor state form (covered by r4d_selftest) and the w2a8 draft head weight above.
|
||||
#
|
||||
# THAT IS NOT THE SAME AS UNCHECKED. Every one of them has a numeric case in r4d_selftest -- the
|
||||
# QSA ops against f64 evaluations of their own formulae, a host sort and a host walk; the four
|
||||
# fusions against the unfused pair they replace, which is a BYTE-IDENTICAL check and stronger than
|
||||
# any tolerance this instrument applies. What the missing rows cost is this instrument's own
|
||||
# question: whether the kernel holds on the ENGINE'S operands rather than on invented ones.
|
||||
#
|
||||
# ACROSS THE FOUR ARCHITECTURES THE GAPS ARE THE SAME THREE. Flash-Next (four-bit MoE, QSA, PLE),
|
||||
# Qwen3.6-35B-A3B (fp8 MoE), the 27B dense with the DFlash2 drafter, and MiniCPM5-2B with DSpark
|
||||
# issue 42 distinct op types between them, and every comparison made agrees. What every
|
||||
# speculating container leaves NOT CHECKED is `gdn_recurrent_update` under the anchor state form
|
||||
# (which r4d_selftest covers instead), `quant_act_i8`'s asum arm, and the w2a8 draft head weight
|
||||
# above. Nothing else.
|
||||
#
|
||||
# A NARROW SWEEP IS STILL WORTH RUNNING: at MAXN=400 the budget is spent inside the prefill of a
|
||||
# deep model, so the drafter and the sampler chain are only reached with FROM past it or with an OPS
|
||||
# list that skips the GEMMs. Both, for a full picture.
|
||||
# At MAXN=400 the budget is spent inside the prefill of a deep model; reach the drafter and the
|
||||
# sampler chain with FROM past the prefill or an OPS list that skips the GEMMs. Run both for a
|
||||
# full picture.
|
||||
#
|
||||
# OPS=a,b op names, or * for every op MAXN=8 stop after this many checks
|
||||
# FROM/TO issue-index window TOL=0.02 relative tolerance
|
||||
@@ -97,7 +73,9 @@
|
||||
P="${P:-8302}"
|
||||
M="${M:-$HOME/models/rad/minicpm5-2b-dspark.v2.rad}"
|
||||
pkill -f "port $P"; while pgrep -f "port $P" >/dev/null; do sleep 1; done
|
||||
cd "$HOME/workspace/radiance/build" || exit 1
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD="${BUILD:-$ROOT/build}"
|
||||
cd "$BUILD" || exit 1
|
||||
env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 \
|
||||
RADIANCE_OP_ORACLE="${OPS:-*}" \
|
||||
RADIANCE_OP_ORACLE_MAX="${MAXN:-8}" \
|
||||
@@ -105,7 +83,7 @@ env GPU_MAX_ALLOC_PERCENT=100 GPU_MAX_HEAP_SIZE=100 \
|
||||
RADIANCE_OP_ORACLE_TOL="${TOL:-0.02}" \
|
||||
${TO:+RADIANCE_OP_ORACLE_TO=$TO} \
|
||||
nohup ./bin/radiance --model "$M" \
|
||||
--radiance-home "$HOME/workspace/radiance/build/radiance_home" \
|
||||
--radiance-home radiance_home \
|
||||
--host 127.0.0.1 --port "$P" \
|
||||
--max-num-seqs 1 --max-model-len "${MLEN:-8192}" --tp "${TP:-1}" \
|
||||
--gpu-headroom-mib "${HR:-512}" --kv-cache-dtype "${KVD:-bf16}" \
|
||||
@@ -124,6 +102,6 @@ curl -s -m 900 "http://127.0.0.1:$P/v1/completions" -H 'Content-Type: applicatio
|
||||
echo
|
||||
pkill -f "port $P"; while pgrep -f "port $P" >/dev/null; do sleep 1; done
|
||||
echo "=== verdicts ==="
|
||||
# The per-operand detail stays in the log; a MISMATCH line names the op and the kernel, and the
|
||||
# NOT CHECKED lines are the coverage gaps. Both are what a sweep is read for.
|
||||
# Per-operand detail stays in the log. A MISMATCH line names the op and the kernel; NOT CHECKED
|
||||
# lines are the coverage gaps.
|
||||
grep -E "oracle #|op oracle|NOT CHECKED" "$HOME/oracle.log" | sed 's/^W //'
|
||||
+41
-57
@@ -1,25 +1,23 @@
|
||||
#!/bin/sh
|
||||
# tiercross.sh -- two conversations through the tiers at once. Does either get the other's state?
|
||||
# tiercross.sh -- two conversations through the KV tiers at once; checks that neither is served
|
||||
# the other's state.
|
||||
#
|
||||
# WHY THIS IS NOT tierident.sh WITH A SECOND PROMPT. That script asks ONE prompt four times and
|
||||
# compares the four answers, which proves a session survives the round trip. It cannot, by
|
||||
# construction, see the failure this one is for: with a single conversation in the server there is
|
||||
# no other conversation's bytes for it to be served. The cross-contamination failures a tiered
|
||||
# cache can have -- an entry holding reassigned block ids, a checkpoint slot freed by one session
|
||||
# and still named by another -- need two sessions in flight to show up at all.
|
||||
# tierident.sh checks that one session survives the round trip, but with one conversation there is
|
||||
# nothing else to be served. Cross-contamination (an entry holding reassigned block ids, a
|
||||
# checkpoint slot freed by one session and still named by another) needs two sessions in flight.
|
||||
#
|
||||
# A HOST TIER THE FILLER OVERFLOWS, so the arena's drops run as well as its restores:
|
||||
# Start the server with a host tier the filler overflows, so the arena's drops run as well as its
|
||||
# restores:
|
||||
#
|
||||
# --prefix-cache-mib 512
|
||||
#
|
||||
# AND ENOUGH SNAPSHOT SLOTS FOR BOTH SESSIONS. On a hybrid model a hit is clamped to the deepest
|
||||
# snapshot it reaches, and a store too small for both makes each session retire the other's: every
|
||||
# arm then re-prefills from zero and restores nothing, so the device arm's reuse is checked below.
|
||||
# The default --checkpoint-slots holds both.
|
||||
# It also needs snapshot slots for both sessions. On a hybrid model a hit is clamped to the deepest
|
||||
# snapshot it reaches; a store too small for both makes each session retire the other's, and every
|
||||
# arm re-prefills from zero (checked below via the device arm's reuse). The default
|
||||
# --checkpoint-slots holds both.
|
||||
#
|
||||
# EACH SESSION IS COMPARED ONLY TO ITSELF. A and B are different prompts and their answers differ
|
||||
# for ordinary reasons; what must hold is that A's restored answer is A's cold answer. Corrupt
|
||||
# state does not produce babble, it produces B's train of thought under A's question.
|
||||
# Each session is compared only to itself: A's restored answer must equal A's reference. Corrupt
|
||||
# state typically shows as B's train of thought under A's question.
|
||||
set -e
|
||||
|
||||
P=${P:-8100}
|
||||
@@ -32,14 +30,12 @@ trap 'rm -rf "$work"' EXIT INT TERM
|
||||
|
||||
command -v jq >/dev/null || { echo "tiercross: jq is required" >&2; exit 2; }
|
||||
|
||||
# TWO PROMPTS THAT SHARE NO PREFIX. A shared opening would put both sessions on the same chain for
|
||||
# its length, and the blocks they then share are legitimately one another's -- which is the whole
|
||||
# point of a prefix cache and would make a difference here unreadable. They diverge at token one.
|
||||
# Two prompts that diverge at the first token: a shared opening would legitimately share blocks
|
||||
# and blur the comparison.
|
||||
#
|
||||
# EACH HAS TO PRODUCE AN ANSWER. A wall of repeated sentences is a passage an instruction-tuned
|
||||
# model can reasonably answer with a single EOS, and every arm of that session would then compare
|
||||
# an empty string to an empty string. Both lengths are checked below, because a vacuous green here
|
||||
# is worse than a red.
|
||||
# Each must produce a real answer. An instruction-tuned model may answer a wall of repeated
|
||||
# sentences with a single EOS, and every arm would then compare empty strings; both lengths are
|
||||
# checked below.
|
||||
mk() { # mk <file> <subject> <opening> <question>
|
||||
: > "$1"
|
||||
i=0
|
||||
@@ -53,10 +49,8 @@ mk "$work/a.txt" "Chapter" "The paged pool is layer-major, so one logical block
|
||||
"Using only the passage above, write three sentences about it."
|
||||
mk "$work/b.txt" "Entry" "The linear layer keeps one state per sequence and updates it token by token." \
|
||||
"Using only the passage above, write three sentences about it."
|
||||
# THE FILES ARE THE PROMPTS, READ VERBATIM, through jq's --rawfile. Flattening them into shell
|
||||
# variables deletes the line breaks the prompts' SHAPE depends on, and a passage whose question
|
||||
# ends up welded to the last sentence is one this model answers with an immediate EOS (the same
|
||||
# reasoning is in tierident.sh).
|
||||
# The files are sent verbatim through jq's --rawfile. Shell variables would lose the line breaks,
|
||||
# and a question joined to the passage's last sentence gets an immediate EOS (as in tierident.sh).
|
||||
|
||||
ask() { # ask <who> <label> -> sha of the answer
|
||||
f="$work/$(printf '%s' "$1" | tr 'AB' 'ab').txt"
|
||||
@@ -69,30 +63,23 @@ ask() { # ask <who> <label> -> sha of the answer
|
||||
sha1sum < "$work/$2.txt" | cut -d' ' -f1
|
||||
}
|
||||
|
||||
# THE HIT LENGTH, which is what decides how the prefill is chunked and therefore the shape every
|
||||
# GEMM in it runs at. Two restores that recovered different amounts of prefix are not the same
|
||||
# computation, and comparing their output hashes would be comparing two different runs -- so this
|
||||
# is printed beside every arm and checked before a mismatch is called corruption.
|
||||
# The hit length decides how the prefill is chunked and so every GEMM's shape. Restores that
|
||||
# recovered different prefix lengths are different computations, so the hit is printed beside every
|
||||
# arm and checked before a mismatch is called corruption.
|
||||
hit() { jq -r '.usage.prompt_tokens_details.cached_tokens' < "$work/$1.json"; }
|
||||
|
||||
fail=0
|
||||
# WHAT A DIFFERING HASH MEANS, AND THE ONE THING THAT HAS TO BE RULED OUT FIRST.
|
||||
# A hybrid session's reuse is clamped by the scheduler to the last linear checkpoint it can reach,
|
||||
# not the attention hit (core/sched/scheduler.cpp, admit_one: RadBatch carries one query length for
|
||||
# every KV group). Reuse is therefore a multiple of the checkpoint interval, depending on which
|
||||
# snapshots survived: 0 on a cold run, 4096 or 6144 on a restored one.
|
||||
#
|
||||
# A hybrid session's reuse is clamped by the scheduler to the last LINEAR CHECKPOINT it can reach,
|
||||
# not to the attention hit (core/sched/scheduler.cpp, admit_one: RadBatch carries one query length
|
||||
# for every KV group, so the linear layers cannot be replayed over a longer range than the
|
||||
# attention ones). So reuse is always a multiple of the checkpoint interval, and which multiple
|
||||
# depends on which snapshots survived -- 0 on a cold run, 4096 or 6144 on a restored one.
|
||||
# On Qwen3.8-Flash-Next with no tiers, the same prompt at reuse 0, 4096 and 6144 gives the same
|
||||
# bytes, so a differing hash is a real difference. On another model, re-check that first: a
|
||||
# near-tie that flips at the chunk boundary looks like corruption.
|
||||
#
|
||||
# Reuse does not change the answer on Qwen3.8-Flash-Next: with no tiers running at all, the same
|
||||
# prompt at reuse 0, 4096 and 6144 gives the same bytes. So a differing hash is a real difference
|
||||
# and not an artefact of a shorter hit -- but it is the first thing to re-check if this fails on
|
||||
# another model, because a near-tie that flips with the chunk boundary would look exactly like
|
||||
# corruption and is not.
|
||||
#
|
||||
# THE COMPARISON IS AGAINST THE DEVICE-HIT ARM, not the cold one. A cold run reuses nothing by
|
||||
# definition, so comparing a restore to it would always be comparing two different hit lengths;
|
||||
# the device hit is the same query the restored arms run, served out of VRAM.
|
||||
# Restored arms are compared against the device-hit arm, not the cold one: the device hit is the
|
||||
# same query served from VRAM, while a cold run always has a different hit length.
|
||||
cmp_arm() { # cmp_arm <label> <sha> <ref sha> <reuse> <ref reuse>
|
||||
if [ "$2" = "$3" ]; then
|
||||
echo " ok $1 (reuse $4)"
|
||||
@@ -109,11 +96,10 @@ cmp_arm() { # cmp_arm <label> <sha> <ref sha> <reuse> <ref reu
|
||||
fi
|
||||
}
|
||||
# ---- pushing a session out of host memory --------------------------------------------------------
|
||||
# A FULL HOST TIER DROPS ITS LEAST RECENTLY USED ENTRIES, so the way to push the sessions out is to
|
||||
# give the arena something else to hold: a prompt that shares no prefix with anything here and is
|
||||
# bigger than the room the arena has left. The server must be started with a host tier FILL
|
||||
# sections of it overflow; --prefix-cache-mib 512 holds about 27K tokens on Qwen3.8-Flash-Next, and
|
||||
# the default FILL is about 30K.
|
||||
# A full host tier drops its least recently used entries, so the sessions are pushed out by a
|
||||
# prompt that shares no prefix with them and exceeds the arena's free room. The host tier must be
|
||||
# small enough for FILL sections to overflow it: --prefix-cache-mib 512 holds about 27K tokens on
|
||||
# Qwen3.8-Flash-Next, and the default FILL is about 30K.
|
||||
fill_arena() {
|
||||
: > "$work/fill.txt"
|
||||
i=0
|
||||
@@ -134,8 +120,7 @@ CKS=$(curl -sS --fail "http://$H:$P/sessions" | jq -r .snapshot_store.bytes_each
|
||||
A0=$(ask A a0); B0=$(ask B b0)
|
||||
echo " first A $A0 reuse $(hit a0)"
|
||||
echo " B $B0 reuse $(hit b0)"
|
||||
# AND THEY MUST DIFFER. Two prompts that produce the same answer would make every comparison
|
||||
# below pass whatever the tiers did with them.
|
||||
# The two answers must differ, or every comparison below would pass regardless.
|
||||
if [ "$A0" = "$B0" ]; then
|
||||
echo "tiercross: both prompts produced the same answer, so no comparison here can tell the" >&2
|
||||
echo " two sessions apart. Change the prompts." >&2
|
||||
@@ -148,13 +133,12 @@ for f in a0 b0; do
|
||||
done
|
||||
|
||||
# ---- the control: both sessions again, straight out of VRAM -------------------------------------
|
||||
# THE SAME QUERY THE RESTORED ARMS WILL RUN. Without it a differing hash below proves nothing: this
|
||||
# engine could be irreproducible across requests for reasons that have nothing to do with tiering,
|
||||
# and the two sessions could be contaminating each other while both are still resident.
|
||||
# The same query the restored arms run. Without this control a differing hash below could come from
|
||||
# non-tiering irreproducibility, or from contamination while both sessions are still resident.
|
||||
AH=$(ask A ah); BH=$(ask B bh)
|
||||
echo " device A $AH reuse $(hit ah)"
|
||||
echo " B $BH reuse $(hit bh)"
|
||||
# A DEVICE HIT THAT REUSED NOTHING TESTS NOTHING: every arm below would be a fresh prefill.
|
||||
# A device hit that reused nothing makes every arm below a fresh prefill, testing nothing.
|
||||
for f in ah bh; do
|
||||
case "$(hit $f)" in 0|null|"") echo " FAIL the $f arm reused nothing -- no hit, so no restore below can be tested
|
||||
(a snapshot store too small for both sessions? --checkpoint-slots)"; fail=$((fail + 1)) ;; esac
|
||||
@@ -185,7 +169,7 @@ cmp_arm "B after the arena's drops is still B" "$B2" "$BH" "$(hit b2)" "$(hit bh
|
||||
|
||||
curl -sS --fail "http://$H:$P/sessions" > "$work/s.json"
|
||||
echo " moved: blocks to_host=$(jq -r .moved.to_host < "$work/s.json") promoted=$(jq -r .moved.promoted < "$work/s.json") host_drops=$(jq -r .moved.host_drops < "$work/s.json")"
|
||||
# A RUN WITH NO CONTENTION TESTED THE EASY CASE: the arena has to run out for its drop path to run.
|
||||
# The drop path runs only if the arena ran out of room.
|
||||
[ "$(jq -r .moved.host_drops < "$work/s.json")" = "0" ] && \
|
||||
echo " note: the host tier never overflowed -- lower --prefix-cache-mib or raise FILL"
|
||||
|
||||
|
||||
+42
-66
@@ -1,30 +1,21 @@
|
||||
#!/bin/sh
|
||||
# tierident.sh -- does a session that left VRAM come back BYTE FOR BYTE, both halves of it?
|
||||
# tierident.sh -- checks that a session that left VRAM comes back byte for byte, attention blocks
|
||||
# and recurrent state both.
|
||||
#
|
||||
# This is the acceptance test for the idle session tiers (core/mem/kvtier.h). It is a byte
|
||||
# comparison because CORRUPT KV DOES NOT READ AS BABBLE -- it reads as fluent, deterministic,
|
||||
# coherent, plausible text that simply is not the text the model would have produced, and nothing
|
||||
# that looks at the engine from outside notices it. Only a byte comparison against a known-good
|
||||
# arm sees it.
|
||||
# Acceptance test for the idle session tiers (core/mem/kvtier.h). Corrupt KV produces fluent,
|
||||
# deterministic, plausible text that is simply not what the model would have produced, so only a
|
||||
# byte comparison against a known-good arm detects it.
|
||||
#
|
||||
# THE CONTROL IS THE WHOLE TEST. Arm 2 asks the same prompt again while the session is still in
|
||||
# VRAM. If that does not reproduce arm 1 exactly, then this model at this temperature is not
|
||||
# reproducible across requests at all and every later comparison is meaningless -- a differing sha
|
||||
# would prove nothing, because a cache hit COULD have been legitimately tie-divergent. Run the
|
||||
# control or do not run the test.
|
||||
# The control is essential: arm 2 asks the same prompt while the session is still in VRAM. If it
|
||||
# does not reproduce arm 1 exactly, the server is not reproducible across requests and every later
|
||||
# comparison is meaningless, so the script stops.
|
||||
#
|
||||
# ============================== AND ON A HYBRID MODEL, HALF THE TEST IS INVISIBLE ===============
|
||||
#
|
||||
# A session on a hybrid model is attention blocks AND a recurrent-state snapshot. The two are
|
||||
# stored separately and can be lost separately -- and losing the snapshot IS NOT VISIBLE IN THE
|
||||
# TEXT. The engine simply replays the linear layers from an older checkpoint, or from token zero,
|
||||
# and produces exactly the same answer, slower. So byte identity proves the blocks came back and
|
||||
# says nothing whatever about the state.
|
||||
#
|
||||
# That is why every snapshot assertion below is a counter and not a sha. A run where the blocks
|
||||
# moved and the snapshots did not is a PASS by text and a FAILURE here, and it is the failure that
|
||||
# matters: it is the difference between a restored 200K session costing a second and costing a
|
||||
# minute of linear replay.
|
||||
# On a hybrid model a session is attention blocks plus a recurrent-state snapshot, stored and lost
|
||||
# separately. A lost snapshot does not change the text: the engine replays the linear layers from
|
||||
# an older checkpoint or token zero and gives the same answer, slower. Byte identity therefore
|
||||
# proves only the blocks, and every snapshot assertion is a counter. Blocks moving without the
|
||||
# snapshot is a failure here: for a restored 200K session it is the difference between a second
|
||||
# and a minute of linear replay.
|
||||
#
|
||||
# scripts/tierident.sh # against a server already up on $P (default 8100)
|
||||
#
|
||||
@@ -47,17 +38,12 @@ trap 'rm -rf "$work"' EXIT INT TERM
|
||||
|
||||
command -v jq >/dev/null || { echo "tierident: jq is required" >&2; exit 2; }
|
||||
|
||||
# A PROMPT LONG ENOUGH TO BE WORTH TIERING, AND LONGER THAN A CHECKPOINT INTERVAL. The unit of the
|
||||
# attention half is the block, so a prompt of a few tokens occupies one and exercises nothing. The
|
||||
# unit of the linear half is the checkpoint interval -- 2048 tokens by default -- and a prompt
|
||||
# shorter than that produces NO snapshot at all, so every snapshot assertion below would be
|
||||
# vacuously satisfied by a server where snapshot tiering is entirely broken.
|
||||
# The prompt must span many blocks and exceed a checkpoint interval (2048 tokens by default):
|
||||
# shorter, it produces no snapshot and every snapshot assertion passes vacuously.
|
||||
#
|
||||
# AND IT HAS TO ASK FOR SOMETHING. A wall of repeated sentences with no question at the end is a
|
||||
# passage an instruction-tuned model can answer with a single EOS, and every arm would then compare
|
||||
# an empty string to an empty string and report the control green. That is the same failure this
|
||||
# whole script is built around -- a comparison that passes because neither side has any content --
|
||||
# so the answer length is checked below as well.
|
||||
# It must also ask a question. An instruction-tuned model may answer a wall of repeated sentences
|
||||
# with a single EOS, and empty answers would pass the control, so the answer length is checked
|
||||
# below.
|
||||
: > "$work/p.txt"
|
||||
i=0
|
||||
while [ $i -lt 300 ]; do
|
||||
@@ -65,10 +51,9 @@ while [ $i -lt 300 ]; do
|
||||
i=$((i + 1))
|
||||
done
|
||||
printf '\nUsing only the passage above, write three sentences about it.\n\nAnswer: ' >> "$work/p.txt"
|
||||
# THE FILE IS THE PROMPT, READ VERBATIM, through jq's --rawfile. Escaping it by hand into a shell
|
||||
# variable doubles the backslash jq adds before every quote, and flattening its newlines welds the
|
||||
# question onto the passage ("...why it matters.Answer:" on one line), which this model answers
|
||||
# with an immediate EOS -- the empty-completion failure described above.
|
||||
# The file is sent verbatim through jq's --rawfile. Escaping it into a shell variable doubles the
|
||||
# backslash jq adds before every quote, and flattening newlines joins the question to the passage
|
||||
# ("...why it matters.Answer:"), which gets an immediate EOS.
|
||||
|
||||
ask() { # ask <label> -> writes $work/<label>.txt, echoes its sha
|
||||
jq -n --rawfile p "$work/p.txt" --argjson n "$N" \
|
||||
@@ -80,11 +65,10 @@ ask() { # ask <label> -> writes $work/<label>.txt, echoes
|
||||
sha1sum < "$work/$1.txt" | cut -d' ' -f1
|
||||
}
|
||||
# ---- pushing a session out of host memory --------------------------------------------------------
|
||||
# A FULL HOST TIER DROPS ITS LEAST RECENTLY USED ENTRIES, so the way to push a session out is to give
|
||||
# the arena something else to hold: a prompt that shares no prefix with anything here and is bigger
|
||||
# than the room the arena has left. The server must be started with a host tier FILL sections of it
|
||||
# overflow; --prefix-cache-mib 512 holds about 27K tokens on Qwen3.8-Flash-Next, and the default
|
||||
# FILL is about 30K.
|
||||
# A full host tier drops its least recently used entries, so the session is pushed out by a
|
||||
# prompt that shares no prefix with it and exceeds the arena's free room. The host tier must be
|
||||
# small enough for FILL sections to overflow it: --prefix-cache-mib 512 holds about 27K tokens on
|
||||
# Qwen3.8-Flash-Next, and the default FILL is about 30K.
|
||||
fill_arena() {
|
||||
: > "$work/fill.txt"
|
||||
i=0
|
||||
@@ -100,10 +84,9 @@ fill_arena() {
|
||||
}
|
||||
snap() { curl -sS --fail "http://$H:$P/sessions" > "$work/s.json"; }
|
||||
q() { jq -r "$1" < "$work/s.json"; }
|
||||
# PROMPT TOKENS A LOOKUP COVERED WITH RECURRENT STATE. Moving a snapshot and moving it back proves
|
||||
# the bytes travelled and nothing more; this is the number that says a hit then SERVED one. They
|
||||
# are not the same claim -- a restore that puts the state back somewhere the chain cannot reach
|
||||
# scores perfectly on the first and zero on this.
|
||||
# Prompt tokens a lookup covered with recurrent state. A snapshot moving out and back only proves
|
||||
# the bytes travelled; this counter shows a hit actually served it. A restore to a place the chain
|
||||
# cannot reach passes the first and scores zero here.
|
||||
lin() { jq -r ".linear.cached_tokens" < "$work/s.json"; }
|
||||
|
||||
where() { # where -> "vram=N ram=N [+ snapshots]" for the whole server
|
||||
@@ -124,9 +107,8 @@ note() { echo " FAIL $1"; fail=$((fail + 1)); }
|
||||
|
||||
echo "tierident: $H:$P, ${TO_HOST}s for VRAM to go, $FILL filler sections to push host memory out"
|
||||
|
||||
# IS THERE A LINEAR HALF AT ALL. A pure-attention model has no snapshots and must not be failed
|
||||
# for having none; a hybrid one with a snapshot store of zero slots is a real misconfiguration and
|
||||
# is named as one rather than skipped.
|
||||
# A pure-attention model has no snapshots and is not failed for it; a hybrid model with zero
|
||||
# snapshot slots is a misconfiguration and is reported.
|
||||
snap
|
||||
HYBRID=0
|
||||
[ "$(q .snapshot_store.bytes_each)" != "0" ] && HYBRID=1
|
||||
@@ -141,8 +123,7 @@ fi
|
||||
COLD=$(ask cold)
|
||||
echo " cold $COLD [$(where)]"
|
||||
|
||||
# AN EMPTY ANSWER MAKES EVERY COMPARISON BELOW VACUOUS, and it is the easiest way for this script
|
||||
# to report a confident green having tested nothing: three identical shas of the empty string.
|
||||
# An empty answer would make every comparison below pass vacuously.
|
||||
CN=$(wc -c < "$work/cold.txt")
|
||||
if [ "$CN" -lt 32 ]; then
|
||||
echo "tierident: the model answered $CN bytes. Every sha below would match for that reason" >&2
|
||||
@@ -165,19 +146,15 @@ echo " waiting $((TO_HOST + 8))s for the session to leave VRAM..."
|
||||
sleep $((TO_HOST + 8))
|
||||
W=$(where)
|
||||
echo " after the host threshold [$W]"
|
||||
# A RUN THAT MOVED NOTHING IS A FAILURE, NOT A PASS. This is the trap the whole script exists to
|
||||
# avoid, turned on itself: if the session never left VRAM then every arm below is an ordinary
|
||||
# device hit, the shas match for a reason that has nothing to do with tiering, and reporting PASS
|
||||
# would be exactly the false confidence a byte comparison is supposed to replace.
|
||||
# A run that moved nothing is a failure: every arm below would be an ordinary device hit.
|
||||
snap
|
||||
# A MISSING FIELD IS THE SAME FAILURE AS A ZERO: if the /sessions layout changes, this guard reads
|
||||
# `null`, and treating that as a pass would pass vacuously.
|
||||
# A missing field counts as zero, so a changed /sessions layout (`null`) fails rather than passes.
|
||||
case "$(q .blocks_sum_overlapping.host)" in 0|null|"") false ;; *) true ;; esac || note "the session never left VRAM -- nothing below would test anything
|
||||
(--prefix-cache-mib set? is the maintenance pass running?)"
|
||||
if [ "$HYBRID" = 1 ]; then
|
||||
snap
|
||||
# A SNAPSHOT IS IN HOST MEMORY FROM THE MOMENT IT IS SAVED (the checkpoint store), so the
|
||||
# session's state must be there -- nowhere else is a place it can be.
|
||||
# Snapshots live in host memory (the checkpoint store) from the moment they are saved, so the
|
||||
# session's state must be there.
|
||||
case "$(q .snapshots_sum_overlapping)" in 0|null|"") false ;; *) true ;; esac || \
|
||||
note "the session holds no linear-state snapshot, so the restore below tests the blocks only"
|
||||
fi
|
||||
@@ -188,8 +165,8 @@ echo " restored from RAM $FROMHOST [$(where)]"
|
||||
check "a session restored from RAM reproduces the cold answer" "$FROMHOST" "$COLD"
|
||||
if [ "$HYBRID" = 1 ]; then
|
||||
snap
|
||||
# A SNAPSHOT NEEDS NO READ: it is restored straight out of its slot in the store. Whether it was
|
||||
# SERVED is the check.
|
||||
# A snapshot is restored straight from its slot in the store; the check is whether it was
|
||||
# served.
|
||||
if [ "$(lin)" -gt "$LIN0" ]; then
|
||||
echo " ok and the restored state was SERVED ($(( $(lin) - LIN0 )) prompt tokens covered by it)"
|
||||
else
|
||||
@@ -199,10 +176,9 @@ if [ "$HYBRID" = 1 ]; then
|
||||
fi
|
||||
|
||||
# ---- a full host tier ---------------------------------------------------------------------------
|
||||
# THE FILLER OVERFLOWS THE ARENA, and the arena drops its least recently used entries -- this
|
||||
# session's -- to make room. What comes back then is a recompute, or a restore of what survived; the
|
||||
# answer is the cold one either way, and an entry the arena dropped that the cache went on serving
|
||||
# would show here as another conversation's context.
|
||||
# The filler overflows the arena, which drops this session's entries as least recently used. The
|
||||
# next answer is a recompute or a partial restore, and must equal the cold one either way; a dropped
|
||||
# entry the cache kept serving would show as another conversation's context.
|
||||
echo " filling host memory with $FILL sections of something else..."
|
||||
snap
|
||||
DROP0=$(q .moved.host_drops)
|
||||
@@ -234,7 +210,7 @@ if [ "$TTL" -gt 0 ]; then
|
||||
check "a session asked again after it expired reproduces the cold answer" "$EXPIRED" "$COLD"
|
||||
fi
|
||||
|
||||
# ---- and the text itself, so a failure says WHERE ----------------------------------------------
|
||||
# ---- the differing text, to locate a failure ---------------------------------------------------
|
||||
if [ "$fail" -ne 0 ]; then
|
||||
echo
|
||||
echo "The first differing line, cold vs the failing arm:"
|
||||
|
||||
Reference in new issue
Block a user