Archived
radiance 1.2.2
- Static YaRN for the Qwen rotary paths (#37): a container whose config names YaRN gets it in attention, the QSA index keys and a DFlash2 drafter; one reader for every rotary type, and a LLaMA container whose type is not served (llama3, longrope, dynamic) is refused by name. - --rope-scaling yarn:FACTOR[:ORIG] (#38) writes YaRN over a container's own rotary keys at load, no reconvert; the persisted prefix cache's fingerprint carries the resolved rotary. - An uneven world's cheaper rank (#36) pages the common token count and gives the rest of its VRAM to its experts; a plan and pool that disagree refuse to start. - MoE prefill (#35): wide gather, parallel scan and run-map prefix, 256-column down tile, early weight loads -- by rule, bit-identical. - MoE decode (#34): the sorted operand's own down kernel, its column tiles by routed rows. - --draft-window fixed|adaptive (#24): a per-sequence draft window priced by measured step time, one head depth per step over the batch; fixed stays the default. New metric radiance:draft_position_accepted_total and Grafana panels. - Out-of-tree plugin builds compile to the tree's device code from any build directory.
This commit is contained in:
1 parent
6fa7707dff
commit
ac79f4dc8a
63 files changed
+2744
-8759
No files matched your search
+33
-26
@@ -459,9 +459,14 @@ whose cache costs most, and one block table serves every rank. Where a rank's ca
|
||||
token -- an attention-zero rank at `--tp 3` keeps no attention cache -- it gets, under
|
||||
`expert_tiered` with both pools derived, a KV pool that pages exactly the common token count and the
|
||||
difference in its weights pool, up to every one of its weights resident; the startup log names the
|
||||
rank and both sizes (`kv: rank N's cache costs ...`). A stated `--vram-kv-mib` or
|
||||
`--vram-weights-mib` is applied to every card unchanged, and an even world is never re-split
|
||||
([`TP3.md`](TP3.md) §1).
|
||||
rank and both sizes (`kv: rank N's cache costs ...`). It holds with or without a lending cache:
|
||||
under `--deterministic`, or on a device without virtual memory management, the bytes that rank
|
||||
would never page go to its experts all the same. A stated `--vram-kv-mib` or `--vram-weights-mib`
|
||||
is applied to every card unchanged, and a rank whose cache costs as much per token as the dearest
|
||||
rank's is never re-split -- which at `--tp 2` and `--tp 4` is every rank. A rank that costs less and
|
||||
keeps the common split says why on the same `kv: rank N's cache costs ...` line. Every rank still
|
||||
allocates its whole `--host-pool-mib`, a re-split rank whose weights all fit on the card included,
|
||||
and that rank's log says its pinned host pool holds no weights ([`TP3.md`](TP3.md) §1).
|
||||
|
||||
**The cache's size decides whether multi-turn works.** The KV side is not only concurrency: prefix
|
||||
caching holds a finished sequence's blocks so the next turn can reuse them. When the pool cannot
|
||||
@@ -744,27 +749,32 @@ from the first token. The reply is the same either way. A hit whose nearest chec
|
||||
point would give back more than two windows is kept whole. `radiance:draft_refills_total` counts
|
||||
the hits ended early and `radiance:draft_refill_tokens_total` the tokens they recomputed.
|
||||
|
||||
**One depth for every request is a compromise; `RADIANCE_DRAFT_ADAPT=1` gives each sequence its
|
||||
own.** Acceptance depends on the text: code and JSON keep accepting deep into the window, prose and
|
||||
summaries fall off after a position or two. With the switch set, `--num-speculative-tokens` is the
|
||||
ceiling, each sequence keeps a smoothed acceptance per draft position, and it drafts into the window
|
||||
that maximises the tokens a step is expected to emit over what that step costs. The costs are
|
||||
`RADIANCE_DRAFT_COST`, the step time at each fixed depth on the same setup, in any unit:
|
||||
**One depth for every request is a compromise; `--draft-window adaptive` lets the text decide.**
|
||||
Acceptance depends on the text: code and JSON keep accepting deep into the window, prose and
|
||||
summaries fall off after a position or two. With the adaptive window, `--num-speculative-tokens` is
|
||||
the ceiling and the engine keeps a smoothed acceptance per draft position for every sequence:
|
||||
|
||||
```sh
|
||||
RADIANCE_DRAFT_ADAPT=1 RADIANCE_DRAFT_COST=1:9.9,2:11.0,3:12.06,4:13.32,5:14.37,6:15.77 \
|
||||
RADIANCE_DRAFT_ADAPT_BUSY=3 radiance --model m.rad --num-speculative-tokens 6
|
||||
radiance --model m.rad --num-speculative-tokens 6 --draft-window adaptive
|
||||
```
|
||||
|
||||
The table belongs to the hardware; without one a step is priced at 1 + 0.06·d. A window moves only
|
||||
past a hysteresis and a hold, because every new window is a new pass shape and a new recording. The
|
||||
table prices a step at one sequence, and with more running a deeper window also costs every
|
||||
neighbour, so `RADIANCE_DRAFT_ADAPT_BUSY=N` caps every window at `RADIANCE_DRAFT_ADAPT_BUSY_DEPTH`
|
||||
(default 3) while more than N sequences run. The window is the serial drafter's policy: with a block
|
||||
drafter the switch is turned off at load, with a warning. At temperature 0 the text is that of a
|
||||
fixed depth wherever fixed depths agree with each other; above 0 it is distribution-exact.
|
||||
`radiance:draft_depth_adaptive` and `radiance:draft_verify_depth_total` (§6.3) show where the
|
||||
windows stand.
|
||||
A serial draft head runs as many rounds as the deepest window in the step, so the depth is chosen
|
||||
for the step, not for one sequence: each step's head depth is the one that maximises the tokens all
|
||||
its sequences are expected to emit over what such a step costs. The cost is measured as the server
|
||||
runs — the time of every decode step, by its depth and by how many sequences it carried — so there
|
||||
is nothing to enter; a depth not yet measured is priced from the nearest one that was. Under that
|
||||
depth each sequence stops at the first draft that would be emitted — it and every draft before it
|
||||
accepted — less than one time in ten, so a prose reply beside a code reply does not pay verify rows
|
||||
for drafts nobody takes. The depth moves only after eight steps and for a two-percent gain, because
|
||||
every new window is a new pass shape and a new recording. A new sequence starts from what the
|
||||
sequences before it finished on, each counted once.
|
||||
|
||||
The adaptive window is the serial draft head's policy. With a block drafter, with prompt lookup
|
||||
alone, or with speculation off the window stays fixed, and the server says so at startup. Prompt
|
||||
lookup proposals made when the head declines are counted in the acceptance metrics but do not move
|
||||
the head's window. At temperature 0 the text is that of a fixed depth wherever fixed depths agree
|
||||
with each other; above 0 it is distribution-exact. `radiance:draft_depth_adaptive` and
|
||||
`radiance:draft_verify_depth_total` (§6.3) show where the windows stand. The default is `fixed`.
|
||||
|
||||
### 4.7 Two cards
|
||||
|
||||
@@ -1031,7 +1041,8 @@ one line naming each one the command line moved.
|
||||
|
||||
| flag | default | |
|
||||
|---|---|---|
|
||||
| `--num-speculative-tokens N` | auto | speculative window; 0 disables |
|
||||
| `--num-speculative-tokens N` | auto | speculative window; 0 disables. The ceiling under `--draft-window adaptive` |
|
||||
| `--draft-window MODE` | fixed | `fixed` drafts N every step; `adaptive` follows each sequence's acceptance and the measured step cost, serial draft heads only (§4.6) |
|
||||
| `--draft-model PATH` | — | **not implemented** — merge at convert time |
|
||||
|
||||
**Server**
|
||||
@@ -1504,7 +1515,7 @@ lists the efforts the chat template takes, or is `null` when it takes any. `serv
|
||||
| `draft_position_reached_total`, `draft_position_accepted_total`, `draft_position_acceptance_ratio` | acceptance by position: the two counters over any window, the ratio since start |
|
||||
| `draft_refills_total`, `draft_refill_tokens_total` | prefix hits ended a drafter window early, and the tokens recomputed (§4.6) |
|
||||
| `decode_rows_unspeculated_total` | rows that never drafted at all |
|
||||
| `draft_depth_adaptive`, `draft_verify_depth_total{depth}` | the adaptive window's mean over the running sequences, and verifies by the drafts they carried; only with `RADIANCE_DRAFT_ADAPT` (§4.6) |
|
||||
| `draft_depth_adaptive`, `draft_verify_depth_total{depth}` | the adaptive window's mean over the running sequences, and verifies by the drafts they carried; only with `--draft-window adaptive` (§4.6) |
|
||||
| `attn_cached_tokens_total`, `linear_cached_tokens_total` | prefix reuse, both halves |
|
||||
| `linear_checkpoints_written_total`, `linear_prefix_cache_hit_rate` | |
|
||||
| `prefix_cache_evictions_total`, `prefix_cache_ckpt_evictions_total` | |
|
||||
@@ -1618,10 +1629,6 @@ rad-kbench --home $RADIANCE_HOME --max-cases 1 # are the kernels correct at al
|
||||
| `RADIANCE_HOME` | where `kernels/`, `architectures/` and `quantizers/` live; a `:`-separated search path, the first home winning. Same as `--radiance-home` |
|
||||
| `RADIANCE_KERNELS` | default kernel hierarchy, comma-separated. Same as `--kernels`, read by the engine *and* every tool, so a plugin validated with `rad-kbench` can be served without editing launchers |
|
||||
| `RADIANCE_LOG` | `error` \| `warn` \| `info` \| `debug` \| `trace` |
|
||||
| `RADIANCE_DRAFT_ADAPT` | `1`: a draft window per sequence, `--num-speculative-tokens` the ceiling (§4.6) |
|
||||
| `RADIANCE_DRAFT_COST` | with it, the step cost by depth, `d:cost,…` |
|
||||
| `RADIANCE_DRAFT_ADAPT_BUSY`, `_BUSY_DEPTH` | above N running sequences, every window capped at `_BUSY_DEPTH` (3) |
|
||||
| `RADIANCE_DRAFT_ADAPT_HYST`, `_HOLD`, `_HALFLIFE`, `_PRIOR`, `_MIN` | the policy's knobs: 0.02, 8 verifies, 16 verifies, 0.8, 1 |
|
||||
| `ROCM_PATH` | where ROCm lives, if not `/opt/rocm` |
|
||||
| `HF_TOKEN` | for `scripts/hfget.sh` on a gated repo |
|
||||
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ not.
|
||||
| `ple_gate` | | device | host |
|
||||
| `qk_norm_rope` | | - | host |
|
||||
| `qk_norm_rope_gate` | | device | - |
|
||||
| `qsa_block_key` | | device | - |
|
||||
| `qsa_block_key` | | device | host |
|
||||
| `qsa_score` | | device | - |
|
||||
| `qsa_select` | | device | - |
|
||||
| `qsa_tail_store` | | device | - |
|
||||
|
||||
+8
-2
@@ -1161,7 +1161,7 @@ stages of its sorting network when the runs are a power of two long and fill the
|
||||
over two runs of 1024 where a full sort is 66 -- and the whole network otherwise. A producer that
|
||||
hands it unsorted runs gets a wrong order, not a slow one.
|
||||
|
||||
## Sparse attention (QSA) — device-only
|
||||
## Sparse attention (QSA)
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
@@ -1173,7 +1173,8 @@ hands it unsorted runs gets a wrong order, not a slow one.
|
||||
|
||||
Five ops decompose one thing: an indexer that scores blocks of key history against the query and
|
||||
hands `attn_paged` a shorter block table. `docs/QSA.md` is that decomposition; these are the
|
||||
schemas, and `arch/common/rad_qsa.h` issues all five.
|
||||
schemas, and `arch/common/rad_qsa.h` issues all five. **`qsa_block_key` has a host kernel in libref
|
||||
and libavx** -- the oracle for libr4d's, YaRN included -- and the other four are **device-only**.
|
||||
|
||||
`qsa_block_key` builds the **compressed key**: one vector per `ratio` tokens of key history, which
|
||||
is what the indexer's block scores are taken against.
|
||||
@@ -1182,6 +1183,11 @@ is what the indexer's block scores are taken against.
|
||||
out[b] = rope( rmsnorm( mean over j<ratio of k[b*ratio + j] ), at position pos0 + b*ratio )
|
||||
```
|
||||
|
||||
The rotation is `rope`'s NeoX ladder over the first `rotary_dim` lanes, with `rope`'s YaRN
|
||||
coefficients (`yarn_factor`, `yarn_low`, `yarn_high`, `yarn_magnitude`) when given -- the
|
||||
attention's own rotary, so a compressed key and the keys it summarises are rotated alike. With
|
||||
YaRN, `scale` must be 1.
|
||||
|
||||
**`M` is BLOCKS and `k` is `ratio` times taller.** Every other op in this document has one output
|
||||
row per input row. A caller that sized `k` at the block count would have every block pool three
|
||||
rows of the next one — plausible numbers and a different model — so libr4d's entry point checks it.
|
||||
|
||||
+21
-9
@@ -43,19 +43,31 @@ card, the dearest rank's -- and an attention-zero rank's cache costs a fraction
|
||||
token (at TP3 on Flash-Next it keeps only the QSA block keys: 2.3 GiB at the worst case where an
|
||||
attention rank's costs 15.2). Under `expert_tiered` with both pools derived, `Engine::plan` gives
|
||||
such a rank a KV pool that pages exactly the common token count (`KVManager::pool_mib_for_tokens`,
|
||||
the inverse of `paged_tokens`, plus a 64 MiB margin) and moves the difference into its weights pool,
|
||||
no further than every one of its weights resident. Both readers of the resolved sizes take the
|
||||
rank's own split -- `Pools::configure` and the planner -- so the grown pool is planned into. The
|
||||
token count, the carve, the loan and the attention ranks' pools are unchanged; a stated
|
||||
`--vram-kv-mib` / `--vram-weights-mib` keeps meaning "this many on every card", and `auto` keeps the
|
||||
common split (a fully resident rank would choose all_vram while its peers spill). At TP2/TP4 every
|
||||
rank costs the same and nothing is re-split. The log line, and its effect on the third rank:
|
||||
the inverse of `paged_tokens`: the least whole MiB whose paged split reaches the count, exact
|
||||
because the split is monotone in the budget and its alignment is among the fixed costs) and moves the
|
||||
difference into its weights pool, no further than every one of its weights resident. Both readers
|
||||
of the resolved sizes take the rank's own split -- `Pools::configure` and the planner -- so the
|
||||
grown pool is planned into, and startup refuses a rank whose plan and weights pool disagree, or
|
||||
whose re-sized KV pool pages fewer tokens than it was sized for. The token count, the carve, the
|
||||
loan and the attention ranks' pools are unchanged; a stated `--vram-kv-mib` / `--vram-weights-mib`
|
||||
keeps meaning "this many on every card", and `auto` keeps the common split (a fully resident rank
|
||||
would choose all_vram while its peers spill). `--deterministic` and a device without virtual memory
|
||||
management re-split like any other: the cache does not lend there, and the bytes the rank never
|
||||
pages are as much its experts' as they are under a lending cache. The condition is the cost, not
|
||||
the world: a rank is re-split only where its cache costs less per token than the dearest rank's,
|
||||
which at TP2/TP4 no rank does. A rank that qualifies and keeps the common split names the reason on
|
||||
its `kv: rank N's cache costs ...` line. The pinned host pool is not re-split: every rank allocates
|
||||
its whole `--host-pool-mib`, and a re-split rank whose weights all fit on the card says so
|
||||
(`its pinned host pool holds no weights`). The log line, and the mover on the third rank:
|
||||
|
||||
```
|
||||
kv: rank 2's cache costs 2.27 GiB at the worst case where its dearest peer's costs 15.16 GiB, so its KV pool pages the common 1446302 tokens in 1875 MiB instead of 10881; its weights pool grows 19747 -> 21692 MiB (every weight resident wants 21.18 GiB), and 7061 MiB stay unclaimed
|
||||
I[2] mover: 25142 slab slots (64 shadow), 0 pinned pool slots (was 22479 slots, 2663 pinned)
|
||||
kv: rank 2's cache costs 2.27 GiB at the worst case where its dearest peer's costs 15.16 GiB, so its KV pool pages the common 1446302 tokens in 1811 MiB instead of 10881; its weights pool grows 19747 -> 21692 MiB (every weight resident wants 21.18 GiB), and 7125 MiB stay unclaimed
|
||||
I[2] mover: 25142 slab slots (64 shadow), 0 pinned pool slots
|
||||
```
|
||||
|
||||
The settle check's INFO line on that card names the unclaimed MiB and points at this line rather
|
||||
than at the budget's `unusable` line alone.
|
||||
|
||||
Under a smaller attention world the plain even shard over `world` is the wrong cut for every
|
||||
attention projection, so the attention ranks declare **spans** (`rad_weight_shard_span`, the same
|
||||
call the KV replication uses for k/v): q|gate rows and output columns `[attn_rank * n_head,
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
# YaRN qualification and final-diff audit
|
||||
|
||||
## Decision
|
||||
|
||||
The six published Qwen containers passed the recorded functional checks. The host
|
||||
regression suite passed 41/41 tests. Architecture routing is covered by source review,
|
||||
declaration tests and model runs as distinguished below.
|
||||
|
||||
**Both compatibility findings are fixed and their focused regressions pass.**
|
||||
The original findings and remedies are in section 5. The model runs predate these
|
||||
fixes and do not exercise those edge cases.
|
||||
Concurrency claims are limited to overlapping server request lifetimes; continuous
|
||||
dual-context GPU residency has not been established by these logs.
|
||||
|
||||
Audit date: 2026-10-06. Reviewed implementation: `1d42304`, against released upstream
|
||||
`e95d397` (Radiance 1.2.0), including `3d7f066` and merge `10721e6`.
|
||||
No production code was changed during the initial audit. The subsequent compatibility
|
||||
fixes change argument normalization and linear-factor validation as detailed below.
|
||||
At the initial audit, all 24 changed non-YARN-doc files
|
||||
matched the remote source/fixtures by SHA-256; the remote `docs/YARN.md` was older.
|
||||
`git diff --check upstream/main...HEAD` passed. This is a direct source review,
|
||||
not an independent second-reviewer sign-off.
|
||||
|
||||
## 1. Architecture audit
|
||||
|
||||
| Architecture / component | Route traced | Evidence and boundary |
|
||||
| --- | --- | --- |
|
||||
| `qwen35_fp8` | `yarn_from` resolves target coefficients; `decl_rope` handles Q/K; `decl_rotary` handles shared `rope_table`; fused prologues consume that table | Three 27B encodings passed actual model checks; direct/table and fused/unfused numerical checks |
|
||||
| DFlash2 | Own `Geom`, theta and `draft.*` metadata; context K, draft Q and draft K all use `decl_rotary` | Independent target/draft parser checks; 128-wide numerical checks; model logs record DFlash2 passes |
|
||||
| `qwen35_bf16` | Target metadata resolved after partial rotary width; gated attention uses `decl_rope` | Dedicated declaration test and shared kernels; no BF16-weight end-to-end model run |
|
||||
| `qwen35moe_fp8` | Includes the Qwen35 FP8 implementation with routed-FFN macros | 35B-A3B model passed at TP2; TP4 stock fails unsupported BF16 attention geometry |
|
||||
| Qwen35 MTP | `MtpBlockFP8::declare` copies target `Geom` and passes it to attention | Source trace plus actual 35B MTP startup and recorded draft passes; no isolated YaRN/MTP declaration regression |
|
||||
| `qwen4exp_fp8` | Target direct/table; QSA query indexer and compressed keys receive target coefficients; indexer rotary width equals target `m.n_rot` | Dedicated declaration test, compressed-key GPU oracle and both Flash model runs |
|
||||
| Qwen4 MTP | `MtpHcBlock` copies target `Geom`; attention and QSA reuse it | Declaration fixture requests speculation; actual Flash logs record MTP passes |
|
||||
| Vision tower | Existing axial rotations do not receive target YaRN parameters | Source trace and red-image smoke checks; not a broad multimodal-quality evaluation |
|
||||
| Llama plugins | Do not call `yarn_from`; shared rotary ops retain absent-parameter defaults | Outside architecture-level YaRN support; no new Llama support claimed |
|
||||
|
||||
Source anchors: `arch/qwen35_fp8/qwen35_fp8.cpp:343,639,957`,
|
||||
`arch/qwen35moe_fp8/qwen35moe_fp8.cpp:20-24`,
|
||||
`arch/qwen35_bf16/qwen35_bf16.cpp:240`,
|
||||
`arch/qwen4exp_fp8/qwen4exp_fp8.cpp:367,700,1004,1397`,
|
||||
`arch/common/rad_block_dflash2.h:541,715,723`,
|
||||
`arch/common/rad_block_mtp_fp8.h:219,290`,
|
||||
`arch/common/rad_block_mtp_hc.h:203-212,291-294`,
|
||||
`arch/common/rad_qsa.h:162,230,272-281`.
|
||||
|
||||
### Compatibility contract
|
||||
|
||||
- Absent/default rotary metadata leaves the existing positional scale and adds no
|
||||
YaRN op parameters. Default op identities therefore retain their parameter lists.
|
||||
- Static YaRN uses the explicit original training length, not runtime/table length.
|
||||
Target and DFlash2 configuration are independent. MTP shares target geometry.
|
||||
- Both modern `rope_parameters` and legacy `rope_scaling` are read. Precedence is
|
||||
nested modern, top-level modern, nested legacy, top-level legacy; the first type
|
||||
found wins. Conflicting layouts are not merged. This precedence is documented,
|
||||
but lacks a dedicated conflicting-layout regression.
|
||||
- Unknown explicit rotary types now fail instead of being silently ignored.
|
||||
`mscale` / `mscale_all_dim` are intentionally unsupported. This is an intentional
|
||||
compatibility change for previously ignored metadata, not universal stock parity.
|
||||
- YaRN plus axial mode or positional scale other than one is rejected by rotary
|
||||
kernels. Model-level YaRN requires a positive even rotary width and finite inputs.
|
||||
- Checkpoint JSON booleans are flattened to `1`/`0`
|
||||
(`core/format/checkpoint.cpp:64`), matching `truncate`'s parser.
|
||||
- Optional op-schema parameters are consistent across reference, AVX and HIP
|
||||
rotary implementations. Compressed-key support is in the existing HIP-only op.
|
||||
Rebuild plugins together; no mixed-old/new-plugin compatibility is claimed.
|
||||
- Existing stock tests and stock checkpoints passed. No bitwise comparison of
|
||||
complete upstream-versus-branch stock-model logits or throughput was performed.
|
||||
|
||||
## 2. Model evidence
|
||||
|
||||
All extended probes used static factor 2, original context 262144, BF16 KV and
|
||||
prefix caching disabled. DFlash2 copies received their own factor/original keys.
|
||||
Every single probe used **499997 prompt tokens**; each paired probe used
|
||||
**255981 prompt tokens**, with three planted values at roughly 5%, 50%, 95% depth.
|
||||
All returned exactly the requested values and `finish_reason=stop`.
|
||||
|
||||
| Model (all under `StillDeadcode`) | TP | Single seconds | Pair A / B seconds | Run evidence |
|
||||
| --- | ---: | ---: | ---: | --- |
|
||||
| `qwen3.8-27b-fp8` | 4 | 309.4 | 283.6 / 283.6 | `v12-media-qualification.json`, `v12-media-engine-audit.log` |
|
||||
| `qwen3.8-27b-uncensored-fp8` | 4 | 309.8 | 283.0 / 282.9 | `matrix-20261006-181056` |
|
||||
| `qwen3.8-27b-mxfp4` | 4 | 301.9 | 274.4 / 274.4 | `matrix-20261006-181056` |
|
||||
| `qwen3.6-35b-a3b-fp8` | 2 | 197.3 | 121.5 / 121.5 | `matrix-20261006-185632` |
|
||||
| `qwen3.8-next-flash-fp8-iq4r-moe` | 4 | 174.5 | 80.9 / 163.3 | `matrix-20261006-183853` |
|
||||
| `qwen3.8-next-flash-uncensored-fp8-iq4r-moe` | 4 | 141.2 | 133.5 / 67.2 | `matrix-20261006-183853` |
|
||||
|
||||
Matrix runs include stock and YaRN arithmetic, tool-envelope, red-image and
|
||||
approximately 20K/180K retrieval checks. The original 27B baseline was collected
|
||||
separately (`ember-baseline*`, `baseline-retrieval.json`), not in this matrix;
|
||||
the release-1.2 media-enabled YaRN run has its own smoke results.
|
||||
These are synthetic functional checks, not a broad accuracy, perplexity or speed
|
||||
comparison. Timings are single observations, not comparative benchmark medians.
|
||||
|
||||
Hardware: four Radeon AI PRO R9700, gfx1201, approximately 31.86 GiB each;
|
||||
121 GiB host RAM; Linux `7.2.3-070203-generic`. The 35B run uses TP2.
|
||||
HIP/media build uses `g++-14`, `RAD_WITH_FFMPEG=ON`, AQL device backend.
|
||||
Recorded serving executable SHA-256:
|
||||
`0c99111b9514e5f30d17b98ce590a588a8cc857373cd7b61d170d03adf16e911`.
|
||||
|
||||
Matrix launch options (exact per-model argv lives in each `command.json`):
|
||||
|
||||
```sh
|
||||
radiance --model MODEL.rad --host 0.0.0.0 --port 8000 \
|
||||
--served-model-name Ember --tp 4 --max-num-seqs 8 \
|
||||
--max-model-len 524288 --kv-cache-dtype bf16 \
|
||||
--gpu-headroom-mib 256 --no-prefix-cache --reasoning-effort medium
|
||||
```
|
||||
|
||||
Stock uses `--max-model-len 262144`. 35B uses `--tp 2`. Both Flash models add
|
||||
`--placement expert_tiered --host-pool-mib 24576 --max-num-batched-tokens 2048`.
|
||||
The original 27B media trial used `--max-num-seqs 32`. Do not assume identical
|
||||
capacity across those configurations. The retained container argv includes device
|
||||
mapping, memlock, source/model mounts and plugin home.
|
||||
|
||||
The five new YaRN artifacts were copied to separate files, then metadata appended;
|
||||
verification checked all 21855 weights for 35B, 1101 for each new 27B, and 51489
|
||||
for each Flash variant. Tokenizer, template and expert profile were identical.
|
||||
This tested metadata-copy workflow is distinct from the documented checkpoint
|
||||
converter command; the full published-model matrix did not rerun that converter.
|
||||
|
||||
### Stock artifact SHA-256
|
||||
|
||||
| Model suffix | SHA-256 |
|
||||
| --- | --- |
|
||||
| 27B FP8 | `e8f662be2be37312fb07b82d1aa6c58c6507856425ce0f28028bdd9440400737` |
|
||||
| 27B uncensored FP8 | `fdb034bd0639d8fcc1c6d97d3b23939286ac7a7d114d1d53501653dd802fffe2` |
|
||||
| 27B MXFP4 | `44aec7fb78d9515907c6ae46e10e506a8578155013af227247f22f3c63c997b2` |
|
||||
| 35B-A3B FP8 | `deb3f9844cc5419ca8f546497b09fa7380f933f13e8244aa2af505bdfe593f36` |
|
||||
| Flash FP8 IQ4R | `0af5e96244e80c21ac8edca1719dae49b8a201b94a2f3994c3e24026ceaa4d20` |
|
||||
| Flash uncensored FP8 IQ4R | `19276213c4905100555508cf9d9383ae393424985f06c99b15935eaea5471f60` |
|
||||
|
||||
Download revisions and sizes are retained in `models/qwen-download-manifest.json`.
|
||||
|
||||
## 3. Concurrency verification
|
||||
|
||||
`audit-evidence.py` matched each response ID to its server request-start and
|
||||
completion lines, rechecked the exact answers, and asserted that both starts
|
||||
preceded either completion. All six pairs passed. Both requests report cache=0.
|
||||
The resulting `concurrency-audit.json` records request IDs, line numbers, exact log
|
||||
excerpts and SHA-256 hashes of the input logs/results.
|
||||
|
||||
| Model | Pair start lines | Pair completion lines | Engine log |
|
||||
| --- | --- | --- | --- |
|
||||
| 27B uncensored | 137, 138 | 148, 149 | corresponding `181056/*-yarn/engine.log` |
|
||||
| 27B MXFP4 | 127, 128 | 138, 139 | corresponding `181056/*-yarn/engine.log` |
|
||||
| 35B | 107, 108 | 109, 110 | corresponding `185632/*-yarn/engine.log` |
|
||||
| Flash | 161, 162 | 163, 164 | corresponding `183853/*-yarn/engine.log` |
|
||||
| Flash uncensored | 161, 162 | 163, 164 | corresponding `183853/*-yarn/engine.log` |
|
||||
|
||||
Original 27B IDs and line numbers are also in the machine-readable audit; its log
|
||||
contains several later server restarts, so it is retained separately.
|
||||
|
||||
This proves overlapping HTTP/server request lifetimes and successful paired
|
||||
completion. It does **not** identify scheduler admission, per-step sequence IDs,
|
||||
preemption or simultaneous KV occupancy. The Flash completion timing is compatible
|
||||
with substantial serialization. Dense 27B and 35B timings suggest overlapping
|
||||
progress, but timing alone is not a GPU-residency measurement. A stronger claim
|
||||
requires scheduler/batch traces or timestamped active-sequence/KV telemetry.
|
||||
|
||||
## 4. Regression and numerical evidence
|
||||
|
||||
- `final-host.log`: 41/41 CTest tests passed, 1633.32 seconds total, including
|
||||
`yarn_test`, `arch_test`, `ref_test`, `avx_check`, `ops_doc`, out-of-tree plugins,
|
||||
`kbench` and `kbench_moe`. Host suite success is not a full GPU-suite run.
|
||||
- `v12-gpu.log`: explicit GPU YaRN table comparisons at rotary widths 64/128,
|
||||
fused/unfused Q/K/gate byte equality, and compressed-key reference checks passed.
|
||||
- CPU fixture cases cover widths 64/128/256 and positions through 524287.
|
||||
GPU numerical oracle coverage is 64/128; presence of a 256-wide fixture is not
|
||||
evidence of a 256-wide GPU run. Cos/sin tolerance is 0.004; compressed BF16 keys
|
||||
use 0.008 absolute error.
|
||||
- AVX checks compare against libref; they are not a separate direct-vLLM oracle.
|
||||
- Independent fixtures use vLLM frequency computation and backend-specific torch
|
||||
FP32 trigonometry. Exact generating vLLM/torch revisions are not embedded in the
|
||||
fixture; pin/record them before calling fixture regeneration fully reproducible.
|
||||
|
||||
Observed run limitations are preserved: initial 35B TP4 stock failure; obsolete
|
||||
Flash launch flag on the first attempt; Flash per-card headroom warnings of roughly
|
||||
157–165 MiB below its stated target; five-second device synchronization diagnostics
|
||||
during some successful long probes. No claim of warning-free production qualification
|
||||
is made. Stock success uses the feature branch, not a clean upstream binary.
|
||||
|
||||
## 5. Final-diff findings
|
||||
|
||||
### Resolved P2 — disabled coefficients diverged across reference and optimized backends
|
||||
|
||||
`abi/rad_yarn.h:40-42` accepts factor zero without validating/normalizing magnitude.
|
||||
`libref/ref_attn.cpp:500,597-598` applies `yarn.magnitude` unconditionally, while AVX
|
||||
and HIP apply it only when factor is nonzero. With `{factor=0, magnitude=2}`, libref
|
||||
scales the rotation by two and optimized backends preserve the stock rotation.
|
||||
NaN magnitude can similarly contaminate only reference output.
|
||||
|
||||
Architecture-generated stock ops omit all four fields, so the six model runs do
|
||||
not hit this. It remains a public optional-op-parameter contract inconsistency.
|
||||
The fix normalizes disabled coefficients to stock defaults in `rad_yarn_args`, shared
|
||||
by all three backends. Reference direct/table tests cover magnitude 2 and NaN with
|
||||
disabled factor and NaN bounds; AVX-versus-reference cases cover magnitude 2 and NaN.
|
||||
|
||||
### Resolved P2 — linear factor validation happened before narrowing to float
|
||||
|
||||
`arch/common/rad_arch.h:1068-1072` accepts positive finite doubles then casts to
|
||||
`float` without checking representability. A compiled probe against the real parser
|
||||
returned `RAD_OK` for `1e300` with scale infinity, and for `1e-300` with scale zero.
|
||||
The former collapses finite positions toward zero; the latter takes the kernel's
|
||||
zero-scale fallback to unscaled positions. Both silently change the intended model.
|
||||
The fix checks the narrowed value is finite and positive before assigning it.
|
||||
The parser regression rejects overflow, underflow and invalid values, checks that
|
||||
rejection preserves the previous scale, and accepts representable fractional scaling.
|
||||
|
||||
Reproducer: local `audit-edge-probe.cpp` includes the real architecture header and
|
||||
supplies only its metadata lookup dependency. Its disabled-magnitude demonstration
|
||||
evaluates the reviewed formulas; it is not a full kernel launch test.
|
||||
|
||||
### P3 — reproducibility and coverage hardening
|
||||
|
||||
- Pin vLLM/torch versions and record backend/version metadata in the fixture generator.
|
||||
- Add explicit declaration assertions separating target and DFlash2 coefficients,
|
||||
plus MoE/MTP and conflicting-metadata precedence cases. Current evidence combines
|
||||
parser tests, shared source paths and model runs rather than isolated assertions.
|
||||
- The rest of the traced YaRN propagation showed no missing rotary path.
|
||||
|
||||
### Fix verification
|
||||
|
||||
`compat-fixes-host.log` records a successful host rebuild and 5/5 focused CTest
|
||||
targets: `yarn_test`, `ref_test`, `arch_test`, `avx_check` and `ops_doc`.
|
||||
This includes the new parser and disabled-coefficient regressions.
|
||||
The previous 41/41 suite and GPU/model results remain historical pre-fix evidence;
|
||||
the GPU serving build was not rebuilt or restarted for this host-side verification.
|
||||
|
||||
## Evidence location and reproduction
|
||||
|
||||
Raw evidence is retained locally at
|
||||
`~/repo/homelab/.local/experiments/radiance-20261006/evidence/`.
|
||||
Trial tools are in its parent: `validate-qwen-matrix.py`, `smoke.py`, `retrieval.py`,
|
||||
`qualify-yarn.py`, `relabel-rad.cpp`, `verify-rad-vocab.cpp`, `audit-evidence.py` and
|
||||
`audit-edge-probe.cpp`. Raw logs are not bundled in this source change.
|
||||
|
||||
```sh
|
||||
ctest --test-dir build-host --output-on-failure
|
||||
python3 audit-evidence.py > concurrency-audit.json
|
||||
python3 smoke.py http://127.0.0.1:8080 smoke.json
|
||||
python3 retrieval.py http://127.0.0.1:8080 retrieval.json
|
||||
python3 qualify-yarn.py http://127.0.0.1:8080 qualify-yarn.json
|
||||
```
|
||||
|
||||
The last three commands require the intended model already serving and run real
|
||||
inference. The matrix runner stops/starts trial containers; it is not a generic
|
||||
upstream CI tool. Package the portable probes and sanitized result excerpts with
|
||||
the PR if reviewers need to reproduce the model qualification outside this lab.
|
||||
+43
-47
@@ -1,48 +1,43 @@
|
||||
# Static YaRN for Qwen architectures
|
||||
# Static YaRN
|
||||
|
||||
Increasing `--max-model-len` reserves a larger serving window; it does not change
|
||||
the model's rotary embeddings. A Qwen checkpoint trained at 262144 positions can
|
||||
the model's rotary embeddings. A checkpoint trained at 262144 positions can
|
||||
explicitly request static YaRN for a 524288-token deployment. Whether that extension
|
||||
preserves useful accuracy must be measured on the model and workload.
|
||||
|
||||
The Qwen architectures read the target's `text_config.rope_parameters`,
|
||||
then `rope_parameters`, then their legacy `rope_scaling` spellings, in that order.
|
||||
The first object with `rope_type` (or legacy `type`) is authoritative. The DFlash2
|
||||
drafter reads its own `draft.rope_parameters` / `draft.rope_scaling`; it does not
|
||||
inherit the target's scaling. The vision tower keeps its original axial rotations.
|
||||
One reader takes every architecture's rotary scaling (`yarn_from`,
|
||||
`arch/common/rad_arch.h`). For the target it reads `text_config.rope_parameters`,
|
||||
then `rope_parameters`, then the legacy `text_config.rope_scaling` and `rope_scaling`,
|
||||
in that order; the first object with `rope_type` (or legacy `type`) is authoritative.
|
||||
A drafter (DFlash2, DSpark) reads its own `draft.rope_parameters` /
|
||||
`draft.rope_scaling`; it does not inherit the target's scaling. The vision tower keeps
|
||||
its original axial rotations. A GGUF's `rope.scaling.*` keys are carried in as the
|
||||
same `rope_scaling` keys when it is read.
|
||||
|
||||
## Coverage
|
||||
**The factor convention is the config's**, as vLLM and transformers read it:
|
||||
`factor` 2 over `original_max_position_embeddings` 262144 reaches 524288 positions.
|
||||
|
||||
| Architecture | Rotary paths | Validation so far |
|
||||
| --- | --- | --- |
|
||||
| `qwen35_fp8` | Target direct/table; independent DFlash2 | 27B FP8, uncensored FP8 and MXFP4: text/tool/image checks, 499997-token retrieval and two overlapping 255981-token requests, TP4/BF16 KV |
|
||||
| `qwen35_bf16` | Target direct rotary | Architecture declaration and shared numerical tests; no end-to-end BF16 model run yet |
|
||||
| `qwen35moe_fp8` | Shared Qwen35 target and MTP geometry | 35B-A3B stock/YaRN smoke and retrieval, including 499997 tokens and paired 255981-token requests; TP2/BF16 KV |
|
||||
| `qwen4exp_fp8` | Attention, indexer, compressed block keys and shared MTP geometry | Both Flash variants: stock/YaRN smoke and retrieval, including 499997 tokens and paired 255981-token requests; TP4, tiered experts, BF16 KV |
|
||||
|
||||
Radiance 1.2.0 also serves the published Qwen3.8-27B MXFP4 container through the
|
||||
Qwen35 FP8 architecture's encoding dispatch. It passed the model checks above.
|
||||
Request logs prove overlapping request lifetimes, not continuous simultaneous GPU
|
||||
residency or a common decode batch. See [qualification and audit](YARN-VALIDATION.md)
|
||||
for exact settings, timings, evidence boundaries and outstanding review findings.
|
||||
Synthetic retrieval is evidence for those requests, not a general accuracy benchmark
|
||||
or a capacity guarantee for other model sizes. Original-context quality should be
|
||||
checked alongside extended-context quality when deploying static YaRN.
|
||||
Validated so far: the Qwen3.8 27B and 35B-A3B containers and both Flash-Next
|
||||
variants at factor 2, with retrieval at ~500K tokens, and TP3 perplexity with
|
||||
`--rope-scaling` within roughly ±1% of stock at factor 2. The LLaMA plugins read the
|
||||
same keys and declare the same ops; YaRN there has had no model run.
|
||||
|
||||
## Metadata
|
||||
|
||||
| Key within the rotary object | Meaning |
|
||||
| --- | --- |
|
||||
| `rope_type` | `yarn`; default/absent preserves stock behavior; `linear` divides positions uniformly |
|
||||
| `rope_type` | `yarn`; `default`, absent or legacy `mrope` is no scaling; `linear` divides positions by `factor` |
|
||||
| `factor` | finite number >= 1, required for YaRN |
|
||||
| `original_max_position_embeddings` | positive integer, required; the **training** length, not the enlarged deployment/table length |
|
||||
| `beta_fast`, `beta_slow` | defaults 32 and 1; finite, fast >= slow > 0 |
|
||||
| `attention_factor` | positive finite cos/sin multiplier; default 1 + 0.1 ln(factor) for factor > 1, otherwise 1 |
|
||||
| `truncate` | 1 (default): floor/ceil correction bounds; 0: retain fractional bounds |
|
||||
| `truncate` | true/1 (default): floor/ceil correction bounds; false/0: retain fractional bounds |
|
||||
|
||||
`mscale` and `mscale_all_dim` variants are refused; specify `attention_factor`
|
||||
explicitly. Other explicit rotary types are refused in this architecture. Rotary
|
||||
width (including partial rotary), theta and M-RoPE section selection are unchanged.
|
||||
Every other type -- `llama3`, `longrope`, `dynamic` -- is refused by name at load,
|
||||
as are the `mscale` and `mscale_all_dim` variants (specify `attention_factor`). A
|
||||
GGUF that sets llama.cpp's YaRN `attn_factor`, `ext_factor` or log multiplier to
|
||||
anything but its neutral value is refused when read. Rotary width (including
|
||||
partial rotary), theta and M-RoPE section selection are unchanged.
|
||||
|
||||
## Convert a separate container
|
||||
|
||||
@@ -95,7 +90,7 @@ radiance --model /models/qwen3.8-next-flash-fp8.rad \
|
||||
(`ORIG`, default the container's own trained length) in the rotary object the reader above
|
||||
takes first -- for a Qwen3.8 container that is `text_config.rope_parameters`, which already says
|
||||
`default`; YaRN written under plain `rope_parameters` would sit behind it and never be read. A
|
||||
DFlash2 drafter gets the same factor over its own trained length. Over a checkpoint's own YaRN
|
||||
drafter gets the same factor over its own trained length. Over a checkpoint's own YaRN
|
||||
the factor is replaced, its trained length kept unless `ORIG` is given, and an explicit
|
||||
`attention_factor` (or `mscale` variant) dropped so the magnitude is derived for the new factor.
|
||||
`none` takes a checkpoint's YaRN off. A linear or other explicit rotary type is refused rather
|
||||
@@ -104,28 +99,29 @@ than stacked over. The result is resolved and checked exactly as a converted con
|
||||
|
||||
Startup says what the rotary is (`rope: YaRN factor 2 over 262144 trained positions -- the rotary
|
||||
reaches 524288`) and warns when `--max-model-len` is past what it covers -- also with no scaling
|
||||
at all, past the trained length. A persisted prefix cache (`--prefix-cache-dir`) written under a
|
||||
different `--rope-scaling` is not reused: every cached key was rotated differently.
|
||||
at all, past the trained length. A persisted prefix cache (`--prefix-cache-dir`) is fingerprinted
|
||||
with the resolved rotary of the target and the drafter, so a store written under a different
|
||||
one -- another `--rope-scaling`, or a container converted with YaRN -- is not reused: every cached
|
||||
key was rotated differently.
|
||||
|
||||
The flag is for trying a factor, or serving a container whose source checkpoints are not at hand;
|
||||
a deployment that settles on one can convert it in as above and drop the flag.
|
||||
|
||||
## Kernel and test contract
|
||||
|
||||
`rope` and `rope_table` take optional resolved coefficients `yarn_factor`,
|
||||
`yarn_low`, `yarn_high`, `yarn_magnitude`. Absent factor is the original path.
|
||||
With YaRN, `scale` must be 1: inverse frequencies are blended rather than all
|
||||
positions being divided. Axial rotary with YaRN is refused. Rebuild the bundled
|
||||
plugins together because their shared op schemas must match.
|
||||
`rope`, `rope_table` and `qsa_block_key` take optional resolved coefficients
|
||||
`yarn_factor`, `yarn_low`, `yarn_high`, `yarn_magnitude` (docs/OPS.md). Absent factor
|
||||
is the original path, with the original op identities. With YaRN, `scale` must be 1:
|
||||
inverse frequencies are blended rather than all positions being divided. Axial
|
||||
rotary with YaRN is refused. Rebuild the bundled plugins together because their
|
||||
shared op schemas must match.
|
||||
|
||||
The math follows the static YaRN formulation (Peng et al.) and is checked against
|
||||
independent vLLM `YaRNScalingRotaryEmbedding` FP32 vectors for each backend. The fixture generator
|
||||
is `tests/data/generate_yarn_reference.py`; it is not a runtime dependency.
|
||||
Vectors cover target rotary width 64, draft width 128, an additional width 256,
|
||||
and positions through 524287.
|
||||
The CPU fixture uses torch CPU; the HIP fixture uses torch ROCm on gfx1201
|
||||
(`generate_yarn_reference.py cuda`). CPU and ROCm `pow` differ by a few ULPs;
|
||||
at 524K positions their cos/sin values can differ by 0.033 even within torch.
|
||||
Compare each implementation against its backend's independent vectors.
|
||||
The numerical check allows 0.004 absolute cos/sin error; fused versus unfused HIP rotation is checked
|
||||
byte-for-byte separately. Existing stock rotary tests remain active.
|
||||
The math follows the static YaRN formulation (Peng et al.) as vLLM's
|
||||
`YaRNScalingRotaryEmbedding` implements it. `tests/yarn_test.cpp` pins the
|
||||
correction bounds to vLLM's integers (14/22, 28/43, 56/85 for rotary widths 64, 128,
|
||||
256 at factor 2, theta 1e7, 262144 trained positions); `tests/ref_test.cpp` and
|
||||
`r4d_selftest` compare libref and libr4d against a double-precision evaluation of the
|
||||
same formula at positions through 524287, within 8 ulp of each angle -- tight where
|
||||
the ramp sits, loose only in the fastest pairs at long positions, which no f32 rotary
|
||||
places better than its angle's own ulp. libavx is held to libref by `avx_check`, and
|
||||
fused versus unfused HIP rotation is checked byte-for-byte separately.
|
||||
Reference in new issue
Block a user