Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6b8751ccc | ||
|
|
c07e665785 | ||
|
|
aba6b19648 | ||
|
|
1e670fe110 | ||
|
|
e63bb1cdcf | ||
|
|
045205de16 | ||
|
|
6813efe9b7 | ||
|
|
d42b7440a4 | ||
|
|
f9dd69db4e | ||
|
|
af1557b1ef | ||
|
|
c349190569 | ||
|
|
67cf57b864 | ||
|
|
0a7516441d | ||
|
|
14761df127 | ||
|
|
66b2036eb5 | ||
|
|
9ddb563c0d | ||
|
|
e3bb5b3ea2 | ||
|
|
f1a1730c3c | ||
|
|
20e7d61ec7 | ||
|
|
4664ac1c2d | ||
|
|
699fd85c97 | ||
|
|
1f1bc7c2b8 | ||
|
|
08968b530b | ||
|
|
8c454110d9 | ||
|
|
ef84fa3f6b | ||
|
|
a37f07b3f8 | ||
|
|
e06863be2c | ||
|
|
30dda03a6f | ||
|
|
aea55a2b1c | ||
|
|
4cbe901054 | ||
|
|
36731f27d5 | ||
|
|
109ac86d12 | ||
|
|
6cd58a564b | ||
|
|
a03e812360 | ||
|
|
33343c4730 | ||
|
|
a0eb3934b5 | ||
|
|
a81a35f2a6 | ||
|
|
ac6ddac7f7 | ||
|
|
2c81c86350 | ||
|
|
06a2b18848 | ||
|
|
3deabdaeca | ||
|
|
917d5e4b93 | ||
|
|
c48708315d | ||
|
|
e4541c7036 | ||
|
|
3b2050a516 | ||
|
|
5bfb69e4ad | ||
|
|
4366748012 | ||
|
|
87fa1f109e | ||
|
|
31467206e1 | ||
|
|
46bce7f443 | ||
|
|
1fd2432365 | ||
|
|
ca38286812 | ||
|
|
a189bcc444 | ||
|
|
dd97f076e6 | ||
|
|
59e8dfe06f | ||
|
|
b8bca7885a | ||
|
|
e78d484e60 | ||
|
|
d0fd4aa1bb | ||
|
|
9b6eba80c6 | ||
|
|
e912b04f5a | ||
|
|
ca7a7212ec | ||
|
|
946a6f9e2b | ||
|
|
01f08152dc | ||
|
|
304597970f | ||
|
|
cfec01ec8d | ||
|
|
315aea7db9 | ||
|
|
d1b5a45e31 | ||
|
|
590dbcc178 | ||
|
|
73a284d799 | ||
|
|
33f9644701 | ||
|
|
2e558e2dcc | ||
|
|
79ac2bd50d | ||
|
|
742191a244 | ||
|
|
73f94b4345 | ||
|
|
7bd195d394 | ||
|
|
b2228c176b | ||
|
|
8dcd8fdcd7 | ||
|
|
8f2e511fcc | ||
|
|
78ad2096a3 | ||
|
|
bfadfbee76 | ||
|
|
1f50d235ed | ||
|
|
df453ff434 | ||
|
|
eaa14ac72a | ||
|
|
ceb92ea701 | ||
|
|
2e0945c106 | ||
|
|
6b96295f54 | ||
|
|
29057b0c6b | ||
|
|
09ad42e633 | ||
|
|
1f00224501 | ||
|
|
21c4544b61 | ||
|
|
f5d2d74a20 | ||
|
|
6997f8da14 | ||
|
|
6c7bcefefa | ||
|
|
660d410196 | ||
|
|
38c182a2ba | ||
|
|
b988378e70 | ||
|
|
bd3fa646bc | ||
|
|
1d94e416a6 | ||
|
|
ba3ebd380f | ||
|
|
157959fd80 | ||
|
|
aadabde0de | ||
|
|
b27f352259 | ||
|
|
c9bce68d45 | ||
|
|
a8d82678fa | ||
|
|
8ac613ddb9 | ||
|
|
97b4590761 | ||
|
|
c256342bc1 | ||
|
|
66b0dcf019 | ||
|
|
0f011f27e1 | ||
|
|
c3a4775f54 | ||
|
|
b9ecbde0d6 | ||
|
|
5e2e596644 | ||
|
|
3bf9dc9593 | ||
|
|
d893fd05d1 | ||
|
|
5c66eecc8e | ||
|
|
f4981154fc | ||
|
|
392746da6b | ||
|
|
4943bba2fb | ||
|
|
6e8a2f0a94 | ||
|
|
9a960c3da9 | ||
|
|
79cc319db2 | ||
|
|
0ff61a19a2 | ||
|
|
b98c2eb13e | ||
|
|
5736dd11c3 | ||
|
|
90b1229bfc | ||
|
|
e5862f3d26 | ||
|
|
c2403b2e29 | ||
|
|
444b85158b | ||
|
|
965a7caa51 | ||
|
|
4c9a79ca98 | ||
|
|
70be48c6fa | ||
|
|
be09d90c71 | ||
|
|
3ac3954fea | ||
|
|
9bfdd95cb6 | ||
|
|
e30ada33e8 | ||
|
|
1231eefbd3 | ||
|
|
51e4c7f0f0 | ||
|
|
1b4e405969 | ||
|
|
d7e3c2a58a | ||
|
|
b44f7a9bb1 | ||
|
|
981cd1e4e1 | ||
|
|
50ea36f283 | ||
|
|
f2f94fc6e7 | ||
|
|
e46a8ba3d4 | ||
|
|
7b9f33653f | ||
|
|
2fda03ccdd | ||
|
|
b83d53cf19 | ||
|
|
41a1aa00fe |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
# VERSION is the server release that /version reports. The plugin ABI version is separate and is
|
||||
# read from abi/rad_abi.h below.
|
||||
project(radiance VERSION 2.1.0 LANGUAGES C CXX)
|
||||
project(radiance VERSION 2.2.0 LANGUAGES C CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
@@ -15,24 +15,27 @@ Written by Deadcode, with contributions from:
|
||||
adaptive draft window, the MoE prefill forms, the sorted operand's decode kernel, two K blocks a
|
||||
pass for up to 80 routed rows, --prefill-span, the towers' lookup tables counted once, and for
|
||||
Gemma 4 its assistant head as a drafter that reads the trunk's cache, bf16 checkpoints, the fused
|
||||
w4a8 decode step, the vision tower and window snapshots that let a prefix hit resume, the
|
||||
Gemma 4 31B heretic-ara and Ornith-1.5-35B-A3B compose files, Gemma 4's E2B/E4B form (KV-shared
|
||||
layers, per-layer embeddings, clipped vision linears) with NVIDIA-Nemotron-3.5-Bolt-E4B, its audio
|
||||
w4a8 decode step, the vision tower and window snapshots that let a prefix hit resume, the Gemma 4
|
||||
31B heretic-ara and Ornith-1.5-35B-A3B compose files, Gemma 4's E2B/E4B form (KV-shared layers,
|
||||
per-layer embeddings, clipped vision linears) with NVIDIA-Nemotron-3.5-Bolt-E4B, its audio
|
||||
encoder, its i8a8 linears and its KV heads replicated over ranks, 4-bit weights at decode heights
|
||||
through w4a16_asym, the Ornith-1.5-122B compose files, the Gemma 4 31B's asymmetric int5
|
||||
linears (w5a8i8 and w5a16), the junctions at quant_act_i8g's grid (rmsnorm_quant_i8g,
|
||||
gelu_mul_quant_i8g and ar_rmsnorm_quant_i8g) with the prefill overlap on the i8a8, a4 and w5
|
||||
grids, the 31B's i8g, heretic-ara-i8g and w5 compose files, and Ling-3.0-flash (bailing_hybrid:
|
||||
KDA, dense latent attention, group-limited sigmoid routing, the clipped SwiGLU and its MTP layer as
|
||||
a serial drafter) with mla_attn_paged, its w4a8 recipes and compose files, possessive quantifiers
|
||||
in the tokenizer's patterns, the Grafana dashboard's first screen, and Gemma 4 12B (its picture
|
||||
and audio embedders, a picture's placeholders read both ways on the sliding layers, the windowed
|
||||
attention at head_dim 512, suppress_tokens) with its compose files, and
|
||||
NVIDIA-Nemotron-3.5-Bolt-74B-A9B (nemotronh: Mamba-2 with ssd_update and ple_conv_bias, the
|
||||
latent MoE's ungated relu^2 experts, NoPE attention with KV heads replicated over ranks, the
|
||||
paged attention at head_dim 128 and gqa 16, attention sinks) with NVIDIA's LiLiCorr drafter
|
||||
(RadBatch::anchor_rows, the candidate correlator), the C-RADIO vision tower and video tubelets,
|
||||
calibration in layer ranges, its recipes and compose files, and the kernel report's fixture
|
||||
through w4a16_asym, the Ornith-1.5-122B compose files, the Gemma 4 31B's asymmetric int5 linears
|
||||
(w5a8i8 and w5a16), the junctions at quant_act_i8g's grid (rmsnorm_quant_i8g, gelu_mul_quant_i8g
|
||||
and ar_rmsnorm_quant_i8g) with the prefill overlap on the i8a8, a4 and w5 grids, the 31B's i8g,
|
||||
heretic-ara-i8g and w5 compose files, and Ling-3.0-flash (bailing_hybrid: KDA, dense latent
|
||||
attention, group-limited sigmoid routing, the clipped SwiGLU and its MTP layer as a serial
|
||||
drafter) with mla_attn_paged, its w4a8 recipes and compose files, possessive quantifiers in the
|
||||
tokenizer's patterns, the Grafana dashboard's first screen, and Gemma 4 12B (its picture and audio
|
||||
embedders, a picture's placeholders read both ways on the sliding layers, the windowed attention
|
||||
at head_dim 512, suppress_tokens) with its compose files, and NVIDIA-Nemotron-3.5-Bolt-74B-A9B
|
||||
(nemotronh: Mamba-2 with ssd_update and ple_conv_bias, the latent MoE's ungated relu^2 experts,
|
||||
NoPE attention with KV heads replicated over ranks, the paged attention at head_dim 128 and gqa
|
||||
16, attention sinks) with NVIDIA's LiLiCorr drafter (RadBatch::anchor_rows, the candidate
|
||||
correlator), the C-RADIO vision tower and video tubelets, calibration in layer ranges, its recipes
|
||||
and compose files, and the kernel report's fixture, and Ling-3.0-flash on an IQ8R trunk with its
|
||||
clamped gated products writing rotated int8 codes, Nemotron-3.5-Bolt-74B-A9B on an int8 trunk
|
||||
(rotated experts and the LiLiCorr backbone reading rotated int8 codes), and the bidirectional
|
||||
media span counted from the window group's first position
|
||||
- mechkbfan: the token embedding in the pinned host pool
|
||||
- Code000: the n-gram gather on the card and the MTP head's history-pass skip, and the MTP draft
|
||||
coupling with its cooperative verify (--draft-coupling), the W4A8 prefill's tail scale read, the
|
||||
@@ -43,7 +46,18 @@ Written by Deadcode, with contributions from:
|
||||
the sampler's planes by the step's token bound, its n-gram ban beside a drafter and no candidate
|
||||
cut over a top-1 row, and --prefill-interleave auto[:SHARE], sized from measured step times and
|
||||
served by default, and the diagnose mode, in which the engine measures itself, with its token
|
||||
parity and reproducibility checks
|
||||
parity and reproducibility checks, and the HDP flush before every doorbell and the scalar-cache
|
||||
invalidate behind a chained wait, chained launches without the packet processor's acquire, the
|
||||
prefetch stream's half-lap acquire, the queue scratch charged to the VRAM budget, the pinned
|
||||
staging ring sized for sixteen builds, --expert-pin-top's fractional cut, the vision tower left
|
||||
off a build without a media decoder, QSA's score and select skipped where no attention reads them,
|
||||
the register form of the fused all-reduce writes with its wake store, Flash-Next's verify and
|
||||
decode launch order, the coded lossless wire of the two-rank fused writes and its staged form, one
|
||||
patch dispatch for an op's weight tables, hc_read's 48-row decode tile and its prefill up product,
|
||||
the packed MoE prefill run map, the spanned prefill's routed pass and its tail snapshot inside the
|
||||
last chunk, block and traversal verification of the coupled MTP chain (--draft-verify), adaptive
|
||||
and load-aware draft depth (--draft-depth, --draft-depth-load), SuffixDecoding as a step selector
|
||||
(--draft-suffix), and the tiled QSA prefill form
|
||||
- baKon: three-rank tensor parallelism, serving any world size from the shipped container, the
|
||||
request log, an uneven world's per-rank KV and weights split, --rope-scaling, the model entry's
|
||||
context length, root and capabilities, /props, the three-rank two-shot all-reduce and tiered-int8
|
||||
@@ -60,7 +74,8 @@ Written by Deadcode, with contributions from:
|
||||
recompute and the running sequences' next blocks free and the bound on its wait
|
||||
(--preempt-wait-ms), prompt lookup alone (--spec-ngram) with each sequence's n-gram index and the
|
||||
gate that verifies a proposal only when it pays, and DeepSeek-V4.1's reply format with its DSML
|
||||
tool calls, and expert_stats_report.py, and the KL mode's own line in the VRAM shortfall report
|
||||
tool calls, and expert_stats_report.py, and the KL mode's own line in the VRAM shortfall report,
|
||||
and the fresh prefill's room gate (--prefill-room-gate)
|
||||
- hazyumps: static YaRN for the Qwen rotary paths
|
||||
- malic: ParoQuant, with its MXFP4, int5 and int4 checkpoints imported and served, the Givens
|
||||
rotation as stages and as dense per-group matrices on the matrix cores, and the 5- and 4-bit
|
||||
@@ -70,12 +85,12 @@ Written by Deadcode, with contributions from:
|
||||
emulator that tests them, the prefill split into two slices with their all-reduces beside the
|
||||
compute, and the vocabulary-sharded draft head; Gemma 4 31B on four cards (its all-reduces fused
|
||||
with the junctions, overlapped with the compute and sent compressed, chained launches with block
|
||||
drafters), the embedding scale rounded as Hugging Face rounds it, block drafters' drafts
|
||||
accepted on the card, z-lab's DFlash drafter drafting on after a prefix-cache hit and the 31B's
|
||||
GPTQ calibration tap, and for speculation the MTP head's first draft read up to where it sits, no
|
||||
step queued behind one that ends its requests, a step's tokens streamed before the drafter's
|
||||
passes end, a block drafter's proposals verified as a tree, the 31B's block-16 DFlash2 tree with
|
||||
its short block under load, a block drafter's window carried in the window snapshot, and window
|
||||
drafters), the embedding scale rounded as Hugging Face rounds it, block drafters' drafts accepted
|
||||
on the card, z-lab's DFlash drafter drafting on after a prefix-cache hit and the 31B's GPTQ
|
||||
calibration tap, and for speculation the MTP head's first draft read up to where it sits, no step
|
||||
queued behind one that ends its requests, a step's tokens streamed before the drafter's passes
|
||||
end, a block drafter's proposals verified as a tree, the 31B's block-16 DFlash2 tree with its
|
||||
short block under load, a block drafter's window carried in the window snapshot, and window
|
||||
snapshots from short prompts
|
||||
- redxherring: --model taking a Hugging Face repo id
|
||||
- Smellyyyy: the idea behind --prefill-interleave
|
||||
@@ -83,8 +98,8 @@ Written by Deadcode, with contributions from:
|
||||
- devmilan: the NVFP4 and FP8 compressed-tensors imports
|
||||
- sfjes: Gemma 4 31B dense -- its plugin, its two attention classes and their kernels, and prefix
|
||||
reuse that leaves a windowed group alone -- and --host-headroom-mib
|
||||
- zivius: LiquidAI's LFM2 and LFM2-VL and d1's /v1/systemone, after the design of their Codeberg
|
||||
PR 50, Qwen3-ASR with /v1/audio/transcriptions and /v1/realtime, and Fish Audio drama-3 -- its
|
||||
- zivius: LiquidAI's LFM2 and LFM2-VL and d1's /v1/systemone, after the design of their Codeberg PR
|
||||
50, Qwen3-ASR with /v1/audio/transcriptions and /v1/realtime, and Fish Audio drama-3 -- its
|
||||
plugin, its codec encoder and decoder, voice cloning from reference clips, and the torch.save
|
||||
reader
|
||||
- mici81: Gemma 3 dense (TranslateGemma 27B) -- its plugin, the windowed h128 attention, the
|
||||
@@ -102,22 +117,23 @@ Written by Deadcode, with contributions from:
|
||||
below the tip, Gemma 3's fused all-reduce junction on the lossy wire, the three-wave verify's
|
||||
split by depth, the delta net's out-projection read beside its decode recurrent update, the MXFP4
|
||||
feed-forward's gated fold up to 16 rows, the three-wave verify floor bounded by the batch's
|
||||
workgroups, the split-KV row sum read with fetch-inactive, KLATE again for the head-256 gqa6
|
||||
paged prefill, the preempted-prefill gate past a KV group that holds no blocks, and the norms'
|
||||
lane sum issuing its reads eight at a time, chained forms for every kernel of
|
||||
Qwen3.8-Flash-Next's decode step with hc_read's forms G, S and B3, and a preempted request
|
||||
publishing its prefix with an overdue one keeping its place
|
||||
workgroups, the split-KV row sum read with fetch-inactive, KLATE again for the head-256 gqa6 paged
|
||||
prefill, the preempted-prefill gate past a KV group that holds no blocks, and the norms' lane sum
|
||||
issuing its reads eight at a time, chained forms for every kernel of Qwen3.8-Flash-Next's decode
|
||||
step with hc_read's forms G, S and B3, and a preempted request publishing its prefix with an
|
||||
overdue one keeping its place, and hc_read's decode forms G, S and B3 restored for ROCm 7.2
|
||||
- eddie168168: the rotated int8 trunk (i8a8h) and the qwen35_w8a8 plugin serving it, and the
|
||||
out-of-tree test at the tree's VOPD setting, and its norm and SiLU producers writing the int8
|
||||
linears' operands directly
|
||||
- davetha: JSON Schema patterns read unanchored, with their shorthand classes and escapes
|
||||
- davetha: JSON Schema patterns read unanchored, with their shorthand classes and escapes, and the
|
||||
README's abliterated Flash-Next container
|
||||
- Nunze: the eight-rank all-reduce's bands, weighted shards from the PCIe links and pieces, the
|
||||
sampler's candidate width at eight ranks, the image test stage's parallelism, budgets and
|
||||
exclusions, jinja's dotted integer index, GLM-5.3-Flash's kernels in libr4d and tool calls whose
|
||||
name the opener opens, GLM-5.3-Flash's vision tower and processor, its decode at a few rows and
|
||||
its DSA indexer split over the ranks, a host-tier restore that makes room as pressure does, KV
|
||||
groups every rank holds kept once a host slot, the eight-rank two-shot in ring order, the MLA
|
||||
row form (--tp-attn-split rows), DELETE /sessions, the dispatch stamps of a played pass with
|
||||
groups every rank holds kept once a host slot, the eight-rank two-shot in ring order, the MLA row
|
||||
form (--tp-attn-split rows), DELETE /sessions, the dispatch stamps of a played pass with
|
||||
stampgaps.py, one n-gram table for engines on separate cards (--ngram-placement ram=DIR), GGUF
|
||||
Q8_0, Q4_K and Q6_K tensors imported as their planes, the dense integer rows at the group they
|
||||
compute, and the GDN conv kernels on an f32 weight
|
||||
@@ -125,10 +141,10 @@ Written by Deadcode, with contributions from:
|
||||
sparse latent attention, f32-scaled FP8 and MXFP4 experts under sigmoid routing) and their
|
||||
reference and AVX ops -- a Quark export's block-FP8 layers, the signed QSA ranking, the
|
||||
one-sequence KV floor over the live plan, and prefill staging paid by expert residency
|
||||
- Memoria: the dashboard's decode floor and recent window, the sparklines' percentile range, and
|
||||
the bringup time in /stats, the acceptance tiles' live figures and statsdump's size-capped
|
||||
rotation, the dashboard's history line, session extremes, card-count changes and Requests-header
|
||||
JSON export, with the page's JavaScript driven by tests/js
|
||||
- Memoria: the dashboard's decode floor and recent window, the sparklines' percentile range, and the
|
||||
bringup time in /stats, the acceptance tiles' live figures and statsdump's size-capped rotation,
|
||||
the dashboard's history line, session extremes, card-count changes and Requests-header JSON
|
||||
export, with the page's JavaScript driven by tests/js
|
||||
- C_Tamas: control vectors, loaded when the deployment asks and applied as a per-layer residual
|
||||
projection, KV streaming for a context bigger than VRAM (--kv-resident), and the dashboard's
|
||||
request history, KV streaming traffic and one-unit KV meter, and the mapped tier kept in the page
|
||||
@@ -141,31 +157,34 @@ Written by Deadcode, with contributions from:
|
||||
- Quackster: cards with a small PCI BAR, their kernel arguments kept in host memory
|
||||
- farcryjohn: periodic window snapshots that let an edited prompt reuse its prefix, and
|
||||
Breeze-TTS-2's native voice cloning with its delivery direction (the Qwen3-TTS reference encoder,
|
||||
vq_euclidean and elu)
|
||||
vq_euclidean and elu), and MiniMax-H3's reference encoder reading host-readable operands (the
|
||||
ref2va and fl2va crash)
|
||||
- gostar: snapshot-backed prefix KV kept across recomputes, and Tencent's Hy-Memory (HYV3) -- its
|
||||
BF16, FP8 and GGUF adapters, its KV scales, its native sectioned tool calls, and its W4 decode
|
||||
(the per-128 I4 expert packing, the one-row W4/W5 epilogue and the fused prologue and folds),
|
||||
and the head-256 prefill softmax rescaled by row rather than by wave, Spark 2.5 (spark25: bf16 and
|
||||
(the per-128 I4 expert packing, the one-row W4/W5 epilogue and the fused prologue and folds), and
|
||||
the head-256 prefill softmax rescaled by row rather than by wave, Spark 2.5 (spark25: bf16 and
|
||||
rotated-int8 IQ8R checkpoints, tensor parallelism with exact collectives, reasoning and tagged
|
||||
tool calls) with its DSpark drafter (exact attention and Markov walk ops), the prefill split keyed
|
||||
by live KV bounds, and --gpu-memory-mib
|
||||
by live KV bounds, and --gpu-memory-mib, and the calibrated U5 gate and W5NL down recipe, U4 gates with W6NL down experts, Muse Glimmer IQ4R-V4 with a
|
||||
quantised DFlash2, and Qwen3.8-27B's native MTP draft head (vhead, the U2 head over a
|
||||
vocabulary-split target, its coupled proposals and calibration)
|
||||
- launch80_assets: tuning collectives as the exchange they serve at the served configuration, the
|
||||
per-layer embeddings' read-ahead queue and gather regimes, and the step loop's stall watch, and
|
||||
Meta Muse Glimmer 30B -- the museglimmer plugins, its windowed vision tower, its DFlash drafter,
|
||||
the ATEM tool dialect and its context extension
|
||||
- hugypufy: M2XFP4 -- its quantiser, its GEMMs and its linears in the Qwen3.8 trunk and the DFlash2
|
||||
drafter -- and the ParoQuant M2XFP4 import
|
||||
- steki: Gemma 4 E2B's per-layer MLP width and the bf16 descriptor for Google's E2B/E4B
|
||||
directories, nomic-embed-text-v2-moe (the nomicbert plugin), its config key aliases and
|
||||
RAD_MAP_TRANSPOSE honouring src_index, an f32 source narrowed to a bf16 declaration at load, and
|
||||
the snapshot store's floor ahead of --host-headroom-mib
|
||||
- steki: Gemma 4 E2B's per-layer MLP width and the bf16 descriptor for Google's E2B/E4B directories,
|
||||
nomic-embed-text-v2-moe (the nomicbert plugin), its config key aliases and RAD_MAP_TRANSPOSE
|
||||
honouring src_index, an f32 source narrowed to a bf16 declaration at load, and the snapshot
|
||||
store's floor ahead of --host-headroom-mib
|
||||
- griffin-warrior: the kernel report's consistency checks and coverage header, collective selftest
|
||||
cases skipped without a peer path, the build's media capability in the diagnostics, and the
|
||||
GUIDE's ROCm SDK and ffmpeg notes
|
||||
- nickreese: GBNF bounded-repetition chains shared across identical operands
|
||||
- Dad_Vibes: hc_read's decode kernels as one grid, its tiled up-mix pipelined and its one-grid
|
||||
wait trapping past its deadline, and gemm_fp8a8's narrow form with its scales staged through LDS
|
||||
and its gated three-tile form at 8 waves
|
||||
- Dad_Vibes: hc_read's decode kernels as one grid, its tiled up-mix pipelined and its one-grid wait
|
||||
trapping past its deadline, and gemm_fp8a8's narrow form with its scales staged through LDS and
|
||||
its gated three-tile form at 8 waves
|
||||
- RikshaDriver: libr3d, the RDNA3 (gfx11) kernel library, and its wave-matrix rewrite: the GEMMs
|
||||
retiled to 16x128 blocks, the grouped MoE GEMMs, the norms and quantisers, and the QSA and MoE
|
||||
router rows, its MoE GEMMs at w4a8 and w4a4 with dequant_w4, row_topk_merge, ngram_ids and the
|
||||
@@ -175,18 +194,19 @@ Written by Deadcode, with contributions from:
|
||||
- fl0l0u: every request entry point bounded, gated and sanitised (JSON parses bounded in depth,
|
||||
errors safe on invalid UTF-8, control bytes kept off the log, the dashboard's CSP, cross-origin
|
||||
browsers refused on the loopback-only routes, method-scoped API-key exemptions), prompt ids that
|
||||
name no vocabulary row refused, and the telemetry the HTTP thread reads made atomic
|
||||
name no vocabulary row refused, and the telemetry the HTTP thread reads made atomic, and the
|
||||
security review of 2.0 and 2.1 with its hardening follow-up
|
||||
- Brandon Bertelsen: Cloudflare's clef and clef-flash with their joint schema head on the card
|
||||
(seg_softmax_pool, a request's words for the plugin), Convai Innovations' Laya decision models,
|
||||
Mica on /v1/systemone, and Metaspace prepending only to text not already starting with its
|
||||
replacement
|
||||
- Gaspa79: NVIDIA's Nemotron 3.5 Embed 1B and 8B -- the nemotron35_embed plugin, its Pixtral
|
||||
tower and their CPU path -- and Nemotron 3.5 Rerank 8B on /rerank, with its BF16 masked mean
|
||||
- Gaspa79: NVIDIA's Nemotron 3.5 Embed 1B and 8B -- the nemotron35_embed plugin, its Pixtral tower
|
||||
and their CPU path -- and Nemotron 3.5 Rerank 8B on /rerank, with its BF16 masked mean
|
||||
(seg_mean_bf16_sum)
|
||||
- overchop: the file tier for large MoEs -- routing-aware reads of only the routed experts, the
|
||||
hot VRAM cache with its deposits and copyless relabels, and GLM-5.3-Flash's experts read
|
||||
file-direct under expert parallelism -- the stall watch counting drive reads as progress, and
|
||||
the DMA lane's lists fenced so a stalled read pointer no longer fills its ring
|
||||
- overchop: the file tier for large MoEs -- routing-aware reads of only the routed experts, the hot
|
||||
VRAM cache with its deposits and copyless relabels, and GLM-5.3-Flash's experts read file-direct
|
||||
under expert parallelism -- the stall watch counting drive reads as progress, and the DMA lane's
|
||||
lists fenced so a stalled read pointer no longer fills its ring
|
||||
- pokesjw: the n-gram reader refilling its reads as they land, and a decode gather waiting on the
|
||||
other rank's read of a row instead of reading it again
|
||||
- AnimusNull: GLM-5.3-Flash on four cards -- its experts split by width, the small-M MXFP4 expert
|
||||
@@ -204,6 +224,20 @@ Written by Deadcode, with contributions from:
|
||||
- eniga: the diagnosis of GLM-5.3-Flash's template refused for tools (jinja's unique filter)
|
||||
- tnhnyzc: the mixed-step service-time target (mixed-step-target-ms)
|
||||
- aelfwyne: the diagnosis of draft trees refusing the int8 KV cache's rows
|
||||
- DokterSmol: LiquidAI's LFM3 (lfm3_bf16: bf16, int8 and IQ8R trunks, the windowed attention at
|
||||
head_dim 128 with four queries a KV head on libr4d and libhalo)
|
||||
- rkcth: Qwen-Image 2.1's, Krea 2's and MiniMax-H3's deployment pixel and reference limits, a video
|
||||
job held through its model's drain, tensor-parallel queues guarded beside single-rank engines,
|
||||
guidance requests refused past the sequence limit, adapter image requests queued in order, model
|
||||
discovery that leaves idle timers alone, host room reserved atomically for loads and fills, idle
|
||||
expert-cache capacity restored, and LoRA rank truncation that drops dependent columns
|
||||
- dowjames: runtime LoRA on a rotated int8 trunk (plain fp GEMM sites over transform-basis weights,
|
||||
the lora_plain kernel library) and served adapters listed as children in /admin/fleet
|
||||
- kaczy44: Gemma 4 26B-A4B's vision tower and rad-convert --add-vision
|
||||
- Itoash: a tool-call delimiter that does not end the turn, and Ling 3.0's function names ending at
|
||||
whitespace
|
||||
- jintakhan: gemma4_bf16's sliding-window attention ported to gemma4
|
||||
- forestjohnson: the dashboard behind a reverse proxy at a relative path
|
||||
|
||||
This product includes software from the following projects, each under the MIT License. The
|
||||
license text is in the file named beside each.
|
||||
|
||||
@@ -21,6 +21,7 @@ To support the development of radiance: [Patreon](https://patreon.com/StillDeadC
|
||||
| model | container | get it | fleet file |
|
||||
|---|---|---|---|
|
||||
| Qwen3.8-Flash-Next: IQR-V4 experts, int8 trunk, MTP, vision | `qwen3.8-next-flash-iqr-v4.rad` (113 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-next-flash-iqr-v4) | `tp1.yaml`, `tp2.yaml` |
|
||||
| Qwen3.8-Flash-Next abliterated (refusals removed): IQR-V4 trunk (GPTQ), codebook experts (round to nearest), MTP, vision | `qwen3.8-flash-next-uncensored-iqr-v4.rad` (113 GiB) | [download](https://huggingface.co/davetha/qwen3.8-flash-next-uncensored-iqr-v4) | — |
|
||||
| Qwen3.8-27B IQ8R (rotated int8), DFlash2 drafter, vision | `qwen3.8-27b-iq8r-dflash.rad` (29 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-27b-iq8r-dflash) | `tp2.yaml` |
|
||||
| Qwen3.8-27B IQR-V4, 2.5 to 8 bits a weight ([docs/IQR.md](docs/IQR.md)), DFlash2 drafter, vision | `qwen3.8-27b-iq2r-v4.rad` .. `qwen3.8-27b-iq8r-v4.rad` (10 to 28 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.8-27b-iqr-v4) | `tp1.yaml` (IQ4R-L) |
|
||||
| Qwen3.6-35B-A3B IQ8R, MTP | `qwen3.6-35b-a3b-iq8r.rad` (35 GiB) | [download](https://huggingface.co/StillDeadcode/qwen3.6-35b-a3b-iq8r) | — |
|
||||
@@ -54,6 +55,8 @@ To support the development of radiance: [Patreon](https://patreon.com/StillDeadC
|
||||
| Stable Diffusion XL bf16 and its finetunes (Illustrious, NoobAI, Pony): text to image, one card | `illustrious-xl-v2.0-bf16.rad` (6.4 GiB), from any single-file SDXL checkpoint | [convert](#convert-a-checkpoint) | — |
|
||||
| EmbeddingGemma 2 bf16: text, image, video and audio embeddings, one card | `embeddinggemma2-bf16.rad` (1.4 GiB) | [convert](#convert-a-checkpoint) | `tp1.yaml`, `tp2.yaml` |
|
||||
| nomic-embed-text-v2-moe bf16: text embeddings, one card | `nomic-embed-v2-moe-bf16.rad` (959 MB) | [convert](#convert-a-checkpoint) | — |
|
||||
| LiquidAI LFM3-1.7B IQ8R: rotated int8 trunk, bf16 head; text, tool calls and reasoning, one card | `lfm3-1.7b-iq8r.rad` (2.5 GiB) | [convert](#convert-a-checkpoint) with `data/recipes/lfm3-1.7b-iq8r.recipe` | — |
|
||||
| LiquidAI LFM3-1.7B bf16: text, tool calls and reasoning, one card | `lfm3-1.7b-bf16.rad` (3.8 GiB) | [convert](#convert-a-checkpoint) | — |
|
||||
| Meta Muse Glimmer 30B bf16: text, images and video; sliding-window rotary layers between NoPE full ones, a windowed ViT | `muse-glimmer-30b-bf16.rad` (56 GiB) | [convert](#convert-a-checkpoint) | — |
|
||||
| Meta Muse Glimmer 30B w4a8: int4 trunk, images and video, one card | `muse-glimmer-30b-w4a8.rad` (16 GiB) | [convert](#convert-a-checkpoint) | — |
|
||||
| Meta Muse Glimmer 30B IQ8R: rotated int8 trunk, int8 head, DFlash drafter, images and video | `muse-glimmer-30b-iq8r-dflash.rad` (36 GiB) | [download](https://huggingface.co/StillDeadcode/muse-glimmer-30b-iq8r-dflash) | — |
|
||||
|
||||
+12
-2
@@ -19,7 +19,7 @@ extern "C" {
|
||||
* version is refused at load with both versions printed. Each also exports the layout's fingerprint
|
||||
* (rad_abi_layout.h), so two layouts given one number are refused as well. A new optional export
|
||||
* (e.g. rad_plugin_reference) is not a change of shape: a plugin without it gets the default. */
|
||||
#define RAD_ABI_VERSION 40u
|
||||
#define RAD_ABI_VERSION 43u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
|
||||
@@ -544,7 +544,17 @@ typedef int (*RadKernelConcurrentFn)(int i);
|
||||
* do, adds exactly once. The record is RAD_CHAIN_REC_BYTES at byte RAD_CHAIN_KARG_OFF of the
|
||||
* kernel's argument segment: { magic, target, ctr, check }, with check = magic ^ target ^ ctr ^
|
||||
* RAD_CHAIN_CHECK. A record whose magic or check does not match means: run without waiting and do
|
||||
* not add. Without the symbol, or with 0, the engine never asks. Symbol name: `rad_kernel_chain`. */
|
||||
* not add. Without the symbol, or with 0, the engine never asks.
|
||||
*
|
||||
* 2 instead of 1 adds a second promise: the chained form's own acquire covers everything it reads
|
||||
* behind the wait, scalar loads included. A compiler's agent-scope fence invalidates the vector
|
||||
* caches only; a load every lane shares may be a scalar one, served from the scalar data cache,
|
||||
* which still holds what was there before the launch in front wrote. A form that invalidates that
|
||||
* cache behind its acquire (`s_dcache_inv`), or reads no operand through it, may say 2. Where
|
||||
* every chainable row an engine loads says 2, the engine issues a chained launch that has lost
|
||||
* its barrier bit without the packet processor's acquire as well: on an R9700 that acquire holds
|
||||
* the processor ~0.9 us a launch, and it comes too early to serve a kernel that then waits for
|
||||
* the launch in front. With 1 the packets keep it. Symbol name: `rad_kernel_chain`. */
|
||||
typedef int (*RadKernelChainFn)(int i);
|
||||
#define RAD_CHAIN_KARG_OFF 992
|
||||
#define RAD_CHAIN_REC_BYTES 32
|
||||
|
||||
@@ -27,6 +27,7 @@ ABI_FIELD(RadArchProbe, tree_pays)
|
||||
ABI_FIELD(RadArchProbe, gen_max_pixels)
|
||||
ABI_FIELD(RadArchProbe, gen_max_refs)
|
||||
ABI_FIELD(RadArchProbe, gen_shape)
|
||||
ABI_FIELD(RadArchProbe, ckpt_snap_ok)
|
||||
ABI_STRUCT(RadArgs)
|
||||
ABI_FIELD(RadArgs, t)
|
||||
ABI_FIELD(RadArgs, n_t)
|
||||
@@ -105,6 +106,8 @@ ABI_FIELD(RadBatch, bidi_n)
|
||||
ABI_FIELD(RadBatch, bidi_seq)
|
||||
ABI_FIELD(RadBatch, bidi_used)
|
||||
ABI_FIELD(RadBatch, anchor_rows)
|
||||
ABI_FIELD(RadBatch, ckpt_cut)
|
||||
ABI_FIELD(RadBatch, ckpt_cu)
|
||||
ABI_STRUCT(RadBufDecl)
|
||||
ABI_FIELD(RadBufDecl, dtype)
|
||||
ABI_FIELD(RadBufDecl, rank)
|
||||
@@ -146,6 +149,7 @@ ABI_FIELD(RadBuildCtx, gen_max_pixels)
|
||||
ABI_FIELD(RadBuildCtx, gen_max_refs)
|
||||
ABI_FIELD(RadBuildCtx, expert_file_tier)
|
||||
ABI_FIELD(RadBuildCtx, slot_base)
|
||||
ABI_FIELD(RadBuildCtx, span_pass_step)
|
||||
ABI_STRUCT(RadAudioGenBatch)
|
||||
ABI_FIELD(RadAudioGenBatch, n_lane)
|
||||
ABI_FIELD(RadAudioGenBatch, lane)
|
||||
@@ -949,3 +953,7 @@ ABI_FIELD(RadMtpCoupleState, x)
|
||||
ABI_FIELD(RadMtpCoupleState, count)
|
||||
ABI_FIELD(RadMtpCoupleState, ids)
|
||||
ABI_FIELD(RadMtpCoupleState, q)
|
||||
ABI_FIELD(RadMtpCoupleState, nkids)
|
||||
ABI_FIELD(RadMtpCoupleState, scheme)
|
||||
ABI_FIELD(RadMtpCoupleState, blk)
|
||||
ABI_FIELD(RadMtpCoupleState, pad_)
|
||||
+23
-4
@@ -283,6 +283,14 @@ typedef struct RadBuildCtx {
|
||||
* rank: one engine in a process, or a test driving a plugin alone. Two engines may serve the
|
||||
* same plugin at once only when it says so (rad_arch_multi_instance). */
|
||||
int slot_base;
|
||||
|
||||
/* ---- appended in ABI 42 (--prefill-span-pass step) */
|
||||
/* Nonzero: where the plugin runs a step wider than max_mixed_tok serially (it pipelines no
|
||||
* part of it), its routed block may take the whole step in one pass rather than one pass a
|
||||
* checkpoint interval, and size the planes that hold a row per (token, expert slot) for
|
||||
* max_tok rows. 0, the zero-initialised default, keeps the interval-tall passes. A plugin
|
||||
* without such a pass ignores it. */
|
||||
int span_pass_step;
|
||||
} RadBuildCtx;
|
||||
|
||||
/* The most instances (engine ranks) one process holds at once; every slot is below it. */
|
||||
@@ -731,16 +739,19 @@ int rad_declare_plugin_words(RadBuilder* b, int64_t max_words);
|
||||
* The kind is a drive shape, not a model. SERIAL runs `depth` dependent passes, each embedding the
|
||||
* last one's proposal, so tokens arrive one at a time and a pass that declines ends the chain
|
||||
* (MTP, EAGLE, Medusa-serial). BLOCK runs a context pass, then one pass that fills every drafted
|
||||
* position at once (DFlash2 and other block-diffusion drafters).
|
||||
* position at once (DFlash2 and other block-diffusion drafters). HISTORY runs just the serial
|
||||
* history pass (draft_pass < 0, every hidden row, n_draft_out = 0) to collect calibration
|
||||
* inputs. It is for --calib-corpus with max_spec = 0; it declares and produces no proposals.
|
||||
*
|
||||
* `proposal` is the buffer a pass writes its token ids into; 0 means the sampler's token buffer,
|
||||
* which suits a head whose logits go through the ordinary sampler chain.
|
||||
*
|
||||
* Declaring no drafter is the normal case; the scheduler's prompt-lookup drafter still runs. */
|
||||
typedef enum {
|
||||
RAD_DRAFT_NONE = 0,
|
||||
RAD_DRAFT_SERIAL = 1, /* `depth` dependent passes, one proposal each */
|
||||
RAD_DRAFT_BLOCK = 2, /* a context pass, then one pass that fills the whole block */
|
||||
RAD_DRAFT_NONE = 0,
|
||||
RAD_DRAFT_SERIAL = 1, /* `depth` dependent passes, one proposal each */
|
||||
RAD_DRAFT_BLOCK = 2, /* a context pass, then one pass that fills the whole block */
|
||||
RAD_DRAFT_HISTORY = 3, /* calibration-only serial history pass, depth zero */
|
||||
} RadDraftKind;
|
||||
|
||||
typedef struct RadDrafterDecl {
|
||||
@@ -1727,6 +1738,14 @@ typedef struct RadArchProbe {
|
||||
* `gen_rows` (its largest pass: a step's two branches, or a query pass's points). It keeps no
|
||||
* KV. */
|
||||
int32_t gen_shape;
|
||||
|
||||
/* ---- appended in ABI 43 (a checkpoint inside the step), in the tail padding behind gen_shape */
|
||||
/* Nonzero when the plugin serves RadBatch::ckpt_cut: a step of one prefill sequence whose
|
||||
* checkpoint lies inside it runs its recurrence in two pieces and snapshots between them
|
||||
* (rad_ckpt_snap). The scheduler then takes a prompt's tail snapshot inside its last chunk
|
||||
* rather than ending the chunk there and running the rows past it as a step of their own.
|
||||
* Zero keeps that step. */
|
||||
int32_t ckpt_snap_ok;
|
||||
} RadArchProbe;
|
||||
|
||||
int rad_arch_probe(const RadModelMeta* meta, RadArchProbe* out);
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
/* rad_mtp_block.h -- BLOCK VERIFICATION of a linear MTP draft chain (--draft-verify block).
|
||||
*
|
||||
* Sun, Mendlovic, Leviathan, Aharoni, Beirami, Ro, Suresh, "Block Verification Accelerates
|
||||
* Speculative Decoding" (arXiv 2403.10444): the chain's draft tokens X_1 .. X_g are accepted or
|
||||
* rejected JOINTLY. Token-wise speculative sampling (what --draft-coupling does at each row) is
|
||||
* optimal per token; block verification is optimal for the whole block: the expected number of
|
||||
* accepted tokens is never lower and the output law is the target's, exactly.
|
||||
*
|
||||
* With P_i = the target's law after X^i (the sampler's filtered candidate softmax at verify row i,
|
||||
* i = 0 .. g-1) and Q_{i+1} = the head's law the draft X_{i+1} was sampled from (the coupled state
|
||||
* of round i + 1, the FP64 softmax of the reranked top 8):
|
||||
*
|
||||
* p_0 = 1, p_i = min(1, p_{i-1} P_{i-1}(X_i) / Q_i(X_i)) i = 1 .. g
|
||||
* S_i = sum_x max(p_i P_i(x) - Q_{i+1}(x), 0) i = 0 .. g-1
|
||||
* h_i = S_i / (S_i + 1 - p_i) (i < g), h_g = p_g
|
||||
*
|
||||
* for i = g, g-1, ..., 0: accept the block's first i tokens with probability h_i; the first
|
||||
* success is tau. (h_0 = 1: it always stops.)
|
||||
* tau = g: X_1 .. X_g are emitted and the next token is the ordinary draw from P_g.
|
||||
* tau < g: X_1 .. X_tau are emitted, then Y ~ max(p_tau P_tau - Q_{tau+1}, 0) normalised.
|
||||
*
|
||||
* Exactness is checked in tests/mtp_block_test.cpp by exact enumeration of the draft tree of a toy
|
||||
* model (the law of the emitted tokens computed in closed form, to 1e-12) and by a chi-square of the
|
||||
* real device-shared code, with a negative control (the same rule with a wrong residual).
|
||||
*
|
||||
* Y may equal X_{tau+1}; the core then takes that draft as accepted (ADV_ACCEPT: "the draft is the
|
||||
* sampler's token at this row") and reads the next row, which keeps its ordinary pick: a draw from
|
||||
* the target's law given exactly the tokens emitted so far, so the extra tokens continue the same
|
||||
* autoregressive sample. The verify op therefore writes only rows 0 .. tau of the block and leaves
|
||||
* every later row alone.
|
||||
*
|
||||
* Relation to --draft-coupling: the DRAFT half is shared (x ~ Q at temperature 1 from the head's
|
||||
* top 8, coupled states with their FP64 Q); only the verify half differs. Maximal coupling decides
|
||||
* row k from P_k and Q_{k+1} alone, so it is a per-row rule the core's token comparison walks
|
||||
* unchanged. Block verification decides row k from the rows after it (h_i for i > k), so the two
|
||||
* rules cannot be applied to the same row; `--draft-verify block` replaces the coupling's verify
|
||||
* and requires the coupled drafting (it switches it on), and it is for a LINEAR chain; Traversal
|
||||
* Verification (abi/rad_mtp_traversal.h, 2505.12398) is the walk that also covers a node with
|
||||
* several children.
|
||||
*/
|
||||
#ifndef RAD_MTP_BLOCK_H
|
||||
#define RAD_MTP_BLOCK_H
|
||||
|
||||
#include "rad_spechub.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#ifdef __HIPCC__
|
||||
#define RAD_BLK_HD __host__ __device__
|
||||
#else
|
||||
#define RAD_BLK_HD
|
||||
#endif
|
||||
|
||||
#define RAD_MTP_BLOCK_MAX RAD_MTP_COUPLE_MAX_ROUNDS /* g: the chain's longest block */
|
||||
#define RAD_MTP_BLOCK_KEY_STOP 0x424c4b53544f5000ull /* the h_i uniforms, per block */
|
||||
|
||||
/* Summation structure. The device decides a block with one workgroup of RAD_MTP_BLOCK_LANES
|
||||
* threads, so every FP64 sum over a row's candidate plane is DEFINED as this fixed tree, which the
|
||||
* host reference mirrors operation for operation (FP64 addition is not associative: the tree is
|
||||
* the definition, not an approximation):
|
||||
* - plane slot j belongs to lane j % LANES; a lane adds its live slots in ascending j;
|
||||
* - the lanes are reduced inside each group of RAD_MTP_BLOCK_WAVE by the butterfly
|
||||
* a[l] = a[l] + a[l ^ d], d = 16, 8, 4, 2, 1 (every lane of a group ends with the same bits),
|
||||
* and the LANES / WAVE group sums are added as ((g0 + g1) + (g2 + g3)).
|
||||
* The exp() of a slot is the same libm / device function on both sides. */
|
||||
#define RAD_MTP_BLOCK_LANES 128
|
||||
#define RAD_MTP_BLOCK_WAVE 32
|
||||
|
||||
/* One verify row's candidate plane, dense (n slots, holes id < 0 and -inf scores skipped), with
|
||||
* `valid` and `top` the scan of the whole plane (rad_mtp_block_scan makes it on the host; the
|
||||
* device reduces the same two values across its workgroup: a max and an OR are order free). */
|
||||
struct RadBlockRow {
|
||||
const int32_t* ids;
|
||||
const float* val;
|
||||
int64_t n;
|
||||
int valid;
|
||||
float top;
|
||||
};
|
||||
|
||||
/* The dense row's validity and maximum, as rad_mtp_couple_decide scans them. */
|
||||
static inline RAD_BLK_HD void rad_mtp_block_scan(RadBlockRow* r, int64_t vocab) {
|
||||
float top = -INFINITY;
|
||||
int valid = 1;
|
||||
for (int64_t j = 0; j < r->n; ++j) {
|
||||
if (r->ids[j] < 0) continue;
|
||||
if (r->ids[j] >= vocab || r->val[j] != r->val[j] || r->val[j] == INFINITY) valid = 0;
|
||||
else if (r->val[j] > top) top = r->val[j];
|
||||
}
|
||||
r->valid = valid;
|
||||
r->top = top;
|
||||
}
|
||||
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_live(int32_t id, float v) { return id >= 0 && v != -INFINITY; }
|
||||
|
||||
/* A lane's partial sums of one row: v[0..7] the mass on Q's ids (by their place in the state),
|
||||
* v[8] the mass off Q's support, v[9] the total. */
|
||||
struct RadBlockAcc { double v[10]; };
|
||||
|
||||
static inline RAD_BLK_HD int rad_mtp_block_find(const RadMtpCoupleState& s, int32_t id) {
|
||||
int k = 0;
|
||||
while (k < s.count && id != s.ids[k]) ++k;
|
||||
return k;
|
||||
}
|
||||
|
||||
/* Adds the live slot (id, v) to a lane's partial. */
|
||||
static inline RAD_BLK_HD void rad_mtp_block_acc_add(RadBlockAcc* a, const RadMtpCoupleState& s,
|
||||
int32_t id, float v, float top) {
|
||||
const double w = ::exp((double)v - top);
|
||||
const int k = rad_mtp_block_find(s, id);
|
||||
for (int kk = 0; kk < 8; ++kk) a->v[kk] += kk == k ? w : 0.0;
|
||||
a->v[8] += k >= s.count ? w : 0.0;
|
||||
a->v[9] += w;
|
||||
}
|
||||
|
||||
/* The lanes' partials reduced by the tree above (the host form; the device does the butterfly with
|
||||
* shuffles and adds the four group sums the same way). */
|
||||
static inline RAD_BLK_HD RadBlockAcc rad_mtp_block_tree(const RadBlockAcc* lane) {
|
||||
RadBlockAcc grp[RAD_MTP_BLOCK_LANES / RAD_MTP_BLOCK_WAVE];
|
||||
for (int w = 0; w < RAD_MTP_BLOCK_LANES / RAD_MTP_BLOCK_WAVE; ++w) {
|
||||
RadBlockAcc a[RAD_MTP_BLOCK_WAVE], t[RAD_MTP_BLOCK_WAVE];
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_WAVE; ++l) a[l] = lane[w * RAD_MTP_BLOCK_WAVE + l];
|
||||
for (int d = RAD_MTP_BLOCK_WAVE / 2; d > 0; d >>= 1) {
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_WAVE; ++l) t[l] = a[l];
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_WAVE; ++l)
|
||||
for (int c = 0; c < 10; ++c) a[l].v[c] = t[l].v[c] + t[l ^ d].v[c];
|
||||
}
|
||||
grp[w] = a[0];
|
||||
}
|
||||
RadBlockAcc o;
|
||||
for (int c = 0; c < 10; ++c) o.v[c] = (grp[0].v[c] + grp[1].v[c]) + (grp[2].v[c] + grp[3].v[c]);
|
||||
return o;
|
||||
}
|
||||
|
||||
/* P_i over Q_{i+1}'s support (pq, normalised, duplicate candidates aggregated), the mass off that
|
||||
* support (pout), the normaliser `sum` and the index `ix` of the draft token in the state's ids. */
|
||||
struct RadBlockStat {
|
||||
double pq[8];
|
||||
double pout, sum;
|
||||
int ix;
|
||||
};
|
||||
|
||||
/* The stat from the reduced partials `t` (what the device builds from its workgroup's tree). */
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_stat_from(const RadBlockAcc& t, int valid, float top,
|
||||
const RadMtpCoupleState& s, RadBlockStat* o) {
|
||||
if (!valid || top == -INFINITY) return false;
|
||||
const double sum = t.v[9];
|
||||
if (!(sum > 0) || !rad_spechub_finite(sum)) return false;
|
||||
o->ix = -1;
|
||||
for (int k = 0; k < 8; ++k) o->pq[k] = k < s.count ? t.v[k] : 0.0;
|
||||
for (int k = 0; k < s.count; ++k) {
|
||||
o->pq[k] /= sum;
|
||||
if (s.ids[k] == s.x) o->ix = k;
|
||||
}
|
||||
o->pout = t.v[8] / sum;
|
||||
o->sum = sum;
|
||||
return o->ix >= 0;
|
||||
}
|
||||
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_stat(const RadBlockRow& r, const RadMtpCoupleState& s,
|
||||
RadBlockStat* o) {
|
||||
if (!r.valid || r.top == -INFINITY) return false;
|
||||
RadBlockAcc lane[RAD_MTP_BLOCK_LANES];
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_LANES; ++l)
|
||||
for (int c = 0; c < 10; ++c) lane[l].v[c] = 0;
|
||||
for (int64_t j = 0; j < r.n; ++j)
|
||||
if (rad_mtp_block_live(r.ids[j], r.val[j]))
|
||||
rad_mtp_block_acc_add(&lane[j % RAD_MTP_BLOCK_LANES], s, r.ids[j], r.val[j], r.top);
|
||||
return rad_mtp_block_stat_from(rad_mtp_block_tree(lane), r.valid, r.top, s, o);
|
||||
}
|
||||
|
||||
/* The block's weights. p[i] (i = 0 .. g), h[i] (i = 0 .. g). */
|
||||
struct RadBlockPlan {
|
||||
int g;
|
||||
double p[RAD_MTP_BLOCK_MAX + 1];
|
||||
double h[RAD_MTP_BLOCK_MAX + 1];
|
||||
double s[RAD_MTP_BLOCK_MAX + 1]; /* S_i, the residual's mass (s[g] unused) */
|
||||
};
|
||||
|
||||
/* The residual mass of one token of row i at weight p: max(p P(x) - Q(x), 0) on Q's support,
|
||||
* p P(x) off it. */
|
||||
static inline RAD_BLK_HD double rad_mtp_block_resid_sum(const RadMtpCoupleState& s,
|
||||
const RadBlockStat& t, double p) {
|
||||
double r = p * t.pout;
|
||||
for (int k = 0; k < s.count; ++k) r += rad_spechub_positive(p * t.pq[k] - s.q[k]);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* st[i] / stat[i] for i = 0 .. g-1. */
|
||||
static inline RAD_BLK_HD void rad_mtp_block_plan(const RadMtpCoupleState* st,
|
||||
const RadBlockStat* stat, int g,
|
||||
RadBlockPlan* o) {
|
||||
o->g = g;
|
||||
o->p[0] = 1.0;
|
||||
for (int i = 0; i < g; ++i) {
|
||||
const double ratio = stat[i].pq[stat[i].ix] / st[i].q[stat[i].ix];
|
||||
const double v = o->p[i] * ratio;
|
||||
o->p[i + 1] = v < 1.0 ? v : 1.0;
|
||||
}
|
||||
for (int i = 0; i < g; ++i) {
|
||||
const double S = rad_mtp_block_resid_sum(st[i], stat[i], o->p[i]);
|
||||
o->s[i] = S;
|
||||
const double den = S + (1.0 - o->p[i]);
|
||||
o->h[i] = (den > 0 && rad_spechub_finite(den)) ? S / den : 1.0;
|
||||
}
|
||||
o->s[g] = 0;
|
||||
o->h[g] = o->p[g];
|
||||
}
|
||||
|
||||
/* tau: the first i, counting down from g, whose uniform falls below h_i. The uniforms are keyed by
|
||||
* the block's first output position, so no row's own draws are reused. */
|
||||
static inline RAD_BLK_HD int rad_mtp_block_tau(const RadBlockPlan& pl, uint64_t seed, uint64_t pos0) {
|
||||
for (int i = pl.g; i > 0; --i)
|
||||
if (rad_spechub_uniform(seed, pos0, RAD_MTP_BLOCK_KEY_STOP + (uint64_t)i) < pl.h[i]) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* One lane's partials of the residual draw: `off` the off-support masses p * (w / sum) (slots whose
|
||||
* id is not among Q's), `all` the plain weights (the fallback draw from P itself), and the last
|
||||
* positive id of each, in the lane's slot order. */
|
||||
struct RadBlockLane { double off, all; int32_t last_off, last_all; };
|
||||
|
||||
static inline RAD_BLK_HD void rad_mtp_block_lane_add(RadBlockLane* a, const RadMtpCoupleState& s,
|
||||
const RadBlockStat& t, double p, int32_t id,
|
||||
float v, float top) {
|
||||
const double w = ::exp((double)v - top);
|
||||
a->all += w;
|
||||
if (w > 0) a->last_all = id;
|
||||
if (rad_mtp_block_find(s, id) >= s.count) {
|
||||
const double m = p * (w / t.sum);
|
||||
a->off += m;
|
||||
if (m > 0) a->last_off = id;
|
||||
}
|
||||
}
|
||||
|
||||
/* Y ~ max(p P - Q, 0) normalised (state s, row r, stat t) with the uniform u in [0, 1). The mass
|
||||
* is walked in a fixed order: the ids of Q (place k = 0 .. count-1, mass max(p pq[k] - q[k], 0)),
|
||||
* then the other live slots lane by lane (the lanes of the tree above, each lane's slots in
|
||||
* ascending order; the lane totals are added in lane order). The walk subtracts the masses from
|
||||
* c = u * total and stops at the first negative; inside the lane it stops in, the walk restarts
|
||||
* from the c at the lane's start, so the structure is exactly what the workgroup computes. When
|
||||
* the total underflows to zero (FP64 cancellation with p = 1: P == Q) Y is drawn from P itself
|
||||
* over all live slots in the same lane order, a branch that depends on (P, Q) only. False: no live
|
||||
* candidate. */
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_resid_walk(const RadBlockRow& r,
|
||||
const RadMtpCoupleState& s,
|
||||
const RadBlockStat& t, double p, double u,
|
||||
const RadBlockLane* lane, int32_t* out) {
|
||||
double on[8];
|
||||
double total = 0;
|
||||
for (int k = 0; k < s.count; ++k) { on[k] = rad_spechub_positive(p * t.pq[k] - s.q[k]); total += on[k]; }
|
||||
double offt = 0;
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_LANES; ++l) offt += lane[l].off;
|
||||
total += offt;
|
||||
const bool resid = total > 0 && rad_spechub_finite(total);
|
||||
double c = resid ? u * total : u * t.sum;
|
||||
int32_t last = -1;
|
||||
if (resid) {
|
||||
for (int k = 0; k < s.count; ++k)
|
||||
if (on[k] > 0) { last = s.ids[k]; c -= on[k]; if (c < 0) { *out = last; return true; } }
|
||||
}
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_LANES; ++l) {
|
||||
const double T = resid ? lane[l].off : lane[l].all;
|
||||
const int32_t ll = resid ? lane[l].last_off : lane[l].last_all;
|
||||
if (!(T > 0)) continue;
|
||||
if (ll >= 0) last = ll;
|
||||
if (c - T < 0) {
|
||||
double cl = c;
|
||||
int32_t lastl = -1;
|
||||
for (int64_t j = l; j < r.n; j += RAD_MTP_BLOCK_LANES) {
|
||||
if (!rad_mtp_block_live(r.ids[j], r.val[j])) continue;
|
||||
const double w = ::exp((double)r.val[j] - r.top);
|
||||
double m;
|
||||
if (resid) {
|
||||
if (rad_mtp_block_find(s, r.ids[j]) < s.count) continue;
|
||||
m = p * (w / t.sum);
|
||||
} else {
|
||||
m = w;
|
||||
}
|
||||
if (m > 0) { lastl = r.ids[j]; cl -= m; if (cl < 0) { *out = lastl; return true; } }
|
||||
}
|
||||
*out = lastl >= 0 ? lastl : ll;
|
||||
return *out >= 0;
|
||||
}
|
||||
c -= T;
|
||||
}
|
||||
*out = last;
|
||||
return last >= 0;
|
||||
}
|
||||
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_resid_draw(const RadBlockRow& r,
|
||||
const RadMtpCoupleState& s,
|
||||
const RadBlockStat& t, double p, double u,
|
||||
int32_t* out) {
|
||||
RadBlockLane lane[RAD_MTP_BLOCK_LANES];
|
||||
for (int l = 0; l < RAD_MTP_BLOCK_LANES; ++l) lane[l] = RadBlockLane{ 0, 0, -1, -1 };
|
||||
for (int64_t j = 0; j < r.n; ++j)
|
||||
if (rad_mtp_block_live(r.ids[j], r.val[j]))
|
||||
rad_mtp_block_lane_add(&lane[j % RAD_MTP_BLOCK_LANES], s, t, p, r.ids[j], r.val[j], r.top);
|
||||
return rad_mtp_block_resid_walk(r, s, t, p, u, lane, out);
|
||||
}
|
||||
|
||||
/* The whole decision on the host: rows[0 .. g-1] / st[0 .. g-1] are the block's verify rows and
|
||||
* their coupled states (round i + 1 at row i), pos0 the first row's output position. Writes tau and
|
||||
* *y; *y = -1 when tau == g (the g-th row's ordinary draw stands). False for an invalid target. */
|
||||
static inline RAD_BLK_HD bool rad_mtp_block_decide(const RadMtpCoupleState* st,
|
||||
const RadBlockRow* rows, int g, uint64_t seed,
|
||||
uint64_t pos0, int* tau, int32_t* y) {
|
||||
RadBlockStat stat[RAD_MTP_BLOCK_MAX];
|
||||
RadBlockPlan pl;
|
||||
if (g < 1 || g > RAD_MTP_BLOCK_MAX) return false;
|
||||
for (int i = 0; i < g; ++i)
|
||||
if (!rad_mtp_block_stat(rows[i], st[i], &stat[i])) return false;
|
||||
rad_mtp_block_plan(st, stat, g, &pl);
|
||||
const int t = rad_mtp_block_tau(pl, seed, pos0);
|
||||
*tau = t;
|
||||
*y = -1;
|
||||
if (t >= g) return true;
|
||||
return rad_mtp_block_resid_draw(rows[t], st[t], stat[t], pl.p[t],
|
||||
rad_spechub_uniform(seed, pos0 + (uint64_t)t, RAD_SAMPLE_KEY_RESID), y);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
#endif /* RAD_MTP_BLOCK_H */
|
||||
@@ -0,0 +1,426 @@
|
||||
/* rad_mtp_rrs.h -- recursive rejection sampling over a node's SIBLING drafts under
|
||||
* --draft-coupling on: the draft side (children sampled without replacement from Q) and the
|
||||
* verify side (the walk over a node's children against the target's P), as plain code the host
|
||||
* oracle, the device kernels and the tests share, so they cannot drift. Traversal verification
|
||||
* (abi/rad_mtp_traversal.h) walks nodes that drafted several children; the serial head of this
|
||||
* engine drafts one (nkids <= 1, the chain), so nothing in the engine draws siblings yet: the
|
||||
* header is the verify side's definition and its tests (tests/mtp_rrs_test.cpp). The short proof:
|
||||
*
|
||||
* Draft. A node whose head pass left the law Q (the FP64 T1 softmax of the reranked top 8,
|
||||
* rad_mtp_couple_build_q) drafts its children x_1, x_2, ... by Gumbel-top-k over log Q: add an
|
||||
* independent Gumbel to every log q_i and take the entries in descending order. That is sampling
|
||||
* without replacement (Plackett-Luce): x_1 ~ Q, x_2 ~ Q(. | not x_1), ... The first m of them are
|
||||
* the node's children, m chosen by anything that does not read the values x_j it applies to
|
||||
* (a fixed count, or a rule over the slot priorities, the j-th largest q of Q, never the drawn
|
||||
* token).
|
||||
*
|
||||
* Verify (Sequoia, Chen et al. 2024, Alg. 1; SpecInfer's multi-step verification with the draft
|
||||
* law renormalised after each removal). P_1 = the target's law, q_1 = Q. For i = 1..m:
|
||||
* accept x_i with probability min(1, P_i(x_i) / q_i(x_i));
|
||||
* on rejection P_{i+1} = norm(max(P_i - q_i, 0)), q_{i+1} = q_i with x_i removed, renormalised.
|
||||
* All rejected: the token is a draw from P_{m+1}. Exactness (induction on m): after a rejection of
|
||||
* the first draft the continuation depends on x_1 only through q_2, and P_2 = norm(max(P - q, 0))
|
||||
* does not depend on x_1 at all, so by the hypothesis it emits ~ P_2 whatever x_1 was; then
|
||||
* P(emit y) = sum_x q(x) min(1, P(x)/q(x)) [x = y] + P(reject) P_2(y) = min(P, q)(y) +
|
||||
* max(P - q, 0)(y) = P(y). The emitted token is the accepted child's token, or a residual draw that
|
||||
* has no mass on any rejected child (P_{i+1}(x_i) = 0 after a rejection), so the core's rule "follow
|
||||
* the first child whose token is the sampler's token at the row" (ADV_ACCEPT) walks exactly the
|
||||
* decision made here and needs no change.
|
||||
*
|
||||
* Wire: the node's RadMtpCoupleState holds Q (ids, q), the children in draft order in ids[0 ..
|
||||
* nkids), x = ids[0]. A state with nkids <= 1 is the chain's (rad_mtp_couple_decide, bit for bit).
|
||||
*/
|
||||
#ifndef RAD_MTP_RRS_H
|
||||
#define RAD_MTP_RRS_H
|
||||
|
||||
#include "rad_spechub.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#ifdef __HIPCC__
|
||||
#define RAD_RRS_HD __host__ __device__
|
||||
#else
|
||||
#define RAD_RRS_HD
|
||||
#endif
|
||||
|
||||
#define RAD_MTP_RRS_KEY_TREE 0x4d54524545474d42ull /* the draft's Gumbel stream */
|
||||
#define RAD_MTP_RRS_KEY_ACCEPT 0x41435054ull
|
||||
|
||||
static inline RAD_RRS_HD uint64_t rad_mtp_rrs_mix(uint64_t z) {
|
||||
z += 0x9e3779b97f4a7c15ull;
|
||||
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ull;
|
||||
z = (z ^ (z >> 27)) * 0x94d049bb133111ebull;
|
||||
return z ^ (z >> 31);
|
||||
}
|
||||
|
||||
/* The open-interval uniform of candidate `c` of draft node `node`: (seed, base) name the draft
|
||||
* stream (the request's seed and its pre-commit output length, which no later step reuses). */
|
||||
static inline RAD_RRS_HD double rad_mtp_rrs_gumbel_u(uint64_t seed, uint64_t base,
|
||||
uint64_t node, int c) {
|
||||
uint64_t z = rad_mtp_rrs_mix(seed ^ RAD_MTP_RRS_KEY_TREE);
|
||||
z = rad_mtp_rrs_mix(z ^ base);
|
||||
z = rad_mtp_rrs_mix(z + node * 16u + (uint64_t)c);
|
||||
return ((double)(z >> 11) + 0.5) * 0x1p-53;
|
||||
}
|
||||
|
||||
/* Gumbel-top-k order of Q's support: order[0 .. s.count) are indices into s.ids, the draft order
|
||||
* (descending of log q + Gumbel, ties to the lower index). Draws one uniform per support entry from
|
||||
* the state's own draw, node `node`. */
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_order(const RadMtpCoupleState& s, uint64_t node,
|
||||
int* order) {
|
||||
double key[8];
|
||||
for (int i = 0; i < s.count; ++i) {
|
||||
const double u = rad_mtp_rrs_gumbel_u(s.draw.seed, s.draw.base, node, i);
|
||||
key[i] = ::log(s.q[i]) - ::log(-::log(u));
|
||||
order[i] = i;
|
||||
}
|
||||
for (int i = 1; i < s.count; ++i) { /* insertion sort, stable */
|
||||
const int o = order[i];
|
||||
int j = i;
|
||||
while (j > 0 && key[order[j - 1]] < key[o]) { order[j] = order[j - 1]; --j; }
|
||||
order[j] = o;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the node's children: reorder Q's support into the draft order (ids and q together), set
|
||||
* x = ids[0] and nkids = `nkids`. */
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_draw(RadMtpCoupleState* s, uint64_t node, int nkids) {
|
||||
int order[8];
|
||||
rad_mtp_rrs_order(*s, node, order);
|
||||
int32_t ids[8];
|
||||
double q[8];
|
||||
for (int i = 0; i < s->count; ++i) { ids[i] = s->ids[order[i]]; q[i] = s->q[order[i]]; }
|
||||
for (int i = 0; i < s->count; ++i) { s->ids[i] = ids[i]; s->q[i] = q[i]; }
|
||||
s->x = s->ids[0];
|
||||
s->nkids = nkids < s->count ? nkids : s->count;
|
||||
}
|
||||
|
||||
/* The SLOT priorities of a node's law: slot j carries the log of the j-th LARGEST q of Q
|
||||
* (descending, ties by position), -inf past the support. They are a function of Q alone, never of
|
||||
* which token was drawn into which slot, so a rule that reads only them admits children by a
|
||||
* quantity independent of the values the children take. `s` is read before the draw reorders it
|
||||
* or after (the multiset of q is the same). */
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_slot_logq(const RadMtpCoupleState& s, float* ov) {
|
||||
double qs[8];
|
||||
const int n = s.count < 8 ? s.count : 8;
|
||||
for (int i = 0; i < n; ++i) qs[i] = s.q[i];
|
||||
for (int i = 1; i < n; ++i) {
|
||||
const double v = qs[i];
|
||||
int j = i;
|
||||
while (j > 0 && qs[j - 1] < v) { qs[j] = qs[j - 1]; --j; }
|
||||
qs[j] = v;
|
||||
}
|
||||
for (int c = 0; c < 8; ++c) ov[c] = c < n ? (float)::log(qs[c]) : -INFINITY;
|
||||
}
|
||||
|
||||
/* The longest prefix of the state's children that are the first `n` of `kid[]` (the tree's
|
||||
* children of this row, in node order, repeats dropped): what a verify may keep when a window cut
|
||||
* the tree short. 0 when even the first differs. */
|
||||
static inline RAD_RRS_HD int rad_mtp_rrs_prefix(const RadMtpCoupleState& s, const int32_t* kid,
|
||||
int n) {
|
||||
const int have = s.nkids >= 1 ? s.nkids : 1;
|
||||
int m = 0;
|
||||
while (m < have && m < n && m < s.count && s.ids[m] == kid[m]) ++m;
|
||||
return s.nkids >= 2 ? m : (n >= 1 && s.x == kid[0] ? 1 : 0);
|
||||
}
|
||||
|
||||
/* The acceptance uniform of the i-th child at output position `pos`: the first is the chain's. */
|
||||
static inline RAD_RRS_HD double rad_mtp_rrs_uaccept(uint64_t seed, uint64_t pos, int i) {
|
||||
return rad_spechub_uniform(seed, pos, i == 0 ? (uint64_t)RAD_SAMPLE_KEY_ACCEPT
|
||||
: RAD_MTP_RRS_KEY_ACCEPT ^ rad_mtp_rrs_mix((uint64_t)i));
|
||||
}
|
||||
|
||||
/* The verify of a node with nkids >= 2 children: the recursion above over the sampler's surviving
|
||||
* candidates (ids/val, n of them, FP64 P = softmax of val). Writes the emitted token to *out and
|
||||
* returns true, or false for an invalid target (the row keeps the ordinary token).
|
||||
*
|
||||
* The decision reads the live candidates (id >= 0, value not -inf) in ascending order through a view
|
||||
* `C::each(f)`, f(id, w, k) -> bool (false stops): w = exp(val - top) in FP64, k the id's slot in the
|
||||
* state's support (the first match) or s.count when it is outside. The host view (RadRrsHostCands)
|
||||
* computes them on the fly; the device verify (plugin/spechub/spechub.hip) compacts the live
|
||||
* candidates and computes every w and k with the whole workgroup, then runs this same function on one
|
||||
* lane over the stored values, so the ordered sums, and with them the token, are the host's. `pq_out`
|
||||
* and `sum_out` (optional) hand back P's masses on the support and their normaliser (the export). */
|
||||
template <class C>
|
||||
static inline RAD_RRS_HD bool rad_mtp_rrs_decide_over(const RadMtpCoupleState& s, const C& cs,
|
||||
uint64_t seed, uint64_t pos, int32_t* out,
|
||||
double* pq_out = nullptr,
|
||||
double* sum_out = nullptr) {
|
||||
double sum = 0, pq[8] = {}, wout = 0;
|
||||
cs.each([&](int32_t, double w, int k) {
|
||||
sum += w;
|
||||
if (k < s.count) pq[k] += w; else wout += w;
|
||||
return true;
|
||||
});
|
||||
if (!(sum > 0) || !rad_spechub_finite(sum)) return false;
|
||||
if (pq_out) for (int k = 0; k < 8; ++k) pq_out[k] = pq[k];
|
||||
if (sum_out) *sum_out = sum;
|
||||
/* P over Q's support (normalised), and the off-support mass's scale `so` (P_i(y) = so * w / sum
|
||||
* there). qr: the draft law with the drawn children removed. */
|
||||
double r[8], qr[8], so = 1.0;
|
||||
for (int k = 0; k < s.count; ++k) { r[k] = pq[k] / sum; qr[k] = s.q[k]; }
|
||||
const double pout = wout / sum;
|
||||
bool direct = false;
|
||||
for (int i = 0; i < s.nkids && !direct; ++i) {
|
||||
double sq = 0;
|
||||
for (int k = 0; k < s.count; ++k) sq += qr[k];
|
||||
if (!(sq > 0)) break;
|
||||
const double qx = qr[i] / sq;
|
||||
if (r[i] >= qx || rad_mtp_rrs_uaccept(seed, pos, i) * qx < r[i]) { *out = s.ids[i]; return true; }
|
||||
double z = so * pout;
|
||||
for (int k = 0; k < s.count; ++k) {
|
||||
const double d = r[k] - qr[k] / sq;
|
||||
r[k] = d > 0 ? d : 0;
|
||||
z += r[k];
|
||||
}
|
||||
if (!(z > 0) || !rad_spechub_finite(z)) { direct = true; break; }
|
||||
for (int k = 0; k < s.count; ++k) r[k] /= z;
|
||||
so /= z;
|
||||
qr[i] = 0;
|
||||
}
|
||||
const double u = rad_spechub_uniform(seed, pos, RAD_SAMPLE_KEY_RESID);
|
||||
double c;
|
||||
int32_t last = -1;
|
||||
if (direct) {
|
||||
c = u * sum;
|
||||
bool hit = false;
|
||||
cs.each([&](int32_t id, double w, int) {
|
||||
if (w > 0) { last = id; c -= w; if (c < 0) { hit = true; return false; } }
|
||||
return true;
|
||||
});
|
||||
*out = last;
|
||||
(void)hit;
|
||||
return true;
|
||||
}
|
||||
double total = 0;
|
||||
for (int k = 0; k < s.count; ++k) total += r[k];
|
||||
total += so * pout;
|
||||
c = u * total;
|
||||
unsigned seen = 0;
|
||||
bool hit = false;
|
||||
cs.each([&](int32_t id, double w, int k) {
|
||||
double m;
|
||||
if (k < s.count) {
|
||||
if (seen & (1u << k)) return true;
|
||||
seen |= 1u << k;
|
||||
m = r[k];
|
||||
} else {
|
||||
m = so * (w / sum);
|
||||
}
|
||||
if (m > 0) { last = id; c -= m; if (c < 0) { hit = true; return false; } }
|
||||
return true;
|
||||
});
|
||||
*out = last;
|
||||
(void)hit;
|
||||
return last >= 0;
|
||||
}
|
||||
|
||||
/* The host view: the candidates as the sampler wrote them, weights computed as they are read. */
|
||||
struct RadRrsHostCands {
|
||||
const RadMtpCoupleState& s;
|
||||
const int32_t* ids; const float* val; int64_t n; float top;
|
||||
template <class F> RAD_RRS_HD void each(F&& f) const {
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) continue;
|
||||
int k = 0;
|
||||
while (k < s.count && ids[j] != s.ids[k]) ++k;
|
||||
if (!f(ids[j], ::exp((double)val[j] - top), k)) return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static inline RAD_RRS_HD bool rad_mtp_rrs_decide(const RadMtpCoupleState& s, const int32_t* ids,
|
||||
const float* val, int64_t n, int64_t vocab,
|
||||
uint64_t seed, uint64_t pos, int32_t* out) {
|
||||
float top = -INFINITY;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0) continue;
|
||||
if (ids[j] >= vocab || val[j] != val[j] || val[j] == INFINITY) return false;
|
||||
if (val[j] > top) top = val[j];
|
||||
}
|
||||
if (top == -INFINITY) return false;
|
||||
return rad_mtp_rrs_decide_over(s, RadRrsHostCands{ s, ids, val, n, top }, seed, pos, out);
|
||||
}
|
||||
|
||||
/* ================================================================== RheoSampling siblings
|
||||
*
|
||||
* --draft-siblings rheo (--draft-rheo-m m). Hu et al. 2025 (arXiv 2502.18779, Thm 8, the greedy
|
||||
* multi-draft verifier) and RheoSampling (arXiv 2609.21827): instead of Gumbel-top-k siblings, a node's
|
||||
* children are
|
||||
* T = the m tokens of largest Q, in descending q order (deterministic, rank slots 0 .. m-1), and
|
||||
* u ~ Qt, ONE token sampled from the tail law Qt(x) = Q(x) / z over the support outside T,
|
||||
* z = Q(outside T), in slot m;
|
||||
* the draft order stored in the state is ids = [T..., u, the rest of the support in descending q],
|
||||
* scheme = m + 1. A node whose support has no more than m tokens has no tail child (all of it is T).
|
||||
*
|
||||
* Verify (derived here, not quoted; the law is checked by tests/mtp_rrs_test.cpp by exhaustive
|
||||
* enumeration). P = the target's law, children present = the first nkids of the draft order.
|
||||
* tail child present (nkids > |T|, which with a prefix draft order means every T token is a child):
|
||||
* accept u with probability min(1, P(u) / Qt(u)) -> emit u
|
||||
* else emit y ~ R / |R|, R(y) = P(y) y in T or off Q's support,
|
||||
* R(y) = max(P(y) - Qt(y), 0) y in the tail support (R(u) = 0 here)
|
||||
* otherwise (the tail slot was pruned or cut by a window, or Q has no tail): emit y ~ P directly.
|
||||
* Exactness: P(emit y) = min(P, Qt)(y) [y in tail] + (1 - A) R(y) / |R| with |R| = 1 - A,
|
||||
* A = sum_tail min(P, Qt), and min(P, Qt) + R = P on the tail, R = P elsewhere: P(emit y) = P(y).
|
||||
* It needs only that u ~ Qt independently of the verifier's uniforms (a separate draft stream), and
|
||||
* that WHICH slots exist depends on Q and the tree's budget alone (never on the value of u): both
|
||||
* hold, the slot priorities are rad_mtp_rrs_slot_logq_rheo. The emitted token is a child with
|
||||
* probability P(T) + A = sum_T P + sum_tail min(P, Qt), Thm 8's value, and a residual draw never
|
||||
* lands on u (R(u) = 0 when u was rejected), so the core's "follow the first child whose token is
|
||||
* the sampler's" walks the decision made here.
|
||||
* m = 0 is the single-draft maximal coupling of the chain (rad_mtp_couple_decide) with the sampled
|
||||
* child in slot 0.
|
||||
*/
|
||||
#define RAD_MTP_RRS_KEY_TAIL_C 8 /* candidate index of the tail draw in the draft stream (0..7 are Gumbel's) */
|
||||
|
||||
/* Slot priorities of a rheo node (functions of Q alone, non-increasing): slots 0 .. m-1 carry the
|
||||
* log of the j-th largest q, slot m RheoSampling's proxy log min{q_(m-1), z} (z = the tail mass; with
|
||||
* m = 0, z = 1), -inf for the other slots and for slots past the support. */
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_slot_logq_rheo(const RadMtpCoupleState& s, int m, float* ov) {
|
||||
double qs[8];
|
||||
const int n = s.count < 8 ? s.count : 8;
|
||||
for (int i = 0; i < n; ++i) qs[i] = s.q[i];
|
||||
for (int i = 1; i < n; ++i) {
|
||||
const double v = qs[i];
|
||||
int j = i;
|
||||
while (j > 0 && qs[j - 1] < v) { qs[j] = qs[j - 1]; --j; }
|
||||
qs[j] = v;
|
||||
}
|
||||
const int nt = m < n ? m : n;
|
||||
for (int c = 0; c < 8; ++c) ov[c] = c < nt ? (float)::log(qs[c]) : -INFINITY;
|
||||
if (n > nt) {
|
||||
double z = 0;
|
||||
for (int i = nt; i < n; ++i) z += qs[i];
|
||||
if (z > 1) z = 1;
|
||||
const double ref = nt > 0 ? qs[nt - 1] : 1.0;
|
||||
ov[nt] = (float)::log(z < ref ? z : ref);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw a rheo node's children: reorder Q's support into [top-m by q desc, the sampled tail child,
|
||||
* the rest by q desc], set x = ids[0], scheme = m + 1 and nkids = min(nkids, children possible). The
|
||||
* tail child is the inverse-CDF draw of Qt with the draft stream's uniform of (seed, base, node). */
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_draw_rheo_u(RadMtpCoupleState* s, double ut, int nkids, int m) {
|
||||
int ord[8];
|
||||
const int n = s->count;
|
||||
for (int i = 0; i < n; ++i) ord[i] = i;
|
||||
for (int i = 1; i < n; ++i) { /* descending q, stable */
|
||||
const int o = ord[i];
|
||||
int j = i;
|
||||
while (j > 0 && s->q[ord[j - 1]] < s->q[o]) { ord[j] = ord[j - 1]; --j; }
|
||||
ord[j] = o;
|
||||
}
|
||||
const int nt = m < n ? m : n;
|
||||
if (n > nt) {
|
||||
double z = 0;
|
||||
for (int i = nt; i < n; ++i) z += s->q[ord[i]];
|
||||
double c = ut * z;
|
||||
int pick = n - 1;
|
||||
for (int i = nt; i < n; ++i) { c -= s->q[ord[i]]; if (c < 0) { pick = i; break; } }
|
||||
const int o = ord[pick];
|
||||
for (int i = pick; i > nt; --i) ord[i] = ord[i - 1];
|
||||
ord[nt] = o;
|
||||
}
|
||||
int32_t ids[8];
|
||||
double q[8];
|
||||
for (int i = 0; i < n; ++i) { ids[i] = s->ids[ord[i]]; q[i] = s->q[ord[i]]; }
|
||||
for (int i = 0; i < n; ++i) { s->ids[i] = ids[i]; s->q[i] = q[i]; }
|
||||
const int cap = nt + (n > nt ? 1 : 0);
|
||||
s->x = s->ids[0];
|
||||
s->scheme = m + 1;
|
||||
s->nkids = nkids < cap ? nkids : cap;
|
||||
}
|
||||
static inline RAD_RRS_HD void rad_mtp_rrs_draw_rheo(RadMtpCoupleState* s, uint64_t node, int nkids, int m) {
|
||||
rad_mtp_rrs_draw_rheo_u(s, rad_mtp_rrs_gumbel_u(s->draw.seed, s->draw.base, node, RAD_MTP_RRS_KEY_TAIL_C),
|
||||
nkids, m);
|
||||
}
|
||||
|
||||
/* The verify of a rheo node (any nkids >= 0): the rule above. Same contract as rad_mtp_rrs_decide. */
|
||||
static inline RAD_RRS_HD bool rad_mtp_rrs_decide_rheo_u(const RadMtpCoupleState& s, const int32_t* ids,
|
||||
const float* val, int64_t n, int64_t vocab,
|
||||
double u_accept, double u_resid, int32_t* out) {
|
||||
float top = -INFINITY;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0) continue;
|
||||
if (ids[j] >= vocab || val[j] != val[j] || val[j] == INFINITY) return false;
|
||||
if (val[j] > top) top = val[j];
|
||||
}
|
||||
if (top == -INFINITY) return false;
|
||||
double sum = 0, pq[8] = {};
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) continue;
|
||||
const double w = ::exp((double)val[j] - top);
|
||||
sum += w;
|
||||
for (int k = 0; k < s.count; ++k)
|
||||
if (ids[j] == s.ids[k]) { pq[k] += w; break; }
|
||||
}
|
||||
if (!(sum > 0) || !rad_spechub_finite(sum)) return false;
|
||||
const int m = s.scheme - 1;
|
||||
const int nt = m < s.count ? m : s.count;
|
||||
const bool tail = m >= 0 && s.count > nt && s.nkids > nt;
|
||||
double qt[8] = {}, r[8] = {};
|
||||
bool dominated = true;
|
||||
for (int k = 0; k < s.count; ++k) pq[k] /= sum;
|
||||
if (tail) {
|
||||
double z = 0;
|
||||
for (int k = nt; k < s.count; ++k) z += s.q[k];
|
||||
for (int k = nt; k < s.count; ++k) {
|
||||
const double v = nt == 0 ? s.q[k] : s.q[k] / z;
|
||||
qt[k] = v > 1 ? 1 : v; /* clamp: rounding must not push a one-token tail past 1 */
|
||||
dominated = dominated && pq[k] >= qt[k];
|
||||
}
|
||||
for (int k = 0; k < s.count; ++k) r[k] = k < nt ? pq[k] : rad_spechub_positive(pq[k] - qt[k]);
|
||||
}
|
||||
/* mass of candidate j in R (the tail case) or in P (otherwise); Q tokens count once. */
|
||||
unsigned seen = 0;
|
||||
auto mass = [&](int64_t j) -> double {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) return 0;
|
||||
for (int k = 0; k < s.count; ++k)
|
||||
if (s.ids[k] == ids[j]) {
|
||||
if (seen & (1u << k)) return 0;
|
||||
seen |= 1u << k;
|
||||
return tail ? r[k] : pq[k];
|
||||
}
|
||||
return ::exp((double)val[j] - top) / sum;
|
||||
};
|
||||
double resid = 0;
|
||||
if (tail) {
|
||||
for (int64_t j = 0; j < n; ++j) resid += mass(j);
|
||||
seen = 0;
|
||||
}
|
||||
if (!tail || (!dominated && !(resid > 0 && rad_spechub_finite(resid)))) {
|
||||
double c = u_resid * sum; /* P itself, in the sampler's candidate order */
|
||||
int32_t last = -1;
|
||||
for (int64_t j = 0; j < n; ++j)
|
||||
if (ids[j] >= 0 && val[j] != -INFINITY) {
|
||||
const double w = ::exp((double)val[j] - top);
|
||||
if (w > 0) { last = ids[j]; c -= w; if (c < 0) { *out = last; return true; } }
|
||||
}
|
||||
*out = last;
|
||||
return last >= 0;
|
||||
}
|
||||
const int iu = nt;
|
||||
if (pq[iu] >= qt[iu] || u_accept * qt[iu] < pq[iu]) {
|
||||
*out = s.ids[iu];
|
||||
return true;
|
||||
}
|
||||
double c = u_resid * resid;
|
||||
int32_t last = -1;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] == s.ids[iu]) continue;
|
||||
const double mm = mass(j);
|
||||
if (mm > 0) { last = ids[j]; c -= mm; if (c < 0) { *out = last; return true; } }
|
||||
}
|
||||
*out = last;
|
||||
return last >= 0;
|
||||
}
|
||||
static inline RAD_RRS_HD bool rad_mtp_rrs_decide_rheo(const RadMtpCoupleState& s, const int32_t* ids,
|
||||
const float* val, int64_t n, int64_t vocab,
|
||||
uint64_t seed, uint64_t pos, int32_t* out) {
|
||||
return rad_mtp_rrs_decide_rheo_u(s, ids, val, n, vocab,
|
||||
rad_spechub_uniform(seed, pos, RAD_SAMPLE_KEY_ACCEPT),
|
||||
rad_spechub_uniform(seed, pos, RAD_SAMPLE_KEY_RESID), out);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
#endif /* RAD_MTP_RRS_H */
|
||||
@@ -0,0 +1,549 @@
|
||||
/* rad_mtp_traversal.h -- Traversal Verification (Weng et al., arXiv 2505.12398) of a draft under
|
||||
* sampling (--draft-verify traversal, needs --draft-coupling on). The walk is defined on a tree; the
|
||||
* serial head of this engine drafts a chain, a tree of one child a node, which the sampler stages
|
||||
* (core/sample/sampler.cpp). Plain code shared by the host oracle, the device kernel and the tests;
|
||||
* the short form of the argument:
|
||||
*
|
||||
* Row-wise verification (rad_mtp_rrs_decide) decides each node on its own. Traversal verification
|
||||
* decides a whole ROOT-TO-LEAF PATH at once, bottom-up, and so can accept a longer prefix from the
|
||||
* same tree (for a chain it is Block Verification, never worse than token-level rejection sampling).
|
||||
*
|
||||
* State of a node v during the walk: p_v (its acceptance rate, a sequence-level ratio), the target
|
||||
* law M_b(.|v) restricted to what has not been rejected below it (r), and the law the NEXT child of
|
||||
* v was drawn from.
|
||||
* - A child c of v enters with p_c = min(1, p_v * r(c)/qn(c)), qn the law c was drawn from GIVEN
|
||||
* the children tried before it.
|
||||
* - The walk descends to the first leaf and tests eta < p_leaf. Accept: the path is accepted and
|
||||
* the final token is drawn from that node's current residual law r (the plain target if none of
|
||||
* its children was rejected). Reject: the leaf is deleted and its parent v is updated:
|
||||
* S = sum_x [ p_v r(x) - qn(x) ]+
|
||||
* p_v' = S / (S + 1 - p_v)
|
||||
* r' = [ p_v r - qn ]+ / S
|
||||
* and the walk continues with v's next child, or tests v itself once it has none.
|
||||
* The walk keeps the PRODUCT m(x) = p_v r(x) (on the draft support per slot, and one number for
|
||||
* everything off it, where qn is zero), which is all the rules read: p_c = min(1, m(c)/qn(c)), and
|
||||
* the update is one division, m' = [m - qn]+ / (S + 1 - p_v), p_v' = S / (S + 1 - p_v), the
|
||||
* off-support mass scaled alike; the final token is drawn in proportion to m. A node entered with
|
||||
* rate p keeps its target law unscaled and the factor p beside it (sc) until its first child is
|
||||
* rejected, so entering a node costs one division (the child's rate) and no pass over its law.
|
||||
* Exactness (Theorem 3.3 of the paper, Lemma A.2 by induction over a node's descendants): the
|
||||
* subtree of v is accepted with probability p_v and, given that, the token after v follows r. One
|
||||
* step of the induction, for a child drawn from ANY law qn that may depend on the children before
|
||||
* it: P(accepted through a child x) = qn(x) min(1, p_v r(x)/qn(x)) = min(qn(x), p_v r(x));
|
||||
* P(the child's subtree is rejected) = 1 - p_v + S; the rest then accepts with p_v' and r', which
|
||||
* adds (1 - p_v + S) p_v' r'(x) = [p_v r(x) - qn(x)]+, and the two sum to p_v r(x). It needs the
|
||||
* tree's shape to be independent of the drawn tokens (a chain's is), and each child's own law:
|
||||
* - Gumbel-top-k siblings (the default, Plackett-Luce without replacement): qn is the node's Q
|
||||
* with the children already tried removed, renormalised;
|
||||
* - RheoSampling siblings (state.scheme = m + 1, abi/rad_mtp_rrs.h): the
|
||||
* sampled tail child is tried FIRST with qn = Qt, the tail law, then the deterministic top-q
|
||||
* children in their order, each with qn = a point mass on its token. A point mass accepts with
|
||||
* p_v r(c) and leaves r without c; tried in this order the node's children take
|
||||
* sum_tail min(P, Qt) + P(T) of the target, the greedy multi-draft verifier's value (Hu et al.
|
||||
* 2025, Thm 8).
|
||||
* tests/mtp_rrs_test.cpp checks the walk by exact enumeration and by chi-square, and shows that
|
||||
* plausible mistakes (token-level ratios, no (1 - p) term, with-replacement update for
|
||||
* without-replacement drafts, a rheo node walked as a Gumbel one) fail the same statistic.
|
||||
*
|
||||
* THE TARGET LAW IN FIXED POINT. The walk reads a row's target law only through its mass on the
|
||||
* node's draft support (eight ids), the mass off it and the total; the final token needs the
|
||||
* off-support candidates in order. Each live candidate's weight is an INTEGER:
|
||||
*
|
||||
* m_j = floor(2^40 * e(val_j - top)), e(x) = rad_mtp_trav_mass's FP32 exponential
|
||||
*
|
||||
* (top the row's largest value; the scale drops a bit per doubling of the plane past 4096 slots so
|
||||
* a row's total stays below 2^53). Integer addition is associative, so the sums are the same bits
|
||||
* whatever order a workgroup adds them in: the device kernel (plugin/spechub/spechub.hip) splits a
|
||||
* row over its threads any way it likes and still equals this header's serial loops, with no
|
||||
* reduction tree to mirror. e() is basic FP32 arithmetic and integer shifts, identical on host and
|
||||
* device (no libm call, no contraction: -ffp-contract=off, and the attribute below for a host
|
||||
* build that enables FMA).
|
||||
* Why FP32 suffices: the algorithm is exact for whatever positive weights define the law, as long as
|
||||
* every decision reads the same ones, which the integers guarantee. The law it realises is
|
||||
* P~(y) = m_y / sum m, within 2^-22 relative per candidate (e's error, tests/mtp_rrs_test.cpp checks
|
||||
* it) plus 2^-40 absolute of the softmax of the sampler's FP32 candidates: the accuracy class of the
|
||||
* uncoupled sample_pick (FP32 expf, FP32 running sum, a 24-bit uniform), which is the law a request
|
||||
* gets without speculation. The 8-wide FP64 sums of the walk are a fixed tree (rad_mtp_trav_sum8),
|
||||
* so a device may run them on one lane or across eight.
|
||||
*
|
||||
* Wire: no new state. The walk reads the same RadMtpCoupleState rows as the row-wise verify and
|
||||
* writes the SAME plane the core already walks (ADV_ACCEPT: the first child whose token is the
|
||||
* sampler's token at the row): on the accepted path every row's token is its path child's token and
|
||||
* the last row's token is the final one; the other rows are not on the walk and keep the pick.
|
||||
*/
|
||||
#ifndef RAD_MTP_TRAVERSAL_H
|
||||
#define RAD_MTP_TRAVERSAL_H
|
||||
|
||||
#include "rad_spechub.h"
|
||||
#include "rad_mtp_rrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define RAD_MTP_TRAV_MAX_DEPTH 16
|
||||
#define RAD_MTP_TRAV_MAX_ROWS 64 /* rows of one request the walk reads (its first ones) */
|
||||
#define RAD_MTP_TRAV_KEY 0x54524156ull /* "TRAV": the walk's acceptance uniforms */
|
||||
#define RAD_MTP_TRAV_QBITS 40 /* the unit of a candidate's mass: 2^-40 of the top's */
|
||||
|
||||
/* A host build with FMA enabled must not contract the exponential's products into its sums: the
|
||||
* device does not (-ffp-contract=off), and the masses have to be the same bits. */
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#define RAD_TRAV_STRICT __attribute__((optimize("fp-contract=off")))
|
||||
#else
|
||||
#define RAD_TRAV_STRICT
|
||||
#endif
|
||||
|
||||
/* Test-only switches; the engine passes the zero value. */
|
||||
struct RadMtpTravOpt {
|
||||
int ctl = 0; /* negative controls: 1 token-level ratios, 2 no (1 - p) term, 3 q never
|
||||
renormalised (the with-replacement update on without-replacement drafts),
|
||||
4 a RheoSampling node walked as a Gumbel one */
|
||||
/* Enumeration (tests): >= 0 replaces the uniforms -- test number `accept_at` (1-based) accepts
|
||||
* and every earlier one rejects; `p_test[i]` receives the acceptance rate of test i + 1 and
|
||||
* `*n_tests` their count. */
|
||||
int accept_at = -1;
|
||||
double* p_test = nullptr;
|
||||
int* n_tests = nullptr;
|
||||
int max_tests = 0;
|
||||
double u_final = -1.0; /* >= 0: the final token's uniform (rad_mtp_trav_walk) */
|
||||
};
|
||||
|
||||
struct RadMtpTravOut {
|
||||
int n = 0; /* nodes on the path, root first */
|
||||
int node[RAD_MTP_TRAV_MAX_DEPTH + 2] = {};
|
||||
int32_t y = -1; /* the final token ... */
|
||||
bool has_y = false; /* ... when the last node carries a valid state */
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------- the target law in fixed point */
|
||||
|
||||
/* The mass unit of a plane of n candidates: 2^-qbits of the top candidate's weight, so that a
|
||||
* row's total stays below 2^53 (exact in FP64). */
|
||||
static inline RAD_RRS_HD int rad_mtp_trav_qbits(int64_t n) {
|
||||
int q = RAD_MTP_TRAV_QBITS;
|
||||
for (int64_t c = 4096; c < n && q > 20; c <<= 1) --q;
|
||||
return q;
|
||||
}
|
||||
|
||||
/* floor(2^qbits * e^(v - top)) for a live candidate (v <= top, both finite): the FP32 exponential
|
||||
* of Cephes' expf (argument reduction by n ln 2 in two parts, a degree-5 polynomial in the reduced
|
||||
* argument), taken as a 24-bit mantissa and shifted. Zero below 2^-41 of the top. Basic IEEE FP32
|
||||
* operations and integer shifts only. */
|
||||
RAD_TRAV_STRICT static inline RAD_RRS_HD uint64_t rad_mtp_trav_mass(float v, float top, int qbits) {
|
||||
#if defined(__clang__)
|
||||
#pragma clang fp contract(off)
|
||||
#endif
|
||||
const float x = v - top;
|
||||
if (!(x > -28.5f)) return 0;
|
||||
const int n = (int)(x * 1.44269504088896341f - 0.5f); /* round(x / ln 2), x <= 0 */
|
||||
const float fn = (float)n;
|
||||
float r = x - fn * 0.693359375f;
|
||||
r = r - fn * -2.12194440e-4f;
|
||||
const float z = r * r;
|
||||
float y = 1.9875691500e-4f;
|
||||
y = y * r + 1.3981999507e-3f;
|
||||
y = y * r + 8.3334519073e-3f;
|
||||
y = y * r + 4.1665795894e-2f;
|
||||
y = y * r + 1.6666665459e-1f;
|
||||
y = y * r + 5.0000001201e-1f;
|
||||
y = y * z + r;
|
||||
y = y + 1.0f; /* e^r, in [0.70, 1.42] */
|
||||
const uint32_t mant = (uint32_t)(y * 8388608.0f); /* y * 2^23, below 2^24 */
|
||||
const int sh = qbits + n - 23;
|
||||
if (sh >= 0) return (uint64_t)mant << sh;
|
||||
return sh > -32 ? (uint64_t)(mant >> -sh) : 0;
|
||||
}
|
||||
|
||||
/* An integer below 2^53 as a double, exactly, the same way on host and device. */
|
||||
static inline RAD_RRS_HD double rad_mtp_trav_u2d(uint64_t x) {
|
||||
return (double)(uint32_t)(x >> 32) * 4294967296.0 + (double)(uint32_t)x;
|
||||
}
|
||||
/* The integer part of a double in [0, 2^53). */
|
||||
static inline RAD_RRS_HD uint64_t rad_mtp_trav_d2u(double d) {
|
||||
const uint32_t hi = (uint32_t)(d * (1.0 / 4294967296.0));
|
||||
const double lo = d - (double)hi * 4294967296.0;
|
||||
return ((uint64_t)hi << 32) + (uint64_t)(uint32_t)lo;
|
||||
}
|
||||
|
||||
/* Candidate id's slot in a node's support (the first match), or cnt when it is outside. */
|
||||
static inline RAD_RRS_HD int rad_mtp_trav_slot(const int32_t* sid, int cnt, int32_t id) {
|
||||
int k = 0;
|
||||
while (k < cnt && id != sid[k]) ++k;
|
||||
return k;
|
||||
}
|
||||
|
||||
/* A row's validity and largest value, as rad_mtp_couple_decide scans them: false for an id past the
|
||||
* vocabulary, a NaN or +inf among the ids >= 0, or no finite value at all. */
|
||||
static inline RAD_RRS_HD bool rad_mtp_trav_row_top(const int32_t* ids, const float* val, int64_t n,
|
||||
int64_t vocab, float* top_out) {
|
||||
float top = -INFINITY;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0) continue;
|
||||
if (ids[j] >= vocab || val[j] != val[j] || val[j] == INFINITY) return false;
|
||||
if (val[j] > top) top = val[j];
|
||||
}
|
||||
*top_out = top;
|
||||
return top != -INFINITY;
|
||||
}
|
||||
|
||||
/* One row's target law over a node's support `sid[0 .. cnt)`: the masses on the support slots
|
||||
* (duplicate candidates aggregated at the first matching slot), off it, and the total. The serial
|
||||
* definition; a workgroup adds the same integers in its own order. */
|
||||
struct RadTravLaw {
|
||||
uint64_t pq[8];
|
||||
uint64_t off, sum;
|
||||
};
|
||||
static inline RAD_RRS_HD void rad_mtp_trav_row_law(const int32_t* ids, const float* val, int64_t n,
|
||||
float top, const int32_t* sid, int cnt,
|
||||
RadTravLaw* o) {
|
||||
const int qb = rad_mtp_trav_qbits(n);
|
||||
for (int k = 0; k < 8; ++k) o->pq[k] = 0;
|
||||
o->off = 0; o->sum = 0;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) continue;
|
||||
const uint64_t m = rad_mtp_trav_mass(val[j], top, qb);
|
||||
o->sum += m;
|
||||
const int k = rad_mtp_trav_slot(sid, cnt, ids[j]);
|
||||
if (k < cnt) o->pq[k] += m; else o->off += m;
|
||||
}
|
||||
}
|
||||
|
||||
/* The off-support candidate that holds unit `t` of the off-support mass, candidates in ascending
|
||||
* slot order (t < the row's off-support mass). -1 when there is none. */
|
||||
static inline RAD_RRS_HD int32_t rad_mtp_trav_off_token(const int32_t* ids, const float* val,
|
||||
int64_t n, float top, const int32_t* sid,
|
||||
int cnt, uint64_t t) {
|
||||
const int qb = rad_mtp_trav_qbits(n);
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) continue;
|
||||
if (rad_mtp_trav_slot(sid, cnt, ids[j]) < cnt) continue;
|
||||
const uint64_t m = rad_mtp_trav_mass(val[j], top, qb);
|
||||
if (t < m) return ids[j];
|
||||
t -= m;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- the prepared tree */
|
||||
|
||||
/* The eight-wide FP64 sums of the walk, as one fixed tree: the xor-4, xor-2, xor-1 butterfly of
|
||||
* eight lanes (IEEE addition is commutative, so every lane of the butterfly ends with these bits). */
|
||||
static inline RAD_RRS_HD double rad_mtp_trav_sum8(const double* v) {
|
||||
return ((v[0] + v[4]) + (v[2] + v[6])) + ((v[1] + v[5]) + (v[3] + v[7]));
|
||||
}
|
||||
|
||||
/* A node's draft side in the walk's canonical order: the children first, in draft order (a chain's
|
||||
* one child is x). `nk` the children the walk may try, `nt` -1 for Gumbel-top-k siblings, else the
|
||||
* number of deterministic top-q children of a RheoSampling node (its tail child is slot nt, `tail`
|
||||
* whether the node carries it), `swap` the stored slot that changed places with slot 0 (a chain row
|
||||
* whose x was not first; else 0).
|
||||
* False when the state names no child (unreachable for a rad_mtp_couple_state_valid state). */
|
||||
static inline RAD_RRS_HD bool rad_mtp_trav_canon(const RadMtpCoupleState& s, int ctl, int32_t* ids,
|
||||
double* q, int* nk, int* nt, int* tail, int* swap) {
|
||||
/* Every index below is a constant: a device lane keeps the state and the result in registers. */
|
||||
*swap = 0;
|
||||
*tail = 0;
|
||||
if (s.scheme > 0 && ctl != 4) {
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
ids[k] = k < s.count ? s.ids[k] : -1;
|
||||
q[k] = k < s.count ? s.q[k] : 0.0;
|
||||
}
|
||||
const int m = s.scheme - 1;
|
||||
const int t = m < s.count ? m : s.count;
|
||||
const int cap = t + (s.count > t ? 1 : 0);
|
||||
*nt = t;
|
||||
*nk = s.nkids < cap ? (s.nkids > 0 ? s.nkids : 0) : cap;
|
||||
*tail = *nk > t;
|
||||
return true;
|
||||
}
|
||||
*nt = -1;
|
||||
*nk = s.nkids >= 2 ? (s.nkids < s.count ? s.nkids : s.count) : 1;
|
||||
/* a chain row: x to the front (the first slot that holds it changes places with slot 0) */
|
||||
int kx = 0;
|
||||
if (s.nkids < 2) {
|
||||
kx = 8;
|
||||
for (int k = 7; k >= 0; --k)
|
||||
if (k < s.count && s.ids[k] == s.x) kx = k;
|
||||
}
|
||||
const bool found = kx < 8;
|
||||
int32_t idx = -1;
|
||||
double qx = 0.0;
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
idx = k == kx ? s.ids[k] : idx;
|
||||
qx = k == kx ? s.q[k] : qx;
|
||||
}
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
const bool in = found && k < s.count;
|
||||
const int32_t idk = k == 0 ? idx : (k == kx ? s.ids[0] : s.ids[k]);
|
||||
const double qk = k == 0 ? qx : (k == kx ? s.q[0] : s.q[k]);
|
||||
ids[k] = in ? idk : -1;
|
||||
q[k] = in ? qk : 0.0;
|
||||
}
|
||||
*swap = found ? kx : 0;
|
||||
return found;
|
||||
}
|
||||
|
||||
/* One request's tree as the walk reads it, node-indexed (node 0 the root, parents before
|
||||
* children). Plain data: the device keeps it in LDS and fills it with a workgroup. */
|
||||
struct RadTravTree {
|
||||
int n; /* nodes */
|
||||
int ok[RAD_MTP_TRAV_MAX_ROWS]; /* an eligible state with a valid target law */
|
||||
int nk[RAD_MTP_TRAV_MAX_ROWS]; /* children the walk tries */
|
||||
int nt[RAD_MTP_TRAV_MAX_ROWS]; /* -1 Gumbel; else a rheo node's deterministic children */
|
||||
int tail[RAD_MTP_TRAV_MAX_ROWS]; /* a rheo node that carries its sampled tail child */
|
||||
int ci[RAD_MTP_TRAV_MAX_ROWS]; /* children tried so far */
|
||||
int child[RAD_MTP_TRAV_MAX_ROWS][8]; /* slot k's child node, or -1 */
|
||||
int32_t ids[RAD_MTP_TRAV_MAX_ROWS][8]; /* the support, canonical order, -1 past it */
|
||||
double qr[RAD_MTP_TRAV_MAX_ROWS][8]; /* the draft law (Gumbel: tried children zeroed) */
|
||||
double m[RAD_MTP_TRAV_MAX_ROWS][8]; /* rate * residual on the support slots (the target's
|
||||
law itself until the node is entered) */
|
||||
double moff[RAD_MTP_TRAV_MAX_ROWS]; /* the same off the support, in all */
|
||||
double sc[RAD_MTP_TRAV_MAX_ROWS]; /* the factor m and moff still owe: the node's rate from
|
||||
its entry to its first rejected child, then 1 */
|
||||
double p[RAD_MTP_TRAV_MAX_ROWS]; /* the node's acceptance rate */
|
||||
uint64_t off[RAD_MTP_TRAV_MAX_ROWS]; /* the off-support mass in units (the final draw) */
|
||||
float top[RAD_MTP_TRAV_MAX_ROWS]; /* the row's largest value */
|
||||
int stack[RAD_MTP_TRAV_MAX_DEPTH + 1];
|
||||
};
|
||||
|
||||
/* Node v's laws from its canonical draft side and its row's integer law (`valid`: the row scanned
|
||||
* clean and its total is positive). */
|
||||
static inline RAD_RRS_HD void rad_mtp_trav_set_law(RadTravTree* t, int v, bool valid, float top,
|
||||
const RadTravLaw& w) {
|
||||
const bool ok = valid && w.sum > 0;
|
||||
const double sum = ok ? rad_mtp_trav_u2d(w.sum) : 1.0;
|
||||
for (int k = 0; k < 8; ++k) t->m[v][k] = ok ? rad_mtp_trav_u2d(w.pq[k]) / sum : 0.0;
|
||||
t->moff[v] = ok ? rad_mtp_trav_u2d(w.off) / sum : 0.0;
|
||||
t->off[v] = ok ? w.off : 0;
|
||||
t->top[v] = top;
|
||||
t->ci[v] = 0;
|
||||
t->ok[v] = ok;
|
||||
}
|
||||
|
||||
/* The slot of node v's j-th tried child. Gumbel: the draft order. Rheo: the sampled tail child
|
||||
* first (when the node carries it), then the deterministic ones. */
|
||||
static inline RAD_RRS_HD int rad_mtp_trav_try_slot(const RadTravTree& t, int v, int j) {
|
||||
const int nt = t.nt[v];
|
||||
if (nt < 0) return j;
|
||||
return t.tail[v] ? (j == 0 ? nt : j - 1) : j;
|
||||
}
|
||||
|
||||
/* The law node v's j-th tried child was drawn from, at support slot k. `isq` is the reciprocal of
|
||||
* rad_mtp_trav_try_norm: the sum of the node's remaining draft law (Gumbel) or of its tail's (rheo). */
|
||||
static inline RAD_RRS_HD double rad_mtp_trav_try_norm(const RadTravTree& t, int v) {
|
||||
const int nt = t.nt[v];
|
||||
if (nt < 0) return rad_mtp_trav_sum8(t.qr[v]);
|
||||
double tail[8];
|
||||
for (int k = 0; k < 8; ++k) tail[k] = k >= nt ? t.qr[v][k] : 0.0;
|
||||
return rad_mtp_trav_sum8(tail);
|
||||
}
|
||||
static inline RAD_RRS_HD double rad_mtp_trav_try_q(const RadTravTree& t, int v, int j, double isq,
|
||||
int k) {
|
||||
const int nt = t.nt[v];
|
||||
if (nt < 0) return t.qr[v][k] * isq;
|
||||
const int slot = rad_mtp_trav_try_slot(t, v, j);
|
||||
if (slot != nt) return k == slot ? 1.0 : 0.0; /* a deterministic child: a point mass */
|
||||
if (k < nt) return 0.0;
|
||||
const double q = nt == 0 ? t.qr[v][k] : t.qr[v][k] * isq;
|
||||
return q > 1.0 ? 1.0 : q; /* clamp: rounding must not push a one-token tail past 1 */
|
||||
}
|
||||
/* m / q for node v's j-th tried child at its own slot i, m the child's mass in the node's law: the
|
||||
* child's rate before the cap, in one division (m * sq / qr rather than m / (qr / sq)). Negative
|
||||
* when the law has no mass there (the child is not tried). */
|
||||
static inline RAD_RRS_HD double rad_mtp_trav_try_ratio(const RadTravTree& t, int v, int j, int i,
|
||||
double m) {
|
||||
const int nt = t.nt[v];
|
||||
const double q = t.qr[v][i];
|
||||
if (nt >= 0 && i != nt) return m; /* a point mass */
|
||||
if (!(q > 0)) return -1.0;
|
||||
if (nt == 0) return q < 1.0 ? m / q : m;
|
||||
const double sq = rad_mtp_trav_try_norm(t, v);
|
||||
return q < sq ? m * sq / q : m; /* the law's value is at most 1 */
|
||||
}
|
||||
|
||||
/* The walk over a prepared tree: the accepted path into path[0 .. *n_path). Returns false when
|
||||
* nothing was decided (an invalid root state: every row keeps the pick). `pos0` is the root row's
|
||||
* output position, the coordinate of the acceptance uniforms. Updates the tree in place: the last
|
||||
* node's m / moff are its residual law (up to the node's factor sc), which
|
||||
* rad_mtp_trav_final_pick reads. */
|
||||
static inline RAD_RRS_HD bool rad_mtp_trav_walk_tree(RadTravTree& t, uint64_t seed, uint64_t pos0,
|
||||
int* path, int* n_path,
|
||||
const RadMtpTravOpt& opt = RadMtpTravOpt{}) {
|
||||
int top = 0, tests = 0;
|
||||
t.stack[0] = 0;
|
||||
t.p[0] = 1.0;
|
||||
t.sc[0] = 1.0; /* the root's m is the target's law itself */
|
||||
*n_path = 0;
|
||||
if (!t.ok[0]) return false;
|
||||
for (;;) {
|
||||
const int v = t.stack[top];
|
||||
if (t.ok[v] && t.ci[v] < t.nk[v]) {
|
||||
const int j = t.ci[v];
|
||||
const int i = rad_mtp_trav_try_slot(t, v, j);
|
||||
/* p_c = min(1, p_v r(c) / qn(c)); control 1 drops p_v (token-level ratios) */
|
||||
const double f = opt.ctl == 1 ? (t.p[v] > 0 ? t.sc[v] / t.p[v] : 0.0) : t.sc[v];
|
||||
const double ratio = rad_mtp_trav_try_ratio(t, v, j, i, f * t.m[v][i]);
|
||||
const int c = top < RAD_MTP_TRAV_MAX_DEPTH && ratio >= 0 ? t.child[v][i] : -1;
|
||||
if (c < 0) { t.nk[v] = j; continue; } /* a child the verify no longer carries: cut here */
|
||||
const double pc = ratio < 1.0 ? ratio : 1.0;
|
||||
t.p[c] = pc;
|
||||
t.sc[c] = pc; /* the child's law becomes rate * law, when it is first needed */
|
||||
t.stack[++top] = c;
|
||||
continue;
|
||||
}
|
||||
/* a leaf: the sequence-level test */
|
||||
++tests;
|
||||
bool accept;
|
||||
if (opt.accept_at >= 0) {
|
||||
if (opt.p_test && tests <= opt.max_tests) opt.p_test[tests - 1] = t.p[v];
|
||||
if (opt.n_tests) *opt.n_tests = tests;
|
||||
accept = tests == opt.accept_at;
|
||||
} else {
|
||||
const double u = rad_spechub_uniform(
|
||||
seed, pos0, RAD_MTP_TRAV_KEY ^ rad_mtp_rrs_mix((uint64_t)tests));
|
||||
accept = u < t.p[v];
|
||||
}
|
||||
if (accept) {
|
||||
*n_path = top + 1;
|
||||
for (int i = 0; i <= top; ++i) path[i] = t.stack[i];
|
||||
return true;
|
||||
}
|
||||
if (top == 0) return false; /* the root always accepts (p = 1); only roundoff gets here */
|
||||
--top;
|
||||
const int g = t.stack[top];
|
||||
const int j = t.ci[g];
|
||||
const double isq = 1.0 / rad_mtp_trav_try_norm(t, g);
|
||||
const double pold = t.p[g], sc = t.sc[g];
|
||||
double d[8];
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
const double x = sc * t.m[g][k] - rad_mtp_trav_try_q(t, g, j, isq, k);
|
||||
d[k] = x > 0 ? x : 0;
|
||||
}
|
||||
const double moff = sc * t.moff[g];
|
||||
const double S = moff + rad_mtp_trav_sum8(d);
|
||||
if (!(S > 0) || !rad_spechub_finite(S)) {
|
||||
/* nothing of the target is left above the draft: this node cannot accept, nor a child of it */
|
||||
t.p[g] = 0;
|
||||
t.sc[g] = 0;
|
||||
} else {
|
||||
const double den = opt.ctl == 2 ? S : S + 1.0 - pold;
|
||||
const double inv = 1.0 / den;
|
||||
const double pn = S * inv;
|
||||
t.p[g] = pn < 1.0 ? pn : 1.0; /* a rate is at most 1: rounding may not push it past */
|
||||
for (int k = 0; k < 8; ++k) t.m[g][k] = d[k] * inv;
|
||||
t.moff[g] = moff * inv;
|
||||
t.sc[g] = 1.0;
|
||||
}
|
||||
/* Gumbel siblings are drawn WITHOUT replacement: the remaining Q renormalises */
|
||||
if (t.nt[g] < 0 && opt.ctl != 3) t.qr[g][j] = 0;
|
||||
++t.ci[g];
|
||||
}
|
||||
}
|
||||
|
||||
/* The final token of node v's residual law (in proportion to m on the support slots and moff off it:
|
||||
* the node's factor sc is common to both and cancels), by the uniform
|
||||
* u: the support slots first, in the canonical order, then the off-support candidates in slot
|
||||
* order. kind 0: no token (the row keeps the pick); 1: the token of support slot `slot`; 2: the
|
||||
* off-support candidate holding unit `t` of the row's off-support mass (rad_mtp_trav_off_token). */
|
||||
struct RadTravPick {
|
||||
int kind, slot;
|
||||
uint64_t t;
|
||||
};
|
||||
static inline RAD_RRS_HD RadTravPick rad_mtp_trav_final_pick(const RadTravTree& t, int v, double u) {
|
||||
RadTravPick o;
|
||||
o.kind = 0; o.slot = -1; o.t = 0;
|
||||
const double woff = t.moff[v];
|
||||
const double total = rad_mtp_trav_sum8(t.m[v]) + woff;
|
||||
if (!(total > 0) || !rad_spechub_finite(total)) return o;
|
||||
double c = u * total;
|
||||
int last = -1;
|
||||
for (int k = 0; k < 8; ++k) {
|
||||
const double m = t.m[v][k];
|
||||
if (m > 0) {
|
||||
last = k;
|
||||
c -= m;
|
||||
if (c < 0) { o.kind = 1; o.slot = k; return o; }
|
||||
}
|
||||
}
|
||||
const uint64_t off = t.off[v];
|
||||
if (woff > 0 && off > 0) {
|
||||
const double frac = c / woff;
|
||||
uint64_t tt = frac < 1.0 ? rad_mtp_trav_d2u(frac * rad_mtp_trav_u2d(off)) : off - 1;
|
||||
if (tt >= off) tt = off - 1;
|
||||
o.kind = 2; o.t = tt;
|
||||
return o;
|
||||
}
|
||||
if (last >= 0) { o.kind = 1; o.slot = last; }
|
||||
return o;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- a tree behind an interface
|
||||
*
|
||||
* The tree the walk reads (a Tree type provides):
|
||||
* const RadMtpCoupleState* state(int v) the node's bound state, or null (node is a leaf)
|
||||
* bool cand(int v, const int32_t** ids, const float** val, int64_t* n) target candidates
|
||||
* int child(int v, int32_t token) the node's first child row with that token, or -1
|
||||
* int64_t vocab()
|
||||
* rad_mtp_trav_walk prepares the nodes the walk can reach (in discovery order, at most
|
||||
* RAD_MTP_TRAV_MAX_ROWS), walks and draws the final token: the host reference and the tests. */
|
||||
template <class Tree>
|
||||
static inline bool rad_mtp_trav_walk(const Tree& T, int root, uint64_t seed, uint64_t pos0,
|
||||
RadMtpTravOut* out, RadMtpTravOpt opt = RadMtpTravOpt{},
|
||||
RadTravTree* keep = nullptr, int* ids_out = nullptr) {
|
||||
RadTravTree local;
|
||||
RadTravTree& t = keep ? *keep : local;
|
||||
int id[RAD_MTP_TRAV_MAX_ROWS]; /* node -> the tree's own id */
|
||||
struct Row { const int32_t* ids; const float* val; int64_t n; };
|
||||
Row rows[RAD_MTP_TRAV_MAX_ROWS];
|
||||
t.n = 1;
|
||||
id[0] = root;
|
||||
for (int a = 0; a < t.n; ++a) {
|
||||
const int v = id[a];
|
||||
t.ok[a] = 0; t.nk[a] = 0; t.nt[a] = -1; t.tail[a] = 0; t.ci[a] = 0;
|
||||
t.moff[a] = 0; t.sc[a] = 1.0; t.p[a] = 0; t.off[a] = 0; t.top[a] = -INFINITY;
|
||||
for (int k = 0; k < 8; ++k) { t.child[a][k] = -1; t.ids[a][k] = -1; t.qr[a][k] = 0; t.m[a][k] = 0; }
|
||||
rows[a] = Row{ nullptr, nullptr, 0 };
|
||||
const RadMtpCoupleState* sp = T.state(v);
|
||||
if (!sp) continue;
|
||||
int swap = 0;
|
||||
if (!rad_mtp_trav_canon(*sp, opt.ctl, t.ids[a], t.qr[a], &t.nk[a], &t.nt[a], &t.tail[a], &swap)) continue;
|
||||
const int32_t* ids = nullptr; const float* val = nullptr;
|
||||
int64_t n = 0;
|
||||
if (!T.cand(v, &ids, &val, &n)) continue;
|
||||
rows[a] = Row{ ids, val, n };
|
||||
float top = -INFINITY;
|
||||
RadTravLaw w{};
|
||||
const bool valid = rad_mtp_trav_row_top(ids, val, n, T.vocab(), &top);
|
||||
if (valid) rad_mtp_trav_row_law(ids, val, n, top, t.ids[a], sp->count, &w);
|
||||
rad_mtp_trav_set_law(&t, a, valid, top, w);
|
||||
if (!t.ok[a]) continue;
|
||||
for (int k = 0; k < t.nk[a]; ++k) {
|
||||
const int c = T.child(v, t.ids[a][k]);
|
||||
if (c < 0 || t.n >= RAD_MTP_TRAV_MAX_ROWS) continue;
|
||||
t.child[a][k] = t.n;
|
||||
id[t.n++] = c;
|
||||
}
|
||||
}
|
||||
int path[RAD_MTP_TRAV_MAX_DEPTH + 1], np = 0;
|
||||
if (ids_out) for (int a = 0; a < t.n; ++a) ids_out[a] = id[a];
|
||||
if (!rad_mtp_trav_walk_tree(t, seed, pos0, path, &np, opt)) return false;
|
||||
out->n = np;
|
||||
for (int i = 0; i < np; ++i) out->node[i] = id[path[i]];
|
||||
out->has_y = false;
|
||||
const int f = path[np - 1];
|
||||
if (t.ok[f]) {
|
||||
const double ur = opt.u_final >= 0 ? opt.u_final
|
||||
: rad_spechub_uniform(seed, pos0 + (uint64_t)(np - 1), RAD_SAMPLE_KEY_RESID);
|
||||
const RadTravPick pk = rad_mtp_trav_final_pick(t, f, ur);
|
||||
if (pk.kind == 1) { out->y = t.ids[f][pk.slot]; out->has_y = true; }
|
||||
if (pk.kind == 2) {
|
||||
int cnt = 0;
|
||||
while (cnt < 8 && t.ids[f][cnt] >= 0) ++cnt;
|
||||
out->y = rad_mtp_trav_off_token(rows[f].ids, rows[f].val, rows[f].n, t.top[f], t.ids[f], cnt, pk.t);
|
||||
out->has_y = out->y >= 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
#endif /* RAD_MTP_TRAVERSAL_H */
|
||||
+23
-2
@@ -344,7 +344,8 @@ typedef struct RadBatch {
|
||||
* (RadEncoderDecl::bidirectional): a picture's or a video frame's placeholders inside one
|
||||
* sequence's chunk. The pass attends them causally like every other row; the plugin attends a
|
||||
* run's rows again without the causal bound, over the keys before `bidi_used` (the position
|
||||
* after the run's last token), in place of that result. The scheduler ends no chunk inside such
|
||||
* after the run's last token, counted as the window group's seqused is: from the first
|
||||
* position of its table), in place of that result. The scheduler ends no chunk inside such
|
||||
* a run, so its keys are this pass's or, after a prefix hit, the cache's; a run longer than any
|
||||
* step is cut where its chunk ends, and that chunk's rows see the run up to the cut.
|
||||
*
|
||||
@@ -363,6 +364,18 @@ typedef struct RadBatch {
|
||||
* context state at the anchor (LiLiCorr) gathers it there; the query rows themselves sit past
|
||||
* that position. Null on every other pass. */
|
||||
const int32_t* anchor_rows;
|
||||
/* ---- appended in ABI 43 (a checkpoint inside the step) */
|
||||
/* A step of one prefill sequence (n_seq 1, no decode rows) whose linear-state checkpoint lies
|
||||
* inside it rather than at its end: host, the rows before the checkpoint (its position less
|
||||
* the sequence's context), 0 on every other step. Set only for a plugin that asked
|
||||
* (RadArchProbe::ckpt_snap_ok). Such a plugin runs its recurrence over [0, ckpt_cut) and
|
||||
* [ckpt_cut, n_tok) as two pieces -- each what a chunk of those rows computes -- and calls
|
||||
* rad_ckpt_snap for each stateful layer between them, so the snapshot is the state a chunk
|
||||
* ending at the checkpoint leaves, without a step of its own for the rows past it.
|
||||
* `ckpt_cu` is [3] device: {0, ckpt_cut, n_tok}, a piece's cu_seqlens at +0 and +1; null when
|
||||
* ckpt_cut is 0. */
|
||||
int32_t ckpt_cut;
|
||||
const int32_t* ckpt_cu;
|
||||
} RadBatch;
|
||||
|
||||
/* What a generator pass carries beside the step batch's own fields, which keep their meanings:
|
||||
@@ -729,7 +742,8 @@ typedef struct RadVideoGenBatch {
|
||||
/* VENCODE: f32 [enc_frames, enc_height, enc_width, 3] RGB in 0..255, the frames padded to
|
||||
* whole clips by repeating the last (rad_arch_encode_geom's entry 23). AENCODE: f32
|
||||
* [enc_channels, enc_n_samples], each channel padded with zeros to the hop (entry 0). Both:
|
||||
* the pass's geometry as rad_arch_encode_geom gave it, i32 on the device, and the media's
|
||||
* the pass's geometry as rad_arch_encode_geom gave it, i32 in pinned host memory also readable
|
||||
* by device kernels (mixed-site encoders share it), and the media's
|
||||
* kind (RAD_ENC_*, below) and its number within the kind from 1. */
|
||||
const float* enc_pixels;
|
||||
int32_t enc_frames, enc_height, enc_width;
|
||||
@@ -924,6 +938,13 @@ int rad_lane_join(RadCtx* c, int from, int to);
|
||||
* the status it set, so a helper can `return rad_step_fail(...)`. */
|
||||
int rad_step_fail(RadCtx* c, const char* what);
|
||||
|
||||
/* A step with a checkpoint inside it (RadBatch::ckpt_cut): copy layer `layer`'s state of the
|
||||
* stateful KV group `group` -- the sequence's committed slot as the issue stands -- into the
|
||||
* engine's checkpoint stage, on the current lane's stream. Called between the two pieces of the
|
||||
* recurrence, once for every stateful group and layer the plugin holds. A no-op returning RAD_OK
|
||||
* on a step with no checkpoint inside it, so a caller need not test. */
|
||||
int rad_ckpt_snap(RadCtx* c, rad_kvgroup group, int layer);
|
||||
|
||||
/* ================================================================== run-phase queries */
|
||||
const RadBatch* rad_batch(RadCtx* c);
|
||||
/* The position of model layer `layer` among `group`'s bound layers, or -1 when this rank has no
|
||||
|
||||
+22
-1
@@ -37,7 +37,23 @@ typedef struct RadMtpCoupleState {
|
||||
int32_t status, round, x, count;
|
||||
int32_t ids[8];
|
||||
double q[8];
|
||||
/* The node drafted `nkids` children, sampled without replacement from q, and ids[0 .. nkids) are
|
||||
* them in draft order (x == ids[0]; ids[nkids .. count) the rest of the support). nkids <= 1 is
|
||||
* the linear chain's single draw, whose ids keep the shortlist's order, and what the serial
|
||||
* MTP head writes (abi/rad_mtp_rrs.h states the siblings' law; the traversal walk of
|
||||
* abi/rad_mtp_traversal.h reads it). Zero from every writer that is not a sibling draw. */
|
||||
int32_t nkids;
|
||||
/* The sibling scheme of those children: 0 = Gumbel-top-k without replacement (the only one a
|
||||
* writer in this engine produces), m + 1 = RheoSampling's m deterministic top-q children plus one
|
||||
* sampled from the tail law (abi/rad_mtp_rrs.h). Zero from every other writer. */
|
||||
int32_t scheme;
|
||||
/* --draft-verify block (abi/rad_mtp_block.h): the length g of the block this row's chain is
|
||||
* verified as one (the rows 0 .. g-1 bound to rounds 1 .. g, staged on every row of it); 0 for
|
||||
* token-by-token verification. Written by the sampler's staging only; zero from the device. */
|
||||
int32_t blk;
|
||||
int32_t pad_;
|
||||
} RadMtpCoupleState;
|
||||
#define RAD_MTP_COUPLE_MAX_RHEO_M 7
|
||||
#define RAD_MTP_COUPLE_DRAW_WORDS (sizeof(RadMtpCoupleDraw) / 4)
|
||||
#define RAD_MTP_COUPLE_STATE_WORDS (sizeof(RadMtpCoupleState) / 4)
|
||||
#define RAD_MTP_COUPLE_MAX_ROUNDS 8
|
||||
@@ -46,7 +62,7 @@ typedef struct RadMtpCoupleState {
|
||||
#define RAD_MTP_COUPLE_KEY_DRAFT 0x4d5450434f55504cull
|
||||
#ifdef __cplusplus
|
||||
static_assert(sizeof(RadMtpCoupleDraw) == 32, "MTP coupling draw wire");
|
||||
static_assert(sizeof(RadMtpCoupleState) == 152, "MTP coupling state wire");
|
||||
static_assert(sizeof(RadMtpCoupleState) == 168, "MTP coupling state wire");
|
||||
static_assert(offsetof(RadMtpCoupleState, q) % 8 == 0, "MTP coupling q alignment");
|
||||
#endif
|
||||
|
||||
@@ -101,6 +117,9 @@ static inline RAD_SPECHUB_HD bool rad_mtp_couple_state_valid(const RadMtpCoupleS
|
||||
sum += s.q[i];
|
||||
has_x |= s.ids[i] == s.x;
|
||||
}
|
||||
if (s.nkids < 0 || s.nkids > s.count || (s.nkids >= 2 && s.ids[0] != s.x)) return false;
|
||||
if (s.scheme < 0 || s.scheme > RAD_MTP_COUPLE_MAX_RHEO_M + 1 || (s.scheme && s.nkids >= 1 && s.ids[0] != s.x))
|
||||
return false;
|
||||
return has_x && (sum - 1) <= 1e-12 && (1 - sum) <= 1e-12;
|
||||
}
|
||||
|
||||
@@ -327,6 +346,8 @@ static inline RAD_SPECHUB_HD int32_t rad_dflash_couple_step(const float* sc, con
|
||||
s->pos = 0;
|
||||
s->round = round;
|
||||
s->count = 0;
|
||||
s->nkids = 0; /* a walk's position is one draw: the chain's wire */
|
||||
s->scheme = 0;
|
||||
for (int i = 0; i < 8; ++i) { s->ids[i] = -1; s->q[i] = 0; }
|
||||
if (d.mode != 1) {
|
||||
s->status = 0;
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
* library serves the rotating norm, each linear quantises the norm's bf16 output itself and
|
||||
* the routed experts read a rotated copy written once a layer. The linears the recipe keeps
|
||||
* bf16 (the KDA beta, the MLA's low-rank q and kv and its head gate) read the norm's bf16
|
||||
* output in either case. Unclamped SwiGLU only: the int8 gated products have no clamped form.
|
||||
* output in either case. A clamped SwiGLU (flash's last layers) writes the bf16 product,
|
||||
* which had_quant_act_i8g quantises: one launch more than the unclamped gated product.
|
||||
* - any other (bf16, the four-bit experts of ling3-w4a8-rtn and ling-3.0-tiny-iq4, the GGUF
|
||||
* releases): the norms write E4M3 codes, each linear reads the bf16 plane or quantises it
|
||||
* itself, and four-bit experts read the E4M3 pair (rotated ones a rotated copy of it).
|
||||
@@ -420,9 +421,9 @@ struct Model {
|
||||
Names nm{};
|
||||
Geom g{};
|
||||
Shape s{};
|
||||
/* The trunk is rotated int8 (rad_fp8.h's linear_is_w8h or linear_is_wnh), its activation codes
|
||||
* one scale a `trunk_g8` columns: 256 for IQ8R, 128 for the other rotated forms. `norm_fed`:
|
||||
* the block norms write those codes themselves (rmsnorm_had_quant_i8g is served). */
|
||||
/* Whether layer 0's probe found a rotated-int8 trunk, and its activation scale group: see
|
||||
* rad_fp8.h's trunk_rotation. `norm_fed`: the block norms write those codes themselves
|
||||
* (rmsnorm_had_quant_i8g is served). */
|
||||
bool trunk_rot = false, norm_fed = false;
|
||||
int64_t trunk_g8 = RAD_FP8_BLOCK;
|
||||
std::vector<Layer> layers;
|
||||
@@ -849,13 +850,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
{
|
||||
RadEncoding enc{};
|
||||
m.trunk_rot = weight_enc(b, nm.f("blk.0.attn_qkv.weight"), &enc) &&
|
||||
(linear_is_w8h(enc) || linear_is_wnh(enc));
|
||||
if (m.trunk_rot) m.trunk_g8 = linear_w8h_group(enc);
|
||||
trunk_rotation(enc, &m.trunk_g8);
|
||||
}
|
||||
int64_t shared_g8 = m.trunk_g8;
|
||||
if (m.trunk_rot) {
|
||||
/* The routed experts read the trunk's rotated int8 codes (MoeFP8::a8), which only a
|
||||
* rotated expert meets; and the int8 gated products have no clamped form. */
|
||||
* rotated expert meets. A clamped layer clamps, then quantises (GateQuantFP8). */
|
||||
for (int l = (int)s.dense_layers; l < (int)s.n_layer + (mtp ? 1 : 0); ++l) {
|
||||
const MoeFP8::Config& c = msrc[(size_t)l].cfg;
|
||||
if (c.expert_bf16 || !c.expert_rot) {
|
||||
@@ -865,14 +865,6 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
l, c.expert_bf16 ? "plain bf16" : "unrotated");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (c.swiglu_limit > 0 || c.shared_swiglu_limit > 0) {
|
||||
fprintf(stderr, "radiance: bailing_hybrid: layer %d clamps its SwiGLU (routed %g, "
|
||||
"shared %g) and the trunk is rotated int8, whose gated products "
|
||||
"write int8 codes with no clamped form; this checkpoint is served "
|
||||
"with a bf16 or four-bit trunk\n",
|
||||
l, c.swiglu_limit, c.shared_swiglu_limit);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
m.norm_fed = rad_op_declared(b, "rmsnorm_had_quant_i8g") != 0;
|
||||
/* The shared expert's down projection is a trunk linear whose input codes take the group
|
||||
|
||||
+85
-7
@@ -184,10 +184,9 @@ inline long long calib_target() {
|
||||
* from an exercised one: libquant reads a per-expert file only when it holds several times K
|
||||
* rows. `domain` is what the tap summed; a reader quantising in another domain converts the file
|
||||
* itself (libquant's calib_sum). */
|
||||
inline bool calib_write_host(const float* h, int64_t k, long long rows, const char* what,
|
||||
uint32_t domain, int rank) {
|
||||
const char* dir = calib_dir();
|
||||
if (!dir || !h || k <= 0) return false;
|
||||
inline bool calib_write_host_to(const char* dir, const float* h, int64_t k, long long rows,
|
||||
const char* what, uint32_t domain, int rank) {
|
||||
if (!dir || !*dir || !h || k <= 0) return false;
|
||||
char path[512];
|
||||
std::snprintf(path, sizeof path, "%s/gram.r%d.%s.bin", dir, rank, what);
|
||||
FILE* f = std::fopen(path, "wb");
|
||||
@@ -211,6 +210,11 @@ inline bool calib_write_host(const float* h, int64_t k, long long rows, const ch
|
||||
return okw;
|
||||
}
|
||||
|
||||
inline bool calib_write_host(const float* h, int64_t k, long long rows, const char* what,
|
||||
uint32_t domain, int rank) {
|
||||
return calib_write_host_to(calib_dir(), h, k, rows, what, domain, rank);
|
||||
}
|
||||
|
||||
/* The same file from a device accumulator: copied back on the block's stream, then written. */
|
||||
inline bool calib_write(RadCtx* c, rad_buf b, int64_t k, long long rows, const char* what,
|
||||
uint32_t domain) {
|
||||
@@ -223,6 +227,19 @@ inline bool calib_write(RadCtx* c, rad_buf b, int64_t k, long long rows, const c
|
||||
return calib_write_host(h.data(), k, rows, what, domain, rad_rank(c));
|
||||
}
|
||||
|
||||
/* A selected architecture tap may use the build context's directory directly, rather than the
|
||||
* legacy process environment helper above. */
|
||||
inline bool calib_write_to(RadCtx* c, rad_buf b, int64_t k, long long rows, const char* what,
|
||||
uint32_t domain, const char* dir) {
|
||||
if (!dir || !*dir || !b || k <= 0) return false;
|
||||
void* p = rad_buf_ptr(c, b);
|
||||
if (!p) return false;
|
||||
std::vector<float> h((size_t)(k * k));
|
||||
if (rad_memcpy_async(h.data(), p, (int64_t)h.size() * 4, rad_stream(c)) < 0) return false;
|
||||
if (rad_stream_sync(rad_stream(c)) < 0) return false;
|
||||
return calib_write_host_to(dir, h.data(), k, rows, what, domain, rad_rank(c));
|
||||
}
|
||||
|
||||
/* A pinned host buffer of at least `bytes`, one per instance (slot), held for the process
|
||||
* lifetime, so a tap that copies a scratch back every pass runs at link speed. Null (and logged)
|
||||
* on failure. */
|
||||
@@ -344,8 +361,24 @@ private:
|
||||
std::string scope_;
|
||||
};
|
||||
|
||||
/* Returns the first negative status from a declare step. */
|
||||
#define RAD_ARCH_TRY(expr) do { int _s = (expr); if (_s < 0) return _s; } while (0)
|
||||
/* Returns the first negative status from a declare step, and says where the status crossed. A
|
||||
* step can return a status with no message of its own, and a failed declare would then report
|
||||
* the status alone. Every level the status passes prints one line, innermost first, so the lines
|
||||
* read as the path from the step that failed up to the plugin's declare. */
|
||||
#ifdef __FILE_NAME__
|
||||
#define RAD_ARCH_FILE __FILE_NAME__
|
||||
#else
|
||||
#define RAD_ARCH_FILE __FILE__
|
||||
#endif
|
||||
#define RAD_ARCH_TRY(expr) \
|
||||
do { \
|
||||
int _s = (expr); \
|
||||
if (_s < 0) { \
|
||||
fprintf(stderr, "radiance: declare: %s, from %s:%d\n", rad_strerror(_s), \
|
||||
RAD_ARCH_FILE, __LINE__); \
|
||||
return _s; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* ================================================================== C++-side decl helpers */
|
||||
/* C++ forms of rad_group_layer() and friends, which are C compound literals (a GNU extension in
|
||||
@@ -676,8 +709,13 @@ inline void prefetch_beside(RadCtx* c, rad_op op, rad_weight w, int64_t T) {
|
||||
}
|
||||
/* The `prefetch` of `w`'s first `bytes` where a library serves it; 0 otherwise. A plugin declares
|
||||
* none where the deployment turns the reads off (RadBuildCtx::weight_prefetch_off). */
|
||||
inline rad_op decl_prefetch(RadBuilder* b, rad_weight w, int64_t bytes) {
|
||||
inline rad_op decl_prefetch(RadBuilder* b, rad_weight w, int64_t bytes, int64_t blocks = 0) {
|
||||
if (!w || bytes <= 0 || !rad_op_declared(b, "prefetch")) return 0;
|
||||
/* `blocks`: the workgroups reading, where the architecture measured its own count (docs/OPS.md);
|
||||
* 0 leaves the kernel's. Stated only when asked, so a declaration without it is what it was. */
|
||||
if (blocks > 0)
|
||||
return RAD_OP(b, "prefetch", RAD_PARAMS(RAD_INT("bytes", bytes), RAD_INT("blocks", blocks)),
|
||||
RAD_WEIGHTS(w));
|
||||
return RAD_OP(b, "prefetch", RAD_PARAMS(RAD_INT("bytes", bytes)), RAD_WEIGHTS(w));
|
||||
}
|
||||
|
||||
@@ -1466,6 +1504,46 @@ inline void batch_split(const RadBatch* b, int64_t* n_seq_dec, int64_t* n_tok_de
|
||||
}
|
||||
}
|
||||
|
||||
/* What a step's attention reads of the QSA selection (AttnGatedFP8::qsa_use), which decides what
|
||||
* the indexer issues for the layer (QsaIndexer::step, docs/QSA.md "Below the bound"):
|
||||
*
|
||||
* kQsaSelect score and select, per layer: a step past the exactness bound, a streamed group,
|
||||
* and every step of a block that did not ask for the forms below;
|
||||
* kQsaUnread nothing reads the selection: the step is entirely at or below the bound and its
|
||||
* attention is the dense one, or the sparse row over the sequence's own block table
|
||||
* (one row a sequence), which is what the selection would be. The indexer stores its
|
||||
* keys and tail and issues no query, score or select;
|
||||
* kQsaOnce the attention reads a selection (the sparse row a query) on a step entirely at or
|
||||
* below the bound: every complete block is taken whatever it scores, so the
|
||||
* selection depends on the positions and the block table alone and is the same
|
||||
* bytes at every layer. The first full-attention layer of the pass issues it;
|
||||
* no later layer issues a query, a score or a select. */
|
||||
enum QsaUse : int { kQsaSelect = 0, kQsaUnread = 1, kQsaOnce = 2 };
|
||||
|
||||
/* Ops of a chain that is independent of a block's own, for the block to issue behind its ordered
|
||||
* launches. A recorded pass lets a launch start beside the last ordered one when it touches
|
||||
* nothing in flight (Ctx::haz_mark). A dependent chain issued in one piece is therefore a row of
|
||||
* ordered launches, each paid in turn; issued one op behind each of the block's own ordered
|
||||
* launches, every op of it is unordered behind the block's launch in front of it, and still
|
||||
* behind its own predecessor, which that launch already waited for. The block calls `at(k)` for
|
||||
* k = 0, 1, 2, ... behind its ordered launches in turn, and the owner issues what is left once
|
||||
* the block returns. The chain must read nothing the block writes and write nothing the block
|
||||
* touches, and its buffers must be excluded from sharing (rad_buf_concurrent): they are in use at
|
||||
* launches the linear order puts after their last declared use. */
|
||||
struct SideOps {
|
||||
void (*fn)(void* u, int stage) = nullptr;
|
||||
void* u = nullptr;
|
||||
void at(int stage) const { if (fn) fn(u, stage); }
|
||||
};
|
||||
|
||||
/* RADIANCE_DEBUG_QSA_EAGER: every step is kQsaSelect, each layer issuing its own selection. An
|
||||
* instrument for comparing that sequence with the forms above (the text must not move); read
|
||||
* once. */
|
||||
inline bool qsa_eager() {
|
||||
static const bool on = std::getenv("RADIANCE_DEBUG_QSA_EAGER") != nullptr;
|
||||
return on;
|
||||
}
|
||||
|
||||
/* The step batch's entry for one declared KV group (built once per step by the core, spec §8). */
|
||||
inline const RadKVGroupBatch* kv_batch(const RadBatch* b, rad_kvgroup group) {
|
||||
for (int i = 0; i < b->n_kv_groups; ++i)
|
||||
|
||||
@@ -156,8 +156,9 @@ inline int AttnFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l, r
|
||||
{w.qkv}, {});
|
||||
|
||||
/* The out-projection's input quantiser; a plain `quant_act_fp8`, as there is no gate pass to
|
||||
* fold it into. */
|
||||
RAD_ARCH_TRY(q_attn.declare(b, g, w.attn, q_dim));
|
||||
* fold it into. Declared where the activation carries a code pair its producer writes: an int8
|
||||
* trunk that leaves each linear to quantise its own input declares none (nemotronh). */
|
||||
if (w.attn.cq()) RAD_ARCH_TRY(q_attn.declare(b, g, w.attn, q_dim));
|
||||
RAD_ARCH_TRY(o.declare(b, nm, g, nm.f("blk.%d.attn_output", l), g.n_embd, q_dim,
|
||||
RAD_SHARD_COL, grp_layer(l), { src.o }, w.attn, w.h.x));
|
||||
|
||||
|
||||
@@ -79,6 +79,21 @@ struct AttnGatedFP8 {
|
||||
/* `sel`'s row pitch is `topk + 1`; the extra slot is the partial page
|
||||
* (r4d_qsa_select_bf16.hip). */
|
||||
int64_t qsa_topk = 0;
|
||||
/* The architecture's word that a sequence with one row in the step has that row at its
|
||||
* context's last position (`seqused - 1`: a plain decode row, a serial head's round), so at or
|
||||
* below `qsa_exact_to` such a row's selection is the head of the sequence's block table and its
|
||||
* `seqused` the sequence's (qsa_select: every complete block in block order, then the partial
|
||||
* page, and `pos + 1`). The sparse row is then issued over the table and the indexer selects
|
||||
* nothing (qsa_use). Off: such a step keeps the selection. */
|
||||
bool qsa_table_rows = false;
|
||||
/* The architecture's pass key carries whether this group's exact host bound
|
||||
* (RadBatch::kv_used_max_h, the furthest context any row of the step can read) is within
|
||||
* `qsa_exact_to`, so that bound may say whether the step needs scores (qsa_within) in place of
|
||||
* the rounded `max_ctx_len + max_q_len`, which a 4-row step leaves at 1025 tokens. It never
|
||||
* moves the choice between the dense and the sparse kernel, which stays the rounded bound's:
|
||||
* the two agree on the keys, not on the last bit of the sum. Off: the rounded bound, which the
|
||||
* core's key holds. */
|
||||
bool qsa_exact_host = false;
|
||||
/* Query rows per sparse attention launch, a scratch budget. The decode kernel's split-KV
|
||||
* partials are sized at declare from `max_seqs` and `q_len`, so issuing more rows than
|
||||
* `max_seqs` means declaring a larger value, which grows the scratch arena (the maximum over
|
||||
@@ -111,6 +126,14 @@ struct AttnGatedFP8 {
|
||||
* (decl_prefetch, rad_arch.h), issued behind the q, k and v projections on decode steps
|
||||
* (prefetch_beside). 0 where none is declared. */
|
||||
rad_op op_pf_o = 0;
|
||||
/* The same read as a second op for steps of at least pf_o_v_rows rows, where the
|
||||
* architecture measured another workgroup count for them (decl_prefetch's `blocks`); 0 where
|
||||
* every step takes op_pf_o. */
|
||||
rad_op op_pf_o_v = 0;
|
||||
int64_t pf_o_v_rows = 0;
|
||||
/* The most rows of a decode step whose k and v projections are issued in front of the q|gate
|
||||
* projection (step()); 0, the default, keeps the declared order on every step. */
|
||||
int64_t kv_first_rows = 0;
|
||||
NormQuantFP8 nq_h{};
|
||||
|
||||
rad_op op_fused = 0; /* qk_norm_rope_gate, if it resolves */
|
||||
@@ -168,8 +191,12 @@ struct AttnGatedFP8 {
|
||||
/* The block's tail, declared last by every rank: the all-reduce and the trailing add. */
|
||||
int declare_out(RadBuilder* b, bool add_out);
|
||||
/* `own_ar` false: the caller issues the all-reduce itself (GdnFP8::step says when). */
|
||||
/* `side`: an independent chain's ops, issued behind this block's ordered launches (SideOps,
|
||||
* rad_arch.h): one behind the prologue and the store, one behind the attention, one behind
|
||||
* the gate where the gate is a launch of its own. Null, and on the paths that return early,
|
||||
* nothing is asked of it. */
|
||||
void step(RadCtx* c, const RadBatch* batch, bool own_ar = true,
|
||||
ArPieces* pieces = nullptr) const;
|
||||
ArPieces* pieces = nullptr, const SideOps* side = nullptr) const;
|
||||
bool issues_ar(int64_t T) const { return op_ar && !ar_taken(g, T, ar_out, ar_out_take); }
|
||||
void issue_ar(RadCtx* c, int64_t r0, int64_t rows) const {
|
||||
RAD_ISSUE_N(c, op_ar_ov ? op_ar_ov : op_ar, rows * g.n_embd,
|
||||
@@ -185,6 +212,41 @@ struct AttnGatedFP8 {
|
||||
* components agree, so plane 0 of an M-RoPE batch's positions is each token's position) and
|
||||
* the gate quantised by gate_quant_fp8. A streamed group never takes it: the pieces path's
|
||||
* plain store never writes the host mirror. */
|
||||
/* The rounded host bound of the furthest context a row of the step reads; by it a step of
|
||||
* several rows a sequence takes the dense or the sparse kernel (step(), `sparse`). */
|
||||
int64_t qsa_reach(const RadBatch* batch) const {
|
||||
return (int64_t)batch->max_ctx_len + batch->max_q_len;
|
||||
}
|
||||
/* Whether every row of the step is at or below the exactness bound, by the tightest host
|
||||
* ceiling there is: the group's exact one where the pass key holds its side of the bound
|
||||
* (qsa_exact_host), else the rounded one. Every row's position + 1 is at most either. */
|
||||
bool qsa_within(const RadBatch* batch, const RadKVGroupBatch* kvb) const {
|
||||
if (qsa_exact_to <= 0) return false;
|
||||
int64_t reach = qsa_reach(batch);
|
||||
if (qsa_exact_host && kvb && batch->kv && batch->kv_used_max_h) {
|
||||
const int64_t tight = batch->kv_used_max_h[kvb - batch->kv];
|
||||
if (tight > 0 && tight < reach) reach = tight;
|
||||
}
|
||||
return reach <= qsa_exact_to;
|
||||
}
|
||||
/* What this step's attention reads of the selection (QsaUse, rad_arch.h); the architecture
|
||||
* hands it to the indexer, which runs first, and step() takes its path by the same call. */
|
||||
int qsa_use(const RadBatch* batch) const {
|
||||
if (!qsa_sel || !qsa_sequ || op_fill || qsa_eager()) return kQsaSelect;
|
||||
const RadKVGroupBatch* kvb = kv_batch(batch, kv);
|
||||
/* A streamed group may be ring-bound, where every pass is sparse and the resolve rewrites
|
||||
* the selection; it keeps the selection at every context. */
|
||||
if (!kvb || kvb->stream || !kvb->block_table || !kvb->seqused) return kQsaSelect;
|
||||
if (!qsa_within(batch, kvb)) return kQsaSelect;
|
||||
/* One row a sequence is the sparse row at every context: over the table where the
|
||||
* architecture vouches for it, else over a selection. */
|
||||
if (batch->n_tok == batch->n_seq)
|
||||
return (qsa_table_rows && batch->max_q_len == 1) ? kQsaUnread : kQsaOnce;
|
||||
/* Several rows a sequence: the dense attention, which reads the table, where the rounded
|
||||
* bound is within the budget too, else the sparse row a query over a selection. */
|
||||
return qsa_reach(batch) <= qsa_exact_to ? kQsaUnread : kQsaOnce;
|
||||
}
|
||||
|
||||
bool takes_pieces(const RadBatch* batch, const ArPieces* pieces) const {
|
||||
const int64_t T = batch->n_tok;
|
||||
const RadKVGroupBatch* kvb = kv_batch(batch, kv);
|
||||
@@ -571,7 +633,7 @@ inline void AttnGatedFP8::store_kv(RadCtx* c, const RadBatch* batch) const {
|
||||
}
|
||||
|
||||
inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
ArPieces* pieces) const {
|
||||
ArPieces* pieces, const SideOps* side) const {
|
||||
const RadKVGroupBatch* kvb = kv_batch(batch, kv);
|
||||
const int32_t* slot = kvb ? kvb->slot_mapping : nullptr;
|
||||
const int32_t* table = kvb ? kvb->block_table : nullptr;
|
||||
@@ -633,11 +695,23 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
if (op_add) RAD_ISSUE(c, op_add, brows(w.x, T), brows(w.h.x, T), brows(w.x, T));
|
||||
return;
|
||||
}
|
||||
qg.step(c, w.h, w.qg, T);
|
||||
kp.step(c, w.h, w.k, T);
|
||||
vp.step(c, w.h, w.v, T);
|
||||
/* The three projections read the same input and none reads another's output, so a recorded
|
||||
* pass starts them together (Ctx::haz_mark) whatever their order; the order decides which
|
||||
* the card launches first. On a decode step of up to `kv_first_rows` rows the two small ones
|
||||
* go first: behind the wide q|gate projection their launches wait until its blocks are all
|
||||
* on the card, and the prologue then waits for them. Qwen3.8-Flash-Next at tp 2, chain 3
|
||||
* with coupling (twelve trunk layers and the head's): -0.66% a step. */
|
||||
if (T <= kv_first_rows && batch->phase == RAD_PHASE_DECODE) {
|
||||
kp.step(c, w.h, w.k, T);
|
||||
vp.step(c, w.h, w.v, T);
|
||||
qg.step(c, w.h, w.qg, T);
|
||||
} else {
|
||||
qg.step(c, w.h, w.qg, T);
|
||||
kp.step(c, w.h, w.k, T);
|
||||
vp.step(c, w.h, w.v, T);
|
||||
}
|
||||
/* The out projection's weight, read beside the prologue and the attention (op_pf_o). */
|
||||
prefetch_beside(c, op_pf_o, o.w, T);
|
||||
prefetch_beside(c, op_pf_o_v && T >= pf_o_v_rows ? op_pf_o_v : op_pf_o, o.w, T);
|
||||
|
||||
/* Fused or unfused prologue. The fused kernel takes the whole [q|gate] projection and splits it
|
||||
* itself, and rotates k in place like the unfused ops. It reads one rotary component per
|
||||
@@ -682,6 +756,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
}
|
||||
|
||||
if (!fused_kv && !folded_stream) store_cache(c, kvb, slot, T);
|
||||
if (side) side->at(0);
|
||||
|
||||
/* Sparse attention issues one row per query. `attn_paged` indexes its block table and length
|
||||
* by row, and a row need not be a sequence, so T queries issued as T rows of q_len 1, each with
|
||||
@@ -694,7 +769,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
* Launches are chunked because the split-KV scratch is sized at declare from `max_seqs` and
|
||||
* `q_len` (rows = max_seqs * q_len_max * heads); more rows are refused as RAD_E_SCRATCH at
|
||||
* issue. Rows of q_len 1 up to the declared max_seqs always fit. */
|
||||
const int64_t reach = (int64_t)batch->max_ctx_len + batch->max_q_len;
|
||||
const int64_t reach = qsa_reach(batch);
|
||||
/* A pass on a streamed group's ring (a ring smaller than the id space, and not staged) must
|
||||
* take the sparse path: on the ring a block id is not a pool address, so the dense path would
|
||||
* read ring slots as pages. `T == n_seq` alone misses a verify pass, whose T is
|
||||
@@ -708,6 +783,19 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
const bool sparse = qsa_sel && qsa_sequ &&
|
||||
(ring_bound || T == batch->n_seq || qsa_exact_to <= 0 ||
|
||||
reach > qsa_exact_to);
|
||||
/* At or below the bound a step of one row a sequence has no selection (qsa_use): the sparse
|
||||
* row reads the sequence's own block table and length, which is what qsa_select would have
|
||||
* written for it (the field says why), so the launch, its kernel and its bytes are the sparse
|
||||
* row's. */
|
||||
const bool by_table = sparse && T == batch->n_seq && qsa_use(batch) == kQsaUnread;
|
||||
const int64_t tpitch = kvb ? kvb->block_table_pitch : 0;
|
||||
auto sel_rows = [&](int64_t off, int64_t rows) {
|
||||
return by_table ? praw2(table + off * tpitch, RAD_I32, rows, tpitch)
|
||||
: brow_slice(qsa_sel, off, rows, qsa_topk + 1);
|
||||
};
|
||||
auto sequ_rows = [&](int64_t off, int64_t rows) {
|
||||
return by_table ? praw(used + off, RAD_I32, rows) : brow_slice(qsa_sequ, off, rows, 1);
|
||||
};
|
||||
const bool gated = sparse && op_attn_gq;
|
||||
/* A streamed group's selection, per launch: make the rows' blocks resident and rewrite `sel`
|
||||
* as ring slots, after this layer's store (a block copied in from the mirror must carry this
|
||||
@@ -715,6 +803,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
* and never resolves, so a prefill cannot overflow the ring. */
|
||||
const KVStreamLayer res_l = op_resolve ? kv_stream_layer(c, kv, layer, kvb) : KVStreamLayer{};
|
||||
auto resolve_sel = [&](int64_t off, int64_t rows) {
|
||||
if (by_table) return; /* never a streamed group (qsa_use) */
|
||||
if (kv_stage_layer(c, kv, kvb, layer)) return;
|
||||
if (!res_l.host || res_l.blocks <= 0 || res_l.slots <= 0 || rows <= 0) return;
|
||||
kv_resolve_issue(c, op_resolve, res_l, brow_slice(qsa_sel, off, rows, qsa_topk + 1),
|
||||
@@ -736,8 +825,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
RAD_ISSUE_N(c, op_attn_gq, 1,
|
||||
brow_slice(w.q, off, rows, qw),
|
||||
kv_cache(kv, layer),
|
||||
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
|
||||
brow_slice(qsa_sequ, off, rows, 1),
|
||||
sel_rows(off, rows), sequ_rows(off, rows),
|
||||
RAD_NONE, RAD_NONE, RAD_NONE,
|
||||
brow_slice(w.attn.x, off, rows, qw),
|
||||
bcol_at(w.qg, off, g.n_head * 2 * hd, hd, hd, rows),
|
||||
@@ -760,8 +848,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
RAD_ISSUE_N(c, op_attn_gq, 1,
|
||||
brow_slice(w.q, off, rows, qw),
|
||||
kv_cache(kv, layer),
|
||||
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
|
||||
brow_slice(qsa_sequ, off, rows, 1),
|
||||
sel_rows(off, rows), sequ_rows(off, rows),
|
||||
RAD_NONE, RAD_NONE, RAD_NONE,
|
||||
brow_slice(w.attn.x, off, rows, qw),
|
||||
bcol_at(w.qg, off, g.n_head * 2 * hd, hd, hd, rows),
|
||||
@@ -777,8 +864,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
RAD_ISSUE_N(c, op_attn, 1,
|
||||
brow_slice(w.q, off, rows, qw),
|
||||
kv_cache(kv, layer),
|
||||
brow_slice(qsa_sel, off, rows, qsa_topk + 1),
|
||||
brow_slice(qsa_sequ, off, rows, 1),
|
||||
sel_rows(off, rows), sequ_rows(off, rows),
|
||||
RAD_NONE, RAD_NONE, RAD_NONE,
|
||||
brow_slice(w.attn.x, off, rows, qw));
|
||||
}
|
||||
@@ -839,6 +925,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
/* Every attention launch of this layer is issued: start the next layer's stage copy, which
|
||||
* crosses the link under the out projection and the next layer's projections. */
|
||||
if (kvb && kvb->stream) kv_stage_next(c, kv, layer);
|
||||
if (side) side->at(1);
|
||||
if (gated) {
|
||||
/* the sparse attention gated and quantised in its merge */
|
||||
} else if (op_sig) {
|
||||
@@ -852,6 +939,7 @@ inline void AttnGatedFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
bcol(w.qg, g.head_dim, g.head_dim, T), brows(w.attn.x, T),
|
||||
brows(w.attn.cq(), T), brows(w.attn.cs(), T), brows(w.attn.x, T));
|
||||
}
|
||||
if (side && !gated) side->at(2);
|
||||
|
||||
o.step(c, w.attn, w.h.x, T);
|
||||
if (own_ar && op_ar && !ar_taken(g, T, ar_out, ar_out_take))
|
||||
|
||||
@@ -147,6 +147,10 @@ struct Dflash2 {
|
||||
/* The target's embedding scale, applied to the query block as the drafter was trained
|
||||
* (dflash_config.input_embedding_scale): 1 for Qwen, sqrt(hidden) in bf16 for Gemma. */
|
||||
double escale = 1.0;
|
||||
/* The drafter's logit transform: `omul` multiplies the final norm's output, `scap` > 0 is
|
||||
* a tanh soft cap on the draft logits. 1 and 0 leave the logits as the head gives them. */
|
||||
double omul = 1.0;
|
||||
double scap = 0.0;
|
||||
/* Bytes of the next GEMM's weight read into the cache beside each all-reduce of the query
|
||||
* pass (prefetch_beside, rad_arch.h); 0 reads none. */
|
||||
int64_t prefetch = 0;
|
||||
@@ -270,6 +274,10 @@ struct Dflash2 {
|
||||
* 31B's: the head read at w8a8, so the selector sees the candidates an 8-bit head ranks), and
|
||||
* the 2-bit grid otherwise. Set by declare from the copy's encoding. */
|
||||
bool head_i8 = false;
|
||||
/* The copy is plain bf16 where the container holds it so, read by gemm_nt: the form for a
|
||||
* vocabulary that is not a multiple of the int8 and 2-bit head kernels' 128-row tile (Muse
|
||||
* Glimmer's 202048 tokens). */
|
||||
bool head_bf16 = false;
|
||||
|
||||
/* per-layer weights */
|
||||
rad_weight w_anorm[MAX_LAYERS] = {}, w_fnorm[MAX_LAYERS] = {};
|
||||
@@ -334,7 +342,7 @@ struct Dflash2 {
|
||||
rad_weight pfa_w[MAX_LAYERS][2] = {}, pff_w[MAX_LAYERS][2] = {}, pfo_w[MAX_LAYERS] = {};
|
||||
|
||||
/* head and selector */
|
||||
rad_op op_gather = 0, op_dquant = 0, op_dlogits = 0, op_dtopk = 0;
|
||||
rad_op op_gather = 0, op_dquant = 0, op_dlogits = 0, op_dcap = 0, op_dtopk = 0;
|
||||
rad_op op_dgather = 0, op_dmerge = 0; /* the vocab-parallel pair; 0 when the head is whole */
|
||||
rad_op op_drerank = 0; /* the candidates rescored against the target's head */
|
||||
/* The target's lm_head, set by the plugin before declare when logit_rerank can read it (fp8 or
|
||||
@@ -482,12 +490,13 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
RAD_ARCH_TRY(map_copy(b, dhn, ck_lm));
|
||||
/* The 8-bit form: int8 codes, one f16 scale per (row, 128 of K), symmetric, which
|
||||
* gemm_nt_q reads at w8a8 against the same quant_act_i8 activation (without its asum). */
|
||||
RadEncoding dhe{};
|
||||
const bool head_known = weight_enc(b, dhn, &dhe);
|
||||
{
|
||||
RadEncoding e{};
|
||||
const RadEncPlane* sc = nullptr;
|
||||
head_i8 = weight_enc(b, dhn, &e) && rad_enc_is(&e, "affine") && e.n_planes == 2 &&
|
||||
!e.transform[0] && e.plane[0].dtype == RAD_I8 && e.plane[0].block[1] == 1 &&
|
||||
(sc = rad_enc_plane(&e, "scale")) && sc->dtype == RAD_F16 &&
|
||||
head_i8 = head_known && rad_enc_is(&dhe, "affine") && dhe.n_planes == 2 &&
|
||||
!dhe.transform[0] && dhe.plane[0].dtype == RAD_I8 && dhe.plane[0].block[1] == 1 &&
|
||||
(sc = rad_enc_plane(&dhe, "scale")) && sc->dtype == RAD_F16 &&
|
||||
sc->block[0] == 1 && sc->block[1] == DF_W2_GROUP;
|
||||
}
|
||||
if (head_i8) {
|
||||
@@ -496,6 +505,11 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
w_dhs = decl_view(b, nm.f("dflash.draft_head.scale"), dhn, "scale", RAD_F16,
|
||||
{head_rows(g), g.n_embd / DF_W2_GROUP}, RAD_ACCESS_PER_TOKEN,
|
||||
dh_split, grp_model());
|
||||
} else if (head_known && rad_enc_is(&dhe, "plain") && dhe.n_planes == 1 &&
|
||||
dhe.plane[0].dtype == RAD_BF16) {
|
||||
head_bf16 = true;
|
||||
w_dh = decl_w(b, dhn, RAD_BF16, {head_rows(g), g.n_embd},
|
||||
RAD_ACCESS_PER_TOKEN, dh_split, grp_model());
|
||||
} else {
|
||||
w_dh = decl_view(b, dhn, nullptr, "codes", RAD_U2, {head_rows(g), g.n_embd},
|
||||
RAD_ACCESS_PER_TOKEN, dh_split, grp_model());
|
||||
@@ -503,7 +517,7 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
{head_rows(g), g.n_embd}, RAD_ACCESS_PER_TOKEN, dh_split,
|
||||
grp_model());
|
||||
}
|
||||
if (!w_dh || !w_dhs) return RAD_E_INVAL;
|
||||
if (!w_dh || (!head_bf16 && !w_dhs)) return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- per-layer weights */
|
||||
@@ -945,12 +959,19 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.x, w.h2}, {w.x});
|
||||
op_final = rw(b, RAD_OP(b, "rmsnorm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", g.n_embd),
|
||||
RAD_F64("eps", g.eps), RAD_F64("wadd", g.wadd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_norm)),
|
||||
{w.x}, {w.h});
|
||||
op_final = cfg.omul != 1.0
|
||||
? rw(b, RAD_OP(b, "rmsnorm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", g.n_embd),
|
||||
RAD_F64("eps", g.eps), RAD_F64("wadd", g.wadd),
|
||||
RAD_F64("mult", cfg.omul), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_norm)),
|
||||
{w.x}, {w.h})
|
||||
: rw(b, RAD_OP(b, "rmsnorm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, qrows), RAD_INT("n", g.n_embd),
|
||||
RAD_F64("eps", g.eps), RAD_F64("wadd", g.wadd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_norm)),
|
||||
{w.x}, {w.h});
|
||||
/* Each residual add and the norm after it as one launch where a library serves add_rmsnorm
|
||||
* (byte-identical to the pair: the norm is taken over the bf16 sum it stores), taken only
|
||||
* where every handle resolves (rad_op_resolved), all or none; the pairs declared beside it run
|
||||
@@ -974,6 +995,9 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
op_afinal = all ? an(w_norm) : 0;
|
||||
if (!op_afinal)
|
||||
for (int i = 0; i < MAX_LAYERS; ++i) op_afn[i] = op_aan[i] = 0;
|
||||
/* The output multiplier is declared on the plain final rmsnorm only: a drafter with one
|
||||
* takes the unfused add and norm. */
|
||||
if (cfg.omul != 1.0) op_afinal = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- the head and the selector
|
||||
@@ -991,12 +1015,19 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
{w.h}, {w.sel_h});
|
||||
/* LiLiCorr's head is the plugin's (rad_block_lilicorr.h), over sel_h. */
|
||||
if (cfg.lili) return RAD_OK;
|
||||
op_dquant = rw(b, RAD_OP(b, "quant_act_i8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n", g.n_embd),
|
||||
RAD_INT("group", DF_W2_GROUP), RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.sel_h}, {w.dq, w.ds, w.dsum});
|
||||
op_dlogits = head_i8
|
||||
if (!head_bf16)
|
||||
op_dquant = rw(b, RAD_OP(b, "quant_act_i8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n", g.n_embd),
|
||||
RAD_INT("group", DF_W2_GROUP), RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.sel_h}, {w.dq, w.ds, w.dsum});
|
||||
op_dlogits = head_bf16
|
||||
? rw(b, RAD_OP(b, "gemm_nt",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("N", head_rows(g)),
|
||||
RAD_INT("K", g.n_embd), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_dh)),
|
||||
{w.sel_h}, {w.dlog})
|
||||
: head_i8
|
||||
? rw(b, RAD_OP(b, "gemm_nt_q",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("N", head_rows(g)),
|
||||
RAD_INT("K", g.n_embd), RAD_INT("group", DF_W2_GROUP),
|
||||
@@ -1009,6 +1040,14 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
|
||||
RAD_STR("dtype", "w2a8")),
|
||||
RAD_WEIGHTS(w_dh, w_dhs)),
|
||||
{w.dq, w.ds, w.dsum}, {w.dlog});
|
||||
if (cfg.scap > 0.0) {
|
||||
op_dcap = rw(b, RAD_OP(b, "logit_softcap",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, srows), RAD_INT("n", head_rows(g)),
|
||||
RAD_F64("cap", cfg.scap), RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.dlog}, {w.dlog});
|
||||
if (!op_dcap) return RAD_E_INVAL;
|
||||
}
|
||||
/* Sharded, the top-R runs over this rank's plane, reports global ids and also writes the pair
|
||||
* plane the gather moves. Replicated, `vocab_off` is omitted: an optional parameter present
|
||||
* with value 0 is a different declaration from an absent one. */
|
||||
@@ -1359,12 +1398,17 @@ inline void Dflash2::step(RadCtx* c, const RadBatch* batch) const {
|
||||
|
||||
/* `dsum` is group-major, [n_embd/group][ceil(M/16)*16], so it has no row slice; pass it
|
||||
* whole. */
|
||||
RAD_ISSUE_N(c, op_dquant, S, brows(w.sel_h, S), brows(w.dq, S), brows(w.ds, S), RAD_B(w.dsum));
|
||||
/* The trailing operand is mxfp4's optional reference, absent here. Operands are positional,
|
||||
* so an absent optional one is RAD_NONE, not a shorter list. The 8-bit head is symmetric and
|
||||
* takes no asum. */
|
||||
RAD_ISSUE_N(c, op_dlogits, S, brows(w.dq, S), brows(w.ds, S), RAD_W(w_dh), RAD_W(w_dhs),
|
||||
brows(w.dlog, S), head_i8 ? RAD_NONE : RAD_B(w.dsum), RAD_NONE);
|
||||
if (head_bf16) {
|
||||
RAD_ISSUE_N(c, op_dlogits, S, brows(w.sel_h, S), RAD_W(w_dh), brows(w.dlog, S));
|
||||
} else {
|
||||
RAD_ISSUE_N(c, op_dquant, S, brows(w.sel_h, S), brows(w.dq, S), brows(w.ds, S), RAD_B(w.dsum));
|
||||
/* The trailing operand is mxfp4's optional reference, absent here. Operands are positional,
|
||||
* so an absent optional one is RAD_NONE, not a shorter list. The 8-bit head is symmetric
|
||||
* and takes no asum. */
|
||||
RAD_ISSUE_N(c, op_dlogits, S, brows(w.dq, S), brows(w.ds, S), RAD_W(w_dh), RAD_W(w_dhs),
|
||||
brows(w.dlog, S), head_i8 ? RAD_NONE : RAD_B(w.dsum), RAD_NONE);
|
||||
}
|
||||
if (op_dcap) RAD_ISSUE_N(c, op_dcap, S, brows(w.dlog, S), brows(w.dlog, S));
|
||||
/* RAD_NONE fills the unused `pairs` slot. Sharded, this rank's top-R are only candidates and
|
||||
* the merge overwrites `cand`/`unary`. */
|
||||
if (op_dmerge) {
|
||||
|
||||
@@ -134,6 +134,11 @@ struct GdnFP8 {
|
||||
* pf_out_rows rows and pf_out_seqs sequences. 0 where none is declared. */
|
||||
rad_op op_pf_out = 0;
|
||||
int64_t pf_out_rows = 0, pf_out_seqs = 0;
|
||||
/* The same read as a second op for steps of at least pf_out_v_rows rows, where the
|
||||
* architecture measured another workgroup count for them (decl_prefetch's `blocks`); 0 where
|
||||
* every step takes op_pf_out. */
|
||||
rad_op op_pf_out_v = 0;
|
||||
int64_t pf_out_v_rows = 0;
|
||||
rad_op op_ar = 0, op_add = 0;
|
||||
/* The next block absorbs this block's closing all-reduce (see rad_block_attn_gated_fp8.h). */
|
||||
bool ar_out = false;
|
||||
@@ -508,11 +513,12 @@ inline void GdnFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
* holds nothing behind it), else on the second lane behind a join from lane 0 (as
|
||||
* prefetch_beside). */
|
||||
if (op_pf_out && D > 0 && D <= pf_out_seqs && P == 0 && T <= pf_out_rows) {
|
||||
const rad_op pf = op_pf_out_v && T >= pf_out_v_rows ? op_pf_out_v : op_pf_out;
|
||||
if (prefetch_lane0()) {
|
||||
RAD_ISSUE(c, op_pf_out, RAD_W(out.w));
|
||||
RAD_ISSUE(c, pf, RAD_W(out.w));
|
||||
} else {
|
||||
if (rad_lane_join(c, 0, 1) == RAD_OK && rad_lane(c, 1) == RAD_OK)
|
||||
RAD_ISSUE(c, op_pf_out, RAD_W(out.w));
|
||||
RAD_ISSUE(c, pf, RAD_W(out.w));
|
||||
rad_lane(c, 0);
|
||||
}
|
||||
}
|
||||
@@ -551,7 +557,43 @@ inline void GdnFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
* gated norm, quantiser and out projection are per row, so a pure prefill step can finish them
|
||||
* a piece at a time and hand off each piece's reduction behind it. */
|
||||
const bool cut = !own_ar && pieces && pieces->cuts(T) && D == 0 && P > 0 && !op_add;
|
||||
/* A checkpoint inside the step (RadBatch::ckpt_cut): the convolution, solve and scan run over
|
||||
* [0, cut) and [cut, T) as two pieces, each the chunk of those rows (the state handed on
|
||||
* through the cache, the second piece's context its first row's position, as ArPieces' pieces
|
||||
* do), and the state and convolution slots go to the checkpoint stage between them. The first
|
||||
* piece is issued at the band a chunk of its rows takes, so the snapshot holds the bytes a
|
||||
* step ending at the checkpoint leaves. */
|
||||
const int64_t ck = batch->ckpt_cut;
|
||||
const bool ck_split = P == 1 && D == 0 && ck > 0 && ck < T && batch->ckpt_cu;
|
||||
if (ck_split) {
|
||||
for (int64_t p = 0; p < 2; ++p) {
|
||||
const int64_t n = p == 0 ? ck : T - ck;
|
||||
const int32_t* cu = batch->ckpt_cu + p;
|
||||
RAD_ISSUE_N(c, op_conv_prep, n,
|
||||
bcol(w.in.x, 0, conv_dim, T), RAD_W(w_conv), RAD_NONE, RAD_W(w_a_log),
|
||||
RAD_W(w_dt_bias), kv_cache(kv_conv, layer), praw(cu, RAD_I32, 2),
|
||||
bcol(w.ab, 0, H, T), bcol(w.ab, H, H, T),
|
||||
praw(cv_idx, RAD_I32, 1),
|
||||
praw(p == 0 ? batch->ctx_lens : batch->positions + ck, RAD_I32, 1),
|
||||
brows(w.q, T), brows(w.k, T), brows(w.v, T),
|
||||
brows(w.gdec, T), brows(w.beta, T));
|
||||
RAD_ISSUE_N(c, op_kkt, n,
|
||||
brows(w.k, T), brows(w.beta, T), brows(w.gdec, T),
|
||||
praw(cu, RAD_I32, 2), brows(w.kkt, T));
|
||||
RAD_ISSUE_N(c, op_scan, n,
|
||||
brows(w.q, T), brows(w.k, T), brows(w.v, T), brows(w.kkt, T),
|
||||
brows(w.gdec, T), brows(w.beta, T),
|
||||
kv_cache(kv_state, layer), praw(cu, RAD_I32, 2),
|
||||
brows(w.o.x, T), kv_cache(kv_state, layer),
|
||||
praw2(st_idx, RAD_I32, 1, st_w));
|
||||
if (p == 0) {
|
||||
rad_ckpt_snap(c, kv_state, layer);
|
||||
rad_ckpt_snap(c, kv_conv, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (P > 0) {
|
||||
if (!ck_split) {
|
||||
RAD_ISSUE(c, op_conv_prep,
|
||||
bcol(w.in.x, 0, conv_dim, T), RAD_W(w_conv), RAD_NONE, RAD_W(w_a_log), RAD_W(w_dt_bias),
|
||||
kv_cache(kv_conv, layer), praw(batch->cu_seqlens + D, RAD_I32, P + 1),
|
||||
@@ -569,6 +611,7 @@ inline void GdnFP8::step(RadCtx* c, const RadBatch* batch, bool own_ar,
|
||||
kv_cache(kv_state, layer), praw(batch->cu_seqlens + D, RAD_I32, P + 1),
|
||||
brows(w.o.x, T), kv_cache(kv_state, layer),
|
||||
praw2(st_idx ? st_idx + D * st_w : nullptr, RAD_I32, P, st_w));
|
||||
}
|
||||
if (cut) {
|
||||
for (int64_t r0 = 0; r0 < T; r0 += pieces->rows) {
|
||||
const int64_t n = T - r0 < pieces->rows ? T - r0 : pieces->rows;
|
||||
|
||||
@@ -170,10 +170,21 @@ struct HyperConn {
|
||||
* (hc_down_kchunk in libr4d), so one read over twice the rows sums in a different order than
|
||||
* two reads over half of them; reading a wide step in pieces computes what the narrower steps
|
||||
* did. */
|
||||
void read_pieces(RadCtx* c_, int64_t T) const {
|
||||
void read_pieces(RadCtx* c_, int64_t T) const { read_span(c_, T, 0, T); }
|
||||
/* The same with a boundary at `cut` (a checkpoint inside the step, RadBatch::ckpt_cut): rows
|
||||
* [0, cut) are read as a chunk of `cut` rows reads them, then [cut, T) on their own; 0 is
|
||||
* none. */
|
||||
void read_pieces(RadCtx* c_, int64_t T, int64_t cut) const {
|
||||
if (cut <= 0 || cut >= T) { read_span(c_, T, 0, T); return; }
|
||||
read_span(c_, T, 0, cut);
|
||||
read_span(c_, T, cut, T);
|
||||
}
|
||||
/* Rows [a, b) in pieces of Config::read_rows from `a`; one read where they fit in one. */
|
||||
void read_span(RadCtx* c_, int64_t T, int64_t a, int64_t b) const {
|
||||
const int64_t piece = c.read_rows;
|
||||
if (piece <= 0 || T <= piece) { read(c_, T, 0, T); return; }
|
||||
for (int64_t r0 = 0; r0 < T; r0 += piece) read(c_, T, r0, T - r0 < piece ? T - r0 : piece);
|
||||
auto one = [&](int64_t r0, int64_t n) { read(c_, T, r0, n); };
|
||||
if (piece <= 0 || b - a <= piece) { one(a, b - a); return; }
|
||||
for (int64_t r0 = a; r0 < b; r0 += piece) one(r0, b - r0 < piece ? b - r0 : piece);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+139
-62
@@ -259,6 +259,7 @@ struct MoeFP8 {
|
||||
* layer's; the 64-group codebook forms may differ by layer and projection, and declare()
|
||||
* resolves each layer's (MoeFP8::fmt). */
|
||||
int expert_w5 = 0;
|
||||
int expert_w6 = 0; /* six-bit codebook, E4M3 scale per 64 */
|
||||
/* Int8 experts (`i8*bf16[1x128]/fwht128`): codes -127..127 with a bf16 scale per (row, 128
|
||||
* of K), each 128 of K rotated as `expert_rot` describes, read against int8 activations
|
||||
* (dtype `i8a8h`). The eight-bit expert of an int8 model, where block fp8 is that of an
|
||||
@@ -387,6 +388,10 @@ struct MoeFP8 {
|
||||
* which the shared arm's first stage then runs beside the router instead (pass()). */
|
||||
bool gu_trellis = false;
|
||||
static constexpr int64_t kSharedFirstRows = 100;
|
||||
/* The steps, by their rows [lo, hi], whose shared down projection is issued in front of the
|
||||
* routed down GEMM instead of behind it (pass()); hi 0, the default, keeps it behind on
|
||||
* every step. */
|
||||
int64_t sh_down_first_lo = 0, sh_down_first_hi = 0;
|
||||
LinearFP8 sh_gate_up{}, sh_down{};
|
||||
rad_op op_router = 0, op_topk = 0, op_scatter = 0;
|
||||
/* `op_scatter` is moe_scatter_inv and `op_gather` moe_gather_inv: the sort writes `w.inv` and
|
||||
@@ -507,22 +512,27 @@ struct MoeFP8 {
|
||||
/* The format `e` names: 0 block fp8, 1 four-bit, 2 four-bit rotated, 3 plain bf16, 4 the
|
||||
* rotated w4nl codebook, 5 and 6 that codebook at E4M3 scales per 64 and 32 of K, 7 its
|
||||
* five-bit form per 64, 8 OCP MXFP4, 9 block fp8 at f32 scales, 10 rotated int8, 11 the rotated
|
||||
* computed trellis under one f32 scale a row (an IQR weight an expert); RAD_E_DTYPE
|
||||
* otherwise. */
|
||||
* computed trellis under one f32 scale a row (an IQR weight an expert), 12 the codebook's
|
||||
* six-bit form per 64; RAD_E_DTYPE otherwise. */
|
||||
static int format_of(const RadEncoding& e);
|
||||
/* format_of's numbers as the grouped GEMMs' dtype strings against an E4M3 activation, and
|
||||
* against an int8 one (null: the format has no such row). Int8 experts read int8 only. */
|
||||
static constexpr const char* kServed[12] = { "fp8a8", "w4a8", "w4a8h", "bf16", "w4nla8h",
|
||||
static constexpr const char* kServed[13] = { "fp8a8", "w4a8", "w4a8h", "bf16", "w4nla8h",
|
||||
"w4nl64a8h", "w4nl32a8h", "w5nl64a8h", "mxfp4a8",
|
||||
"fp8a8f32", nullptr, nullptr };
|
||||
static constexpr const char* kServed8[12] = { nullptr, nullptr, "w4a8i8h", nullptr, nullptr,
|
||||
"fp8a8f32", nullptr, nullptr, "w6nl64a8h" };
|
||||
static constexpr const char* kServed8[13] = { nullptr, nullptr, "w4a8i8h", nullptr, nullptr,
|
||||
"w4nl64a8i8h", "w4nl32a8i8h", nullptr, nullptr,
|
||||
nullptr, "i8a8h", "i8a8h" };
|
||||
nullptr, "i8a8h", "i8a8h", nullptr };
|
||||
|
||||
int declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
const Wire& wire, const Src& src, bool fold = false, bool add_out = true,
|
||||
int ar_in = kArNone, bool ar_out_ = false);
|
||||
void step(RadCtx* c, const RadBatch* batch) const;
|
||||
/* A checkpoint inside the step (RadBatch::ckpt_cut): its token on the card, for the routed
|
||||
* GEMMs' `split` operand, while step() issues a step that is one pass; null otherwise. Each
|
||||
* expert's rows before the checkpoint are then a run of their own, as a step ending there
|
||||
* gives them (moe_gemm_iqr's packed map), so they take the same paths. */
|
||||
mutable const int32_t* split_tok = nullptr;
|
||||
/* The block over the first `T` rows of its buffers, for passes that need fewer rows than the
|
||||
* batch (the MTP head's history pass reads its output only at drafting rows). */
|
||||
void step_rows(RadCtx* c, int64_t T) const;
|
||||
@@ -556,7 +566,7 @@ inline int MoeFP8::format_of(const RadEncoding& e) {
|
||||
if (!rad_enc_is(&e, "affine")) return RAD_E_DTYPE;
|
||||
const RadEncPlane* sc = rad_enc_plane(&e, "scale");
|
||||
/* The codebook at E4M3 scales per 64 or 32 of K under one fixed f32 (w4nl64a8h, w4nl32a8h),
|
||||
* and its five-bit form per 64 (w5nl64a8h). */
|
||||
* and its five- and six-bit forms per 64 (w5nl64a8h, w6nl64a8h). */
|
||||
if (e.n_planes == 4 && sc && sc->dtype == RAD_F8E4M3) {
|
||||
const RadEncPlane* s2 = rad_enc_plane(&e, "scale.1");
|
||||
const RadEncPlane* t = rad_enc_plane(&e, "table");
|
||||
@@ -569,6 +579,8 @@ inline int MoeFP8::format_of(const RadEncoding& e) {
|
||||
return sc->block[1] == RAD_FP8_BLOCK / 2 ? 5 : 6;
|
||||
if (t->extent[1] == 32 && e.plane[0].dtype == RAD_U5 && sc->block[1] == RAD_FP8_BLOCK / 2)
|
||||
return 7;
|
||||
if (t->extent[1] == 64 && e.plane[0].dtype == RAD_U6 && sc->block[1] == RAD_FP8_BLOCK / 2)
|
||||
return 12;
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
if (!sc) return RAD_E_DTYPE;
|
||||
@@ -685,13 +697,14 @@ inline int MoeFP8::probe(RadBuilder* b, Names& nm, int l, const Src& src, Config
|
||||
return linear_refuse_retired(guw, f == 8 ? "MXFP4" : "block fp8");
|
||||
if (f != 3) break;
|
||||
}
|
||||
cfg->expert_w4 = (f == 1 || f == 2 || f == 4 || f == 5 || f == 6 || f == 7) ? 1 : 0;
|
||||
cfg->expert_rot = (f == 2 || f == 4 || f == 5 || f == 6 || f == 7 || f == 10 || f == 11) ? 1 : 0;
|
||||
cfg->expert_w4 = (f == 1 || f == 2 || f == 4 || f == 5 || f == 6 || f == 7 || f == 12) ? 1 : 0;
|
||||
cfg->expert_rot = (f == 2 || f == 4 || f == 5 || f == 6 || f == 7 || f == 10 || f == 11 || f == 12) ? 1 : 0;
|
||||
cfg->expert_i8 = f == 10 ? 1 : 0;
|
||||
cfg->expert_iqr = f == 11 ? 1 : 0;
|
||||
cfg->expert_nl = (f == 4 || f == 5 || f == 6 || f == 7) ? 1 : 0;
|
||||
cfg->expert_g64 = (f == 5 || f == 7) ? 2 : f == 6 ? 4 : 0;
|
||||
cfg->expert_nl = (f == 4 || f == 5 || f == 6 || f == 7 || f == 12) ? 1 : 0;
|
||||
cfg->expert_g64 = (f == 5 || f == 7 || f == 12) ? 2 : f == 6 ? 4 : 0;
|
||||
cfg->expert_w5 = f == 7 ? 1 : 0;
|
||||
cfg->expert_w6 = f == 12 ? 1 : 0;
|
||||
cfg->expert_bf16 = f == 3 ? 1 : 0;
|
||||
cfg->expert_mx = f == 8 ? 1 : 0;
|
||||
cfg->expert_f32_scale = f == 9 ? 1 : 0;
|
||||
@@ -777,7 +790,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
a8 = w.eff.q8_fed && !c.expert_bf16;
|
||||
prot.clear();
|
||||
{
|
||||
const int want = c.expert_iqr ? 11 : c.expert_i8 ? 10 : c.expert_f32_scale ? 9 : c.expert_mx ? 8 : c.expert_bf16 ? 3 : c.expert_w5 ? 7 : c.expert_g64 == 4 ? 6
|
||||
const int want = c.expert_iqr ? 11 : c.expert_i8 ? 10 : c.expert_f32_scale ? 9 : c.expert_mx ? 8 : c.expert_bf16 ? 3 : c.expert_w6 ? 12 : c.expert_w5 ? 7 : c.expert_g64 == 4 ? 6
|
||||
: c.expert_g64 ? 5 : c.expert_nl ? 4
|
||||
: c.expert_w4 ? (c.expert_rot ? 2 : 1) : 0;
|
||||
auto fmt_of = [&](int64_t e, RadEncoding (&enc)[2], int (&fe)[2], const char* (&nmv)[2]) {
|
||||
@@ -799,7 +812,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
const bool a8f = a8;
|
||||
auto family = [a8f](int f) {
|
||||
return a8f ? (f == 2 || f == 5 || f == 6 || f == 10 || f == 11)
|
||||
: (f == 5 || f == 6 || f == 7);
|
||||
: (f == 5 || f == 6 || f == 7 || f == 12);
|
||||
};
|
||||
fmt[0] = fmt[1] = want;
|
||||
fenc[0] = fenc[1] = RadEncoding{};
|
||||
@@ -810,7 +823,12 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
fmt_of(e, enc, fe, nmv);
|
||||
if (fe[0] == 3 && fe[1] == 3) continue;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (family(want) && family(fe[i])) fmt[i] = fe[i];
|
||||
/* A trellis gate_up reads rotated int8, but the down projection can use the
|
||||
* W5NL or W6NL E4M3 kernel: its gated intermediate is quantised independently
|
||||
* below. */
|
||||
const bool mixed_codebook_down = a8f && want == 11 && i == 1 &&
|
||||
(fe[i] == 7 || fe[i] == 12);
|
||||
if (family(want) && (family(fe[i]) || mixed_codebook_down)) fmt[i] = fe[i];
|
||||
fenc[i] = enc[i];
|
||||
}
|
||||
break;
|
||||
@@ -1036,6 +1054,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
struct EFmt { uint32_t cdt; const char* cplanes; uint32_t sdt; int64_t sgk; const char* splanes; };
|
||||
auto efmt_of = [](int f, const RadEncoding& fe) -> EFmt {
|
||||
switch (f) {
|
||||
case 12: return { RAD_U6, "codes,table", RAD_F8E4M3, 1, "scale,scale.1" };
|
||||
/* An IQR weight: the codes at their stored width with the code's planes, and the row and
|
||||
* block scales as one view at the weight's extents (LinearFP8's views of the same form). */
|
||||
case 11: return { fe.plane[0].dtype, "codes,trellis,trellis.mad", RAD_F32, 1,
|
||||
@@ -1074,22 +1093,32 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* ---- The routed arm's activations (see `a8`). */
|
||||
if ((c.expert_i8 || c.expert_iqr || fmt[0] >= 10 || fmt[1] >= 10) && !a8) {
|
||||
if ((c.expert_i8 || c.expert_iqr || fmt[0] == 10 || fmt[0] == 11 ||
|
||||
fmt[1] == 10 || fmt[1] == 11) && !a8) {
|
||||
fprintf(stderr, "radiance: layer %d's experts read int8 activations (int8, or an IQR weight); the "
|
||||
"architecture declared the routed arm's codes E4M3\n", l);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
const bool down_codebook_fp8 = a8 && fmt[0] == 11 && (fmt[1] == 7 || fmt[1] == 12);
|
||||
if (a8) {
|
||||
const bool pair = w.eff.q8 && w.eff.s8 && w.eff.q8_rot && w.eff.g8 == RAD_FP8_BLOCK;
|
||||
if (!pair || !c.expert_rot || !kServed8[fmt[0]] || !kServed8[fmt[1]] || c.calib ||
|
||||
c.swiglu_limit > 0) {
|
||||
const bool down_supported = down_codebook_fp8 ? (w.eff.q && w.eff.s && kServed[fmt[1]])
|
||||
: kServed8[fmt[1]] != nullptr;
|
||||
/* A clamped layer: GateQuantFP8 clamps into the bf16 plane, then quantises it into the
|
||||
* rotated codes. A codebook (W5NL, W6NL) down projection reads rotated E4M3, which no
|
||||
* clamp writes, so it is served unclamped only. */
|
||||
const bool clamp_codebook = down_codebook_fp8 && c.swiglu_limit > 0;
|
||||
if (!pair || !c.expert_rot || !kServed8[fmt[0]] || !down_supported || c.calib ||
|
||||
clamp_codebook) {
|
||||
fprintf(stderr, "radiance: layer %d: int8 activations meet rotated experts (int8, "
|
||||
"four-bit, or the codebook at E4M3 scales a 64 or 32 of K) through "
|
||||
"rotated codes at one scale a 128 of K, unclamped, outside "
|
||||
"calibration; these are %s / %s%s\n", l,
|
||||
"rotated codes at one scale a 128 of K, outside calibration; these "
|
||||
"are %s / %s%s%s\n", l,
|
||||
kServed[fmt[0]] ? kServed[fmt[0]] : kServed8[fmt[0]],
|
||||
kServed[fmt[1]] ? kServed[fmt[1]] : kServed8[fmt[1]],
|
||||
pair ? "" : ", and the gated product's int8 pair is not that");
|
||||
pair ? "" : ", and the gated product's int8 pair is not that",
|
||||
clamp_codebook ? ", and a W5NL or W6NL down projection is served unclamped only"
|
||||
: "");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
@@ -1105,7 +1134,7 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
* experts' encoding or the kernel is not a candidate. */
|
||||
gu_trellis = fmt[0] == 11;
|
||||
const char* const edtype[2] = { a8 ? kServed8[fmt[0]] : kServed[fmt[0]],
|
||||
a8 ? kServed8[fmt[1]] : kServed[fmt[1]] };
|
||||
a8 && !down_codebook_fp8 ? kServed8[fmt[1]] : kServed[fmt[1]] };
|
||||
/* This class's slice of each expert: gate and up rows [lo, hi), down columns [lo, hi), scale
|
||||
* planes the same in their own units. */
|
||||
auto span = [&](rad_weight h, int q, int64_t unit) -> int {
|
||||
@@ -1302,9 +1331,13 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
* which takes the codes alone (no bf16 product is written), so the gated quantiser resolves to
|
||||
* the rotated op at no extra launch. */
|
||||
gq_exp.fuse_clamped = c.swiglu_quant != 0;
|
||||
/* Fed int8, `eff` names the rotating int8 quantiser itself (ActFP8::q8_rot). */
|
||||
RAD_ARCH_TRY(gq_exp.declare(b, g, w.egu, w.eff, c.n_ff_exp, gact, c.rows * c.top_k,
|
||||
false, rot && !a8, c.swiglu_limit, c.swiglu_step != 0));
|
||||
/* Gate_up and down are separate GEMMs. A trellis gate uses int8 input while a codebook (W5NL,
|
||||
* W6NL) down reads rotated E4M3: select the latter pair only for the gated intermediate. */
|
||||
ActFP8 down_eff = w.eff;
|
||||
if (down_codebook_fp8) down_eff.q8_fed = down_eff.q8_rot = false;
|
||||
RAD_ARCH_TRY(gq_exp.declare(b, g, w.egu, down_eff, c.n_ff_exp, gact, c.rows * c.top_k,
|
||||
false, rot && (!a8 || down_codebook_fp8), c.swiglu_limit,
|
||||
c.swiglu_step != 0));
|
||||
{
|
||||
const std::vector<rad_weight> tab = tables(w_dn, w_dns);
|
||||
const RadParam p4[] = { RAD_RANGE("M", 1, c.rows), RAD_INT("N", g.n_embd),
|
||||
@@ -1321,13 +1354,13 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
RAD_STR("a_order", "sorted"), RAD_STR("dtype", edtype[1]),
|
||||
RAD_INT("N_odd", g.n_embd), RAD_INT("K_odd", wq[1]),
|
||||
RAD_INT("parts", 1), RAD_INT("a_group", RAD_FP8_BLOCK) };
|
||||
const int cut = a8 ? 0 : 1;
|
||||
const int cut = a8 && !down_codebook_fp8 ? 0 : 1;
|
||||
rad_op h = ncls == 4
|
||||
? rad_decl_op(b, "moe_gemm_q_mod4", p4, (int)(sizeof p4 / sizeof *p4) - cut,
|
||||
tab.data(), (int)tab.size())
|
||||
: rad_decl_op(b, "moe_gemm_q", p2, (int)(sizeof p2 / sizeof *p2) - cut,
|
||||
tab.data(), (int)tab.size());
|
||||
op_dn = rw(b, h, {w.eff.cq(), w.eff.cs(), w.sorted, w.eoff}, {w.edn});
|
||||
op_dn = rw(b, h, {down_eff.cq(), down_eff.cs(), w.sorted, w.eoff}, {w.edn});
|
||||
}
|
||||
/* ---- The protected experts' own GEMM pair. Their weights belong to the layer group, not to
|
||||
* expert slots: each container expert unit has a fixed size and these are four times larger, so
|
||||
@@ -1887,6 +1920,9 @@ inline void MoeFP8::pass(RadCtx* c_, int64_t T, int64_t r0, int64_t rows, bool o
|
||||
* in turn. Flash-Next's 16- and 32-row verify passes on two R9700: 22.1 -> 21.9 ms and
|
||||
* 31.6 -> 30.95 ms. Below, the arm fits inside the routed GEMM's time and stays beside it. */
|
||||
const bool sh_first = shared && gu_trellis && rows * k >= kSharedFirstRows;
|
||||
/* The routed GEMMs' `split` (split_tok), on a pass that is the whole step. */
|
||||
const bool split_on = split_tok && r0 == 0 && rows == T;
|
||||
const RadOperand sp = split_on ? praw(split_tok, RAD_I32, 1) : RAD_NONE;
|
||||
if (sh_first)
|
||||
shared_up(c_, T, r0, rows,
|
||||
(rfused && router_fused_gate) || (sfused && sigmoid_scatter_gate));
|
||||
@@ -1897,48 +1933,71 @@ inline void MoeFP8::pass(RadCtx* c_, int64_t T, int64_t r0, int64_t rows, bool o
|
||||
RAD_ISSUE_N(c_, op_gu, rows, brow_slice(w.h.x, r0, rows, g.n_embd),
|
||||
RAD_WTAB(w_gu[0], ne), brows(w.sorted, rows * k), brows(w.eoff, ne + 1),
|
||||
brows(w.egu, rows * k));
|
||||
else if (ncls == 4)
|
||||
RAD_ISSUE_N(c_, op_gu, rows,
|
||||
brow_slice(gin_q, r0, rows, g.n_embd),
|
||||
brow_slice(gin_s, r0, rows, g.n_embd / gin_g),
|
||||
RAD_WTAB(w_gu[0], n4[0]), RAD_WTAB(w_gus[0], n4[0]),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_gu[1], n4[1]), RAD_WTAB(w_gus[1], n4[1]),
|
||||
RAD_WTAB(w_gu[2], n4[2]), RAD_WTAB(w_gus[2], n4[2]),
|
||||
RAD_WTAB(w_gu[3], n4[3]), RAD_WTAB(w_gus[3], n4[3]),
|
||||
brows(w.egu, rows * k));
|
||||
else
|
||||
RAD_ISSUE_N(c_, op_gu, rows,
|
||||
brow_slice(gin_q, r0, rows, g.n_embd),
|
||||
brow_slice(gin_s, r0, rows, g.n_embd / gin_g),
|
||||
RAD_WTAB(w_gu[0], n_reg / 2), RAD_WTAB(w_gus[0], n_reg / 2),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_gu[1], n_reg / 2), RAD_WTAB(w_gus[1], n_reg / 2),
|
||||
brows(w.egu, rows * k));
|
||||
else if (ncls == 4) {
|
||||
/* `split` only where set, so every other step's operand list carries none. */
|
||||
const RadOperand o_[] = {
|
||||
brow_slice(gin_q, r0, rows, g.n_embd),
|
||||
brow_slice(gin_s, r0, rows, g.n_embd / gin_g),
|
||||
RAD_WTAB(w_gu[0], n4[0]), RAD_WTAB(w_gus[0], n4[0]),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_gu[1], n4[1]), RAD_WTAB(w_gus[1], n4[1]),
|
||||
RAD_WTAB(w_gu[2], n4[2]), RAD_WTAB(w_gus[2], n4[2]),
|
||||
RAD_WTAB(w_gu[3], n4[3]), RAD_WTAB(w_gus[3], n4[3]),
|
||||
brows(w.egu, rows * k), sp };
|
||||
rad_issue(c_, op_gu, o_, (int)(sizeof o_ / sizeof *o_) - (split_on ? 0 : 1), rows);
|
||||
} else {
|
||||
/* `split` only where set, so every other step's operand list carries none. */
|
||||
const RadOperand o_[] = {
|
||||
brow_slice(gin_q, r0, rows, g.n_embd),
|
||||
brow_slice(gin_s, r0, rows, g.n_embd / gin_g),
|
||||
RAD_WTAB(w_gu[0], n_reg / 2), RAD_WTAB(w_gus[0], n_reg / 2),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_gu[1], n_reg / 2), RAD_WTAB(w_gus[1], n_reg / 2),
|
||||
brows(w.egu, rows * k), sp };
|
||||
rad_issue(c_, op_gu, o_, (int)(sizeof o_ / sizeof *o_) - (split_on ? 0 : 1), rows);
|
||||
}
|
||||
if (shared && !sh_first)
|
||||
shared_up(c_, T, r0, rows,
|
||||
(rfused && router_fused_gate) || (sfused && sigmoid_scatter_gate));
|
||||
gq_exp.step(c_, w.egu, rows * k, 0, rows * k);
|
||||
if (shared && !(op_sh_gated && rows <= sh_gated_rows)) gq_sh.step(c_, w.sgu, T, r0, rows);
|
||||
/* The shared arm's down projection in front of the routed down GEMM on a step of
|
||||
* [sh_down_first_lo, sh_down_first_hi] rows. Behind it (below) the two still run together,
|
||||
* but the card launches the arm only once every block of the routed GEMM is on it; at a
|
||||
* verify step's forty routed rows that is a few microseconds before that GEMM ends, and the
|
||||
* gather then waits for the arm. In front, the arm is the ordered launch behind the two
|
||||
* quantisers and the routed GEMM starts beside it (it reads nothing the arm writes): the same
|
||||
* start for the routed GEMM, and the arm is done long before it. At one row the routed GEMM
|
||||
* is a quarter of the blocks, the arm behind it is launched in time, and in front it only
|
||||
* delays that GEMM's launch (+0.38% a step), hence the lower bound. The arm's buffers are
|
||||
* excluded from sharing (declare), so the order is free. Qwen3.8-Flash-Next at tp 2 with
|
||||
* coupling, chain 1 / 2 / 3 (two / three / four rows): -0.28% / -0.21% / -0.25% a step. */
|
||||
const bool sh_dn_first = shared && T >= sh_down_first_lo && T <= sh_down_first_hi;
|
||||
if (sh_dn_first) sh_down.step(c_, w.sff, w.sout, T, r0, rows);
|
||||
if (c.expert_bf16)
|
||||
RAD_ISSUE_N(c_, op_dn, rows, brows(w.eff.x, rows * k), RAD_WTAB(w_dn[0], ne),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, ne + 1), brows(w.edn, rows * k));
|
||||
else if (ncls == 4)
|
||||
RAD_ISSUE_N(c_, op_dn, rows,
|
||||
brows(w.eff.cq(), rows * k), brows(w.eff.cs(), rows * k),
|
||||
RAD_WTAB(w_dn[0], n4[0]), RAD_WTAB(w_dns[0], n4[0]),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_dn[1], n4[1]), RAD_WTAB(w_dns[1], n4[1]),
|
||||
RAD_WTAB(w_dn[2], n4[2]), RAD_WTAB(w_dns[2], n4[2]),
|
||||
RAD_WTAB(w_dn[3], n4[3]), RAD_WTAB(w_dns[3], n4[3]),
|
||||
brows(w.edn, rows * k));
|
||||
else
|
||||
RAD_ISSUE_N(c_, op_dn, rows,
|
||||
brows(w.eff.cq(), rows * k), brows(w.eff.cs(), rows * k),
|
||||
RAD_WTAB(w_dn[0], n_reg / 2), RAD_WTAB(w_dns[0], n_reg / 2),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_dn[1], n_reg / 2), RAD_WTAB(w_dns[1], n_reg / 2),
|
||||
brows(w.edn, rows * k));
|
||||
else if (ncls == 4) {
|
||||
/* `split` only where set, so every other step's operand list carries none. */
|
||||
const RadOperand o_[] = {
|
||||
brows(gq_exp.a.cq(), rows * k), brows(gq_exp.a.cs(), rows * k),
|
||||
RAD_WTAB(w_dn[0], n4[0]), RAD_WTAB(w_dns[0], n4[0]),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_dn[1], n4[1]), RAD_WTAB(w_dns[1], n4[1]),
|
||||
RAD_WTAB(w_dn[2], n4[2]), RAD_WTAB(w_dns[2], n4[2]),
|
||||
RAD_WTAB(w_dn[3], n4[3]), RAD_WTAB(w_dns[3], n4[3]),
|
||||
brows(w.edn, rows * k), sp };
|
||||
rad_issue(c_, op_dn, o_, (int)(sizeof o_ / sizeof *o_) - (split_on ? 0 : 1), rows);
|
||||
} else {
|
||||
/* `split` only where set, so every other step's operand list carries none. */
|
||||
const RadOperand o_[] = {
|
||||
brows(gq_exp.a.cq(), rows * k), brows(gq_exp.a.cs(), rows * k),
|
||||
RAD_WTAB(w_dn[0], n_reg / 2), RAD_WTAB(w_dns[0], n_reg / 2),
|
||||
brows(w.sorted, rows * k), brows(w.eoff, n_reg + 1),
|
||||
RAD_WTAB(w_dn[1], n_reg / 2), RAD_WTAB(w_dns[1], n_reg / 2),
|
||||
brows(w.edn, rows * k), sp };
|
||||
rad_issue(c_, op_dn, o_, (int)(sizeof o_ / sizeof *o_) - (split_on ? 0 : 1), rows);
|
||||
}
|
||||
/* This layer's streamed experts are consumed; the next layer's copies may start. */
|
||||
(void)rad_expert_prefetch_mark(c_);
|
||||
/* The protected experts, over the trailing offsets: the quantised down GEMM zeroed their
|
||||
@@ -1954,7 +2013,7 @@ inline void MoeFP8::pass(RadCtx* c_, int64_t T, int64_t r0, int64_t rows, bool o
|
||||
RAD_ISSUE_N(c_, op_pdn, rows, brows(pff.x, rows * k), RAD_WTAB(w_pdn[0], np),
|
||||
brows(w.sorted, rows * k), poff, brows(w.edn, rows * k));
|
||||
}
|
||||
if (shared) sh_down.step(c_, w.sff, w.sout, T, r0, rows);
|
||||
if (shared && !sh_dn_first) sh_down.step(c_, w.sff, w.sout, T, r0, rows);
|
||||
/* The calibration tap reads the GEMMs' operands and writes nothing they touch, so it does not
|
||||
* change the model's output. */
|
||||
if (op_gram_gu && !calib_done) {
|
||||
@@ -2075,7 +2134,25 @@ inline void MoeFP8::calib_experts_pass(RadCtx* c_, int64_t slots) const {
|
||||
}
|
||||
|
||||
inline void MoeFP8::step(RadCtx* c_, const RadBatch* batch) const {
|
||||
step_rows(c_, batch->n_tok);
|
||||
const int64_t T = batch->n_tok, ck = batch->ckpt_cut;
|
||||
const bool cut = ck > 0 && ck < T && batch->ckpt_cu;
|
||||
if (cut && T > c.rows) {
|
||||
/* A checkpoint inside a step wider than a pass: the passes start again at the checkpoint
|
||||
* (as HyperConn::read_pieces does), so the rows before it are passed as a chunk ending
|
||||
* there passes them, and the rows after it as the next chunk would. */
|
||||
for (int64_t a = 0; a < T; a = ck > a ? ck : T) {
|
||||
const int64_t b = ck > a ? ck : T;
|
||||
for (int64_t r0 = a; r0 < b; r0 += c.rows)
|
||||
pass(c_, T, r0, b - r0 < c.rows ? b - r0 : c.rows);
|
||||
}
|
||||
route_report(c_);
|
||||
return;
|
||||
}
|
||||
/* One pass over the whole step: `split` gives the rows before the checkpoint runs of their
|
||||
* own (split_tok). */
|
||||
split_tok = cut ? batch->ckpt_cu + 1 : nullptr;
|
||||
step_rows(c_, T);
|
||||
split_tok = nullptr;
|
||||
}
|
||||
|
||||
inline void MoeFP8::step_rows(RadCtx* c_, int64_t T) const {
|
||||
|
||||
+138
-45
@@ -92,6 +92,7 @@
|
||||
#include "rad_block_attn_gated_fp8.h"
|
||||
#include "rad_block_mlp_fp8.h"
|
||||
#include "rad_block_vit.h"
|
||||
#include "rad_spechub.h"
|
||||
|
||||
namespace rad {
|
||||
namespace arch {
|
||||
@@ -116,6 +117,9 @@ inline bool mtp_draft_head_q2(RadBuilder* b, const char* head, const char* lm) {
|
||||
* (MoeFP8's Config travels inside its Src for this reason). */
|
||||
template <class Ffn>
|
||||
struct MtpBlockFP8 {
|
||||
/* spechub consumes a top-eight law; otherwise only the greedy token is needed. */
|
||||
static constexpr int proposal_pitch(bool coupled) { return coupled ? 8 : 1; }
|
||||
|
||||
struct Wire {
|
||||
/* [max_tok, n_embd] the trunk's final hidden states for the step just run (the plugin's
|
||||
* `h`). A pass names the rows it wants through out_ids. */
|
||||
@@ -128,14 +132,19 @@ struct MtpBlockFP8 {
|
||||
rad_buf c = 0; /* [max_tok, 2 * n_embd] the two normed halves, fc's input */
|
||||
rad_buf x = 0; /* [max_tok, n_embd] the head's own residual stream */
|
||||
rad_buf logits = 0; /* [max_logit_rows, n_vocab] the trunk's, shared */
|
||||
/* The 2-bit draft head's working set (see op_dlogits), sized at max_logit_rows: only
|
||||
* drafting rows reach it. */
|
||||
rad_buf dq = 0; /* [max_logit_rows, n_embd] int8 codes */
|
||||
rad_buf ds = 0; /* [max_logit_rows, 1] f32, one scale a row */
|
||||
rad_buf dsum = 0; /* [n_embd/group, mpad] f32, group-major (quant_act_i8's asum) */
|
||||
rad_buf dlog = 0; /* [max_logit_rows, n_vocab] bf16, the coarse logits */
|
||||
rad_buf didx = 0; /* [max_logit_rows, 1] i32, the proposed token */
|
||||
rad_buf dval = 0; /* [max_logit_rows, 1] f32, its logit */
|
||||
/* The 2-bit projection's scratch: at most one proposal per sequence, including the
|
||||
* selected final history rows. The unselected history rows need only K/V. */
|
||||
rad_buf dq = 0; /* [max_seqs, n_embd] int8 codes */
|
||||
rad_buf ds = 0; /* [max_seqs, 1] f32, one scale a row */
|
||||
rad_buf dsum = 0; /* [n_embd/group, mpad] f32, group-major (quant_act_i8's asum) */
|
||||
rad_buf dlog = 0; /* [max_seqs, n_vocab_all] bf16, the coarse logits */
|
||||
rad_buf didx = 0; /* [max_seqs, proposal_pitch] i32, proposal in column zero */
|
||||
rad_buf dval = 0; /* [max_seqs, proposal_pitch] f32, shortlist logits */
|
||||
bool coupled = false;
|
||||
/* A targeted calib-corpus run may select the virtual MTP layer (n_main) and record the
|
||||
* draft head's actual input. The trunk's CalibFull is intentionally not involved. */
|
||||
const char* calib_dir = nullptr;
|
||||
int64_t calib_tokens = 0;
|
||||
/* The layer reuses the trunk's working set, which is dead by the time the head runs (a
|
||||
* second set would be 150 MiB). */
|
||||
AttnGatedFP8::Wire attn{};
|
||||
@@ -147,9 +156,6 @@ struct MtpBlockFP8 {
|
||||
const char* norm = nullptr;
|
||||
const char* pre_norm_hidden = nullptr;
|
||||
const char* pre_norm_embedding = nullptr;
|
||||
/* The checkpoint's lm_head. The trunk maps it as `output.weight`; the draft head is a
|
||||
* second logical weight over the same tensor, quantised to 2 bits (mtp_draft_head_q2). */
|
||||
const char* lm = nullptr;
|
||||
AttnGatedFP8::Src attn{};
|
||||
typename Ffn::Src mlp{};
|
||||
};
|
||||
@@ -172,6 +178,11 @@ struct MtpBlockFP8 {
|
||||
MediaRows mrows{};
|
||||
rad_op op_norm = 0, op_dsel = 0, op_dback = 0, op_logits = 0;
|
||||
rad_op op_dquant = 0, op_dlogits = 0, op_dtopk = 0;
|
||||
rad_buf couple_draws = 0, couple_state = 0;
|
||||
rad_op op_couple[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
|
||||
CalibTap draft_head_calib{};
|
||||
bool draft_head_calib_on = false;
|
||||
mutable int64_t draft_head_calib_rows = 0;
|
||||
|
||||
int declare(RadBuilder* b, Names& nm, const Geom& geom, int l, rad_kvgroup kv,
|
||||
int64_t rotary_dim, rad_weight tok_embd, rad_weight lm_head, float out_wadd,
|
||||
@@ -186,7 +197,25 @@ inline int MtpBlockFP8<Ffn>::declare(RadBuilder* b, Names& nm, const Geom& geom,
|
||||
const Src& src) {
|
||||
g = geom; w = wire; layer = l; w_tok = tok_embd; w_lm = lm_head;
|
||||
rows = g.max_tok;
|
||||
if (rows <= 0 || !w_tok || !w_lm) return RAD_E_INVAL;
|
||||
q2 = w.dq != 0;
|
||||
draft_head_calib_on = w.calib_dir && *w.calib_dir;
|
||||
if (draft_head_calib_on && (w.calib_tokens <= 0 || g.max_spec != 0 || q2 || w.coupled)) {
|
||||
std::fprintf(stderr, "radiance: MTP draft-head calibration requires a non-empty corpus "
|
||||
"and a history-only head (speculation off)\n");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (w.coupled && (!q2 || g.max_spec < 1 || g.max_spec > RAD_MTP_COUPLE_MAX_ROUNDS)) {
|
||||
std::fprintf(stderr, "radiance: Qwen35 native MTP coupling requires the U2 draft head and "
|
||||
"a draft depth in 1..%d\n", RAD_MTP_COUPLE_MAX_ROUNDS);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (w.coupled && !rad_op_declared(b, "mtp_couple_propose")) {
|
||||
std::fprintf(stderr, "radiance: load the spechub kernels for Qwen35 MTP draft coupling\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (rows <= 0 || !w_tok || (!draft_head_calib_on &&
|
||||
(q2 ? (!w.ds || !w.dsum || !w.dlog || !w.didx || !w.dval) : (!w_lm || !w.logits))))
|
||||
return RAD_E_INVAL;
|
||||
|
||||
/* The normed embedding first, then the normed hidden state (see the header). */
|
||||
off_e = 0;
|
||||
@@ -257,17 +286,19 @@ inline int MtpBlockFP8<Ffn>::declare(RadBuilder* b, Names& nm, const Geom& geom,
|
||||
* to the front of `x` before the feed-forward, which then runs on those rows only. Goes through
|
||||
* `hout` (dead between fc's read and the norm's write), since an in-place gather could
|
||||
* overwrite a row not yet read. */
|
||||
op_dsel = rw(b, RAD_OP(b, "gather_rows",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.x}, {w.hout});
|
||||
op_dback = rw(b, RAD_OP(b, "cast",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("from", g.dtype), RAD_STR("to", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.hout}, {w.x});
|
||||
if (!op_dsel || !op_dback) return RAD_E_INVAL;
|
||||
if (!draft_head_calib_on) {
|
||||
op_dsel = rw(b, RAD_OP(b, "gather_rows",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.x}, {w.hout});
|
||||
op_dback = rw(b, RAD_OP(b, "cast",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("from", g.dtype), RAD_STR("to", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.hout}, {w.x});
|
||||
if (!op_dsel || !op_dback) return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
RAD_ARCH_TRY(mlp.declare(b, nm, g, l, w.mlp, src.mlp));
|
||||
|
||||
@@ -277,15 +308,22 @@ inline int MtpBlockFP8<Ffn>::declare(RadBuilder* b, Names& nm, const Geom& geom,
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_norm)),
|
||||
{w.x}, {w.hout});
|
||||
if (!op_norm) return RAD_E_INVAL;
|
||||
if (draft_head_calib_on)
|
||||
return g.rank == 0 ? draft_head_calib.declare(b, nm, rows, nm.f("mtp.draft_head"),
|
||||
w.hout, g.n_embd) : RAD_OK;
|
||||
|
||||
/* The trunk's lm_head over the head's hidden state, banded at the logits buffer's extent: it
|
||||
* runs over one row per drafting sequence. */
|
||||
op_logits = rw(b, RAD_OP(b, "logits_gemm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_INT("n_vocab", g.n_vocab),
|
||||
RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_lm)),
|
||||
{w.hout}, {w.logits});
|
||||
/* Only the fallback projects through the target's single lm_head. In particular do not
|
||||
* declare an unused logits_gemm with a null weight when the target uses width classes. */
|
||||
if (!q2) {
|
||||
op_logits = rw(b, RAD_OP(b, "logits_gemm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_INT("n_vocab", g.n_vocab),
|
||||
RAD_INT("n_embd", g.n_embd), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_lm)),
|
||||
{w.hout}, {w.logits});
|
||||
if (!op_logits) return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* ---- The 2-bit draft head.
|
||||
*
|
||||
@@ -299,20 +337,26 @@ inline int MtpBlockFP8<Ffn>::declare(RadBuilder* b, Names& nm, const Geom& geom,
|
||||
* asymmetric (four levels are too few for a symmetric one), so the activation side uses
|
||||
* `quant_act_i8`'s three-output form, whose per-group row sums subtract the stored zero.
|
||||
*
|
||||
* The draft head bypasses the sampler, which reads f32 logits: `row_topk` at R=1 takes the
|
||||
* argmax on the GEMM's bf16 output and the engine reads the id from `didx`. The trunk's logits
|
||||
* plane is untouched.
|
||||
* The head bypasses the sampler's f32 logits. row_topk takes the argmax, or the shortlist
|
||||
* when coupling is on; the engine reads the proposal from column zero of didx. The target's
|
||||
* logits plane is untouched.
|
||||
*/
|
||||
enum { MTP_W2_GROUP = 128 }; /* libr4d's R4D_GEMM_W2A8_GROUP, and the layout's g128 tag */
|
||||
/* The plugin declares the working set only when mtp_draft_head_q2 found a 2-bit head (and
|
||||
* declared its name map). */
|
||||
q2 = src.lm && w.dq && w.ds && w.dsum && w.dlog && w.didx && w.dval;
|
||||
if (q2) {
|
||||
/* Replicated over the whole vocabulary. Without the sampler's cross-rank merge, a sharded
|
||||
* plane would let each rank propose only its own vocabulary slice. Replication costs 341
|
||||
* MiB per card at 2 bits and keeps the draft path single-rank. (The stored bytes are also
|
||||
* tile-major, 16 output rows per packed block, so a shard would have to be whole tiles.) */
|
||||
const char* dhn = nm.f("mtp.draft_head.weight");
|
||||
RadEncoding enc{}, expected = rad_enc_affine(RAD_U2, RAD_F16, 1, MTP_W2_GROUP);
|
||||
rad_enc_add_plane(&expected, "zero", RAD_U8, 1, MTP_W2_GROUP);
|
||||
if (!weight_enc(b, dhn, &enc) || !rad_enc_equal(&enc, &expected)) {
|
||||
std::fprintf(stderr, "radiance: %s requires unrotated U2 codes with an F16 scale and "
|
||||
"U8 zero per group of 128\n", dhn);
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
w_dh = decl_view(b, dhn, nullptr, "codes", RAD_U2, {g.n_vocab_all, g.n_embd},
|
||||
RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_layer(l));
|
||||
w_dhs = decl_view(b, nm.f("mtp.draft_head.scale"), dhn, "scale,zero", RAD_F16,
|
||||
@@ -321,32 +365,49 @@ inline int MtpBlockFP8<Ffn>::declare(RadBuilder* b, Names& nm, const Geom& geom,
|
||||
if (!w_dh || !w_dhs) return RAD_E_INVAL;
|
||||
|
||||
op_dquant = rw(b, RAD_OP(b, "quant_act_i8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs),
|
||||
RAD_INT("n", g.n_embd), RAD_INT("group", MTP_W2_GROUP),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.hout}, {w.dq, w.ds, w.dsum});
|
||||
|
||||
op_dlogits = rw(b, RAD_OP(b, "gemm_nt_q",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs),
|
||||
RAD_INT("N", g.n_vocab_all), RAD_INT("K", g.n_embd),
|
||||
RAD_INT("group", MTP_W2_GROUP), RAD_STR("dtype", "w2a8")),
|
||||
RAD_WEIGHTS(w_dh, w_dhs)),
|
||||
{w.dq, w.ds, w.dsum}, {w.dlog});
|
||||
|
||||
op_dtopk = rw(b, RAD_OP(b, "row_topk",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_INT("N", g.n_vocab_all), RAD_INT("R", 1),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs),
|
||||
RAD_INT("N", g.n_vocab_all), RAD_INT("R", proposal_pitch(w.coupled)),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.dlog}, {w.didx, w.dval});
|
||||
if (!op_dquant || !op_dlogits || !op_dtopk) return RAD_E_INVAL;
|
||||
if (w.coupled) {
|
||||
/* The engine binds these persistent planes by name. The U2 projection is
|
||||
* replicated over the full vocabulary, so its shortlist already holds global ids. */
|
||||
couple_draws = decl_b(b, nm.f("mtp_couple_draws"), RAD_U32,
|
||||
{g.max_seqs, RAD_MTP_COUPLE_DRAW_WORDS}, RAD_BUF_PERSIST);
|
||||
couple_state = decl_b(b, nm.f("mtp_couple_state"), RAD_U32,
|
||||
{g.max_spec, g.max_seqs, RAD_MTP_COUPLE_STATE_WORDS}, RAD_BUF_PERSIST);
|
||||
if (!couple_draws || !couple_state) return RAD_E_INVAL;
|
||||
for (int rd = 1; rd <= g.max_spec; ++rd) {
|
||||
op_couple[rd - 1] = rw(b, RAD_OP(b, "mtp_couple_propose",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_seqs), RAD_INT("n_vocab", g.n_vocab_all),
|
||||
RAD_INT("round", rd), RAD_INT("max_rounds", g.max_spec)),
|
||||
RAD_NOWEIGHTS), {w.didx, w.dval, couple_draws}, {w.didx, couple_state});
|
||||
if (!op_couple[rd - 1]) return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep `hout` live through the head's last op: it is the next round's input, and if only the
|
||||
* lm_head's first op read it, the planner could give its bytes to later ops (silently lowering
|
||||
* acceptance). */
|
||||
{
|
||||
const rad_op last = q2 ? op_dtopk : op_logits;
|
||||
const rad_op last = w.coupled ? op_couple[g.max_spec - 1] : q2 ? op_dtopk : op_logits;
|
||||
if (rad_op_reads(b, last, &w.hout, 1) < 0) return RAD_E_INVAL;
|
||||
}
|
||||
return RAD_OK;
|
||||
@@ -359,6 +420,11 @@ template <class Ffn>
|
||||
inline void MtpBlockFP8<Ffn>::step(RadCtx* c, const RadBatch* batch) const {
|
||||
const int64_t T = batch->n_tok;
|
||||
const int r = batch->draft_pass;
|
||||
const bool tap_history = draft_head_calib_on;
|
||||
if (tap_history && (r >= 0 || batch->n_out != T || batch->n_draft_out != 0)) {
|
||||
rad_step_fail(c, "MTP draft-head calibration requires every history row and no proposals");
|
||||
return;
|
||||
}
|
||||
|
||||
/* The history pass gathers; later rounds read the previous pass's output from the same
|
||||
* buffer. */
|
||||
@@ -367,6 +433,10 @@ inline void MtpBlockFP8<Ffn>::step(RadCtx* c, const RadBatch* batch) const {
|
||||
"the history pass (RadBatch::draft_out_ids) and has no pass of its own");
|
||||
return;
|
||||
}
|
||||
if (w.coupled && (r == 0 || r > g.max_spec)) {
|
||||
rad_step_fail(c, "Qwen35 MTP coupled round outside the declared draft depth");
|
||||
return;
|
||||
}
|
||||
if (r < 0 && batch->n_out > 0)
|
||||
RAD_ISSUE_N(c, op_gather, batch->n_out,
|
||||
RAD_B(w.src), praw(batch->out_ids, RAD_I32, batch->n_out),
|
||||
@@ -381,18 +451,19 @@ inline void MtpBlockFP8<Ffn>::step(RadCtx* c, const RadBatch* batch) const {
|
||||
|
||||
RAD_ISSUE(c, op_fc, brows(w.c, T), RAD_W(w_fc), brows(w.x, T));
|
||||
|
||||
/* A history pass with no drafting rows (every prefill chunk but a prompt's last) only needs
|
||||
* K and V. `n_draft_out` is the same on every rank, so skipped collectives match. */
|
||||
if (r < 0 && batch->n_draft_out <= 0) {
|
||||
/* The ordinary history fast path only stores K/V. A selected MTP calibration layer instead
|
||||
* runs every prompt row through the block so the U2 draft head gets a real, full-rank Gram. */
|
||||
if (r < 0 && batch->n_draft_out <= 0 && !tap_history) {
|
||||
attn.store_kv(c, batch);
|
||||
return;
|
||||
}
|
||||
attn.step(c, batch);
|
||||
|
||||
/* A history pass with drafting rows continues on those rows alone (round 1): they are moved
|
||||
* to the front of `x` and the rest of the head runs over them. */
|
||||
* to the front of `x` and the rest of the head runs over them. Calibration uses all prompt
|
||||
* rows and returns before the proposal path. */
|
||||
int64_t L = T; /* the rows the stream goes on with */
|
||||
if (r < 0) {
|
||||
if (r < 0 && !tap_history) {
|
||||
L = batch->n_draft_out;
|
||||
RAD_ISSUE_N(c, op_dsel, L, RAD_B(w.x), praw(batch->draft_out_ids, RAD_I32, L),
|
||||
brows(w.hout, L));
|
||||
@@ -402,6 +473,22 @@ inline void MtpBlockFP8<Ffn>::step(RadCtx* c, const RadBatch* batch) const {
|
||||
mlp.step_rows(c, L);
|
||||
|
||||
RAD_ISSUE(c, op_norm, brows(w.x, L), RAD_W(w_norm), brows(w.hout, L));
|
||||
if (tap_history) {
|
||||
/* Only the owner counts and writes. Followers can replay this pass without a host tap. */
|
||||
if (g.rank == 0) {
|
||||
if (L > w.calib_tokens - draft_head_calib_rows) {
|
||||
rad_step_fail(c, "MTP draft-head calibration would count more rows than the corpus holds");
|
||||
return;
|
||||
}
|
||||
draft_head_calib.step(c, w.hout, L, true);
|
||||
draft_head_calib_rows += L;
|
||||
if (draft_head_calib_rows == w.calib_tokens &&
|
||||
!calib_write_to(c, draft_head_calib.h, draft_head_calib.K, draft_head_calib_rows,
|
||||
"mtp.draft_head", 0, w.calib_dir))
|
||||
rad_step_fail(c, "failed to write the MTP draft-head RADGRAM2 calibration");
|
||||
}
|
||||
return; /* calib-corpus needs the head input, not a speculative proposal */
|
||||
}
|
||||
if (q2) {
|
||||
/* `dsum` is group-major [n_embd/group][ceil(L/16)*16], so it has no row slice; pass it
|
||||
* whole. */
|
||||
@@ -413,6 +500,12 @@ inline void MtpBlockFP8<Ffn>::step(RadCtx* c, const RadBatch* batch) const {
|
||||
brows(w.dlog, L), RAD_B(w.dsum), RAD_NONE);
|
||||
RAD_ISSUE_N(c, op_dtopk, L, brows(w.dlog, L), brows(w.didx, L), brows(w.dval, L),
|
||||
RAD_NONE); /* the `pairs` slot, absent: operands are positional */
|
||||
if (w.coupled) {
|
||||
const int rd = r < 0 ? 1 : r; /* history already supplied round one's rows */
|
||||
RAD_ISSUE_N(c, op_couple[rd - 1], L, brows(w.didx, L), brows(w.dval, L),
|
||||
praw(batch->seq_ids, RAD_I32, batch->n_seq), brows(couple_draws, L),
|
||||
RAD_B(couple_state));
|
||||
}
|
||||
} else {
|
||||
RAD_ISSUE_N(c, op_logits, L, brows(w.hout, L), RAD_W(w_lm), brows(w.logits, L));
|
||||
}
|
||||
|
||||
@@ -152,6 +152,13 @@ struct MtpHcBlock {
|
||||
MoeFP8 mlp{};
|
||||
|
||||
rad_op op_gather = 0, op_embed = 0, op_embed_ar = 0, op_enter = 0, op_carry = 0;
|
||||
/* The selected draft calibration also records the bf16 attention input shared by
|
||||
* qg/k/v, independently of the expert gate's later input. */
|
||||
rad_buf b_attn_gram = 0;
|
||||
rad_op op_attn_gram = 0;
|
||||
const char* attn_gram_stem = nullptr;
|
||||
mutable int64_t attn_gram_rows = 0;
|
||||
mutable bool attn_gram_done = false;
|
||||
|
||||
/* Media rows over the head's embedding (see MtpBlockFP8::media). Set before declare when the
|
||||
* program has an encoder. */
|
||||
@@ -258,6 +265,20 @@ inline int MtpHcBlock::declare(RadBuilder* b, Names& nm, const Geom& geom, int l
|
||||
* order. */
|
||||
RAD_ARCH_TRY(hc_attn.declare(b, nm, g, nm.f("mtp.attn_hc"), hc, HyperConn::Wire{w.hw, w.x, w.inj},
|
||||
src.hc_attn));
|
||||
if (src.mlp.cfg.calib) {
|
||||
/* Only a BF16 source supplies domain-0 inputs for this calibration. The input
|
||||
* is replicated, so each TP rank records the same width and GPTQ sums them. */
|
||||
if (!src.mlp.cfg.expert_bf16 || !w.attn.h.x) return RAD_E_UNSUPPORTED;
|
||||
attn_gram_stem = nm.f("blk.%d.attn_qg", l);
|
||||
b_attn_gram = decl_b(b, nm.f("blk.%d.mtp_attn_gram", l), RAD_F32,
|
||||
{g.n_embd, g.n_embd}, RAD_BUF_PERSIST);
|
||||
op_attn_gram = rw(b, RAD_OP(b, "gram_accum",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", g.n_embd),
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{w.attn.h.x, b_attn_gram}, {b_attn_gram});
|
||||
if (!b_attn_gram || !op_attn_gram) return RAD_E_INVAL;
|
||||
}
|
||||
RAD_ARCH_TRY(rad_bind_layer_kv(b, l, kv));
|
||||
attn.ar_out_take = hc_attn.ar_take();
|
||||
RAD_ARCH_TRY(attn.declare(b, nm, g, l, kv, rotary_dim, w.attn, src.attn,
|
||||
@@ -471,6 +492,17 @@ inline int MtpHcBlock::declare(RadBuilder* b, Names& nm, const Geom& geom, int l
|
||||
inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
|
||||
const int64_t T = batch->n_tok;
|
||||
const int r = batch->draft_pass;
|
||||
/* Expert calibration needs real draft-layer inputs, not the trunk's Hessian. In a
|
||||
* selected calibration layer, run the history's teacher-forced rows through the full
|
||||
* draft block before selecting the rows needed by the drafter. Normal inference and
|
||||
* a tap that has reached its target retain the ordinary history-only fast path. */
|
||||
const bool tap_history = r < 0 && mlp.c.calib && !mlp.calib_done;
|
||||
/* serial_batch names one trunk hidden row per history token. Refuse an incomplete
|
||||
* gather instead of silently calibrating stale hin rows if that contract changes. */
|
||||
if (tap_history && (batch->n_out != T || !batch->out_ids)) {
|
||||
rad_step_fail(c, "MTP calibration needs one trunk hidden row per history token");
|
||||
return;
|
||||
}
|
||||
|
||||
/* The history pass continues from the trunk's wide stream; later rounds from the head's,
|
||||
* which the carry left in the same buffer. */
|
||||
@@ -493,11 +525,26 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
|
||||
RAD_W(w_fc_h), RAD_W(w_fc_e), brows(w.hw, T));
|
||||
|
||||
hc_attn.read_pieces(c, T);
|
||||
if (tap_history && op_attn_gram && !attn_gram_done) {
|
||||
if (attn_gram_rows == 0)
|
||||
rad_memset_async(rad_buf_ptr(c, b_attn_gram), 0,
|
||||
g.n_embd * g.n_embd * 4, rad_stream(c));
|
||||
RAD_ISSUE_N(c, op_attn_gram, T, brows(w.attn.h.x, T), RAD_NONE,
|
||||
brows(b_attn_gram, g.n_embd));
|
||||
attn_gram_rows += T;
|
||||
if (attn_gram_rows >= calib_target()) {
|
||||
if (!calib_write(c, b_attn_gram, g.n_embd, attn_gram_rows, attn_gram_stem, 0)) {
|
||||
rad_step_fail(c, "MTP calibration could not write its attention input Gram");
|
||||
return;
|
||||
}
|
||||
attn_gram_done = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* A history pass with no drafting rows (every prefill chunk but a prompt's last) only stores
|
||||
* the head's state: K and V, and the indexer's block keys and tail. `n_draft_out` is the same
|
||||
* on every rank, so skipped collectives match. */
|
||||
if (r < 0 && batch->n_draft_out <= 0) {
|
||||
if (r < 0 && batch->n_draft_out <= 0 && !tap_history) {
|
||||
qsa.store(c, attn.w.h, batch);
|
||||
attn.store_kv(c, batch);
|
||||
return;
|
||||
@@ -505,7 +552,7 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
|
||||
|
||||
/* The indexer runs first because the attention reads its selection; `w.h` is already final,
|
||||
* written by the connection above. */
|
||||
qsa.step(c, attn.w.h, batch, qsa_win_cu);
|
||||
qsa.step(c, attn.w.h, batch, qsa_win_cu, attn.qsa_use(batch));
|
||||
attn.step(c, batch);
|
||||
|
||||
hc_attn.write(c, T, 0, T);
|
||||
@@ -513,7 +560,7 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
|
||||
/* A history pass with drafting rows continues on those rows alone (round 1): they are moved
|
||||
* to the front of `hw` and the rest of the head runs over them. */
|
||||
int64_t L = T; /* the rows the stream goes on with */
|
||||
if (r < 0) {
|
||||
if (r < 0 && !tap_history) {
|
||||
L = batch->n_draft_out;
|
||||
RAD_ISSUE_N(c, op_dsel, L, RAD_B(w.hw), praw(batch->draft_out_ids, RAD_I32, L),
|
||||
brows(w.hin, L));
|
||||
@@ -524,6 +571,16 @@ inline void MtpHcBlock::step(RadCtx* c, const RadBatch* batch) const {
|
||||
mlp.step_rows(c, L);
|
||||
hc_mlp.write(c, L, 0, L);
|
||||
|
||||
if (tap_history) {
|
||||
/* History-only chunks have no proposal. For the last chunk, select the same
|
||||
* round-1 rows the ordinary path would have selected before its feed-forward. */
|
||||
L = batch->n_draft_out;
|
||||
if (L <= 0) return;
|
||||
RAD_ISSUE_N(c, op_dsel, L, RAD_B(w.hw), praw(batch->draft_out_ids, RAD_I32, L),
|
||||
brows(w.hin, L));
|
||||
RAD_ISSUE_N(c, op_dback, L, brows(w.hin, L), brows(w.hw, L));
|
||||
}
|
||||
|
||||
/* The carry, only if a later round reads it: a history pass is round 1, followed by round 2
|
||||
* when depth > 1; the last round is followed by a trunk step. */
|
||||
if (r < 0 ? depth > 1 : r < depth)
|
||||
|
||||
@@ -132,11 +132,24 @@ inline int MuseTower::declare(RadBuilder* b, const RadModelMeta* m, const RadBui
|
||||
proj_ff = rad_meta_geti(m, "projector_hidden_size", 4096);
|
||||
out_hidden = rad_meta_geti(m, "out_hidden_size", 6144);
|
||||
n_embd = model_embd;
|
||||
if (depth <= 0 || width <= 0 || heads <= 0 || ff <= 0 || patch <= 0 || temporal <= 0 ||
|
||||
merge <= 0 || side <= 0 || proj_ff <= 0 || out_hidden <= 0 || width % heads ||
|
||||
/* Bounds the walk and the host allocations below take at face value, set against published
|
||||
* maxima rather than round numbers: the deepest vision encoder ever shipped is 48 layers
|
||||
* (ViT-22B, InternViT-6B; this family's towers are SigLIP-class, tens), and the largest
|
||||
* stored position table a side of 92 (SigLIP at 1292 px over patch 14; CLIP 16, SAM 64 --
|
||||
* native-resolution towers store no side x side table at all). The caps sit ~2.6x and
|
||||
* ~5.5x past those maxima, so they never bite an honest container, and at the cap the
|
||||
* guarded shapes are harmless: the depth vectors cost KiB and the grid products reach 2^18
|
||||
* at most. Past the caps the container is not describing a model but a vector size
|
||||
* (full.assign(depth) and L.assign(depth) would throw past max_size, and the grid products
|
||||
* below overflow signed 64 before any comparison could notice). Refuse like every other
|
||||
* bad config: say so and RAD_E_INVAL. */
|
||||
if (depth <= 0 || depth > 128 || width <= 0 || heads <= 0 || ff <= 0 || patch <= 0 ||
|
||||
temporal <= 0 || merge <= 0 || side <= 0 || side > 512 || proj_ff <= 0 ||
|
||||
out_hidden <= 0 || width % heads ||
|
||||
rad_meta_geti(m, "vision_config.pos_emb_width", 0) != side) {
|
||||
fprintf(stderr, "radiance: museglimmer: the container's vision_config is incomplete or "
|
||||
"inconsistent (depth %lld, hidden %lld, heads %lld, ff %lld, patch %lld, "
|
||||
fprintf(stderr, "radiance: museglimmer: the container's vision_config is incomplete, "
|
||||
"inconsistent, or past what this tower walks (depth %lld, hidden %lld, "
|
||||
"heads %lld, ff %lld, patch %lld, "
|
||||
"temporal %lld, merge %lld, position grid %lld x %lld, projector %lld, "
|
||||
"merged %lld)\n", (long long)depth, (long long)width, (long long)heads,
|
||||
(long long)ff, (long long)patch, (long long)temporal, (long long)merge,
|
||||
|
||||
@@ -501,7 +501,24 @@ inline void PleLayer::ids(RadCtx* c_, const RadBatch* batch) const {
|
||||
* after the step's (`tok` reaches A tokens past the step); the window left behind is the
|
||||
* step's alone. */
|
||||
const int64_t A = P > 0 ? ahead_rows(batch) : 0;
|
||||
if (P > 0)
|
||||
/* A checkpoint inside the step (RadBatch::ckpt_cut): the rows before it, the window's
|
||||
* snapshot, then the rest with the ahead rows, each as a chunk of those rows hashes them. */
|
||||
const int64_t ck = batch->ckpt_cut;
|
||||
if (P == 1 && D == 0 && ck > 0 && ck < T && batch->ckpt_cu) {
|
||||
for (int64_t p = 0; p < 2; ++p) {
|
||||
const int64_t r0 = p == 0 ? 0 : ck, n = p == 0 ? ck : T - ck;
|
||||
RAD_ISSUE_N(c_, op_ids, n,
|
||||
praw(batch->token_ids, RAD_I32, T + A), kv_cache(kv_tok, layer_),
|
||||
praw(batch->ckpt_cu + p, RAD_I32, 2),
|
||||
RAD_W(w_mult), RAD_W(w_vsz), RAD_W(w_off),
|
||||
praw(tk_idx, RAD_I32, 1),
|
||||
praw(p == 0 ? batch->ctx_lens : batch->positions + r0, RAD_I32, 1),
|
||||
RAD_NONE,
|
||||
brows(b_ids, T),
|
||||
p == 1 && A > 0 ? brow_slice(b_ids, T, A, c.heads) : RAD_NONE);
|
||||
if (p == 0) rad_ckpt_snap(c_, kv_tok, layer_);
|
||||
}
|
||||
} else if (P > 0)
|
||||
RAD_ISSUE_N(c_, op_ids, T,
|
||||
praw(batch->token_ids, RAD_I32, T + A), kv_cache(kv_tok, layer_),
|
||||
praw(batch->cu_seqlens + D, RAD_I32, P + 1),
|
||||
@@ -577,7 +594,21 @@ inline void PleLayer::step(RadCtx* c_, const RadBatch* batch) const {
|
||||
praw(batch->ctx_lens, RAD_I32, D),
|
||||
praw(batch->num_accepted, RAD_I32, D),
|
||||
brows(b_out, DT));
|
||||
if (P > 0)
|
||||
const int64_t ck = batch->ckpt_cut;
|
||||
if (P == 1 && D == 0 && ck > 0 && ck < T && batch->ckpt_cu) {
|
||||
/* A checkpoint inside the step: the window over the rows before it, its snapshot, then
|
||||
* the rest (as ids()). */
|
||||
for (int64_t p = 0; p < 2; ++p) {
|
||||
RAD_ISSUE_N(c_, op_conv, p == 0 ? ck : T - ck,
|
||||
brows(b_gvn, T), RAD_W(w_conv), kv_cache(kv_conv, layer_),
|
||||
praw(batch->ckpt_cu + p, RAD_I32, 2), brows(b_gv, T),
|
||||
praw(cv_idx, RAD_I32, 1),
|
||||
praw(p == 0 ? batch->ctx_lens : batch->positions + ck, RAD_I32, 1),
|
||||
RAD_NONE,
|
||||
brows(b_out, T));
|
||||
if (p == 0) rad_ckpt_snap(c_, kv_conv, layer_);
|
||||
}
|
||||
} else if (P > 0)
|
||||
RAD_ISSUE_N(c_, op_conv, T,
|
||||
brows(b_gvn, T), RAD_W(w_conv), kv_cache(kv_conv, layer_),
|
||||
praw(batch->cu_seqlens + D, RAD_I32, P + 1), brows(b_gv, T),
|
||||
|
||||
+27
-7
@@ -605,20 +605,27 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up,
|
||||
{ gate_up }, { a.x });
|
||||
if (!op) return RAD_E_INVAL;
|
||||
if (bf16) return RAD_OK;
|
||||
const char* qn = rot ? "had_quant_act_fp8" : a.q8_fed ? "quant_act_i8g" : "quant_act_fp8";
|
||||
/* Fed rotated int8 (ActFP8::q8_rot: a rotated down projection under an int8 routed
|
||||
* arm), had_quant_act_i8g at the pair's group. */
|
||||
const char* qn = rot ? "had_quant_act_fp8"
|
||||
: a.q8_fed ? (a.q8_rot ? "had_quant_act_i8g" : "quant_act_i8g")
|
||||
: "quant_act_fp8";
|
||||
op_q = rw(b, RAD_OP(b, qn,
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n),
|
||||
RAD_INT("group", RAD_FP8_BLOCK), RAD_STR("dtype", g.dtype)),
|
||||
RAD_INT("group", a.cg()), RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{ a.x }, { a.cq(), a.cs() });
|
||||
return op_q ? RAD_OK : RAD_E_INVAL;
|
||||
}
|
||||
if (clipped) {
|
||||
/* No rotated int8 form: its quantiser would be quant_act_i8g, unrotated; and no clamp
|
||||
* with `silu_only`. */
|
||||
if (!gate_up || !a.x || n <= 0 || rot || silu_only || (a.q8_fed && a.q8_rot) ||
|
||||
std::strcmp(act_name, "silu"))
|
||||
/* The clamp writes the bf16 plane and a quantiser reads it: E4M3, plain int8, or the
|
||||
* rotated int8 codes an i8a8h consumer reads (had_quant_act_i8g at that consumer's
|
||||
* group, the quantiser the rotated trunk's other inputs use). Against the unclamped
|
||||
* gated_had_quant_i8g that is one launch more, in the clamped layers only. No clamp
|
||||
* with `silu_only`, and none into a rotated E4M3 consumer (`rot`). */
|
||||
if (!gate_up || !a.x || n <= 0 || rot || silu_only || std::strcmp(act_name, "silu"))
|
||||
return RAD_E_INVAL;
|
||||
const bool hi8 = a.q8_fed && a.q8_rot;
|
||||
const int64_t rows = max_rows > 0 ? max_rows : g.max_tok;
|
||||
if (fuse_clamped && !step && !bf16 && !a.q8_fed && a.cq() && a.cs() &&
|
||||
rad_op_declared(b, "swiglu_clamped_quant_fp8")) {
|
||||
@@ -644,9 +651,11 @@ inline int GateQuantFP8::declare(RadBuilder* b, const Geom& g, rad_buf gate_up,
|
||||
{ gate_up }, { a.x });
|
||||
if (!bf16) {
|
||||
if (!a.cq() || !a.cs()) return RAD_E_INVAL;
|
||||
const char* qn = hi8 ? "had_quant_act_i8g" : a.q8_fed ? "quant_act_i8g"
|
||||
: "quant_act_fp8";
|
||||
op_quant =
|
||||
rw(b,
|
||||
RAD_OP(b, a.q8_fed ? "quant_act_i8g" : "quant_act_fp8",
|
||||
RAD_OP(b, qn,
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n),
|
||||
RAD_INT("group", a.cg()), RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
@@ -1081,6 +1090,17 @@ inline bool linear_is_wnh(const RadEncoding& e) {
|
||||
zp->block[1] == RAD_FP8_BLOCK;
|
||||
}
|
||||
|
||||
/* Whether a trunk whose first linear probed as `e` is rotated int8 -- w8h or wnh -- and if so
|
||||
* how wide its activation codes' scale group is: 256 for IQ8R, 128 for the other rotated forms
|
||||
* (linear_w8h_group spells the rule). An arch learns this by probing layer 0's q projection
|
||||
* before declaring activations; the probe and the fields are the arch's, the question belongs
|
||||
* beside the predicates it is made of. */
|
||||
inline bool trunk_rotation(const RadEncoding& e, int64_t* g8) {
|
||||
if (!linear_is_w8h(e) && !linear_is_wnh(e)) return false;
|
||||
*g8 = linear_w8h_group(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* The OCP-MXFP4 weight LinearFP8 serves at mxfp4a8: e2m1 codes and an E8M0 exponent per [1 x 32],
|
||||
* no transform (libr4d's MXFP4 layout hook). */
|
||||
enum { RAD_MX_GROUP = 32 };
|
||||
|
||||
File renamed without changes.
+101
-27
@@ -9,7 +9,8 @@
|
||||
* Contents: the projection and query path, the block-key path with its two states, and the score
|
||||
* and selection. Below `budget + ratio - 1` tokens of context every visible block is selected, so
|
||||
* the sparse path must reproduce the dense path's text byte for byte; that is the test for any
|
||||
* change here.
|
||||
* change here. A step entirely at or below that bound therefore needs no selection at all, and
|
||||
* step() issues only the block-key path for it (its `use`; docs/QSA.md, "Below the bound").
|
||||
*/
|
||||
#ifndef RAD_QSA_H
|
||||
#define RAD_QSA_H
|
||||
@@ -121,13 +122,43 @@ struct QsaIndexer {
|
||||
int declare(RadBuilder* b, Names& nm, const Geom& geom, int l, const Config& cfg,
|
||||
const Wire& wire, const ActFP8& in, rad_kvgroup* bk);
|
||||
/* `win_cu`, device: {0, plane_rows}, the one sequence of a window of a step wider than the
|
||||
* score plane (Config::plane_rows); null where no step is. */
|
||||
* score plane (Config::plane_rows); null where no step is.
|
||||
*
|
||||
* `use` is what the layer's attention reads of the selection this step (QsaUse, rad_arch.h;
|
||||
* AttnGatedFP8::qsa_use): the default issues the query, the scores and the selection as every
|
||||
* step did before. `first` is whether this is the first full-attention layer the pass issues:
|
||||
* at or below the bound the selection is made there once and read by every layer after it (the
|
||||
* buffers are the model's, live across its layers, and nothing else writes them). The default
|
||||
* makes it at every layer. */
|
||||
void step(RadCtx* c, const ActFP8& in, const RadBatch* batch,
|
||||
const int32_t* win_cu = nullptr) const;
|
||||
const int32_t* win_cu = nullptr, int use = kQsaSelect, bool first = true) const;
|
||||
/* Stores the pass's block keys and tail exactly as step() does, with no query, score or
|
||||
* selection (see AttnGatedFP8::store_kv). */
|
||||
void store(RadCtx* c, const ActFP8& in, const RadBatch* batch) const;
|
||||
bool store_keys(RadCtx* c, const RadBatch* batch) const;
|
||||
/* `part` 0 issues all of it; 1, 2 and 3 its three stages apart and in that order (the work
|
||||
* list, the block keys, the tail store), for a caller that issues them behind another block's
|
||||
* launches (deferrable, below). */
|
||||
bool store_keys(RadCtx* c, const RadBatch* batch, int part = 0) const;
|
||||
/* Whether this step's keys and tail may be issued behind the attention block's launches
|
||||
* instead of in front of them (SideOps, rad_arch.h): nothing reads a selection of this
|
||||
* layer's (`use` as step() resolves it), so the attention reads nothing the three ops write.
|
||||
* The caller answers for the buffers (Wire: qk, stage, page, bpos, nc excluded from
|
||||
* sharing). */
|
||||
bool deferrable(const RadBatch* batch, int use, bool first) const {
|
||||
if (!on() || qsa_eager()) return false;
|
||||
/* step() stores no keys for a batch without the attention's group; leave that to it. */
|
||||
if (!kv_batch(batch, c.kv_attn)) return false;
|
||||
if (use == kQsaOnce) use = first ? kQsaSelect : kQsaUnread;
|
||||
return use == kQsaUnread;
|
||||
}
|
||||
/* What step() issues on a deferrable step, a piece at a time: the projection, then
|
||||
* store_keys's stages 1..3. */
|
||||
void step_proj(RadCtx* c, const ActFP8& in, const RadBatch* batch) const {
|
||||
proj.step(c, in, w.qk, batch->n_tok);
|
||||
}
|
||||
void step_part(RadCtx* c, const RadBatch* batch, int part) const {
|
||||
(void)store_keys(c, batch, part);
|
||||
}
|
||||
};
|
||||
|
||||
inline int QsaIndexer::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
@@ -267,7 +298,7 @@ inline int QsaIndexer::declare(RadBuilder* b, Names& nm, const Geom& geom, int l
|
||||
/* Stores the block keys of the blocks the pass completes and the tail of raw keys after them,
|
||||
* from the projection's raw-key head. False when the step has no batch for the indexer's
|
||||
* groups. */
|
||||
inline bool QsaIndexer::store_keys(RadCtx* c_, const RadBatch* batch) const {
|
||||
inline bool QsaIndexer::store_keys(RadCtx* c_, const RadBatch* batch, int part) const {
|
||||
const int64_t T = batch->n_tok, S = batch->n_seq;
|
||||
const int64_t nw = (c.heads + 1) * c.head_dim;
|
||||
const int64_t koff = c.heads * c.head_dim; /* the raw-key head, after the query heads */
|
||||
@@ -289,26 +320,45 @@ inline bool QsaIndexer::store_keys(RadCtx* c_, const RadBatch* batch) const {
|
||||
const bool mc = g.rope_mc && batch->rope_pos;
|
||||
RadOperand bpos = g.rope_mc ? RAD_B_COL(w.bpos, 0, mc ? 3 : 1) : brows(w.bpos, work);
|
||||
if (g.rope_mc) bpos.rows = work;
|
||||
RAD_ISSUE_N(c_, op_work, T,
|
||||
bcol_at(w.qk, 0, nw, koff, c.head_dim, T),
|
||||
praw(batch->positions, RAD_I32, T),
|
||||
praw(batch->cu_seqlens, RAD_I32, S + 1),
|
||||
kv_cache(c.kv_tail, layer),
|
||||
praw2(tlb->state_index, RAD_I32, S, tw),
|
||||
praw2(bkb->block_table, RAD_I32, S, bkb->block_table_pitch),
|
||||
mc ? praw2(batch->rope_pos, RAD_I32, 3, T) : RAD_NONE,
|
||||
brows(w.stage, work * c.ratio), brows(w.page, work), bpos,
|
||||
brows(w.nc, S));
|
||||
RAD_ISSUE_N(c_, op_bkey, work,
|
||||
brows(w.stage, work * c.ratio), RAD_W(w_kn),
|
||||
brows(w.page, work), bpos,
|
||||
kv_cache(kv_bk, layer));
|
||||
RAD_ISSUE_N(c_, op_tail, T,
|
||||
bcol_at(w.qk, 0, nw, koff, c.head_dim, T),
|
||||
praw(batch->positions, RAD_I32, T),
|
||||
praw(batch->cu_seqlens, RAD_I32, S + 1),
|
||||
kv_cache(c.kv_tail, layer),
|
||||
praw2(tlb->state_index, RAD_I32, S, tw));
|
||||
if (part <= 1)
|
||||
RAD_ISSUE_N(c_, op_work, T,
|
||||
bcol_at(w.qk, 0, nw, koff, c.head_dim, T),
|
||||
praw(batch->positions, RAD_I32, T),
|
||||
praw(batch->cu_seqlens, RAD_I32, S + 1),
|
||||
kv_cache(c.kv_tail, layer),
|
||||
praw2(tlb->state_index, RAD_I32, S, tw),
|
||||
praw2(bkb->block_table, RAD_I32, S, bkb->block_table_pitch),
|
||||
mc ? praw2(batch->rope_pos, RAD_I32, 3, T) : RAD_NONE,
|
||||
brows(w.stage, work * c.ratio), brows(w.page, work), bpos,
|
||||
brows(w.nc, S));
|
||||
if (part == 1) return true;
|
||||
if (part == 0 || part == 2)
|
||||
RAD_ISSUE_N(c_, op_bkey, work,
|
||||
brows(w.stage, work * c.ratio), RAD_W(w_kn),
|
||||
brows(w.page, work), bpos,
|
||||
kv_cache(kv_bk, layer));
|
||||
if (part == 2) return true;
|
||||
if (S == 1 && batch->ckpt_cut > 0 && batch->ckpt_cut < T && batch->ckpt_cu) {
|
||||
/* A checkpoint inside the step (RadBatch::ckpt_cut): the ring over the rows before it,
|
||||
* the snapshot, then the rest -- the ring a chunk ending there leaves, and after both
|
||||
* the ring the whole step leaves (a row writes its own position's slot). */
|
||||
const int64_t ck = batch->ckpt_cut;
|
||||
for (int64_t p = 0; p < 2; ++p) {
|
||||
RAD_ISSUE_N(c_, op_tail, p == 0 ? ck : T - ck,
|
||||
bcol_at(w.qk, 0, nw, koff, c.head_dim, T),
|
||||
praw(batch->positions, RAD_I32, T),
|
||||
praw(batch->ckpt_cu + p, RAD_I32, 2),
|
||||
kv_cache(c.kv_tail, layer),
|
||||
praw2(tlb->state_index, RAD_I32, S, tw));
|
||||
if (p == 0) rad_ckpt_snap(c_, c.kv_tail, layer);
|
||||
}
|
||||
} else
|
||||
RAD_ISSUE_N(c_, op_tail, T,
|
||||
bcol_at(w.qk, 0, nw, koff, c.head_dim, T),
|
||||
praw(batch->positions, RAD_I32, T),
|
||||
praw(batch->cu_seqlens, RAD_I32, S + 1),
|
||||
kv_cache(c.kv_tail, layer),
|
||||
praw2(tlb->state_index, RAD_I32, S, tw));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -319,13 +369,31 @@ inline void QsaIndexer::store(RadCtx* c_, const ActFP8& in, const RadBatch* batc
|
||||
}
|
||||
|
||||
inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch,
|
||||
const int32_t* win_cu) const {
|
||||
const int32_t* win_cu, int use, bool first) const {
|
||||
if (!on()) return;
|
||||
const int64_t T = batch->n_tok, S = batch->n_seq;
|
||||
const int64_t qw = c.heads * c.head_dim;
|
||||
const int64_t nw = (c.heads + 1) * c.head_dim;
|
||||
|
||||
/* What the attention reads this step (QsaUse); anything asked of a step that cannot give it is
|
||||
* the full issue, which every reader accepts.
|
||||
*
|
||||
* kQsaOnce: the attention reads a selection on a step entirely at or below the exactness
|
||||
* bound. A row there has at most `topk` complete blocks, so qsa_select takes every one whose
|
||||
* key is not 0 -- every block with a page and a score that is a number, whatever the number --
|
||||
* and what it writes (the pages in block order, the partial page, their count, seqused) is a
|
||||
* function of the positions and the block table: the same bytes from every layer's scores. So
|
||||
* the pass's first full-attention layer issues the selection in full, and
|
||||
* every later layer reads that one and issues none of its own: no query, no score. */
|
||||
if (use == kQsaOnce) use = first ? kQsaSelect : kQsaUnread;
|
||||
if (use != kQsaUnread) use = kQsaSelect;
|
||||
/* RADIANCE_DEBUG_QSA_EAGER: every layer issues its own query, score and select. */
|
||||
if (qsa_eager()) use = kQsaSelect;
|
||||
|
||||
/* The projection always: its raw-key head is the block keys' and the tail's. */
|
||||
proj.step(c_, in, w.qk, T);
|
||||
/* The query heads are read by the score alone. */
|
||||
if (use == kQsaSelect) {
|
||||
/* One fused launch or `heads` + 1 unfused. The fused form takes the whole projection at its
|
||||
* row pitch and writes the query heads contiguous and rotated. `n_head` 0 is the k-only form:
|
||||
* no q_gate, q_w or q_out, and `gate_out` absent. `T <= qprep_rows` is a correctness bound
|
||||
@@ -342,8 +410,10 @@ inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch
|
||||
bcol_at(w.q, 0, qw, h * c.head_dim, c.head_dim, T));
|
||||
RAD_ISSUE_N(c_, op_rope, T, brows(w.q, T), rope_posmc(g, batch, T));
|
||||
}
|
||||
}
|
||||
|
||||
/* The keys first: the selection below reads the blocks they complete. */
|
||||
/* The keys first: the selection below reads the blocks they complete. The stateful half runs
|
||||
* whatever the attention reads: later steps score the block keys and build on the tail. */
|
||||
const RadKVGroupBatch* bkb = kv_batch(batch, kv_bk);
|
||||
const RadKVGroupBatch* atb = kv_batch(batch, c.kv_attn);
|
||||
if (!atb || !store_keys(c_, batch)) return;
|
||||
@@ -352,6 +422,10 @@ inline void QsaIndexer::step(RadCtx* c_, const ActFP8& in, const RadBatch* batch
|
||||
* is a query row, so each query of a prefill chunk selects from the shared history, as the
|
||||
* checkpoint does. */
|
||||
if (!c.emit_sel) return;
|
||||
/* Nothing reads a selection of this layer's: the step is at or below the exactness bound and
|
||||
* its attention reads the block table, or the selection the pass's first full-attention layer
|
||||
* made (AttnGatedFP8::qsa_use). */
|
||||
if (use == kQsaUnread) return;
|
||||
|
||||
/* Narrow the score columns to the live history. Both kernels size their grid from the
|
||||
* operand's width (the live count is device data), so the full `max_ctx` width would make a
|
||||
|
||||
@@ -53,8 +53,8 @@ struct Model {
|
||||
Geom g{};
|
||||
int64_t n_ff_expert = 0, n_ff_shared = 0;
|
||||
rad_kvgroup kv_full = 0, kv_win = 0;
|
||||
/* The trunk is rotated int8 (rad_fp8.h's linear_is_w8h or linear_is_wnh), its activation codes
|
||||
* one scale a `trunk_g8` columns: 256 for IQ8R, 128 for the other rotated forms. */
|
||||
/* Whether layer 0's probe found a rotated-int8 trunk, and its activation scale group: see
|
||||
* rad_fp8.h's trunk_rotation. */
|
||||
bool trunk_rot = false;
|
||||
int64_t trunk_g8 = RAD_FP8_BLOCK;
|
||||
|
||||
@@ -183,17 +183,15 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
|
||||
const int64_t T = g.max_tok, qd = g.q_dim(), kvd = g.kv_dim();
|
||||
|
||||
/* ---- the trunk's stored form, read from layer 0's q projection through that layer's own
|
||||
* LinearFP8, which then does not map it again; the activations below carry rotated int8
|
||||
* codes only for a rotated trunk. */
|
||||
/* The trunk's stored form, probed from layer 0's q projection: rad_fp8.h's trunk_rotation
|
||||
* answers whether it is rotated int8 and how wide the activation codes' scale group is. */
|
||||
m.layers.resize((size_t)g.n_layer);
|
||||
RAD_ARCH_TRY(m.layers[0].attn.q.probe(b, nm, g, nm.f("blk.0.attn_q"),
|
||||
{ nm.ckpt("model.layers.0.self_attn.q_proj.weight") }));
|
||||
{
|
||||
RadEncoding enc{};
|
||||
m.trunk_rot = weight_enc(b, nm.f("blk.0.attn_q.weight"), &enc) &&
|
||||
(linear_is_w8h(enc) || linear_is_wnh(enc));
|
||||
if (m.trunk_rot) m.trunk_g8 = linear_w8h_group(enc);
|
||||
trunk_rotation(enc, &m.trunk_g8);
|
||||
}
|
||||
|
||||
MoeFP8::Config mc{};
|
||||
|
||||
+113
-21
@@ -1,6 +1,6 @@
|
||||
/* gemma4 -- Gemma 4 text decoders (26B-A4B MoE, and the dense members of the family): a bf16
|
||||
/* gemma4 -- Gemma 4 decoders (26B-A4B MoE, and the dense members of the family): a bf16
|
||||
* trunk, routed experts bf16, block fp8 or rotated int8 (see FP8 EXPERTS), and the DFlash
|
||||
* block-diffusion drafter.
|
||||
* block-diffusion drafter, with the shared Gemma 4 vision tower.
|
||||
*
|
||||
* ============================== THE SHAPE (gemma-4-26B-A4B-it) ==============================
|
||||
*
|
||||
@@ -91,13 +91,11 @@
|
||||
*
|
||||
* ============================== NOT DECLARED ==============================
|
||||
*
|
||||
* the vision tower (arch/embgemma2 declares Gemma 4's for an encoder): this plugin serves text;
|
||||
* a container carrying a tower is served with --mm-max-patches 0 and media parts are refused by
|
||||
* name;
|
||||
* an fp8 attention or dense arm: under a tenth of the weight bytes, and the dense arm's 2112 is
|
||||
* not whole 128-blocks.
|
||||
*/
|
||||
#include <arch/rad_arch.h>
|
||||
#include <arch/rad_block_gemma4_vision.h>
|
||||
#include <arch/rad_fp8.h>
|
||||
#include <arch/rad_gemma4_chat.h>
|
||||
#include <arch/rad_gemma4_dflash.h>
|
||||
@@ -158,6 +156,7 @@ struct Layer {
|
||||
rad_op op_anorm = 0, op_qkv = 0, op_qknr = 0, op_lift = 0;
|
||||
rad_op op_q = 0, op_k = 0, op_vnorm = 0, op_qn = 0, op_kn = 0, op_qrope = 0, op_krope = 0;
|
||||
rad_op op_store = 0, op_attn = 0, op_o = 0, op_ar_o = 0, op_apost = 0, op_add_a = 0;
|
||||
rad_op op_bidi = 0, op_ahead = 0;
|
||||
/* dense arm */
|
||||
rad_weight w_fnorm = 0, w_gu = 0, w_dn = 0, w_fpost1 = 0;
|
||||
rad_op op_fnorm = 0, op_gu = 0, op_act = 0, op_dn = 0;
|
||||
@@ -241,6 +240,8 @@ struct Model {
|
||||
|
||||
rad_weight w_tok = 0, w_onorm = 0;
|
||||
rad_op op_embed = 0, op_embed_ar = 0, op_onorm = 0, op_gather = 0, op_logits = 0, op_cap = 0;
|
||||
rad_op op_mm = 0;
|
||||
Gemma4Vision vis{};
|
||||
|
||||
enum { MAX_TAPS = Dflash1::MAX_TAPS };
|
||||
int n_taps = 0;
|
||||
@@ -569,24 +570,39 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* ---- the KV groups, one per geometry: the sliding layers' (256-wide heads) and the full
|
||||
* layers' (512).
|
||||
*
|
||||
* The sliding layers' group is RAD_KV_FULL, not RAD_KV_WINDOW; the window lives on the
|
||||
* attention op (`window` 1024), which reads only keys inside it. A window group is not
|
||||
* prefix-cached (core/mem/prefix.cpp), so a prefix hit on a model with one reuses nothing and
|
||||
* re-prefills (core/sched). As FULL the group is cached with the others and the drafter's KV
|
||||
* has no hole. The only loss is recycling below the window, which gains nothing here: the
|
||||
* planner gives every paged group the same block count, so the full group bounds the tokens a
|
||||
* card holds anyway. */
|
||||
* The sliding layers' group is RAD_KV_WINDOW, sized to the attention window, which is what
|
||||
* the kernel reads: attn_paged takes `window` 1024 on those layers and never looks at a key
|
||||
* older than it. As a window group the pool is capped at the window plus one block per
|
||||
* sequence (core/mem/kv.cpp), so the sliding layers cost about 1k tokens of cache each
|
||||
* instead of the whole context. The full layers' group stays RAD_KV_FULL: it is the only one
|
||||
* whose keys outlive a window.
|
||||
*
|
||||
* A windowed group is not prefix-cached (core/mem/prefix.cpp): its rows below the window are
|
||||
* recycled, and adopt() would overfill a table capped at window_blocks. On a prefix hit the
|
||||
* full layers' rows come back from the store, and the window resumes from the deepest
|
||||
* retained checkpoint at or below the matched end: that checkpoint's slot carries the window
|
||||
* behind it, and only the gap between it and the match end is recomputed. Where no retained
|
||||
* checkpoint sits at or below the match, the windowed layers start their cache where the hit
|
||||
* ended and the prompt is prefilled again. Gemma 3 declares its sliding group the same way.
|
||||
*
|
||||
* The drafter does not read the trunk's cache. DFlash keeps its own windowed draft KV,
|
||||
* rebuilt each context pass from the trunk's residual taps, so a windowed trunk group costs
|
||||
* the drafter nothing. */
|
||||
{
|
||||
const uint32_t kvdt = rad_kv_cache_dtype(ctx, RAD_BF16);
|
||||
RadKVGroupDecl d{};
|
||||
d.kind = RAD_KV_FULL;
|
||||
d.dtype = rad_kv_cache_dtype(ctx, RAD_BF16);
|
||||
d.kind = RAD_KV_WINDOW;
|
||||
d.window = m.ks.window; /* the same 1024 the attention op reads */
|
||||
d.dtype = kvdt;
|
||||
d.n_head_kv = m.ks.nkv;
|
||||
d.head_dim = m.ks.hd;
|
||||
m.ks.kv = rad_decl_kv_group(b, nm.f("kv_swa"), &d);
|
||||
d.kind = RAD_KV_FULL;
|
||||
d.window = 0;
|
||||
d.n_head_kv = m.kf.nkv;
|
||||
d.head_dim = m.kf.hd;
|
||||
m.kf.kv = rad_decl_kv_group(b, nm.f("kv_full"), &d);
|
||||
g.kv_dtype = rad_dtype_name(d.dtype);
|
||||
g.kv_dtype = rad_dtype_name(kvdt);
|
||||
}
|
||||
|
||||
/* Gemma4ForConditionalGeneration keeps the text model under model.language_model;
|
||||
@@ -731,6 +747,14 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_INT("vocab_offset", g.vocab_off), RAD_F64("mult", m.escale)),
|
||||
RAD_WEIGHTS(m.w_tok)),
|
||||
{}, {m.b_x});
|
||||
const bool vision = ctx->max_enc_patches > 0 && Gemma4Vision::present(meta);
|
||||
const char* bidi = meta_text_gets(meta, "use_bidirectional_attention", "");
|
||||
m.vis.bidirectional = vision && bidi && !std::strcmp(bidi, "vision");
|
||||
if (vision)
|
||||
m.op_mm = rw(b, RAD_OP(b, "scatter_rows",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", E), RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_x}, {m.b_x});
|
||||
if (W > 1)
|
||||
m.op_embed_ar = rw(b, RAD_OP(b, "all_reduce",
|
||||
RAD_PARAMS(RAD_INT("world_size", W), RAD_RANGE("numel", E, T * E),
|
||||
@@ -781,10 +805,11 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_NOWEIGHTS),
|
||||
{buf}, {buf});
|
||||
};
|
||||
auto attn = [&](const Kind& k, rad_buf q, rad_buf out, const char* op = "attn_paged") {
|
||||
auto attn = [&](const Kind& k, rad_buf q, rad_buf out, const char* op = "attn_paged",
|
||||
int causal = 1) {
|
||||
return rw(b, RAD_OP(b, op,
|
||||
RAD_PARAMS(RAD_RANGE("q_len", 1, T), RAD_INT("head_dim", k.hd),
|
||||
RAD_INT("gqa", k.nh / k.nkv), RAD_INT("causal", 1),
|
||||
RAD_INT("gqa", k.nh / k.nkv), RAD_INT("causal", causal),
|
||||
RAD_INT("window", k.window), RAD_INT("n_head", k.nh),
|
||||
RAD_INT("block_size", RAD_KV_BLOCK),
|
||||
RAD_INT("max_seqs", g.max_seqs), RAD_INT("max_ctx", g.max_ctx),
|
||||
@@ -919,6 +944,19 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
{m.b_qkv}, {m.b_qs});
|
||||
y.op_attn = attn(k, m.b_qs, m.b_atts);
|
||||
}
|
||||
if (m.vis.bidirectional) {
|
||||
const bool dense_q = y.op_lift != 0;
|
||||
const rad_buf q = dense_q ? m.b_qs : m.b_qkv;
|
||||
y.op_bidi = attn(k, q, m.b_atts, dense_q ? "attn_paged" : "attn_paged_qrow", 0);
|
||||
if (!y.op_bidi) {
|
||||
fprintf(stderr, "radiance: gemma4: no sliding attention kernel for "
|
||||
"bidirectional image spans\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
const char* ahead = dense_q ? "attn_paged_ahead" : "attn_paged_qrow_ahead";
|
||||
if (T > k.window && rad_op_declared(b, ahead))
|
||||
y.op_ahead = attn(k, q, m.b_atts, ahead, 0);
|
||||
}
|
||||
y.op_store = kv_store(k, m.b_qkv, m.b_qkv);
|
||||
y.op_o = gemm(T, E, k.q(), y.w_o, m.b_atts, m.b_o);
|
||||
} else {
|
||||
@@ -1346,9 +1384,29 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
"output draws from a sharper distribution", m.softcap, m.softcap);
|
||||
}
|
||||
|
||||
/* The drafter last: declaration order is the buffer planner's liveness. */
|
||||
/* The drafter follows the trunk: declaration order is the buffer planner's liveness. */
|
||||
if (m.n_taps > 0)
|
||||
RAD_ARCH_TRY(declare_dflash(b, meta, ctx, m, (int)m.n_layer));
|
||||
if (vision) {
|
||||
/* Reserve the draft groups even when speculation is disabled. */
|
||||
const int64_t draft_layers = dflash_kind(meta) == 1
|
||||
? rad_meta_geti(meta, "draft.num_hidden_layers", 0) : 0;
|
||||
RAD_ARCH_TRY(m.vis.declare(b, meta, ctx, nm, E, (int)(m.n_layer + draft_layers),
|
||||
"model.", "gemma4"));
|
||||
/* A declaration without a weight source is valid for graph tools and tests. When
|
||||
* the trunk is backed by weights, check the tower's entry and exit before loading. */
|
||||
RadEncoding enc{};
|
||||
if (rad_weight_encoding(b, nm.f("token_embd.weight"), &enc, nullptr, nullptr) == RAD_OK) {
|
||||
for (const char* name : { "v.patch.weight", "v.embed.weight" }) {
|
||||
if (rad_weight_encoding(b, nm.f("%s", name), &enc, nullptr, nullptr) != RAD_E_NOTFOUND)
|
||||
continue;
|
||||
fprintf(stderr, "radiance: gemma4: vision is enabled but the model is missing "
|
||||
"vision weight '%s'; use --mm-max-patches 0 for text-only serving\n",
|
||||
name);
|
||||
return RAD_E_NOTFOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nfull = 0;
|
||||
for (int f : full) nfull += f;
|
||||
@@ -1518,7 +1576,8 @@ static void attend(RadCtx* c, const Model& m, const Layer& y, size_t li, const R
|
||||
const int32_t* slot = kvb ? kvb->slot_mapping : nullptr;
|
||||
const int32_t* table = kvb ? kvb->block_table : nullptr;
|
||||
const int32_t* used = kvb ? kvb->seqused : nullptr;
|
||||
const RadOperand bt = praw2(table, RAD_I32, batch->n_seq, kvb ? kvb->block_table_pitch : 0);
|
||||
const int64_t pitch = kvb ? kvb->block_table_pitch : 0;
|
||||
const RadOperand bt = praw2(table, RAD_I32, batch->n_seq, pitch);
|
||||
const RadOperand su = praw(used, RAD_I32, batch->n_seq);
|
||||
|
||||
if (!y.full) {
|
||||
@@ -1530,6 +1589,24 @@ static void attend(RadCtx* c, const Model& m, const Layer& y, size_t li, const R
|
||||
RAD_ISSUE_N(c, y.op_attn, batch->max_q_len,
|
||||
y.op_lift ? brows(m.b_qs, T) : bcol(m.b_qkv, 0, qd, T),
|
||||
kv_cache(k.kv, (int)li), bt, su, RAD_NONE, RAD_NONE, cu, brows(m.b_atts, T));
|
||||
/* Recompute only the image rows, with the cache ending at the span's last row.
|
||||
* The window still limits lookback; for a long span it must not limit lookahead. */
|
||||
for (int64_t i = 0; y.op_bidi && i < batch->n_bidi; ++i) {
|
||||
const int64_t first = batch->bidi_row[i], n = batch->bidi_n[i], s = batch->bidi_seq[i];
|
||||
const rad_op op = n > k.window ? y.op_ahead : y.op_bidi;
|
||||
if (!op) {
|
||||
rad_step_fail(c, "gemma4: an image span exceeds the sliding window and needs "
|
||||
"a paged attention kernel with unrestricted lookahead");
|
||||
return;
|
||||
}
|
||||
RAD_ISSUE_N(c, op, n,
|
||||
y.op_lift ? brow_slice(m.b_qs, first, n, qd)
|
||||
: bcol_at(m.b_qkv, first, qd + 2 * kvd, 0, qd, n),
|
||||
kv_cache(k.kv, (int)li),
|
||||
praw2(table ? table + s * pitch : nullptr, RAD_I32, 1, pitch),
|
||||
praw(batch->bidi_used + i, RAD_I32, 1),
|
||||
RAD_NONE, RAD_NONE, RAD_NONE, brow_slice(m.b_atts, first, n, qd));
|
||||
}
|
||||
} else {
|
||||
RAD_ISSUE_N(c, y.op_vnorm, T * k.nkv, brows(m.b_kf, T), RAD_NONE, brows(m.b_vf, T));
|
||||
RAD_ISSUE_N(c, y.op_qn, T * k.nh, brows(m.b_qf, T), RAD_W(y.w_qn), brows(m.b_qf, T));
|
||||
@@ -1808,13 +1885,24 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
return;
|
||||
}
|
||||
if (batch->enc) {
|
||||
rad_step_fail(c, "gemma4 declares no encoder; serve this container with --mm-max-patches 0");
|
||||
if (batch->enc & ~(RAD_MM_IMAGE | RAD_MM_VIDEO))
|
||||
rad_step_fail(c, "gemma4: unsupported encoder modality");
|
||||
else if (!m.vis.on)
|
||||
rad_step_fail(c, "gemma4: no vision tower was declared; image and video encoding "
|
||||
"require vision weights and --mm-max-patches greater than 0");
|
||||
else
|
||||
m.vis.step(c, batch);
|
||||
return;
|
||||
}
|
||||
const int64_t T = batch->n_tok, E = m.E;
|
||||
if (T <= 0) return;
|
||||
|
||||
RAD_ISSUE(c, m.op_embed, praw(batch->token_ids, RAD_I32, T), RAD_W(m.w_tok), brows(m.b_x, T));
|
||||
/* The batch supplies image rows on rank 0 and zeros on the other ranks. */
|
||||
if (m.op_mm && batch->n_mm_rows > 0)
|
||||
RAD_ISSUE_N(c, m.op_mm, batch->n_mm_rows,
|
||||
praw2(batch->mm_embd, RAD_BF16, batch->n_mm_rows, E),
|
||||
praw(batch->mm_rows, RAD_I32, batch->n_mm_rows), brows(m.b_x, T));
|
||||
if (m.op_embed_ar)
|
||||
RAD_ISSUE_N(c, m.op_embed_ar, T * E, brows(m.b_x, T), RAD_NONE);
|
||||
|
||||
@@ -1842,6 +1930,10 @@ static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
out->draft_depth = 0;
|
||||
(void)dflash_probe(meta, out);
|
||||
if (Gemma4Vision::present(meta)) {
|
||||
const int64_t k = rad_meta_geti(meta, "vision_config.pooling_kernel_size", 0);
|
||||
if (k > 0) out->enc_merge = k * k;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -1857,7 +1949,7 @@ static const RadChatFormat* chat_format(const RadModelMeta*) { return gemma4_cha
|
||||
/* Every per-instance state above is indexed by slot (rad_build_slot / rad_slot). */
|
||||
RAD_ARCH_MULTI_INSTANCE()
|
||||
RAD_ARCH_PLUGIN(gemma4, "gemma4", "", "0.1.0",
|
||||
"Gemma 4 text decoders (26B-A4B MoE, dense 31B), bf16: sliding and full attention "
|
||||
"Gemma 4 decoders (26B-A4B MoE, dense 31B) with vision, bf16: sliding and full attention "
|
||||
"with proportional rope and K = V, a dense and a routed feed-forward side by side, "
|
||||
"and z-lab's DFlash block-diffusion drafter")
|
||||
RAD_ARCH_PROBE(gemma4)
|
||||
|
||||
@@ -2269,7 +2269,7 @@ static int declare_dflash2(RadBuilder* b, const RadModelMeta* meta, const RadBui
|
||||
(long long)dg.n_layer, (long long)m.n_main, (long long)dg.n_head_all,
|
||||
(long long)dg.n_head_kv_all, (long long)dg.head_dim, (long long)dg.n_ff_all,
|
||||
dc.causal ? "causal" : "non-causal", (long long)dc.window, m.n_taps,
|
||||
(long long)dc.steps(), m.df2.head_i8 ? "8-bit" : "2-bit");
|
||||
(long long)dc.steps(), m.df2.head_i8 ? "8-bit" : m.df2.head_bf16 ? "bf16" : "2-bit");
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
|
||||
+28
-17
@@ -67,7 +67,10 @@ using namespace rad::arch;
|
||||
|
||||
/* ================================================================== the model's constants */
|
||||
/* The largest image: 2048 x 2048 pixels, 16384 latent tokens. 1024 x 1024 is the default. */
|
||||
enum { kMaxImageTokens = 16384 };
|
||||
static constexpr int64_t kMaxImageTokens = 16384;
|
||||
static int64_t image_tokens(int64_t pixels) {
|
||||
return pixels > 0 ? std::min<int64_t>(kMaxImageTokens, pixels / 256) : kMaxImageTokens;
|
||||
}
|
||||
/* The longest conditioning in rows: the pipeline's max_sequence_length. The prompt the language
|
||||
* model reads is that plus the template's system turn, at most kTeRows. */
|
||||
enum { kCondRows = 512, kTeRows = kCondRows + 64 };
|
||||
@@ -155,6 +158,7 @@ enum : int {
|
||||
|
||||
struct Model {
|
||||
Names nm{""};
|
||||
int64_t max_image_tokens = kMaxImageTokens;
|
||||
Geom gt{}, gf{}, gd{}; /* the language model's, the text fusion's and the DiT's geometry */
|
||||
bool turbo = false;
|
||||
std::string te_pre; /* the language model's tensor prefix */
|
||||
@@ -752,7 +756,9 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
const int64_t C = m.C, L = g.n_layer;
|
||||
const double eps = g.eps;
|
||||
const int gx = kGrpDit;
|
||||
const int64_t NI = std::min<int64_t>(T, 2 * (int64_t)kMaxImageTokens); /* image rows a pass */
|
||||
/* Image rows a pass: a denoising branch an entry (one for an unguided image, two under
|
||||
* classifier-free guidance), as many entries as max-num-seqs allows, within the step's rows. */
|
||||
const int64_t NI = g.max_seqs > T / m.max_image_tokens ? T : g.max_seqs * m.max_image_tokens;
|
||||
|
||||
/* ---- the timestep: [cos | sin] of 1000 bf16(t) over 256, linear, gelu_tanh, linear (temb);
|
||||
* the shared modulation from gelu_tanh(temb), then each block's table added (table_add), and
|
||||
@@ -817,13 +823,13 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
m.b_h = decl_b(b, nm.f("dit.h"), RAD_BF16, { T, D });
|
||||
m.op_randn = rw(b, RAD_OP(b, "randn_lanes",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, NI), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", (int64_t)m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_state }, { m.b_state });
|
||||
m.op_lgather = rw(b, RAD_OP(b, "lane_gather",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, NI), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", (int64_t)m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_state }, { m.b_lat });
|
||||
@@ -997,7 +1003,7 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
m.b_fz, m.b_v, &m.w_pout, &m.b_pout, RAD_ACCESS_PER_TOKEN, gx);
|
||||
m.op_euler = rw(b, RAD_OP(b, "flow_euler",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, NI), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", (int64_t)m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_v, m.b_state, m.b_prev }, { m.b_state, m.b_prev });
|
||||
@@ -1016,7 +1022,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
v.scope = "vdec";
|
||||
v.down = false;
|
||||
v.first_group = kGrpVaeDec;
|
||||
v.base_px = (int64_t)kMaxImageTokens * 4;
|
||||
v.base_px = (int64_t)m.max_image_tokens * 4;
|
||||
v.form = VAE_CONV_CAUSAL;
|
||||
const int64_t base = rad_meta_geti(meta, "vae.base_dim", 96);
|
||||
const int64_t zd = rad_meta_geti(meta, "vae.z_dim", 16);
|
||||
@@ -1043,7 +1049,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
m.ones += k ? " 1" : "1";
|
||||
m.zeros += k ? " 0" : "0";
|
||||
}
|
||||
const int64_t NT = kMaxImageTokens;
|
||||
const int64_t NT = m.max_image_tokens;
|
||||
m.b_dl = decl_b(b, nm.f("vdec.lat"), RAD_BF16, { NT, 4 * zd });
|
||||
m.b_dl2 = decl_b(b, nm.f("vdec.lat2"), RAD_BF16, { NT, 4 * zd });
|
||||
m.b_decin = decl_b(b, nm.f("vdec.in"), RAD_BF16, { 4 * NT, zd });
|
||||
@@ -1108,7 +1114,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
m.dec_out = v.conv(x, 3, 3, 1, 1, "same", "vae.decoder.conv_out");
|
||||
if (!m.dec_out.buf) return RAD_E_INVAL;
|
||||
RAD_ARCH_TRY(v.attn_reads(m.b_cu4));
|
||||
const int64_t px = (int64_t)kMaxImageTokens * 256;
|
||||
const int64_t px = (int64_t)m.max_image_tokens * 256;
|
||||
m.b_img = decl_b(b, nm.f("image_out"), RAD_U8, { px * 3 }, RAD_BUF_PERSIST);
|
||||
m.op_rgb = rw(b, RAD_OP(b, "to_rgba8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, px), RAD_INT("n", 3),
|
||||
@@ -1126,7 +1132,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
* unpacked latent, two rows a token row, eight pixels a latent row. */
|
||||
const int world = m.gt.world;
|
||||
if (world > 1) {
|
||||
const int64_t H0 = 4 * (int64_t)kMaxImageTokens;
|
||||
const int64_t H0 = 4 * (int64_t)m.max_image_tokens;
|
||||
const int64_t bpx = (H0 / world + H0 / (2 * v.halo) + 1) * 64;
|
||||
m.b_rgbf = decl_b(b, nm.f("vdec.bands"), RAD_BF16, { world * bpx, 3 });
|
||||
m.op_bands = rw(b, RAD_OP(b, "all_gather",
|
||||
@@ -1146,12 +1152,14 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
}
|
||||
|
||||
static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) {
|
||||
if (!b || !meta || !ctx) return RAD_E_INVAL;
|
||||
if (!b || !meta || !ctx || ctx->max_seqs <= 0) return RAD_E_INVAL;
|
||||
if (ctx->rank < 0 || ctx->rank >= MAX_RANKS || rad_build_slot(ctx) >= MAX_SLOTS)
|
||||
return RAD_E_INVAL;
|
||||
Model& m = g_model[rad_build_slot(ctx)];
|
||||
m = Model{};
|
||||
m.nm = Names(ctx->scope);
|
||||
m.max_image_tokens = image_tokens(ctx->gen_max_pixels);
|
||||
if (m.max_image_tokens == 0) return RAD_E_INVAL;
|
||||
RAD_ARCH_TRY(check_format(meta));
|
||||
RAD_ARCH_TRY(geom_from(m.gt, meta, ctx, "bf16", RAD_BF16));
|
||||
Names& nm = m.nm;
|
||||
@@ -1219,7 +1227,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
|
||||
/* ---- the per-image state, the conditioning store, and in issue order the language model,
|
||||
* the text fusion, the DiT and the decoder */
|
||||
const int64_t lane_rows = (int64_t)kMaxLanes * kMaxImageTokens;
|
||||
const int64_t lane_rows = (int64_t)kMaxLanes * m.max_image_tokens;
|
||||
m.b_state = decl_b(b, nm.f("lat_state"), RAD_BF16, { lane_rows, m.C }, RAD_BUF_PERSIST);
|
||||
m.b_prev = decl_b(b, nm.f("lat_preview"), RAD_BF16, { lane_rows, m.C }, RAD_BUF_PERSIST);
|
||||
m.b_store = decl_b(b, nm.f("cond_store"), RAD_BF16,
|
||||
@@ -1247,11 +1255,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
d.size_multiple = 16;
|
||||
d.pixel_channels = 3;
|
||||
d.slot_rows = 1;
|
||||
d.max_tokens = kMaxImageTokens;
|
||||
d.max_tokens = m.max_image_tokens;
|
||||
d.max_refs = 0;
|
||||
d.ref_area = 1;
|
||||
d.default_width = 1024;
|
||||
d.default_height = 1024;
|
||||
const int64_t side = (int64_t)std::sqrt(std::min<int64_t>(m.max_image_tokens, 4096)) * 16;
|
||||
d.default_width = side;
|
||||
d.default_height = side;
|
||||
/* Raw: 28 steps on the resolution-shifted schedule, guidance 4.5 in the card's terms.
|
||||
* Turbo: 8 steps at a fixed mu of 1.15 (base and max shift equal), no guidance. */
|
||||
d.default_steps = m.turbo ? 8 : 28;
|
||||
@@ -1405,7 +1414,7 @@ static void step_denoise(RadCtx* c, const RadBatch* batch, const Model& m) {
|
||||
const RadOperand cu = praw(batch->cu_seqlens, RAD_I32, S + 1);
|
||||
const RadOperand icu = praw(G->img_cu, RAD_I32, S + 1);
|
||||
const RadOperand lanes = praw(G->lane, RAD_I32, S);
|
||||
const int64_t LR = (int64_t)kMaxLanes * kMaxImageTokens;
|
||||
const int64_t LR = (int64_t)kMaxLanes * m.max_image_tokens;
|
||||
|
||||
/* ---- modulation: the timestep MLP, the shared projection, each block's table, the final */
|
||||
RAD_ISSUE_N(c, m.op_temb, S, praw(G->sigma, RAD_F32, S), brows(m.b_tproj, S));
|
||||
@@ -1506,7 +1515,7 @@ static void step_decode(RadCtx* c, const RadBatch* batch, const Model& m) {
|
||||
const RadGenBatch* G = batch->gen_b;
|
||||
const int64_t H = G->dec_height / 16, W = G->dec_width / 16, n = H * W, C = m.C;
|
||||
const rad_buf src = G->dec_preview ? m.b_prev : m.b_state;
|
||||
RAD_ISSUE_N(c, m.op_dinv, n, brow_slice(src, (int64_t)G->dec_lane * kMaxImageTokens, n, C),
|
||||
RAD_ISSUE_N(c, m.op_dinv, n, brow_slice(src, (int64_t)G->dec_lane * m.max_image_tokens, n, C),
|
||||
brows(m.b_dl, n));
|
||||
RAD_ISSUE_N(c, m.op_dadd, n, brows(m.b_dl, n), brows(m.b_dl2, n));
|
||||
const int64_t zd = C / 4, H0 = 2 * H, W0 = 2 * W;
|
||||
@@ -1556,7 +1565,9 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
/* The rows a pass carries: one image at the largest size with guidance, its text both ways. */
|
||||
static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
out->gen_rows = 2 * ((int64_t)kMaxImageTokens + kCondRows);
|
||||
const int64_t tokens = image_tokens(out->gen_max_pixels);
|
||||
if (tokens == 0) return RAD_E_INVAL;
|
||||
out->gen_rows = 2 * (tokens + kCondRows);
|
||||
out->gen_patches = 0;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Built in radiance's tree, or standalone against an installed radiance
|
||||
# (`cmake -S arch/lfm3_bf16 -B build -DCMAKE_PREFIX_PATH=<radiance prefix>`); see cmake/RadAddPlugin.cmake.
|
||||
if(NOT COMMAND rad_add_plugin)
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(lfm3_bf16 LANGUAGES CXX)
|
||||
find_package(radiance REQUIRED)
|
||||
rad_plugin_defaults()
|
||||
endif()
|
||||
|
||||
rad_add_plugin(lfm3_bf16 architectures SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lfm3_bf16.cpp)
|
||||
@@ -0,0 +1,786 @@
|
||||
/* lfm3_bf16 -- LiquidAI's LFM3, bf16 activations over bf16 or int8 (IQ8R) linears, one rank.
|
||||
*
|
||||
* ============================== THE SHAPE ==============================
|
||||
*
|
||||
* LFM2's hybrid with a third layer kind, in the order the checkpoint's `layer_types` lists them
|
||||
* (read, not derived):
|
||||
*
|
||||
* conv in_proj -> [B | C | x], y = out_proj(C * conv(B * x)), where conv is a
|
||||
* depthwise causal convolution of width `conv_L_cache` with no activation
|
||||
* full_attention GQA with per-head RMS norms on q and k, a partial NeoX rotary on the "head"
|
||||
* ladder (the first `partial_rotary_factor * head_dim` channels rotate, at the
|
||||
* frequencies of the whole head; the rest do not), and a gate per query head
|
||||
* sliding_attention the same attention over the last `sliding_window` tokens, its rotary over
|
||||
* the whole head at its own theta
|
||||
*
|
||||
* each followed by a SwiGLU feed-forward (w1 the gate, w3 the up, w2 the down). The norms are a
|
||||
* sandwich: `operator_norm` before the mixer and `post_operator_norm` on its output, before the
|
||||
* residual add; `ffn_norm` and `post_ffn_norm` likewise. Every norm is a plain RMSNorm
|
||||
* (`x_hat * w`), and the final one is `embedding_norm`. A post norm, its add and the norm that
|
||||
* reads the sum are one `norm_add_norm` where a library serves it (Gemma's sandwich join; see
|
||||
* declare). At 1.7B: 24 layers (13 conv, 6 full, 5
|
||||
* sliding with a window of 256), hidden 2048, 16 heads over 4 at head_dim 128, ffn 7680,
|
||||
* vocabulary 128000 with the lm_head tied to the embedding, conv width 7; theta 1e6 over half the
|
||||
* head on the full layers, 1e4 on the sliding ones.
|
||||
*
|
||||
* ============================== THE GATE ==============================
|
||||
*
|
||||
* The attention output of each query head is multiplied by sigmoid(gate_proj(h)), one scalar a
|
||||
* (token, head), before the out projection. `mul` multiplies planes of equal width, so the gate
|
||||
* is computed at the output's width: the name map repeats each of gate_proj's n_head rows head_dim
|
||||
* times (RAD_MAP_ROWS), and `gemm_nt` + `sigmoid` + `mul` then give every channel of a head that
|
||||
* head's gate, with the reference's rounding (the gate and the product are each a bf16 tensor
|
||||
* there). It costs n_embd * (q_dim - n_head) stored weights an attention layer, 2.6% of the
|
||||
* container at 1.7B.
|
||||
*
|
||||
* ============================== 8-BIT LINEARS ==============================
|
||||
*
|
||||
* Every linear but the gate is a LinearFP8 (rad_fp8.h), as lfm2_bf16's are, so the container's
|
||||
* encoding of each weight decides the GEMM: plain bf16 is `gemm_nt` over the bf16 activation,
|
||||
* exactly as a bf16 model runs; int8 (`codes=i8 group=128 scale=bf16`) is `gemm_nt_q` at i8a8, and
|
||||
* the rotated form (those codes under the 128-wide Hadamard, data/recipes/lfm3-1.7b-iq8r.recipe,
|
||||
* or IQ8R's scale per 256 of K) the same at i8a8h, each linear quantising its input from
|
||||
* the bf16 plane. The trunk's format is read off layer 0's first linear and every linear must
|
||||
* match it. The gate stays bf16 in every container (n_head distinct rows; its product is a hard
|
||||
* multiplier on a whole head), as do the convolution, the norms, the joins and attention. The
|
||||
* lm_head is read at its stored codes.
|
||||
*
|
||||
* ============================== WHAT IT DOES NOT SERVE ==============================
|
||||
*
|
||||
* Tensor parallelism (the model needs one card), block-fp8 or narrower linears, a trunk that mixes
|
||||
* formats, a quantised gate, a drafter, media, conv bias, a checkpoint without the sandwich norms,
|
||||
* or a rotary other than the default type: each is refused by name.
|
||||
*/
|
||||
#include <arch/rad_arch.h>
|
||||
#include <arch/rad_fp8.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace lfm3_bf16 {
|
||||
|
||||
using namespace rad::arch;
|
||||
|
||||
enum Kind { kConv = 0, kFull = 1, kSliding = 2 };
|
||||
|
||||
/* One plain bf16 linear: its weight and the gemm_nt over it. The attention gate is the one linear
|
||||
* declared this way: its weight is gate_proj's rows repeated, which the shared LinearFP8 that
|
||||
* serves every other linear does not map. */
|
||||
struct Linear {
|
||||
rad_weight w = 0;
|
||||
rad_op op = 0;
|
||||
};
|
||||
|
||||
/* What differs between the two attention classes. */
|
||||
struct AttnClass {
|
||||
double theta = 0.0;
|
||||
int64_t rot = 0; /* rotary_dim */
|
||||
int64_t window = 0; /* 0: full */
|
||||
rad_kvgroup kv = 0;
|
||||
};
|
||||
|
||||
struct Layer {
|
||||
Kind kind = kConv;
|
||||
rad_weight w_norm = 0, w_post_norm = 0, w_ffn_norm = 0, w_ffn_post_norm = 0;
|
||||
rad_op op_norm = 0, op_post_norm = 0, op_add = 0;
|
||||
/* conv */
|
||||
LinearFP8 conv_in, conv_out;
|
||||
rad_weight w_conv = 0;
|
||||
rad_op op_gate_in = 0, op_conv = 0, op_gate_out = 0;
|
||||
/* attention */
|
||||
LinearFP8 q, k, v, out;
|
||||
Linear gate;
|
||||
rad_weight w_q_norm = 0, w_k_norm = 0;
|
||||
rad_op op_q_norm = 0, op_k_norm = 0, op_rope_q = 0, op_rope_k = 0;
|
||||
rad_op op_store = 0, op_attn = 0, op_sigmoid = 0, op_gate_mul = 0;
|
||||
/* the feed-forward: norm, gate|up (w1 | w3), SiLU(gate) * up, down (w2), norm, residual add */
|
||||
LinearFP8 gate_up, down;
|
||||
rad_op op_ffn_norm = 0, op_act = 0, op_ffn_post_norm = 0, op_ffn_add = 0;
|
||||
/* The sandwich joins, fused: op_join is post_norm + add + ffn_norm, and op_ffn_join is
|
||||
* ffn_post_norm + ffn_add + the next layer's norm, which that layer then does not declare. */
|
||||
rad_op op_join = 0, op_ffn_join = 0;
|
||||
};
|
||||
|
||||
struct Model {
|
||||
Names nm{""};
|
||||
Geom g{};
|
||||
int64_t width = 0; /* conv_L_cache: the convolution's taps */
|
||||
AttnClass full{}, sliding{};
|
||||
rad_kvgroup kv_conv = 0;
|
||||
|
||||
rad_buf b_x = 0, b_h = 0, b_arm = 0, b_bcx = 0, b_conv_in = 0, b_conv_out = 0;
|
||||
rad_buf b_q = 0, b_k = 0, b_v = 0, b_attn = 0, b_gate = 0, b_gate_up = 0, b_ffn = 0;
|
||||
rad_buf b_hout = 0, b_logits = 0;
|
||||
/* The four activations a linear reads, as LinearFP8 takes them: the bf16 plane is the buffer
|
||||
* above. */
|
||||
ActFP8 a_h{}, a_attn{}, a_conv{}, a_ffn{};
|
||||
/* An int8 trunk (i8a8, or IQ8R at i8a8h), and its scale group along K, which the activations'
|
||||
* int8 pairs share (ActFP8::g8). */
|
||||
bool q_i8 = false;
|
||||
int64_t g8 = RAD_FP8_BLOCK;
|
||||
|
||||
rad_weight w_tok = 0, w_out_norm = 0, w_lm_head = 0;
|
||||
rad_op op_embed = 0, op_gather = 0, op_final_norm = 0, op_logits = 0;
|
||||
|
||||
std::vector<Layer> layers;
|
||||
|
||||
const AttnClass& cls(const Layer& L) const { return L.kind == kSliding ? sliding : full; }
|
||||
};
|
||||
|
||||
static Model g_model[MAX_SLOTS];
|
||||
|
||||
static int64_t meta_int(const RadModelMeta* m, const char* key, int64_t dflt) {
|
||||
const char* v = rad_meta_gets(m, key, nullptr);
|
||||
return v ? std::strtoll(v, nullptr, 10) : dflt;
|
||||
}
|
||||
static double meta_f64(const RadModelMeta* m, const char* key, double dflt) {
|
||||
const char* v = rad_meta_gets(m, key, nullptr);
|
||||
return v ? std::strtod(v, nullptr) : dflt;
|
||||
}
|
||||
static bool meta_bool(const RadModelMeta* m, const char* key, bool dflt) {
|
||||
const char* v = rad_meta_gets(m, key, nullptr);
|
||||
if (!v) return dflt;
|
||||
return std::strcmp(v, "true") == 0 || std::strcmp(v, "1") == 0;
|
||||
}
|
||||
|
||||
/* `layer_types`, one word per layer, space-separated in the container. */
|
||||
static int read_schedule(const RadModelMeta* m, int64_t n_layer, std::vector<Layer>* out) {
|
||||
const char* s = rad_meta_gets(m, "layer_types", nullptr);
|
||||
if (!s || !*s) {
|
||||
fprintf(stderr, "radiance: lfm3: the container has no layer_types; this family's schedule "
|
||||
"is read, not derived\n");
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
std::istringstream in(s);
|
||||
std::string kind;
|
||||
while (in >> kind) {
|
||||
Layer l;
|
||||
if (kind == "conv") l.kind = kConv;
|
||||
else if (kind == "full_attention") l.kind = kFull;
|
||||
else if (kind == "sliding_attention") l.kind = kSliding;
|
||||
else {
|
||||
fprintf(stderr, "radiance: lfm3: layer_types[%zu] is '%s'; this plugin knows 'conv', "
|
||||
"'full_attention' and 'sliding_attention'\n", out->size(), kind.c_str());
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
out->push_back(l);
|
||||
}
|
||||
if ((int64_t)out->size() != n_layer) {
|
||||
fprintf(stderr, "radiance: lfm3: layer_types names %zu layers and the model has %lld\n",
|
||||
out->size(), (long long)n_layer);
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* One class's rotary from `rope_parameters.<type>`: theta is required (the typed rope_theta is a
|
||||
* top-level key this family does not write), the type must be the default, and the partial factor
|
||||
* gives an even rotary width inside the head. */
|
||||
static int read_rotary(const RadModelMeta* m, const char* type, int64_t head_dim, AttnClass* c) {
|
||||
const std::string pre = std::string("rope_parameters.") + type + ".";
|
||||
const char* rt = rad_meta_gets(m, (pre + "rope_type").c_str(), "default");
|
||||
if (std::strcmp(rt, "default") != 0) {
|
||||
fprintf(stderr, "radiance: lfm3: rope_parameters.%s.rope_type '%s' is not 'default'\n",
|
||||
type, rt);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
c->theta = meta_f64(m, (pre + "rope_theta").c_str(), 0.0);
|
||||
if (!(c->theta > 0.0)) {
|
||||
fprintf(stderr, "radiance: lfm3: rope_parameters.%s.rope_theta is required\n", type);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
const double prf = meta_f64(m, (pre + "partial_rotary_factor").c_str(), 1.0);
|
||||
/* the reference's int(prf * head_dim) // 2 angles */
|
||||
c->rot = 2 * ((int64_t)(prf * (double)head_dim) / 2);
|
||||
if (!(prf > 0.0) || c->rot < 2 || c->rot > head_dim) {
|
||||
fprintf(stderr, "radiance: lfm3: rope_parameters.%s.partial_rotary_factor %g gives a "
|
||||
"rotary width %lld outside 2..head_dim\n", type, prf, (long long)c->rot);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) {
|
||||
if (!b || !meta || !ctx || ctx->rank < 0 || ctx->rank >= MAX_RANKS ||
|
||||
rad_build_slot(ctx) >= MAX_SLOTS)
|
||||
return RAD_E_INVAL;
|
||||
if (ctx->world_size > 1) {
|
||||
fprintf(stderr, "radiance: lfm3_bf16 serves one rank; run it with --tp 1\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (meta->n_expert > 0 || meta_bool(meta, "conv_bias", false) ||
|
||||
!meta_bool(meta, "use_sandwich_norm", true)) {
|
||||
fprintf(stderr, "radiance: lfm3_bf16 serves the dense SwiGLU model with sandwich norms, "
|
||||
"gated attention and bias-free convolutions; this checkpoint is not that\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Model& m = g_model[rad_build_slot(ctx)];
|
||||
m = Model{};
|
||||
m.nm = Names(ctx->scope);
|
||||
Names& nm = m.nm;
|
||||
|
||||
RAD_ARCH_TRY(geom_from(m.g, meta, ctx, "bf16", RAD_BF16));
|
||||
Geom& g = m.g;
|
||||
/* The attention rows are keyed on a whole number of queries a KV head. */
|
||||
if (g.n_head_kv <= 0 || g.n_head % g.n_head_kv != 0) {
|
||||
fprintf(stderr, "radiance: lfm3: %lld attention heads over %lld key/value heads is not a "
|
||||
"whole number of queries a key/value head\n",
|
||||
(long long)g.n_head, (long long)g.n_head_kv);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
RAD_ARCH_TRY(read_schedule(meta, g.n_layer, &m.layers));
|
||||
m.width = meta_int(meta, "conv_L_cache", 0);
|
||||
if (m.width < 2 || m.width > 8) {
|
||||
fprintf(stderr, "radiance: lfm3: conv_L_cache %lld is outside the 2..8 the convolution "
|
||||
"kernels serve\n", (long long)m.width);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
bool has_full = false, has_sliding = false, has_conv = false;
|
||||
for (const Layer& L : m.layers) {
|
||||
has_full |= L.kind == kFull;
|
||||
has_sliding |= L.kind == kSliding;
|
||||
has_conv |= L.kind == kConv;
|
||||
}
|
||||
if (has_full) RAD_ARCH_TRY(read_rotary(meta, "full_attention", g.head_dim, &m.full));
|
||||
if (has_sliding) {
|
||||
RAD_ARCH_TRY(read_rotary(meta, "sliding_attention", g.head_dim, &m.sliding));
|
||||
m.sliding.window = meta_int(meta, "sliding_window", 0);
|
||||
if (m.sliding.window < 1) {
|
||||
fprintf(stderr, "radiance: lfm3: the sliding_attention layers need a sliding_window, "
|
||||
"and the container has %lld\n", (long long)m.sliding.window);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
|
||||
const char* pre = "model";
|
||||
|
||||
/* ---- the state groups: paged KV for the full layers, the same bounded by the window for the
|
||||
* sliding ones, and a rolling window of the convolution's last width-1 inputs (plus the
|
||||
* speculative slack the manager adds) for the conv layers. The conv group's channels are
|
||||
* n_head_kv * head_dim: one "head" of n_embd. */
|
||||
const uint32_t kvdt = rad_kv_cache_dtype(ctx, RAD_BF16);
|
||||
g.kv_dtype = rad_dtype_name(kvdt);
|
||||
if (has_full) {
|
||||
RadKVGroupDecl fd{};
|
||||
fd.kind = RAD_KV_FULL;
|
||||
fd.dtype = kvdt;
|
||||
fd.n_head_kv = g.n_head_kv;
|
||||
fd.head_dim = g.head_dim;
|
||||
m.full.kv = rad_decl_kv_group(b, nm.f("kv_attn"), &fd);
|
||||
if (!m.full.kv) return RAD_E_INVAL;
|
||||
}
|
||||
if (has_sliding) {
|
||||
RadKVGroupDecl sd{};
|
||||
sd.kind = RAD_KV_WINDOW;
|
||||
sd.dtype = kvdt;
|
||||
sd.window = m.sliding.window;
|
||||
sd.n_head_kv = g.n_head_kv;
|
||||
sd.head_dim = g.head_dim;
|
||||
m.sliding.kv = rad_decl_kv_group(b, nm.f("kv_sliding"), &sd);
|
||||
if (!m.sliding.kv) return RAD_E_INVAL;
|
||||
}
|
||||
if (has_conv) {
|
||||
RadKVGroupDecl cd{};
|
||||
cd.kind = RAD_KV_CONV;
|
||||
cd.dtype = RAD_BF16;
|
||||
cd.n_head_kv = 1;
|
||||
cd.head_dim = g.n_embd;
|
||||
cd.conv_width = m.width;
|
||||
m.kv_conv = rad_decl_kv_group(b, nm.f("kv_conv"), &cd);
|
||||
if (!m.kv_conv) return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
m.b_x = decl_b(b, nm.f("x"), RAD_BF16, {g.max_tok, g.n_embd});
|
||||
m.b_h = decl_b(b, nm.f("h"), RAD_BF16, {g.max_tok, g.n_embd});
|
||||
/* a mixer's or a feed-forward's output, before its post norm: a join reads it beside x and
|
||||
* writes h, so it is not h */
|
||||
m.b_arm = decl_b(b, nm.f("arm"), RAD_BF16, {g.max_tok, g.n_embd});
|
||||
m.b_bcx = decl_b(b, nm.f("conv_bcx"), RAD_BF16, {g.max_tok, 3 * g.n_embd});
|
||||
m.b_conv_in = decl_b(b, nm.f("conv_in"), RAD_BF16, {g.max_tok, g.n_embd});
|
||||
m.b_conv_out = decl_b(b, nm.f("conv_out"), RAD_BF16, {g.max_tok, g.n_embd});
|
||||
m.b_q = decl_b(b, nm.f("attn_q"), RAD_BF16, {g.max_tok, g.q_dim()});
|
||||
m.b_k = decl_b(b, nm.f("attn_k"), RAD_BF16, {g.max_tok, g.kv_dim()});
|
||||
m.b_v = decl_b(b, nm.f("attn_v"), RAD_BF16, {g.max_tok, g.kv_dim()});
|
||||
m.b_attn = decl_b(b, nm.f("attn_out"), RAD_BF16, {g.max_tok, g.q_dim()});
|
||||
m.b_gate = decl_b(b, nm.f("attn_gate"), RAD_BF16, {g.max_tok, g.q_dim()});
|
||||
m.b_gate_up = decl_b(b, nm.f("gate_up"), RAD_BF16, {g.max_tok, 2 * g.n_ff});
|
||||
m.b_ffn = decl_b(b, nm.f("ffn"), RAD_BF16, {g.max_tok, g.n_ff});
|
||||
m.b_hout = decl_b(b, nm.f("h_out"), RAD_BF16, {g.max_logit_rows, g.n_embd});
|
||||
m.b_logits = decl_b(b, nm.f("logits"), RAD_F32, {g.max_logit_rows, g.n_vocab});
|
||||
RAD_ARCH_TRY(rad_declare_logits(b, m.b_logits));
|
||||
/* ---- the trunk's format, read off layer 0's first linear before any activation is declared
|
||||
* (probe() makes its name map and reads its encoding). Plain bf16, or no encoding yet, is a
|
||||
* bf16 trunk: every linear is `gemm_nt` over its input's bf16 plane. An int8 weight makes the
|
||||
* activations carry int8 codes beside it. */
|
||||
{
|
||||
Layer& L0 = m.layers[0];
|
||||
const bool at = L0.kind != kConv;
|
||||
LinearFP8& first = at ? L0.q : L0.conv_in;
|
||||
const char* base0 = nm.f(at ? "blk.%d.attn_q" : "blk.%d.conv_in", 0);
|
||||
RAD_ARCH_TRY(first.probe(b, nm, g, base0,
|
||||
{ nm.ckpt(at ? "%s.layers.%d.self_attn.%s" : "%s.layers.%d.conv.%s",
|
||||
pre, 0, at ? "q_proj.weight" : "in_proj.weight") }));
|
||||
RadEncoding enc{};
|
||||
const bool known = weight_enc(b, nm.f("%s.weight", base0), &enc);
|
||||
const bool plain = !known || (rad_enc_is(&enc, "plain") && enc.n_planes == 1 &&
|
||||
enc.plane[0].dtype == RAD_BF16);
|
||||
g.w_bf16 = plain;
|
||||
m.q_i8 = !plain && first.probed_i8;
|
||||
if (m.q_i8) m.g8 = first.probed_g8;
|
||||
if (!plain && !m.q_i8) {
|
||||
char en[256];
|
||||
rad_enc_format(&enc, en, sizeof en);
|
||||
fprintf(stderr, "radiance: lfm3: '%s.weight' is %s; this plugin serves a bf16 trunk or "
|
||||
"an int8 one (codes=i8 group=128, or IQ8R)\n", base0, en);
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
}
|
||||
if (m.q_i8 && (g.n_embd % m.g8 || g.q_dim() % m.g8 || g.n_ff % m.g8)) {
|
||||
fprintf(stderr, "radiance: lfm3: the int8 trunk keeps one scale a %lld of K, which does not "
|
||||
"divide this model's widths (hidden %lld, attention %lld, feed-forward "
|
||||
"%lld)\n",
|
||||
(long long)m.g8, (long long)g.n_embd, (long long)g.q_dim(), (long long)g.n_ff);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
m.a_h.x = m.b_h; m.a_attn.x = m.b_attn; m.a_conv.x = m.b_conv_out; m.a_ffn.x = m.b_ffn;
|
||||
RAD_ARCH_TRY(m.a_h.declare_qs(b, nm, g, "h", g.n_embd, 0, m.q_i8, false, m.g8));
|
||||
RAD_ARCH_TRY(m.a_attn.declare_qs(b, nm, g, "attn_out", g.q_dim(), 0, m.q_i8, false, m.g8));
|
||||
RAD_ARCH_TRY(m.a_conv.declare_qs(b, nm, g, "conv_out", g.n_embd, 0, m.q_i8, false, m.g8));
|
||||
RAD_ARCH_TRY(m.a_ffn.declare_qs(b, nm, g, "ffn", g.n_ff, 0, m.q_i8, false, m.g8));
|
||||
|
||||
/* ---- the vocabulary edges. The lm_head is tied but declared as its own weight: the
|
||||
* embedding may live in host memory (--embedding-placement) and the head on the card. */
|
||||
RAD_ARCH_TRY(map_copy(b, nm.f("token_embd.weight"), nm.ckpt("%s.embed_tokens.weight", pre)));
|
||||
RAD_ARCH_TRY(map_copy(b, nm.f("output_norm.weight"), nm.ckpt("%s.embedding_norm.weight", pre)));
|
||||
RAD_ARCH_TRY(map_copy_alt(b, nm.f("output.weight"), nm.ckpt("lm_head.weight"),
|
||||
nm.ckpt("%s.embed_tokens.weight", pre)));
|
||||
m.w_tok = decl_w(b, nm.f("token_embd.weight"), RAD_BF16, {g.n_vocab, g.n_embd},
|
||||
RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model());
|
||||
m.w_out_norm = decl_w(b, nm.f("output_norm.weight"), RAD_F32, {g.n_embd},
|
||||
RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE, grp_model());
|
||||
/* The head at its codes' dtype: bf16, or int8 where a recipe made it so. */
|
||||
m.w_lm_head = decl_w(b, nm.f("output.weight"),
|
||||
weight_codes_dtype(b, nm.f("output.weight"), RAD_BF16),
|
||||
{g.n_vocab, g.n_embd}, RAD_ACCESS_VOCAB, RAD_SHARD_NONE, grp_model());
|
||||
|
||||
m.op_embed = rw(b, RAD_OP(b, "embed_lookup",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n_embd", g.n_embd),
|
||||
RAD_INT("n_vocab", g.n_vocab), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(m.w_tok)),
|
||||
{}, {m.b_x});
|
||||
|
||||
/* `op`: "rmsnorm", or "rmsnorm_rows" for the head norms, whose short-row form a prefill's
|
||||
* thousands of head_dim-wide rows take. */
|
||||
auto rmsnorm = [&](int64_t rows, int64_t n, rad_weight w, rad_buf in, rad_buf out,
|
||||
const char* op = "rmsnorm") {
|
||||
return rw(b, RAD_OP(b, op,
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, rows), RAD_INT("n", n), RAD_F64("eps", g.eps),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w)),
|
||||
{in}, {out});
|
||||
};
|
||||
auto add = [&](rad_buf x, rad_buf h) {
|
||||
return rw(b, RAD_OP(b, "add",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{x, h}, {x});
|
||||
};
|
||||
auto mul = [&](std::initializer_list<rad_buf> rd, rad_buf out, int64_t n) {
|
||||
return rw(b, RAD_OP(b, "mul",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", n),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
rd, {out});
|
||||
};
|
||||
auto layer_w = [&](const char* name, int l, std::initializer_list<int64_t> shape,
|
||||
uint32_t dtype) {
|
||||
return decl_w(b, nm.f(name, l), dtype, shape, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE,
|
||||
grp_layer(l));
|
||||
};
|
||||
/* A norm's gain: mapped, and declared f32. */
|
||||
auto norm_w = [&](rad_weight* w, const char* name, int l, const char* src, int64_t n) -> int {
|
||||
RAD_ARCH_TRY(map_copy(b, nm.f(name, l), src));
|
||||
*w = layer_w(name, l, {n}, RAD_F32);
|
||||
return *w ? RAD_OK : RAD_E_INVAL;
|
||||
};
|
||||
/* The gate: one plain bf16 linear over an already mapped weight, in every container. */
|
||||
auto plain_linear = [&](Linear& lin, int l, const char* name, int64_t N, int64_t K, rad_buf in,
|
||||
rad_buf out) -> int {
|
||||
RadEncoding enc{};
|
||||
if (weight_enc(b, nm.f(name, l), &enc) &&
|
||||
!(rad_enc_is(&enc, "plain") && enc.n_planes == 1 && enc.plane[0].dtype == RAD_BF16)) {
|
||||
char en[256];
|
||||
rad_enc_format(&enc, en, sizeof en);
|
||||
fprintf(stderr, "radiance: lfm3: '%s' is %s; the attention gate stays bf16 (leave "
|
||||
"gate_proj out of the recipe)\n", nm.f(name, l), en);
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
lin.w = decl_w(b, nm.f(name, l), RAD_BF16, {N, K}, RAD_ACCESS_PER_TOKEN, RAD_SHARD_NONE,
|
||||
grp_layer(l));
|
||||
if (!lin.w) return RAD_E_INVAL;
|
||||
lin.op = rw(b, RAD_OP(b, "gemm_nt",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("N", N), RAD_INT("K", K),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(lin.w)),
|
||||
{in}, {out});
|
||||
return lin.op ? RAD_OK : RAD_E_INVAL;
|
||||
};
|
||||
/* One linear: `base` is the declared name without `.weight`, `src` its checkpoint tensor (or
|
||||
* the tensors stacked along its rows, `parts` their row counts), `a` the activation it reads. */
|
||||
auto linear = [&](LinearFP8& lin, int l, const char* base_fmt, int64_t N, int64_t K,
|
||||
std::initializer_list<const char*> src, const ActFP8& a, rad_buf y,
|
||||
std::initializer_list<int64_t> parts) -> int {
|
||||
const char* base = nm.f(base_fmt, l);
|
||||
RAD_ARCH_TRY(lin.declare(b, nm, g, base, N, K, RAD_SHARD_NONE, grp_layer(l), src, a, y, 0,
|
||||
parts));
|
||||
/* Every linear has the trunk's format. LinearFP8 refuses a quantised weight in a bf16
|
||||
* trunk; this refuses a bf16 or narrower one in an int8 trunk. */
|
||||
if (g.w_bf16 ? !lin.bf16 : !(lin.i8 && !lin.iqr)) {
|
||||
fprintf(stderr, "radiance: lfm3: '%s.weight' is not in the trunk's format (%s); "
|
||||
"quantise every linear of the trunk alike\n",
|
||||
base, g.w_bf16 ? "bf16" : "int8");
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
return RAD_OK;
|
||||
};
|
||||
/* q names its query heads; k is rotated as a q-only row of the kv heads (its own buffer).
|
||||
* The partial rotary is on the "head" ladder; over the whole head the ladders coincide and
|
||||
* the parameter is left out. */
|
||||
auto rope = [&](const AttnClass& c, int64_t heads, rad_buf buf) {
|
||||
const RadParam ps[] = { RAD_RANGE("M", 1, g.max_tok), RAD_INT("head_dim", g.head_dim),
|
||||
RAD_INT("n_head", heads), RAD_INT("n_head_kv", 0),
|
||||
RAD_F64("theta", c.theta), RAD_F64("scale", 1.0),
|
||||
RAD_STR("mode", "neox"), RAD_INT("rotary_dim", c.rot),
|
||||
RAD_STR("ladder", "head") };
|
||||
const int n = (int)(sizeof ps / sizeof ps[0]) - (c.rot < g.head_dim ? 0 : 1);
|
||||
return rw(b, rad_decl_op(b, "rope_rows", ps, n, nullptr, 0), {buf}, {buf});
|
||||
};
|
||||
|
||||
|
||||
/* ---- the sandwich joins. `norm_add_norm` is a post norm, the residual add and the norm that
|
||||
* reads the sum in one launch: post_norm + add + ffn_norm inside a layer, and ffn_post_norm +
|
||||
* add + the next layer's norm between two. It rounds where the chain rounds. The device
|
||||
* libraries serve it and libref and libavx do not, and declaring an op no loaded library
|
||||
* declares is an error, so it is asked for first; without it, or where it does not resolve,
|
||||
* the rmsnorm / add / rmsnorm chain runs. The last layer's feed-forward keeps the chain: the
|
||||
* final norm is on the gathered rows. */
|
||||
const bool has_join = rad_op_declared(b, "norm_add_norm") != 0;
|
||||
auto join = [&](rad_weight w_a, rad_weight w_y) {
|
||||
return rw(b, RAD_OP(b, "norm_add_norm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd),
|
||||
RAD_F64("eps", g.eps), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(w_a, w_y)),
|
||||
{m.b_arm, m.b_x}, {m.b_x, m.b_h});
|
||||
};
|
||||
int n_joins = 0;
|
||||
|
||||
/* Every layer's input norm gain, ahead of the layers: a feed-forward join names the next
|
||||
* layer's, and an op can only name weights already declared. */
|
||||
for (int l = 0; l < (int)m.layers.size(); ++l)
|
||||
RAD_ARCH_TRY(norm_w(&m.layers[(size_t)l].w_norm, "blk.%d.attn_norm.weight", l,
|
||||
nm.ckpt("%s.layers.%d.%s", pre, l, "operator_norm.weight"), g.n_embd));
|
||||
|
||||
for (int l = 0; l < (int)m.layers.size(); ++l) {
|
||||
Layer& L = m.layers[(size_t)l];
|
||||
const char* lay = "%s.layers.%d.%s";
|
||||
RAD_ARCH_TRY(norm_w(&L.w_post_norm, "blk.%d.attn_post_norm.weight", l,
|
||||
nm.ckpt(lay, pre, l, "post_operator_norm.weight"), g.n_embd));
|
||||
RAD_ARCH_TRY(norm_w(&L.w_ffn_norm, "blk.%d.ffn_norm.weight", l,
|
||||
nm.ckpt(lay, pre, l, "ffn_norm.weight"), g.n_embd));
|
||||
RAD_ARCH_TRY(norm_w(&L.w_ffn_post_norm, "blk.%d.ffn_post_norm.weight", l,
|
||||
nm.ckpt(lay, pre, l, "post_ffn_norm.weight"), g.n_embd));
|
||||
/* written by the layer before, where its feed-forward join is fused */
|
||||
if (!(l > 0 && m.layers[(size_t)l - 1].op_ffn_join))
|
||||
L.op_norm = rmsnorm(g.max_tok, g.n_embd, L.w_norm, m.b_x, m.b_h);
|
||||
|
||||
if (L.kind != kConv) {
|
||||
const AttnClass& c = m.cls(L);
|
||||
RAD_ARCH_TRY(rad_bind_layer_kv(b, l, c.kv));
|
||||
const char* a = "%s.layers.%d.self_attn.%s";
|
||||
/* The gate at the output's width: row h of gate_proj, head_dim times, for each head
|
||||
* in turn (see the head of the file). Successive ROWS maps extend the weight. */
|
||||
{
|
||||
const std::string dst = nm.f("blk.%d.attn_gate.weight", l);
|
||||
const std::string src = nm.ckpt(a, pre, l, "gate_proj.weight");
|
||||
for (int64_t h = 0; h < g.n_head; ++h)
|
||||
for (int64_t d = 0; d < g.head_dim; d += 8) {
|
||||
RadNameMap mp = map_base(dst.c_str(), RAD_MAP_ROWS);
|
||||
for (int64_t i = d; i < g.head_dim && i < d + 8; ++i) {
|
||||
mp.src[mp.n_src] = src.c_str();
|
||||
mp.src_index[mp.n_src] = (int)h;
|
||||
mp.src_rows[mp.n_src] = 1;
|
||||
++mp.n_src;
|
||||
}
|
||||
RAD_ARCH_TRY(rad_decl_name_map(b, &mp));
|
||||
}
|
||||
}
|
||||
RAD_ARCH_TRY(linear(L.q, l, "blk.%d.attn_q", g.q_dim(), g.n_embd,
|
||||
{ nm.ckpt(a, pre, l, "q_proj.weight") }, m.a_h, m.b_q, {}));
|
||||
RAD_ARCH_TRY(linear(L.k, l, "blk.%d.attn_k", g.kv_dim(), g.n_embd,
|
||||
{ nm.ckpt(a, pre, l, "k_proj.weight") }, m.a_h, m.b_k, {}));
|
||||
RAD_ARCH_TRY(linear(L.v, l, "blk.%d.attn_v", g.kv_dim(), g.n_embd,
|
||||
{ nm.ckpt(a, pre, l, "v_proj.weight") }, m.a_h, m.b_v, {}));
|
||||
RAD_ARCH_TRY(plain_linear(L.gate, l, "blk.%d.attn_gate.weight", g.q_dim(), g.n_embd,
|
||||
m.b_h, m.b_gate));
|
||||
RAD_ARCH_TRY(norm_w(&L.w_q_norm, "blk.%d.attn_q_norm.weight", l,
|
||||
nm.ckpt(a, pre, l, "q_norm.weight"), g.head_dim));
|
||||
RAD_ARCH_TRY(norm_w(&L.w_k_norm, "blk.%d.attn_k_norm.weight", l,
|
||||
nm.ckpt(a, pre, l, "k_norm.weight"), g.head_dim));
|
||||
|
||||
/* The head norms run over rows of head_dim: a [T, heads * head_dim] buffer is
|
||||
* T * heads rows. */
|
||||
L.op_q_norm = rmsnorm(g.max_tok * g.n_head, g.head_dim, L.w_q_norm, m.b_q, m.b_q,
|
||||
"rmsnorm_rows");
|
||||
L.op_k_norm = rmsnorm(g.max_tok * g.n_head_kv, g.head_dim, L.w_k_norm, m.b_k, m.b_k,
|
||||
"rmsnorm_rows");
|
||||
L.op_rope_q = rope(c, g.n_head, m.b_q);
|
||||
L.op_rope_k = rope(c, g.n_head_kv, m.b_k);
|
||||
/* attn_paged before kv_store: the cache's block size is read from the resolved
|
||||
* attention kernel. */
|
||||
L.op_attn = rw(b, RAD_OP(b, "attn_paged",
|
||||
RAD_PARAMS(RAD_RANGE("q_len", 1, g.max_tok),
|
||||
RAD_INT("head_dim", g.head_dim), RAD_INT("gqa", g.gqa()),
|
||||
RAD_INT("causal", 1), RAD_INT("window", c.window),
|
||||
RAD_INT("n_head", g.n_head),
|
||||
RAD_INT("block_size", RAD_KV_BLOCK),
|
||||
RAD_INT("max_seqs", g.max_seqs),
|
||||
RAD_INT("max_ctx", g.max_ctx),
|
||||
RAD_STR("q_dtype", g.dtype),
|
||||
RAD_STR("kv_dtype", g.kv_dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_q}, {m.b_attn});
|
||||
L.op_store = rw(b, RAD_OP(b, "kv_store",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok),
|
||||
RAD_INT("head_dim", g.head_dim),
|
||||
RAD_INT("n_head_kv", g.n_head_kv),
|
||||
RAD_INT("block_size", rad_kv_block_size(b, c.kv)),
|
||||
RAD_STR("kv_dtype", g.kv_dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_k, m.b_v}, {});
|
||||
L.op_sigmoid = rw(b, RAD_OP(b, "sigmoid",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.q_dim()),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_gate}, {m.b_gate});
|
||||
L.op_gate_mul = mul({m.b_gate, m.b_attn}, m.b_attn, g.q_dim());
|
||||
RAD_ARCH_TRY(linear(L.out, l, "blk.%d.attn_output", g.n_embd, g.q_dim(),
|
||||
{ nm.ckpt(a, pre, l, "o_proj.weight") }, m.a_attn, m.b_arm, {}));
|
||||
} else {
|
||||
RAD_ARCH_TRY(rad_bind_layer_kv(b, l, m.kv_conv));
|
||||
const char* c = "%s.layers.%d.conv.%s";
|
||||
RAD_ARCH_TRY(map_copy(b, nm.f("blk.%d.conv.weight", l), nm.ckpt(c, pre, l, "conv.weight")));
|
||||
/* in_proj's row is [B | C | x]: conv(B * x), then C * that. */
|
||||
RAD_ARCH_TRY(linear(L.conv_in, l, "blk.%d.conv_in", 3 * g.n_embd, g.n_embd,
|
||||
{ nm.ckpt(c, pre, l, "in_proj.weight") }, m.a_h, m.b_bcx, {}));
|
||||
/* The checkpoint ships [n_embd, 1, width]; the depthwise group axis is squeezed at
|
||||
* convert, as LFM2's is. */
|
||||
L.w_conv = layer_w("blk.%d.conv.weight", l, {g.n_embd, m.width}, RAD_BF16);
|
||||
L.op_gate_in = mul({m.b_bcx}, m.b_conv_in, g.n_embd);
|
||||
L.op_conv = rw(b, RAD_OP(b, "causal_conv1d",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_embd),
|
||||
RAD_INT("width", m.width), RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(L.w_conv)),
|
||||
{m.b_conv_in}, {m.b_conv_out});
|
||||
L.op_gate_out = mul({m.b_bcx, m.b_conv_out}, m.b_conv_out, g.n_embd);
|
||||
RAD_ARCH_TRY(linear(L.conv_out, l, "blk.%d.conv_out", g.n_embd, g.n_embd,
|
||||
{ nm.ckpt(c, pre, l, "out_proj.weight") }, m.a_conv, m.b_arm, {}));
|
||||
}
|
||||
/* the sandwich: the mixer's output is normed before it joins the stream, and the
|
||||
* feed-forward reads the norm of the sum */
|
||||
if (has_join) L.op_join = join(L.w_post_norm, L.w_ffn_norm);
|
||||
if (!L.op_join) {
|
||||
L.op_post_norm = rmsnorm(g.max_tok, g.n_embd, L.w_post_norm, m.b_arm, m.b_arm);
|
||||
L.op_add = add(m.b_x, m.b_arm);
|
||||
L.op_ffn_norm = rmsnorm(g.max_tok, g.n_embd, L.w_ffn_norm, m.b_x, m.b_h);
|
||||
}
|
||||
|
||||
/* ---- the feed-forward */
|
||||
const char* ffn = "%s.layers.%d.feed_forward.%s";
|
||||
RAD_ARCH_TRY(linear(L.gate_up, l, "blk.%d.ffn_gate_up", 2 * g.n_ff, g.n_embd,
|
||||
{ nm.ckpt(ffn, pre, l, "w1.weight"), nm.ckpt(ffn, pre, l, "w3.weight") },
|
||||
m.a_h, m.b_gate_up, { g.n_ff, g.n_ff }));
|
||||
L.op_act = rw(b, RAD_OP(b, "silu_mul",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_tok), RAD_INT("n", g.n_ff),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_gate_up}, {m.b_ffn});
|
||||
RAD_ARCH_TRY(linear(L.down, l, "blk.%d.ffn_down", g.n_embd, g.n_ff,
|
||||
{ nm.ckpt(ffn, pre, l, "w2.weight") }, m.a_ffn, m.b_arm, {}));
|
||||
if (has_join && l + 1 < (int)m.layers.size())
|
||||
L.op_ffn_join = join(L.w_ffn_post_norm, m.layers[(size_t)l + 1].w_norm);
|
||||
if (!L.op_ffn_join) {
|
||||
L.op_ffn_post_norm = rmsnorm(g.max_tok, g.n_embd, L.w_ffn_post_norm, m.b_arm, m.b_arm);
|
||||
L.op_ffn_add = add(m.b_x, m.b_arm);
|
||||
}
|
||||
n_joins += (L.op_join ? 1 : 0) + (L.op_ffn_join ? 1 : 0);
|
||||
}
|
||||
|
||||
/* The final norm runs on the gathered rows only: it is per token, and those are the rows the
|
||||
* lm_head reads. */
|
||||
m.op_gather = rw(b, RAD_OP(b, "gather_rows",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows), RAD_INT("n", g.n_embd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_x}, {m.b_hout});
|
||||
m.op_final_norm = rmsnorm(g.max_logit_rows, g.n_embd, m.w_out_norm, m.b_hout, m.b_hout);
|
||||
/* A tied head is the bf16 embedding table: a scored step leaves the final-normed rows in
|
||||
* h_out and the core takes the candidates' logits from the table on the host. */
|
||||
if (meta_bool(meta, "tie_word_embeddings", false))
|
||||
RAD_ARCH_TRY(rad_declare_scores(b, m.b_hout, m.w_tok));
|
||||
m.op_logits = rw(b, RAD_OP(b, "logits_gemm",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, g.max_logit_rows),
|
||||
RAD_INT("n_vocab", g.n_vocab), RAD_INT("n_embd", g.n_embd),
|
||||
RAD_STR("dtype", g.dtype)),
|
||||
RAD_WEIGHTS(m.w_lm_head)),
|
||||
{m.b_hout}, {m.b_logits});
|
||||
|
||||
int64_t n_full = 0, n_sliding = 0;
|
||||
for (const Layer& L : m.layers) {
|
||||
n_full += L.kind == kFull ? 1 : 0;
|
||||
n_sliding += L.kind == kSliding ? 1 : 0;
|
||||
}
|
||||
rad_note(b, "lfm3: %lld layers, %lld full attention + %lld sliding (window %lld) + %lld short "
|
||||
"convolution of width %lld; %lld heads over %lld at head_dim %lld, ffn %lld, "
|
||||
"vocab %lld",
|
||||
(long long)g.n_layer, (long long)n_full, (long long)n_sliding,
|
||||
(long long)m.sliding.window, (long long)(g.n_layer - n_full - n_sliding),
|
||||
(long long)m.width, (long long)g.n_head, (long long)g.n_head_kv,
|
||||
(long long)g.head_dim, (long long)g.n_ff, (long long)g.n_vocab);
|
||||
rad_note(b, "sandwich joins: %d of %lld fused (norm_add_norm)%s", n_joins,
|
||||
(long long)(2 * g.n_layer - 1),
|
||||
n_joins == 0 ? " -- not served, the rmsnorm / add / rmsnorm chain" : "");
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
static void lin_step(RadCtx* c, const Linear& lin, rad_buf in, rad_buf out, int64_t T) {
|
||||
RAD_ISSUE(c, lin.op, brows(in, T), RAD_W(lin.w), brows(out, T));
|
||||
}
|
||||
|
||||
/* The convolution is issued once per half of the step, as LFM2's is: the decode rows [0, D) with
|
||||
* `num_accepted`, leaving the window in the layout a partly rejected verify reads back from, and
|
||||
* the prefill chunks [D, S) without it, each leaving its tail at offset zero. `has_init` is
|
||||
* `ctx_lens` (a sequence with earlier tokens has a history). The prefill half's per-sequence
|
||||
* arrays start at `+ D`; the token operands stay at their base, since the kernel reads rows at the
|
||||
* absolute offsets in `cu`. */
|
||||
static void conv_step(const Model& m, const Layer& L, RadCtx* c, const RadBatch* batch, int l) {
|
||||
const int64_t T = batch->n_tok, S = batch->n_seq;
|
||||
const RadKVGroupBatch* cv = kv_batch(batch, m.kv_conv);
|
||||
const int32_t* idx = cv ? cv->state_index : nullptr;
|
||||
int64_t D = 0, DT = 0;
|
||||
batch_split(batch, &D, &DT);
|
||||
const int64_t P = S - D;
|
||||
if (D > 0)
|
||||
RAD_ISSUE_N(c, L.op_conv, DT,
|
||||
brows(m.b_conv_in, DT), RAD_W(L.w_conv), kv_cache(m.kv_conv, l),
|
||||
praw(batch->cu_seqlens, RAD_I32, D + 1), praw(idx, RAD_I32, D),
|
||||
praw(batch->ctx_lens, RAD_I32, D), praw(batch->num_accepted, RAD_I32, D),
|
||||
brows(m.b_conv_out, DT));
|
||||
if (P > 0)
|
||||
RAD_ISSUE_N(c, L.op_conv, T,
|
||||
brows(m.b_conv_in, T), RAD_W(L.w_conv), kv_cache(m.kv_conv, l),
|
||||
praw(batch->cu_seqlens + D, RAD_I32, P + 1),
|
||||
praw(idx ? idx + D : nullptr, RAD_I32, P),
|
||||
praw(batch->ctx_lens + D, RAD_I32, P), RAD_NONE,
|
||||
brows(m.b_conv_out, T));
|
||||
}
|
||||
|
||||
static void step(RadCtx* c, const RadBatch* batch) {
|
||||
const Model& m = g_model[rad_slot(c)];
|
||||
const Geom& g = m.g;
|
||||
if (batch->draft_pass || batch->spec_parent || batch->enc || batch->n_mm_rows > 0) {
|
||||
rad_step_fail(c, "lfm3_bf16: this step asks for an encoder, a draft pass or media rows, "
|
||||
"and the program declares none of them");
|
||||
return;
|
||||
}
|
||||
const int64_t T = batch->n_tok, n = g.n_embd;
|
||||
RAD_ISSUE(c, m.op_embed, praw(batch->token_ids, RAD_I32, T), RAD_W(m.w_tok), brows(m.b_x, T));
|
||||
|
||||
for (int l = 0; l < (int)m.layers.size(); ++l) {
|
||||
const Layer& L = m.layers[(size_t)l];
|
||||
if (!(l > 0 && m.layers[(size_t)l - 1].op_ffn_join))
|
||||
RAD_ISSUE(c, L.op_norm, brows(m.b_x, T), RAD_W(L.w_norm), brows(m.b_h, T));
|
||||
if (L.kind != kConv) {
|
||||
const rad_kvgroup grp = m.cls(L).kv;
|
||||
const RadKVGroupBatch* kv = kv_batch(batch, grp);
|
||||
L.q.step(c, m.a_h, m.b_q, T);
|
||||
L.k.step(c, m.a_h, m.b_k, T);
|
||||
L.v.step(c, m.a_h, m.b_v, T);
|
||||
lin_step(c, L.gate, m.b_h, m.b_gate, T);
|
||||
RAD_ISSUE_N(c, L.op_q_norm, T * g.n_head, brows(m.b_q, T), RAD_W(L.w_q_norm),
|
||||
brows(m.b_q, T));
|
||||
RAD_ISSUE_N(c, L.op_k_norm, T * g.n_head_kv, brows(m.b_k, T), RAD_W(L.w_k_norm),
|
||||
brows(m.b_k, T));
|
||||
RAD_ISSUE(c, L.op_rope_q, brows(m.b_q, T), rope_pos1(batch, T));
|
||||
RAD_ISSUE(c, L.op_rope_k, brows(m.b_k, T), rope_pos1(batch, T));
|
||||
RAD_ISSUE(c, L.op_store, brows(m.b_k, T), brows(m.b_v, T),
|
||||
praw(kv ? kv->slot_mapping : nullptr, RAD_I32, T), kv_cache(grp, l));
|
||||
RAD_ISSUE_N(c, L.op_attn, batch->max_q_len,
|
||||
brows(m.b_q, T), kv_cache(grp, l),
|
||||
praw2(kv ? kv->block_table : nullptr, RAD_I32, batch->n_seq,
|
||||
kv ? kv->block_table_pitch : 0),
|
||||
praw(kv ? kv->seqused : nullptr, RAD_I32, batch->n_seq),
|
||||
RAD_NONE, RAD_NONE,
|
||||
praw(batch->cu_seqlens, RAD_I32, batch->n_seq + 1),
|
||||
brows(m.b_attn, T));
|
||||
RAD_ISSUE(c, L.op_sigmoid, brows(m.b_gate, T), brows(m.b_gate, T));
|
||||
RAD_ISSUE(c, L.op_gate_mul, brows(m.b_gate, T), brows(m.b_attn, T), brows(m.b_attn, T));
|
||||
L.out.step(c, m.a_attn, m.b_arm, T);
|
||||
} else {
|
||||
L.conv_in.step(c, m.a_h, m.b_bcx, T);
|
||||
RAD_ISSUE(c, L.op_gate_in, bcol(m.b_bcx, 0, n, T), bcol(m.b_bcx, 2 * n, n, T),
|
||||
brows(m.b_conv_in, T));
|
||||
conv_step(m, L, c, batch, l);
|
||||
RAD_ISSUE(c, L.op_gate_out, bcol(m.b_bcx, n, n, T), brows(m.b_conv_out, T),
|
||||
brows(m.b_conv_out, T));
|
||||
L.conv_out.step(c, m.a_conv, m.b_arm, T);
|
||||
}
|
||||
if (L.op_join) {
|
||||
RAD_ISSUE(c, L.op_join, brows(m.b_arm, T), RAD_W(L.w_post_norm), brows(m.b_x, T),
|
||||
RAD_W(L.w_ffn_norm), brows(m.b_h, T));
|
||||
} else {
|
||||
RAD_ISSUE(c, L.op_post_norm, brows(m.b_arm, T), RAD_W(L.w_post_norm),
|
||||
brows(m.b_arm, T));
|
||||
RAD_ISSUE(c, L.op_add, brows(m.b_x, T), brows(m.b_arm, T), brows(m.b_x, T));
|
||||
RAD_ISSUE(c, L.op_ffn_norm, brows(m.b_x, T), RAD_W(L.w_ffn_norm), brows(m.b_h, T));
|
||||
}
|
||||
L.gate_up.step(c, m.a_h, m.b_gate_up, T);
|
||||
RAD_ISSUE(c, L.op_act, brows(m.b_gate_up, T), brows(m.b_ffn, T));
|
||||
L.down.step(c, m.a_ffn, m.b_arm, T);
|
||||
if (L.op_ffn_join) {
|
||||
/* y is the next layer's input norm */
|
||||
RAD_ISSUE(c, L.op_ffn_join, brows(m.b_arm, T), RAD_W(L.w_ffn_post_norm),
|
||||
brows(m.b_x, T), RAD_W(m.layers[(size_t)l + 1].w_norm), brows(m.b_h, T));
|
||||
} else {
|
||||
RAD_ISSUE(c, L.op_ffn_post_norm, brows(m.b_arm, T), RAD_W(L.w_ffn_post_norm),
|
||||
brows(m.b_arm, T));
|
||||
RAD_ISSUE(c, L.op_ffn_add, brows(m.b_x, T), brows(m.b_arm, T), brows(m.b_x, T));
|
||||
}
|
||||
}
|
||||
|
||||
/* The lm_head runs only on the rows the sampler asked for; a prefill chunk that finishes no
|
||||
* sequence skips it. */
|
||||
if (batch->n_out > 0) {
|
||||
RAD_ISSUE_N(c, m.op_gather, batch->n_out, brows(m.b_x, T),
|
||||
praw(batch->out_ids, RAD_I32, batch->n_out), brows(m.b_hout, batch->n_out));
|
||||
RAD_ISSUE_N(c, m.op_final_norm, batch->n_out, brows(m.b_hout, batch->n_out),
|
||||
RAD_W(m.w_out_norm), brows(m.b_hout, batch->n_out));
|
||||
if (!batch->score_only)
|
||||
RAD_ISSUE_N(c, m.op_logits, batch->n_out, brows(m.b_hout, batch->n_out),
|
||||
RAD_W(m.w_lm_head), brows(m.b_logits, batch->n_out));
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace lfm3_bf16 */
|
||||
|
||||
#ifndef RAD_ARCH_NO_EXPORTS
|
||||
/* Every per-instance state above is indexed by slot (rad_build_slot / rad_slot). */
|
||||
RAD_ARCH_MULTI_INSTANCE()
|
||||
RAD_ARCH_PLUGIN(lfm3_bf16, "lfm3", "", "0.1.0",
|
||||
"LiquidAI LFM3, bf16 or IQ8R: short gated convolutions, full and sliding-window GQA "
|
||||
"attention with a partial rotary and a gate per head, sandwich norms, in the "
|
||||
"checkpoint's own schedule, one rank")
|
||||
#endif
|
||||
@@ -187,28 +187,35 @@ static int64_t tiles_of(int64_t lat_h, int64_t lat_w) {
|
||||
}
|
||||
|
||||
/* Whether a frame of w x h pixels is one this model makes. */
|
||||
static bool size_ok(int64_t w, int64_t h) {
|
||||
static int64_t video_area(int64_t requested) {
|
||||
return requested > 0 ? std::min<int64_t>(requested, kMaxArea) : kMaxArea;
|
||||
}
|
||||
|
||||
static bool size_ok(int64_t w, int64_t h, int64_t area) {
|
||||
return w % kMult == 0 && h % kMult == 0 && w >= kMinSide && h >= kMinSide &&
|
||||
w * h <= kMaxArea && std::max(w, h) <= kMaxAspect * std::min(w, h);
|
||||
w * h <= area && std::max(w, h) <= kMaxAspect * std::min(w, h);
|
||||
}
|
||||
|
||||
/* The most tiles a decode pass carries, over every size. */
|
||||
static int64_t max_tiles() {
|
||||
static int64_t max_tiles(int64_t area) {
|
||||
int64_t best = 0;
|
||||
for (int64_t w = kMinSide; w <= (int64_t)kMaxArea / kMinSide; w += kMult)
|
||||
for (int64_t h = kMinSide; h * w <= kMaxArea; h += kMult)
|
||||
if (size_ok(w, h)) best = std::max(best, tiles_of(h / kScale, w / kScale));
|
||||
for (int64_t w = kMinSide; w <= area / kMinSide; w += kMult)
|
||||
for (int64_t h = kMinSide; h * w <= area; h += kMult)
|
||||
if (size_ok(w, h, area)) best = std::max(best, tiles_of(h / kScale, w / kScale));
|
||||
return best;
|
||||
}
|
||||
|
||||
static int64_t max_lat_frames() { return (int64_t)kLpc * kMaxChunks + kLtail; }
|
||||
static int64_t max_patches() { return (int64_t)kMaxArea / (kScale * kPatch * kScale * kPatch); }
|
||||
static int64_t max_video_rows() { return max_lat_frames() * max_patches(); }
|
||||
static int64_t max_audio() {
|
||||
const int64_t frames = (int64_t)kFpc * kMaxChunks + kFtail;
|
||||
static int64_t max_lat_frames(int64_t chunks = kMaxChunks) { return kLpc * chunks + kLtail; }
|
||||
static int64_t max_video_rows(int64_t area, int64_t chunks = kMaxChunks) {
|
||||
return max_lat_frames(chunks) * (area / (kMult * kMult));
|
||||
}
|
||||
static int64_t max_audio(int64_t chunks = kMaxChunks) {
|
||||
const int64_t frames = (int64_t)kFpc * chunks + kFtail;
|
||||
return (frames * kAudioRate + kFps / 2) / kFps + 1;
|
||||
}
|
||||
static int64_t max_step_rows() { return kMaxText + kAudioCh * max_audio() + max_video_rows(); }
|
||||
static int64_t max_step_rows(int64_t area, int64_t chunks = kMaxChunks) {
|
||||
return kMaxText + kAudioCh * max_audio(chunks) + max_video_rows(area, chunks);
|
||||
}
|
||||
|
||||
/* Video sparse attention's video tiles over a grid of F x ph x pw patches, and the ones a video
|
||||
* query keeps at `sparsity`: ceil((1 - sparsity) V) in f64, at least one. */
|
||||
@@ -225,7 +232,7 @@ static void vsa_bounds(double sparsity, int64_t* tiles, int64_t* keep) {
|
||||
int64_t best = 0;
|
||||
for (int64_t w = kMinSide; w <= (int64_t)kMaxArea / kMinSide; w += kMult)
|
||||
for (int64_t h = kMinSide; h * w <= kMaxArea; h += kMult)
|
||||
if (size_ok(w, h))
|
||||
if (size_ok(w, h, kMaxArea))
|
||||
best = std::max(best, vsa_video_tiles(max_lat_frames(), h / (kScale * kPatch),
|
||||
w / (kScale * kPatch)));
|
||||
const int64_t prefix = ((int64_t)kMaxText + kVsaRows - 1) / kVsaRows +
|
||||
@@ -387,7 +394,9 @@ struct Model {
|
||||
int64_t D = 0, S = kMaxSteps;
|
||||
int64_t W = 1, Ws = 0; /* ranks, and a rank's share of a modality's six vectors */
|
||||
int64_t maxV = 0, maxA = 0; /* a lane's video and soundtrack latent rows */
|
||||
int64_t max_area = kMaxArea;
|
||||
int64_t tiles = 0, tpr = 0; /* the most tiles a decode carries, and a rank's share of them */
|
||||
int64_t enc_tiles = 0; /* reference images have their own bounds */
|
||||
|
||||
/* ---- the text encoder */
|
||||
rad_weight w_tok = 0;
|
||||
@@ -1708,7 +1717,7 @@ static int declare_video(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
}
|
||||
m.v_mean = join_list(mean);
|
||||
m.v_std = join_list(sd);
|
||||
const int64_t maxhw = (int64_t)kMaxArea / (kScale * kScale);
|
||||
const int64_t maxhw = m.max_area / (kScale * kScale);
|
||||
const int64_t vox = (int64_t)kDecLat * maxhw;
|
||||
const int64_t R = m.tpr * kPeriod; /* this rank's tile rows */
|
||||
const int64_t RA = (int64_t)m.W * R; /* every rank's, gathered */
|
||||
@@ -1891,11 +1900,11 @@ static int declare_video(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
if (!m.op_vgather) return RAD_E_INVAL;
|
||||
}
|
||||
const int64_t fmax = (int64_t)kFpc + kFtail;
|
||||
m.b_prev = decl_b(b, nm.f("lane.prev"), RAD_BF16, { (int64_t)kMaxLanes * kFtail * kMaxArea, 3 },
|
||||
m.b_prev = decl_b(b, nm.f("lane.prev"), RAD_BF16, { (int64_t)kMaxLanes * kFtail * m.max_area, 3 },
|
||||
RAD_BUF_PERSIST);
|
||||
m.b_frames = decl_b(b, nm.f("frames_out"), RAD_U8, { fmax * kMaxArea, 3 }, RAD_BUF_PERSIST);
|
||||
m.b_frames = decl_b(b, nm.f("frames_out"), RAD_U8, { fmax * m.max_area, 3 }, RAD_BUF_PERSIST);
|
||||
m.op_stitch = rw(b, RAD_OP(b, "vtile_stitch",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, fmax * kMaxArea), RAD_INT("tile", kTile),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, fmax * m.max_area), RAD_INT("tile", kTile),
|
||||
RAD_INT("overlap", kOverlap), RAD_INT("scale", kScale),
|
||||
RAD_INT("pt", 4), RAD_INT("skip", 3), RAD_INT("keep", kFpc),
|
||||
RAD_INT("blend", kFtail), RAD_INT("period", kPeriod),
|
||||
@@ -1955,7 +1964,7 @@ static int declare_ups(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
|
||||
/* The most voxels a frame of latents and a video hold, before or after: the small size is
|
||||
* never larger than the full one. */
|
||||
const int64_t V = max_lat_frames() * ((int64_t)kMaxArea / (kScale * kScale));
|
||||
const int64_t V = max_lat_frames() * (m.max_area / (kScale * kScale));
|
||||
const int64_t P = m.maxV;
|
||||
const int acc = RAD_ACCESS_PER_TOKEN;
|
||||
auto wt = [&](const char* name, uint32_t dt, std::initializer_list<int64_t> shape) {
|
||||
@@ -2346,7 +2355,11 @@ static int declare_venc(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
m.ve_fold_mul = join_list(fm);
|
||||
m.ve_fold_add = join_list(fa);
|
||||
m.b_epix32 = decl_b(b, nm.f("venc.pix32"), RAD_F32, { Rmax, 3 });
|
||||
m.b_epix = decl_b(b, nm.f("venc.pix"), RAD_BF16, { Rmax, 3 });
|
||||
/* conv_in and the k=1 projections run on the host. Their activation operands must be
|
||||
* pinned host buffers too: joining a device queue does not make its VRAM CPU-readable.
|
||||
* Device convolutions can read/write these boundary buffers over the link in place. */
|
||||
m.b_epix = decl_b(b, nm.f("venc.pix"), RAD_BF16, { Rmax, 3 },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST);
|
||||
m.b_egn = decl_b(b, nm.f("venc.gn"), RAD_F32, { G * (2 + 3 * 1024) });
|
||||
const rad_buf st = m.b_egn;
|
||||
/* The tiled encode's two planes and the quant_conv are declared ahead of the trunk, and the
|
||||
@@ -2354,12 +2367,17 @@ static int declare_venc(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
* tiled pass reruns the whole trunk once a tile while `b_vtile` holds every tile's pixels and
|
||||
* `b_eqt` the finished tiles' moments, so both lifetimes must span the trunk's ops (from
|
||||
* op_ve_pix's and op_ve_q's use to op_vt_crop and op_vt_join). */
|
||||
m.b_tplan = decl_b(b, nm.f("venc.tplan"), RAD_I32, { m.tiles, 22 }, RAD_BUF_PERSIST);
|
||||
m.enc_tiles = max_tiles(kMaxArea);
|
||||
m.b_tplan = decl_b(b, nm.f("venc.tplan"), RAD_I32, { m.enc_tiles, 22 },
|
||||
RAD_BUF_PERSIST, RAD_DOMAIN_HOST);
|
||||
m.b_vtile = decl_b(b, nm.f("venc.vtile"), RAD_F32,
|
||||
{ m.tiles * (int64_t)kEncMaxSide * kEncMaxSide, 3 });
|
||||
m.b_eq48 = decl_b(b, nm.f("venc.q48"), RAD_BF16, { R[5], 48 });
|
||||
m.b_eq2 = decl_b(b, nm.f("venc.q"), RAD_BF16, { R[5], 48 });
|
||||
m.b_eqt = decl_b(b, nm.f("venc.qt"), RAD_BF16, { m.tiles * (int64_t)kTile * kTile, 48 });
|
||||
{ m.enc_tiles * (int64_t)kEncMaxSide * kEncMaxSide, 3 });
|
||||
m.b_eq48 = decl_b(b, nm.f("venc.q48"), RAD_BF16, { R[5], 48 },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST);
|
||||
m.b_eq2 = decl_b(b, nm.f("venc.q"), RAD_BF16, { R[5], 48 },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST);
|
||||
m.b_eqt = decl_b(b, nm.f("venc.qt"), RAD_BF16, { m.enc_tiles * (int64_t)kTile * kTile, 48 },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST);
|
||||
m.ve_qw = wh(nm.f("venc.q.weight"), nm.ckpt("vae.quant_conv.weight"), { 48, 48, 1, 1, 1 });
|
||||
m.ve_qb = wh(nm.f("venc.q.bias"), nm.ckpt("vae.quant_conv.bias"), { 48 });
|
||||
/* The whole-canvas pass writes b_eq2; the tiled pass writes a tile's slice of b_eqt, which
|
||||
@@ -2396,7 +2414,8 @@ static int declare_venc(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
const int64_t cout = (int64_t)dims[L], cin = L == 0 ? cout : (int64_t)dims[L - 1];
|
||||
const bool sc = L > 0 && cout != cin;
|
||||
E.cin = cin, E.cout = cout, E.rows = R[L], E.pf = PF[L], E.frames = tf[L];
|
||||
E.a = decl_b(b, nm.f("venc.l%d.a", L), RAD_BF16, { R[L], cout });
|
||||
E.a = decl_b(b, nm.f("venc.l%d.a", L), RAD_BF16, { R[L], cout },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST);
|
||||
E.b = decl_b(b, nm.f("venc.l%d.b", L), RAD_BF16, { R[L], cout });
|
||||
E.c = decl_b(b, nm.f("venc.l%d.c", L), RAD_BF16, { R[L], cout });
|
||||
/* A level that changes the width takes its input in a buffer of that width, which the
|
||||
@@ -2404,7 +2423,8 @@ static int declare_venc(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
* none. */
|
||||
if (sc) {
|
||||
const bool dn_in = (int64_t)sds[L - 1] == 2 || (int64_t)tds[L - 1] == 2;
|
||||
E.in = dn_in ? decl_b(b, nm.f("venc.l%d.in", L), RAD_BF16, { R[L], cin })
|
||||
E.in = dn_in ? decl_b(b, nm.f("venc.l%d.in", L), RAD_BF16, { R[L], cin },
|
||||
RAD_BUF_TRANSIENT, RAD_DOMAIN_HOST)
|
||||
: m.v_lv[(size_t)L - 1].a;
|
||||
const char* sc_src = nm.ckpt("vae.encoder.down_blocks.%d.resnets.0.conv_shortcut", L);
|
||||
E.scw = wh(nm.f("venc.l%d.sc.weight", L), nm.ckpt("%s.weight", sc_src),
|
||||
@@ -2508,13 +2528,13 @@ static int declare_venc(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
/* The tiled encode's ops, declared last: b_vtile and b_eqt then live across the whole trunk,
|
||||
* which the tiled pass runs once a tile, so no trunk buffer shares their bytes. */
|
||||
m.op_vt_plan = rw(b, RAD_OP(b, "vtile_plan",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.tiles), RAD_INT("tile", kTile),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.enc_tiles), RAD_INT("tile", kTile),
|
||||
RAD_INT("overlap", kOverlap),
|
||||
RAD_INT("ratio", kVaeRatio)),
|
||||
RAD_NOWEIGHTS),
|
||||
{}, { m.b_tplan });
|
||||
m.op_vt_crop = rw(b, RAD_OP(b, "vtile_crop",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.tiles * (int64_t)kEncMaxSide * kEncMaxSide),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.enc_tiles * (int64_t)kEncMaxSide * kEncMaxSide),
|
||||
RAD_INT("tile", kTile), RAD_INT("overlap", kOverlap),
|
||||
RAD_INT("ratio", kVaeRatio), RAD_STR("dtype", "f32")),
|
||||
RAD_NOWEIGHTS),
|
||||
@@ -2885,6 +2905,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
return RAD_E_INVAL;
|
||||
Model& m = g_model[rad_build_slot(ctx)];
|
||||
m = Model{};
|
||||
m.max_area = video_area(ctx->gen_max_pixels);
|
||||
if (m.max_area < kMinSide * kMinSide) {
|
||||
fprintf(stderr, "radiance: minimaxh3: the video pixel limit must allow a %dx%d frame\n",
|
||||
kMinSide, kMinSide);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
m.nm = Names(ctx->scope);
|
||||
Names& nm = m.nm;
|
||||
RAD_ARCH_TRY(check_format(meta));
|
||||
@@ -2972,21 +2998,29 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
}
|
||||
m.gr = gd;
|
||||
m.gr.max_tok = kMaxText;
|
||||
m.maxV = max_video_rows();
|
||||
m.maxV = max_video_rows(m.max_area);
|
||||
m.maxA = kAudioCh * max_audio();
|
||||
m.tiles = max_tiles();
|
||||
m.tiles = max_tiles(m.max_area);
|
||||
m.tpr = (m.tiles + m.W - 1) / m.W;
|
||||
if (gd.n_layer >= kGrpAda - kGrpDit - 1 || gd.n_layer > kGrpVae - kGrpAda ||
|
||||
m.gt.n_layer >= kGrpRefiner) {
|
||||
fprintf(stderr, "radiance: minimaxh3: the networks are too deep for the weight groups\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (ctx->max_tok < max_step_rows() || ctx->max_tok < m.tpr * kPeriod) {
|
||||
fprintf(stderr, "radiance: minimaxh3: a pass carries %lld rows; the longest video's step "
|
||||
"needs %lld and its decode %lld\n", (long long)ctx->max_tok,
|
||||
(long long)max_step_rows(), (long long)(m.tpr * kPeriod));
|
||||
/* The driver checks the full decode row count, even though each rank issues only its share. */
|
||||
const int64_t decode_max_rows = m.tiles * kPeriod;
|
||||
const int64_t min_step_rows = max_step_rows(m.max_area, kMinChunks);
|
||||
if (ctx->max_tok < min_step_rows || ctx->max_tok < decode_max_rows) {
|
||||
fprintf(stderr, "radiance: minimaxh3: a pass carries %lld rows; the shortest video's step "
|
||||
"needs up to %lld and a decode up to %lld\n", (long long)ctx->max_tok,
|
||||
(long long)min_step_rows, (long long)decode_max_rows);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* An explicit row cap can shorten the video while keeping enough room for every canvas.
|
||||
* Keep the original bounds for codecs and reference buffers. References consume the
|
||||
* remaining step rows and the driver checks the complete packed sequence per request. */
|
||||
int64_t max_chunks = kMaxChunks;
|
||||
while (max_step_rows(m.max_area, max_chunks) > ctx->max_tok) --max_chunks;
|
||||
|
||||
/* The vision tower, when the checkpoint or container has its weights: every MiniMax-H3 config
|
||||
* names one. */
|
||||
@@ -3036,16 +3070,20 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
d.latents_tail = kLtail;
|
||||
d.dec_latents = kDecLat;
|
||||
d.min_chunks = kMinChunks;
|
||||
d.max_chunks = kMaxChunks;
|
||||
d.max_chunks = max_chunks;
|
||||
d.latent_scale = kScale;
|
||||
d.latent_channels = kC;
|
||||
d.patch = kPatch;
|
||||
d.size_multiple = kMult;
|
||||
d.min_side = kMinSide;
|
||||
d.max_area = kMaxArea;
|
||||
d.max_area = m.max_area;
|
||||
d.max_aspect = kMaxAspect;
|
||||
d.default_width = kDefW;
|
||||
d.default_height = kDefH;
|
||||
const double shrink = std::sqrt(static_cast<double>(m.max_area) / static_cast<double>(kMaxArea));
|
||||
const int64_t scaled_h = static_cast<int64_t>(static_cast<double>(kDefH) * shrink);
|
||||
const int64_t scaled_w = static_cast<int64_t>(static_cast<double>(kDefW) * shrink);
|
||||
d.default_height = std::max<int64_t>(kMinSide, (scaled_h / kMult) * kMult);
|
||||
const int64_t fit_w = std::min(scaled_w, m.max_area / d.default_height);
|
||||
d.default_width = std::max<int64_t>(kMinSide, (fit_w / kMult) * kMult);
|
||||
d.default_chunks = kDefChunks;
|
||||
d.sample_rate = kRate;
|
||||
d.audio_rate = kAudioRate;
|
||||
@@ -3645,7 +3683,7 @@ static void step_video(RadCtx* c, const RadBatch* batch, const Model& m) {
|
||||
const int64_t hp = lh * kScale, wp = lw * kScale, n = (int64_t)V->n_frames_out * hp * wp;
|
||||
RAD_ISSUE_N(c, m.op_stitch, n, brows(pix, nt * kPeriod),
|
||||
praw(V->geom_d + RAD_VGEOM_CHUNK_FRAMES, RAD_I32, 5),
|
||||
brow_slice(m.b_prev, lane * kFtail * (int64_t)kMaxArea, (int64_t)kFtail * hp * wp, 3),
|
||||
brow_slice(m.b_prev, lane * kFtail * m.max_area, (int64_t)kFtail * hp * wp, 3),
|
||||
brows(m.b_frames, n));
|
||||
}
|
||||
|
||||
@@ -3728,7 +3766,7 @@ static int64_t step_venc_tiled(RadCtx* c, const RadVideoGenBatch* V, const Model
|
||||
const int64_t lat_h = H / kVaeRatio, lat_w = W / kVaeRatio;
|
||||
const std::vector<int64_t> ty = tile_starts(lat_h), tx = tile_starts(lat_w);
|
||||
const int64_t nh = (int64_t)ty.size(), nw = (int64_t)tx.size(), nt = nh * nw;
|
||||
if (nt > m.tiles) {
|
||||
if (nt > m.enc_tiles) {
|
||||
rad_step_fail(c, "minimaxh3: a Vencode pass whose picture splits into more tiles than "
|
||||
"the encoder declares room for");
|
||||
return row0;
|
||||
@@ -4066,7 +4104,9 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
* the most tiles. */
|
||||
static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
out->gen_rows = std::max<int64_t>(max_step_rows(), max_tiles() * kPeriod);
|
||||
const int64_t area = video_area(out->gen_max_pixels);
|
||||
if (area < kMinSide * kMinSide) return RAD_E_INVAL;
|
||||
out->gen_rows = std::max<int64_t>(max_step_rows(area), max_tiles(area) * kPeriod);
|
||||
out->gen_video = 1;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
/* dflash2.h -- wire rad_block_dflash2.h onto a Muse Glimmer trunk.
|
||||
*
|
||||
* Meta's assistant is a plain DFlash (rad_block_muse_dflash.h). incoai's Muse-Glimmer-30B-DFlash2
|
||||
* is the DFlash2 block: candidate selector, grouped convolutions, 8 KV heads. The two are
|
||||
* selected by draft.architectures. Muse's DFlash2 ships output_multiplier and
|
||||
* final_logit_softcapping; the block applies those (Config::omul / Config::scap).
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <arch/rad_block_dflash2.h>
|
||||
#include <arch/rad_block_muse_dflash.h>
|
||||
#include <arch/rad_fp8.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace rad {
|
||||
namespace arch {
|
||||
|
||||
inline bool muse_draft_is_dflash2(const RadModelMeta* meta) {
|
||||
const char* da = rad_meta_gets(meta, "draft.architectures", "");
|
||||
return da && std::strstr(da, "DFlash2");
|
||||
}
|
||||
|
||||
/* The drafter's weight prefetch window: 12 MiB, the value measured for the Qwen3.8 DFlash2
|
||||
* drafter on two R9700s. */
|
||||
constexpr int64_t kMuseDf2Prefetch = (int64_t)12 << 20;
|
||||
|
||||
inline int declare_muse_dflash2(Dflash2* ds, Dflash2::Wire* w, rad_kvgroup* kv,
|
||||
RadBuilder* b, Names& nm, const RadModelMeta* meta,
|
||||
const RadBuildCtx* ctx, const Geom& target,
|
||||
const MuseTaps& taps, int base_layer, rad_weight tok_embd,
|
||||
rad_weight head_w) {
|
||||
if (!ds || !w || !kv || !b) return RAD_E_INVAL;
|
||||
Geom dg{};
|
||||
RAD_ARCH_TRY(drafter_geom(dg, target, meta, "DFlash2", /*kv_repl_ok=*/true));
|
||||
const int64_t want_embd = rad_meta_geti(meta, "draft.hidden_size",
|
||||
rad_meta_geti(meta, "draft.dflash_config.hidden_size",
|
||||
dg.n_embd));
|
||||
if (want_embd != dg.n_embd) {
|
||||
fprintf(stderr, "radiance: museglimmer: the DFlash2 drafter reads a %lld-wide trunk and "
|
||||
"this target is %lld wide; they are not the same model\n",
|
||||
(long long)want_embd, (long long)dg.n_embd);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Dflash2::Config dc{};
|
||||
dc.short_block = 1;
|
||||
dc.prefetch = kMuseDf2Prefetch;
|
||||
dc.n_taps = taps.n;
|
||||
dc.block = ctx->max_spec + 1;
|
||||
dc.taps = rad_meta_geti(meta, "draft.dflash_config.conv_kernel_size", 2);
|
||||
dc.group = rad_meta_geti(meta, "draft.dflash_config.conv_group_size", 16);
|
||||
dc.sel_rank = rad_meta_geti(meta, "draft.dflash_config.selector_rank", 0);
|
||||
dc.sel_topk = rad_meta_geti(meta, "draft.dflash_config.selector_top_k", 0);
|
||||
dc.causal = rad_meta_geti(meta, "draft.is_causal", 0) ? 1 : 0;
|
||||
if (rad_meta_geti(meta, "draft.use_sliding_window", 0))
|
||||
dc.window = rad_meta_geti(meta, "draft.dflash_config.swa_window_size",
|
||||
rad_meta_geti(meta, "draft.sliding_window", 0));
|
||||
if (dc.sel_rank <= 0 || dc.sel_topk <= 0) {
|
||||
fprintf(stderr, "radiance: museglimmer: the DFlash2 drafter states no selector geometry "
|
||||
"(rank %lld, top_k %lld)\n",
|
||||
(long long)dc.sel_rank, (long long)dc.sel_topk);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
const long long trained = rad_meta_geti(meta, "draft.dflash_config.block_size", 0);
|
||||
if (dc.block < 2 || (dc.block & (dc.block - 1))) {
|
||||
fprintf(stderr, "radiance: museglimmer: DFlash2's convolution masks the block position "
|
||||
"with block_size - 1, so the query block has to be a power of two. This "
|
||||
"serve asks for %d draft tokens, which makes it %lld; the checkpoint was "
|
||||
"trained at %lld.\n",
|
||||
ctx->max_spec, (long long)dc.block, trained);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (trained > 0 && trained != dc.block)
|
||||
rad_note(b, "DFlash2 was trained at block_size %lld (%lld draft tokens) and runs at "
|
||||
"%lld; it accepts less away from its trained block length",
|
||||
trained, trained - 1, (long long)dc.block);
|
||||
|
||||
dc.escale = rad_meta_getf(meta, "draft.dflash_config.input_embedding_scale", 1.0);
|
||||
dc.omul = rad_meta_getf(meta, "draft.dflash_config.output_multiplier", 1.0);
|
||||
dc.scap = rad_meta_getf(meta, "draft.dflash_config.final_logit_softcapping", 0.0);
|
||||
RAD_ARCH_TRY(Dflash2::probe_i8(b, nm, "draft", &dc.act_i8, &dc.act_g8));
|
||||
dc.fc_mapped = true;
|
||||
|
||||
RAD_ARCH_TRY(drafter_kv_group(b, nm, ctx, dg, dc.window, base_layer, kv));
|
||||
|
||||
const int64_t qd = dg.n_head * dg.head_dim;
|
||||
const int64_t kvd = dg.n_head_kv * dg.head_dim;
|
||||
const uint32_t act_dtype = dc.act_i8 ? RAD_I8 : RAD_F8E4M3;
|
||||
const int64_t act_group = dc.act_i8 ? dc.act_g8 : RAD_FP8_BLOCK;
|
||||
const auto act_groups = [act_group](int64_t n) { return (n + act_group - 1) / act_group; };
|
||||
int64_t qr = dg.max_seqs * dc.block;
|
||||
if (qr > dg.max_tok) qr = dg.max_tok;
|
||||
const int64_t sr = dg.max_seqs * dc.steps();
|
||||
const int64_t spad = ((sr + 15) / 16) * 16;
|
||||
|
||||
Dflash2::Wire& dw = *w;
|
||||
dw.src = taps.src;
|
||||
dw.c = decl_b(b, nm.f("df_c"), dg.act_dtype, {dg.max_tok, dg.n_embd});
|
||||
dw.ck = decl_b(b, nm.f("df_ck"), dg.act_dtype, {dg.max_tok, kvd});
|
||||
dw.cv = decl_b(b, nm.f("df_cv"), dg.act_dtype, {dg.max_tok, kvd});
|
||||
dw.x = decl_b(b, nm.f("df_x"), dg.act_dtype, {qr, dg.n_embd});
|
||||
dw.h = decl_b(b, nm.f("df_h"), dg.act_dtype, {qr, dg.n_embd});
|
||||
dw.h2 = decl_b(b, nm.f("df_h2"), dg.act_dtype, {qr, dg.n_embd});
|
||||
dw.coef = decl_b(b, nm.f("df_coef"), dg.act_dtype, {qr, dc.coef_dim(dg.n_embd)});
|
||||
dw.q = decl_b(b, nm.f("df_q"), dg.act_dtype, {qr, qd});
|
||||
dw.k = decl_b(b, nm.f("df_k"), dg.act_dtype, {qr, kvd});
|
||||
dw.v = decl_b(b, nm.f("df_v"), dg.act_dtype, {qr, kvd});
|
||||
dw.attn = decl_b(b, nm.f("df_attn"), dg.act_dtype, {qr, qd});
|
||||
dw.gate_up = decl_b(b, nm.f("df_gate_up"), dg.act_dtype, {qr, 2 * dg.n_ff});
|
||||
dw.ffn = decl_b(b, nm.f("df_ffn"), dg.act_dtype, {qr, dg.n_ff});
|
||||
dw.srcq = decl_b(b, nm.f("df_srcq"), act_dtype,
|
||||
{dg.max_tok, dc.n_taps * dg.n_embd});
|
||||
dw.srcs = decl_b(b, nm.f("df_srcs"), RAD_F32,
|
||||
{dg.max_tok, act_groups(dc.n_taps * dg.n_embd)});
|
||||
dw.cq = decl_b(b, nm.f("df_cq"), act_dtype, {dg.max_tok, dg.n_embd});
|
||||
dw.cs = decl_b(b, nm.f("df_cs"), RAD_F32, {dg.max_tok, act_groups(dg.n_embd)});
|
||||
dw.h2q = decl_b(b, nm.f("df_h2q"), act_dtype, {qr, dg.n_embd});
|
||||
dw.h2s = decl_b(b, nm.f("df_h2s"), RAD_F32, {qr, act_groups(dg.n_embd)});
|
||||
dw.atq = decl_b(b, nm.f("df_atq"), act_dtype, {qr, qd});
|
||||
dw.ats = decl_b(b, nm.f("df_ats"), RAD_F32, {qr, act_groups(qd)});
|
||||
dw.ffq = decl_b(b, nm.f("df_ffq"), act_dtype, {qr, dg.n_ff});
|
||||
dw.ffs = decl_b(b, nm.f("df_ffs"), RAD_F32, {qr, act_groups(dg.n_ff)});
|
||||
dw.sel_h = decl_b(b, nm.f("df_selh"), dg.act_dtype, {sr, dg.n_embd});
|
||||
dw.hp = decl_b(b, nm.f("df_hp"), dg.act_dtype, {sr, dc.sel_rank});
|
||||
dw.dq = decl_b(b, nm.f("df_dq"), RAD_I8, {sr, dg.n_embd});
|
||||
dw.ds = decl_b(b, nm.f("df_ds"), RAD_F32, {sr, 1});
|
||||
dw.dsum = decl_b(b, nm.f("df_dsum"), RAD_F32, {dg.n_embd / 128, spad});
|
||||
dw.dlog = decl_b(b, nm.f("df_dlog"), dg.act_dtype, {sr, Dflash2::head_rows(dg)});
|
||||
{
|
||||
const uint32_t hd = weight_codes_dtype(b, nm.f("output.weight"), RAD_BF16);
|
||||
if (head_w && (hd == RAD_F8E4M3 || hd == RAD_I8) &&
|
||||
(Dflash2::head_sharded(dg) || dg.world <= 1)) {
|
||||
ds->w_lm = head_w;
|
||||
ds->top_w = Dflash2::kRerankR;
|
||||
}
|
||||
}
|
||||
const int64_t tw = ds->w_lm ? ds->top_w : dc.sel_topk;
|
||||
dw.cand = decl_b(b, nm.f("df_cand"), RAD_I32, {sr, tw});
|
||||
dw.unary = decl_b(b, nm.f("df_unary"), RAD_F32, {sr, tw});
|
||||
if (Dflash2::head_sharded(dg)) {
|
||||
dw.dpair = decl_b(b, nm.f("df_dpair"), RAD_F32, {sr, tw, 2});
|
||||
dw.dgath = decl_b(b, nm.f("df_dgath"), RAD_F32, {sr, (int64_t)dg.world * tw, 2});
|
||||
}
|
||||
dw.tokens = decl_b(b, nm.f("dflash_tokens"), RAD_I32, {dg.max_seqs, dc.steps()});
|
||||
if (ctx->draft_coupling) {
|
||||
if (dc.steps() > RAD_MTP_COUPLE_MAX_ROUNDS || dc.sel_topk > RAD_DFLASH_COUPLE_MAX_K ||
|
||||
dc.sel_rank % RAD_DFLASH_EDGE_PARTS || dc.sel_rank > RAD_DFLASH_COUPLE_MAX_R) {
|
||||
fprintf(stderr, "radiance: museglimmer: --draft-coupling on DFlash2 needs at most "
|
||||
"%d drafts, %d candidates and a selector rank that is a multiple of "
|
||||
"%d up to %d\n",
|
||||
RAD_MTP_COUPLE_MAX_ROUNDS, RAD_DFLASH_COUPLE_MAX_K, RAD_DFLASH_EDGE_PARTS,
|
||||
RAD_DFLASH_COUPLE_MAX_R);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
dc.q_temp = 0.6;
|
||||
dw.couple_draws = decl_b(b, nm.f("mtp_couple_draws"), RAD_U32,
|
||||
{dg.max_seqs, RAD_MTP_COUPLE_DRAW_WORDS}, RAD_BUF_PERSIST);
|
||||
dw.couple_state = decl_b(b, nm.f("mtp_couple_state"), RAD_U32,
|
||||
{dc.steps(), dg.max_seqs, RAD_MTP_COUPLE_STATE_WORDS},
|
||||
RAD_BUF_PERSIST);
|
||||
if (!dw.couple_draws || !dw.couple_state) return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
RAD_ARCH_TRY(ds->declare(b, nm, dg, dc, base_layer, *kv, tok_embd, "draft",
|
||||
nm.ckpt("lm_head.weight"), dw));
|
||||
|
||||
RadDrafterDecl drf{};
|
||||
drf.name = "dflash2";
|
||||
drf.kind = RAD_DRAFT_BLOCK;
|
||||
drf.depth = ctx->max_spec;
|
||||
drf.block = dc.block;
|
||||
drf.proposal = dw.tokens;
|
||||
drf.proposal_pitch = dc.steps();
|
||||
drf.window = dc.window;
|
||||
drf.mask_token = (int32_t)rad_meta_geti(meta, "draft.dflash_config.mask_token_id", -1);
|
||||
if (drf.mask_token < 0) {
|
||||
fprintf(stderr, "radiance: museglimmer: this DFlash2 checkpoint declares no "
|
||||
"dflash_config.mask_token_id\n");
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
RAD_ARCH_TRY(rad_declare_drafter(b, &drf));
|
||||
if (ds->block_lo > 0) RAD_ARCH_TRY(rad_drafter_short_block(b, ds->block_lo));
|
||||
|
||||
rad_note(b, "DFlash2 drafter: %lld layers at absolute %d..%d, %lld heads / %lld kv x %lld, "
|
||||
"ffn %lld, %s attention with a %lld-token window, %d trunk tap(s); one forward "
|
||||
"proposes %lld tokens through the candidate selector",
|
||||
(long long)dg.n_layer, base_layer, base_layer + (int)dg.n_layer - 1,
|
||||
(long long)dg.n_head, (long long)dg.n_head_kv, (long long)dg.head_dim,
|
||||
(long long)dg.n_ff, dc.causal ? "causal" : "non-causal", (long long)dc.window,
|
||||
taps.n, (long long)dc.steps());
|
||||
if (dc.omul != 1.0 || dc.scap > 0.0)
|
||||
rad_note(b, "DFlash2 logits: output_multiplier %g, softcap %g", dc.omul, dc.scap);
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
} /* namespace arch */
|
||||
} /* namespace rad */
|
||||
@@ -56,7 +56,8 @@
|
||||
#include <arch/rad_block_museglimmer_vision.h>
|
||||
#include <arch/rad_block_muse_dflash.h>
|
||||
#include <arch/rad_calib_full.h>
|
||||
#include "chat.h"
|
||||
#include <arch/rad_museglimmer_chat.h>
|
||||
#include "dflash2.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
@@ -70,19 +71,6 @@ using namespace rad::arch;
|
||||
* the bare spelling too, so a text-only GGUF container of the same family reads the same way. */
|
||||
namespace {
|
||||
|
||||
double cfg_f(const RadModelMeta* m, const char* key, double dflt) {
|
||||
return rad_meta_getf(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_getf(m, key, dflt));
|
||||
}
|
||||
long long cfg_i(const RadModelMeta* m, const char* key, long long dflt) {
|
||||
return rad_meta_geti(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_geti(m, key, dflt));
|
||||
}
|
||||
const char* cfg_s(const RadModelMeta* m, const char* key, const char* dflt) {
|
||||
return rad_meta_gets(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_gets(m, key, dflt));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/* One trunk layer. The rope ops exist only where layer_rope_theta says so; the branch is fixed
|
||||
@@ -133,13 +121,12 @@ struct Model {
|
||||
rad_op op_media_rows = 0;
|
||||
MuseTower vit{};
|
||||
|
||||
/* ---- the DFlash drafter (arch/common/rad_block_muse_dflash.h): declared last, only when the
|
||||
* container carries one and the serve asks for drafts. It reads the trunk's residual stream at
|
||||
* `draft.target_layer_ids`, keeps its own KV group, and proposes `block_size - 1` tokens a
|
||||
* pass for the trunk to verify. */
|
||||
bool have_df = false;
|
||||
/* ---- Meta's DFlash or incoai's DFlash2, selected by draft.architectures. */
|
||||
bool have_df = false, have_df2 = false;
|
||||
MuseDflash df{};
|
||||
MuseDflash::Wire dfw{};
|
||||
Dflash2 df2{};
|
||||
Dflash2::Wire df2w{};
|
||||
MuseTaps taps{};
|
||||
rad_kvgroup kv_draft = 0;
|
||||
|
||||
@@ -177,13 +164,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* ---- the family's own config. Everything that changes the mathematics is required or read
|
||||
* from the family defaults the reference config class states; a wrong default yields fluent
|
||||
* wrong text, so nothing here falls back to a "reasonable" value silently. */
|
||||
m.qk_mult = (float)cfg_f(meta, "qk_scale_factor", 3.87);
|
||||
m.post_eps = (float)cfg_f(meta, "post_norm_eps", 1e-8);
|
||||
m.out_mult = (float)cfg_f(meta, "output_multiplier", 0.19611613513818404);
|
||||
m.softcap = (float)cfg_f(meta, "final_logit_softcapping", 20.0);
|
||||
m.window = cfg_i(meta, "sliding_window", 2048);
|
||||
const double theta_rope = cfg_f(meta, "rope_parameters.rope_theta",
|
||||
cfg_f(meta, "rope_theta", 0.0));
|
||||
m.qk_mult = (float)meta_text_getf(meta, "qk_scale_factor", 3.87);
|
||||
m.post_eps = (float)meta_text_getf(meta, "post_norm_eps", 1e-8);
|
||||
m.out_mult = (float)meta_text_getf(meta, "output_multiplier", 0.19611613513818404);
|
||||
m.softcap = (float)meta_text_getf(meta, "final_logit_softcapping", 20.0);
|
||||
m.window = meta_text_geti(meta, "sliding_window", 2048);
|
||||
const double theta_rope = meta_text_getf(meta, "rope_parameters.rope_theta",
|
||||
meta_text_getf(meta, "rope_theta", 0.0));
|
||||
if (!(m.qk_mult > 0.0f) || !(m.out_mult > 0.0f) || !(m.post_eps > 0.0f) || m.window <= 0 ||
|
||||
!(theta_rope > 0.0)) {
|
||||
fprintf(stderr, "radiance: museglimmer: qk_scale_factor %g output_multiplier %g "
|
||||
@@ -206,7 +193,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* interval rule stands in. The two must agree where both exist: the schedule decides which
|
||||
* layers keep a long context, and a wrong layer still generates fluent text. */
|
||||
std::vector<int> full;
|
||||
const char* kinds = cfg_s(meta, "layer_types", nullptr);
|
||||
const char* kinds = meta_text_gets(meta, "layer_types", nullptr);
|
||||
if (kinds && *kinds)
|
||||
RAD_ARCH_TRY(parse_layer_kinds("museglimmer", kinds, {"full_attention"},
|
||||
"sliding_attention", &full));
|
||||
@@ -234,7 +221,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* Per-layer rotary: the shipped `layer_rope_theta`, else the family pattern (theta on the
|
||||
* sliding layers, 0 -- NoPE -- on the full ones). */
|
||||
std::vector<float> theta((size_t)g.n_layer, 0.0f);
|
||||
const char* thetas = cfg_s(meta, "layer_rope_theta", nullptr);
|
||||
const char* thetas = meta_text_gets(meta, "layer_rope_theta", nullptr);
|
||||
if (thetas && *thetas) {
|
||||
size_t i = 0;
|
||||
for_each_token(thetas, [&](const char* t, size_t n) {
|
||||
@@ -666,12 +653,17 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
if (m.media)
|
||||
RAD_ARCH_TRY(m.vit.declare(b, meta, ctx, nm, g.n_embd, (int)g.n_layer));
|
||||
|
||||
/* ---- the DFlash drafter, declared last: its passes run after the whole trunk's, and the
|
||||
* planner lays lifetimes out in declaration order. */
|
||||
/* ---- the drafter is declared last so its buffers cannot overlap trunk temporaries. */
|
||||
if (m.taps.n > 0) {
|
||||
RAD_ARCH_TRY(declare_muse_dflash(&m.df, &m.dfw, &m.kv_draft, b, nm, meta, ctx, g, m.taps,
|
||||
(int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df = true;
|
||||
if (muse_draft_is_dflash2(meta)) {
|
||||
RAD_ARCH_TRY(declare_muse_dflash2(&m.df2, &m.df2w, &m.kv_draft, b, nm, meta, ctx, g,
|
||||
m.taps, (int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df2 = true;
|
||||
} else {
|
||||
RAD_ARCH_TRY(declare_muse_dflash(&m.df, &m.dfw, &m.kv_draft, b, nm, meta, ctx, g,
|
||||
m.taps, (int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- notes for --debug-graph. */
|
||||
@@ -716,6 +708,11 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
/* A draft pass runs only the drafter: >0 the query pass on the staged block, <0 the context
|
||||
* pass that projects and stores K/V for the tokens the trunk just committed. */
|
||||
if (batch->draft_pass != 0) {
|
||||
if (m.have_df2) {
|
||||
if (batch->draft_pass > 0) m.df2.step(c, batch);
|
||||
else m.df2.context(c, batch);
|
||||
return;
|
||||
}
|
||||
if (!m.have_df) {
|
||||
rad_step_fail(c, "this serve stages a draft pass but the container carries no drafter");
|
||||
return;
|
||||
@@ -751,8 +748,9 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
const int32_t* table = kvb ? kvb->block_table : nullptr;
|
||||
const int32_t* used = kvb ? kvb->seqused : nullptr;
|
||||
|
||||
/* -- attention. */
|
||||
/* -- attention. The first Hessian sees the normalized input consumed by q/gate/k/v. */
|
||||
RAD_ISSUE(c, l.op_norm, brows(m.b_x, T), RAD_W(l.w_norm), brows(m.b_h, T));
|
||||
if (l.cs_in >= 0) m.calib.tap(c, (size_t)l.cs_in, T);
|
||||
RAD_ISSUE(c, l.op_q, brows(m.b_h, T), RAD_W(l.w_q), brows(m.b_q, T));
|
||||
RAD_ISSUE(c, l.op_gate, brows(m.b_h, T), RAD_W(l.w_gate), brows(m.b_gate, T));
|
||||
RAD_ISSUE(c, l.op_k, brows(m.b_h, T), RAD_W(l.w_k), brows(m.b_k, T));
|
||||
@@ -776,6 +774,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
brows(m.b_attn, T));
|
||||
RAD_ISSUE_N(c, l.op_sig, T * m.g.n_head, brows(m.b_gate, T), brows(m.b_gate, T));
|
||||
RAD_ISSUE(c, l.op_mul, brows(m.b_attn, T), brows(m.b_gate, T), brows(m.b_attn, T));
|
||||
if (l.cs_o >= 0) m.calib.tap(c, (size_t)l.cs_o, T);
|
||||
RAD_ISSUE(c, l.op_o, brows(m.b_attn, T), RAD_W(l.w_o), brows(m.b_h, T));
|
||||
if (l.op_ar) RAD_ISSUE_N(c, l.op_ar, T * m.g.n_embd, brows(m.b_h, T), RAD_NONE);
|
||||
RAD_ISSUE(c, l.op_post, brows(m.b_h, T), RAD_W(l.w_post), brows(m.b_h, T));
|
||||
@@ -783,8 +782,10 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
|
||||
/* -- feed-forward. */
|
||||
RAD_ISSUE(c, l.op_fnorm, brows(m.b_x, T), RAD_W(l.w_fnorm), brows(m.b_h, T));
|
||||
if (l.cs_mlp >= 0) m.calib.tap(c, (size_t)l.cs_mlp, T);
|
||||
RAD_ISSUE(c, l.op_gu, brows(m.b_h, T), RAD_W(l.w_gate_up), brows(m.b_gu, T));
|
||||
RAD_ISSUE(c, l.op_act, brows(m.b_gu, T), brows(m.b_ffn, T));
|
||||
if (l.cs_down >= 0) m.calib.tap(c, (size_t)l.cs_down, T);
|
||||
RAD_ISSUE(c, l.op_down, brows(m.b_ffn, T), RAD_W(l.w_down), brows(m.b_h, T));
|
||||
if (l.op_far) RAD_ISSUE_N(c, l.op_far, T * m.g.n_embd, brows(m.b_h, T), RAD_NONE);
|
||||
RAD_ISSUE(c, l.op_fpost, brows(m.b_h, T), RAD_W(l.w_fpost), brows(m.b_h, T));
|
||||
@@ -796,6 +797,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
|
||||
RAD_ISSUE(c, m.op_final_norm,
|
||||
brows(m.b_x, batch->n_tok), RAD_W(m.w_out_norm), brows(m.b_h, batch->n_tok));
|
||||
if (m.cs_head >= 0) m.calib.tap(c, (size_t)m.cs_head, T);
|
||||
m.calib.after_step(c, T);
|
||||
|
||||
/* The lm_head runs only on the rows the sampler asked for; a mid-prompt prefill chunk has
|
||||
@@ -819,8 +821,14 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
if (MuseTower::present(meta)) out->enc_merge = 4;
|
||||
/* The drafter denoises `block_size` positions and the anchor row proposes nothing, so the
|
||||
* draft width is block_size - 1. It is trained for that one block, hence fixed. */
|
||||
/* DFlash2 reads block_size from dflash_config; its anchor row proposes nothing. */
|
||||
if (muse_draft_is_dflash2(meta)) {
|
||||
const long long bs = rad_meta_geti(meta, "draft.dflash_config.block_size", 16);
|
||||
out->draft_depth = bs > 1 ? (int)(bs - 1) : 15;
|
||||
out->draft_depth_fixed = 1;
|
||||
return RAD_OK;
|
||||
}
|
||||
/* Meta DFlash denoises `block_size` positions; the anchor proposes nothing. */
|
||||
const long long bs = rad_meta_geti(meta, "draft.block_size", 0);
|
||||
if (bs > 1) {
|
||||
out->draft_depth = (int)(bs - 1);
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
* adapter stay bf16 whatever the trunk does: the recipes never touch them, and a container that
|
||||
* quantised tower weights is refused naming the weight.
|
||||
*
|
||||
* An IQ8R trunk (data/recipes/museglimmer-30b-iq8r.recipe: int8 codes rotated 128 wide by the
|
||||
* unnormalised Hadamard, a u8 scale per [1 x 256] under a bf16 scale a row) is a whole-trunk form,
|
||||
* read from layer 0's q projection before any activation is declared. Its linears are rad_fp8.h's
|
||||
* LinearFP8 at gemm_nt_q i8a8h, group 256, against int8 activations quantised under the same
|
||||
* rotation: the two pre-norms write them (rmsnorm_had_quant_i8g), the gated product writes the
|
||||
* down projection's (gated_had_quant_i8g), and the out projection quantises the gated attention
|
||||
* output itself (had_quant_act_i8g). q, gate, k and v read one pair. Every trunk linear of such a
|
||||
* container must be IQ8R; anything else in it is refused naming the weight.
|
||||
* Rotated i8a8h trunks are whole-trunk forms, detected from layer 0's q projection before any
|
||||
* activation is declared. IQ8R uses a 256-column scale group; computed-trellis IQR (including
|
||||
* IQ4R-V4) uses 128. Both reuse LinearFP8's encoding-aware IQR views and GEMMs. The two centered
|
||||
* pre-norms produce rotated int8 pairs, the gated product produces the down-projection pair, and
|
||||
* o_proj quantises its gated attention input. q, gate, k and v share one pair. Every trunk linear
|
||||
* must use the same rotated family; mixed encodings fail at declaration with the offending name.
|
||||
*
|
||||
* The lm_head is declared at whatever the model holds (weight_codes_dtype): bf16, or a recipe-made
|
||||
* int8 head (`codes=i8 group=128 scale=bf16`), which `logits_gemm` then reads with the int8 head
|
||||
@@ -29,7 +27,8 @@
|
||||
#include <arch/rad_block_museglimmer_vision.h>
|
||||
#include <arch/rad_block_muse_dflash.h>
|
||||
#include <arch/rad_calib_full.h>
|
||||
#include "../museglimmer/chat.h"
|
||||
#include <arch/rad_museglimmer_chat.h>
|
||||
#include "../museglimmer/dflash2.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
@@ -50,19 +49,6 @@ using namespace rad::arch;
|
||||
* the bare spelling too, so a text-only GGUF container of the same family reads the same way. */
|
||||
namespace {
|
||||
|
||||
double cfg_f(const RadModelMeta* m, const char* key, double dflt) {
|
||||
return rad_meta_getf(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_getf(m, key, dflt));
|
||||
}
|
||||
long long cfg_i(const RadModelMeta* m, const char* key, long long dflt) {
|
||||
return rad_meta_geti(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_geti(m, key, dflt));
|
||||
}
|
||||
const char* cfg_s(const RadModelMeta* m, const char* key, const char* dflt) {
|
||||
return rad_meta_gets(m, (std::string("text_config.") + key).c_str(),
|
||||
rad_meta_gets(m, key, dflt));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/* ---- one trunk linear, encoding-aware. The gemma3 G3Linear shape with gemma4_bf16's grids: the
|
||||
@@ -318,11 +304,10 @@ inline int MlLinear::declare(RadBuilder* b, Names& nm, const Geom& g, const char
|
||||
|
||||
char en[256];
|
||||
rad_enc_format(&enc, en, sizeof en);
|
||||
/* IQ8R is served only as a whole trunk, decided by layer 0's q projection (declare()). */
|
||||
if (known && linear_is_iq8r(enc)) {
|
||||
fprintf(stderr, "radiance: '%s' is IQ8R (%s) and layer 0's attn_q is not; an IQ8R "
|
||||
"container stores every trunk linear in it "
|
||||
"(data/recipes/museglimmer-30b-iq8r.recipe)\n", wn, en);
|
||||
/* Rotated i8a8h encodings are served only as a whole trunk, decided by layer 0's q. */
|
||||
if (known && linear_is_w8h(enc)) {
|
||||
fprintf(stderr, "radiance: '%s' is a rotated i8a8h weight (%s), but layer 0's attn_q "
|
||||
"does not select a matching whole-trunk path\n", wn, en);
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
fprintf(stderr, "radiance: '%s' is %s, and this model's linears are plain bf16, symmetric "
|
||||
@@ -392,11 +377,10 @@ struct Layer {
|
||||
rad_weight w_fnorm = 0, w_fpost = 0;
|
||||
MlLinear lq, lgate, lk, lv, lo, lgu, ldown;
|
||||
|
||||
/* The same seven linears in an IQ8R trunk (Model::iq8r), at gemm_nt_q i8a8h. The pre-norms
|
||||
* write their int8 pair as rmsnorm_had_quant_i8g where a loaded library declares it (nq_attn,
|
||||
* nq_ffn; op_norm / op_fnorm stay 0 then), and the gated product writes the down projection's
|
||||
* as gated_had_quant_i8g (gq_ffn; op_act stays 0). Where they are not declared, the plain norm
|
||||
* and silu_mul run and the first linear reading each input quantises it (had_quant_act_i8g). */
|
||||
/* The seven rotated linears in an IQ8R or IQR trunk, at gemm_nt_q i8a8h. The pre-norms
|
||||
* write their int8 pair as rmsnorm_had_quant_i8g when available; the gated product writes the
|
||||
* down-projection pair as gated_had_quant_i8g. Otherwise the first consumer quantises with
|
||||
* had_quant_act_i8g. `rot_group` is 256 for IQ8R, 128 for computed-trellis IQR. */
|
||||
LinearFP8 rq, rgate, rk, rv, ro, rgu, rdown;
|
||||
NormQuantFP8 nq_attn, nq_ffn;
|
||||
GateQuantFP8 gq_ffn;
|
||||
@@ -427,12 +411,10 @@ struct Model {
|
||||
rad_buf b_q = 0, b_gate = 0, b_k = 0, b_v = 0, b_attn = 0;
|
||||
rad_buf b_gu = 0, b_ffn = 0;
|
||||
|
||||
/* An IQ8R trunk: every trunk linear is IQ8R (layer 0's q projection decides), and the three
|
||||
* linear inputs carry an int8 code pair at one f32 scale per (row, 256) under the 128-wide
|
||||
* rotation beside their bf16 plane: `a_h` over `b_h` (both pre-norms' output; q, gate, k, v and
|
||||
* gate/up read it), `a_attn` over `b_attn` (the gated attention output; o_proj), `a_ffn` over
|
||||
* `b_ffn` (the gated product; down_proj). */
|
||||
bool iq8r = false;
|
||||
/* A whole-trunk rotated-int8 mode selected from layer 0's q projection. `iq8r` keeps the
|
||||
* legacy wide-group case explicit; IQR-V4 is computed trellis/MAD at group 128. */
|
||||
bool rotated_i8 = false, iq8r = false, iqr_v4 = false;
|
||||
int64_t rot_group = RAD_FP8_BLOCK;
|
||||
ActFP8 a_h{}, a_attn{}, a_ffn{};
|
||||
|
||||
rad_weight w_tok = 0, w_out_norm = 0, w_lm_head = 0;
|
||||
@@ -447,11 +429,12 @@ struct Model {
|
||||
rad_op op_media_rows = 0;
|
||||
MuseTower vit{};
|
||||
|
||||
/* ---- the DFlash drafter (arch/common/rad_block_muse_dflash.h): same wiring as the bf16
|
||||
* plugin declares, so a compressed-tensors container carries the drafter the same way. */
|
||||
bool have_df = false;
|
||||
/* ---- Meta's DFlash or incoai's DFlash2, selected by draft.architectures. */
|
||||
bool have_df = false, have_df2 = false;
|
||||
MuseDflash df{};
|
||||
MuseDflash::Wire dfw{};
|
||||
Dflash2 df2{};
|
||||
Dflash2::Wire df2w{};
|
||||
MuseTaps taps{};
|
||||
rad_kvgroup kv_draft = 0;
|
||||
|
||||
@@ -489,13 +472,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* ---- the family's own config. Everything that changes the mathematics is required or read
|
||||
* from the family defaults the reference config class states; a wrong default yields fluent
|
||||
* wrong text, so nothing here falls back to a "reasonable" value silently. */
|
||||
m.qk_mult = (float)cfg_f(meta, "qk_scale_factor", 3.87);
|
||||
m.post_eps = (float)cfg_f(meta, "post_norm_eps", 1e-8);
|
||||
m.out_mult = (float)cfg_f(meta, "output_multiplier", 0.19611613513818404);
|
||||
m.softcap = (float)cfg_f(meta, "final_logit_softcapping", 20.0);
|
||||
m.window = cfg_i(meta, "sliding_window", 2048);
|
||||
const double theta_rope = cfg_f(meta, "rope_parameters.rope_theta",
|
||||
cfg_f(meta, "rope_theta", 0.0));
|
||||
m.qk_mult = (float)meta_text_getf(meta, "qk_scale_factor", 3.87);
|
||||
m.post_eps = (float)meta_text_getf(meta, "post_norm_eps", 1e-8);
|
||||
m.out_mult = (float)meta_text_getf(meta, "output_multiplier", 0.19611613513818404);
|
||||
m.softcap = (float)meta_text_getf(meta, "final_logit_softcapping", 20.0);
|
||||
m.window = meta_text_geti(meta, "sliding_window", 2048);
|
||||
const double theta_rope = meta_text_getf(meta, "rope_parameters.rope_theta",
|
||||
meta_text_getf(meta, "rope_theta", 0.0));
|
||||
if (!(m.qk_mult > 0.0f) || !(m.out_mult > 0.0f) || !(m.post_eps > 0.0f) || m.window <= 0 ||
|
||||
!(theta_rope > 0.0)) {
|
||||
fprintf(stderr, "radiance: museglimmer: qk_scale_factor %g output_multiplier %g "
|
||||
@@ -518,7 +501,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* interval rule stands in. The two must agree where both exist: the schedule decides which
|
||||
* layers keep a long context, and a wrong layer still generates fluent text. */
|
||||
std::vector<int> full;
|
||||
const char* kinds = cfg_s(meta, "layer_types", nullptr);
|
||||
const char* kinds = meta_text_gets(meta, "layer_types", nullptr);
|
||||
if (kinds && *kinds)
|
||||
RAD_ARCH_TRY(parse_layer_kinds("museglimmer", kinds, {"full_attention"},
|
||||
"sliding_attention", &full));
|
||||
@@ -546,7 +529,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* Per-layer rotary: the shipped `layer_rope_theta`, else the family pattern (theta on the
|
||||
* sliding layers, 0 -- NoPE -- on the full ones). */
|
||||
std::vector<float> theta((size_t)g.n_layer, 0.0f);
|
||||
const char* thetas = cfg_s(meta, "layer_rope_theta", nullptr);
|
||||
const char* thetas = meta_text_gets(meta, "layer_rope_theta", nullptr);
|
||||
if (thetas && *thetas) {
|
||||
size_t i = 0;
|
||||
for_each_token(thetas, [&](const char* t, size_t n) {
|
||||
@@ -606,21 +589,26 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
}
|
||||
|
||||
/* ---- the trunk's form, read from layer 0's q projection before any activation is declared:
|
||||
* only an IQ8R trunk's activations carry an int8 code pair. The probe makes the weight's name
|
||||
* map through that layer's own LinearFP8, so neither linear of layer 0 maps it again. */
|
||||
* IQ8R and computed-trellis IQR activations carry an int8 code pair. The probe maps layer 0's
|
||||
* q weight, so neither linear maps it again. */
|
||||
const char* const pre = "model.language_model.layers";
|
||||
m.layers.resize((size_t)g.n_layer);
|
||||
RAD_ARCH_TRY(m.layers[0].rq.probe(b, nm, g, nm.f("blk.0.attn_q"),
|
||||
{ nm.ckpt("%s.0.self_attn.q_proj.weight", pre) }));
|
||||
{
|
||||
RadEncoding e0{};
|
||||
m.iq8r = weight_enc(b, nm.f("blk.0.attn_q.weight"), &e0) && linear_is_iq8r(e0);
|
||||
const bool known = weight_enc(b, nm.f("blk.0.attn_q.weight"), &e0);
|
||||
const W8hForm form = known ? linear_w8h_form(e0) : W8hForm::None;
|
||||
m.iq8r = known && linear_is_iq8r(e0);
|
||||
m.iqr_v4 = known && !m.iq8r && form == W8hForm::Trellis && linear_w8h_mad(e0);
|
||||
m.rotated_i8 = m.iq8r || m.iqr_v4;
|
||||
if (m.rotated_i8) m.rot_group = linear_w8h_group(e0);
|
||||
}
|
||||
if (m.iq8r && (g.n_embd % RAD_I8_GROUP_WIDE || q_dim % RAD_I8_GROUP_WIDE ||
|
||||
g.n_ff % RAD_I8_GROUP_WIDE)) {
|
||||
fprintf(stderr, "radiance: museglimmer: the IQ8R trunk keeps one scale a %d of K, which "
|
||||
if (m.rotated_i8 && (g.n_embd % m.rot_group || q_dim % m.rot_group ||
|
||||
g.n_ff % m.rot_group)) {
|
||||
fprintf(stderr, "radiance: museglimmer: the rotated trunk's %lld-column activation group "
|
||||
"does not divide this rank's widths (hidden %lld, attention %lld, "
|
||||
"feed-forward %lld)\n", RAD_I8_GROUP_WIDE, (long long)g.n_embd,
|
||||
"feed-forward %lld)\n", (long long)m.rot_group, (long long)g.n_embd,
|
||||
(long long)q_dim, (long long)g.n_ff);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
@@ -636,24 +624,18 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
m.b_attn = decl_b(b, nm.f("attn_out"), g.act_dtype, {g.max_tok, q_dim});
|
||||
m.b_gu = decl_b(b, nm.f("gate_up"), g.act_dtype, {g.max_tok, 2 * g.n_ff});
|
||||
m.b_ffn = decl_b(b, nm.f("ffn"), g.act_dtype, {g.max_tok, g.n_ff});
|
||||
/* An IQ8R trunk's int8 pairs, one scale per (row, 256). `a_h` is fed by the pre-norms where
|
||||
* rmsnorm_had_quant_i8g is declared; neither norm absorbs a collective (the all-reduce sits
|
||||
* before the post norm, and the embedding's before the weightless embedding norm), so the
|
||||
* all-reduce form is not needed at two ranks. `a_ffn` is fed by gated_had_quant_i8g where it
|
||||
* is declared. `a_attn` is never fed: the attention output is a sigmoid gate and a multiply
|
||||
* over separate buffers, and o_proj's own had_quant_act_i8g quantises the product (the gated
|
||||
* quantiser's per-head rows are head_dim wide, narrower than the 256-column group). No E4M3
|
||||
* pair: nothing here reads one. */
|
||||
if (m.iq8r) {
|
||||
/* Rotated int8 pairs, one scale per row and `rot_group` columns. The two centered pre-norms
|
||||
* can fuse normalization and quantisation; the gated product can fuse its quantiser. The
|
||||
* attention gate/multiply stays BF16, so o_proj quantises that product separately. */
|
||||
if (m.rotated_i8) {
|
||||
m.a_h.x = m.b_h;
|
||||
RAD_ARCH_TRY(m.a_h.declare_qs(b, nm, g, "h", g.n_embd, 0, true, false, RAD_I8_GROUP_WIDE));
|
||||
RAD_ARCH_TRY(m.a_h.declare_qs(b, nm, g, "h", g.n_embd, 0, true, false, m.rot_group));
|
||||
m.a_h.q8_fed = m.a_h.q8_rot = rad_op_declared(b, "rmsnorm_had_quant_i8g") != 0;
|
||||
m.a_attn.x = m.b_attn;
|
||||
RAD_ARCH_TRY(m.a_attn.declare_qs(b, nm, g, "attn_out", q_dim, 0, true, false,
|
||||
RAD_I8_GROUP_WIDE));
|
||||
m.rot_group));
|
||||
m.a_ffn.x = m.b_ffn;
|
||||
RAD_ARCH_TRY(m.a_ffn.declare_qs(b, nm, g, "ffn", g.n_ff, 0, true, false,
|
||||
RAD_I8_GROUP_WIDE));
|
||||
RAD_ARCH_TRY(m.a_ffn.declare_qs(b, nm, g, "ffn", g.n_ff, 0, true, false, m.rot_group));
|
||||
m.a_ffn.q8_fed = m.a_ffn.q8_rot = rad_op_declared(b, "gated_had_quant_i8g") != 0;
|
||||
}
|
||||
/* The lm_head runs over the sampled rows only (RadBatch::out_ids), not the whole step. */
|
||||
@@ -734,10 +716,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* qk_scale_factor rides the q norm's `mult`. */
|
||||
(void)attn_scale_num;
|
||||
|
||||
/* One linear of an IQ8R trunk: its name map (layer 0's q has it from the probe), its encoding
|
||||
* checked to be IQ8R, then LinearFP8's declaration (codes view i8 [N, K], one "scale,scale.1"
|
||||
* u8 view at the logical [N, K], gemm_nt_q at i8a8h, group 256, over `a`'s int8 pair; and
|
||||
* had_quant_act_i8g over `a.x` unless `a` is fed). */
|
||||
/* One rotated linear: IQ8R must stay IQ8R; IQR-V4 must be a computed MAD trellis. LinearFP8
|
||||
* selects the stored code/trellis/scale views and gemm_nt_q i8a8h at the proper scale group. */
|
||||
auto rot_linear = [&](int64_t l, LinearFP8& L, const char* base,
|
||||
std::initializer_list<const char*> src, int64_t n_out, int64_t n_in,
|
||||
int shard, const ActFP8& a, rad_buf y,
|
||||
@@ -746,12 +726,16 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
const char* wn = nm.f("%s.weight", base);
|
||||
RadEncoding e{};
|
||||
const bool known = weight_enc(b, wn, &e);
|
||||
if (!known || !linear_is_iq8r(e)) {
|
||||
const W8hForm form = known ? linear_w8h_form(e) : W8hForm::None;
|
||||
const bool valid = known && (m.iq8r ? linear_is_iq8r(e)
|
||||
: m.iqr_v4 && form == W8hForm::Trellis &&
|
||||
linear_w8h_mad(e));
|
||||
if (!valid || linear_w8h_group(e) != m.rot_group) {
|
||||
char en[256] = "plain bf16";
|
||||
if (known) rad_enc_format(&e, en, sizeof en);
|
||||
fprintf(stderr, "radiance: '%s' is %s, and this container's trunk is IQ8R (layer 0's "
|
||||
"attn_q): every trunk linear of an IQ8R container is IQ8R "
|
||||
"(data/recipes/museglimmer-30b-iq8r.recipe)\n", wn, en);
|
||||
fprintf(stderr, "radiance: '%s' is %s, which does not match this container's whole "
|
||||
"rotated trunk (layer 0 attn_q selects %s)\n", wn, en,
|
||||
m.iq8r ? "IQ8R" : "computed-trellis IQR");
|
||||
return RAD_E_DTYPE;
|
||||
}
|
||||
return L.declare(b, nm, g, base, n_out, n_in, shard, grp_layer((int)l), src, a, y, 0,
|
||||
@@ -794,10 +778,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
|
||||
/* -- ops, in run order except attn_paged, declared before kv_store like every family: the
|
||||
* two touch disjoint buffers and the block size comes from the resolved kernel. */
|
||||
/* The input norm: with an IQ8R trunk fed by its norms, rmsnorm_had_quant_i8g writes the
|
||||
* bf16 output and its rotated int8 pair in one pass (no residual operand: the residual add
|
||||
* is the post-normed branch's, not this norm's). */
|
||||
if (m.iq8r && m.a_h.q8_fed)
|
||||
/* A rotated trunk can fuse the centered norm and its int8 pair into one pass. */
|
||||
if (m.rotated_i8 && m.a_h.q8_fed)
|
||||
RAD_ARCH_TRY(lay.nq_attn.declare(b, gn, lay.w_norm, m.b_x, m.a_h, g.n_embd));
|
||||
else
|
||||
lay.op_norm = rw(b, RAD_OP(b, "rmsnorm",
|
||||
@@ -811,7 +793,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
nm.ckpt("%s.%lld.self_attn.gate_proj.weight", pre, (long long)l);
|
||||
const char* const src_k = nm.ckpt("%s.%lld.self_attn.k_proj.weight", pre, (long long)l);
|
||||
const char* const src_v = nm.ckpt("%s.%lld.self_attn.v_proj.weight", pre, (long long)l);
|
||||
if (m.iq8r) {
|
||||
if (m.rotated_i8) {
|
||||
/* q, gate, k and v read one int8 pair of the norm output: the norm's, or q's own
|
||||
* quantiser's where the norm writes none. The three after q read it as fed. */
|
||||
ActFP8 h_shared = m.a_h;
|
||||
@@ -902,8 +884,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_attn, m.b_gate}, {m.b_attn});
|
||||
const char* const src_o = nm.ckpt("%s.%lld.self_attn.o_proj.weight", pre, (long long)l);
|
||||
/* IQ8R: o_proj quantises the gated product itself (had_quant_act_i8g into `a_attn`). */
|
||||
if (m.iq8r)
|
||||
/* The rotated path quantises o_proj's gated product into its int8 pair. */
|
||||
if (m.rotated_i8)
|
||||
RAD_ARCH_TRY(rot_linear(l, lay.ro, nm.f("blk.%d.attn_output", (int)l), {src_o},
|
||||
g.n_embd, q_dim, RAD_SHARD_COL, m.a_attn, m.b_h, {}));
|
||||
else
|
||||
@@ -931,9 +913,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_NOWEIGHTS),
|
||||
{m.b_x, m.b_h}, {m.b_x});
|
||||
|
||||
/* ---- the feed-forward, the same double norm. With an IQ8R trunk fed by its norms the
|
||||
* pre-feed-forward norm writes the int8 pair too, as the input norm does. */
|
||||
if (m.iq8r && m.a_h.q8_fed)
|
||||
/* ---- the feed-forward, the same double norm. A rotated trunk can fuse the norm and pair. */
|
||||
if (m.rotated_i8 && m.a_h.q8_fed)
|
||||
RAD_ARCH_TRY(lay.nq_ffn.declare(b, gn, lay.w_fnorm, m.b_x, m.a_h, g.n_embd));
|
||||
else
|
||||
lay.op_fnorm = rw(b, RAD_OP(b, "rmsnorm",
|
||||
@@ -945,7 +926,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
const char* const src_gate_ff = nm.ckpt("%s.%lld.mlp.gate_proj.weight", pre, (long long)l);
|
||||
const char* const src_up = nm.ckpt("%s.%lld.mlp.up_proj.weight", pre, (long long)l);
|
||||
const char* const src_down = nm.ckpt("%s.%lld.mlp.down_proj.weight", pre, (long long)l);
|
||||
if (m.iq8r) {
|
||||
if (m.rotated_i8) {
|
||||
/* gate|up in the checkpoint's row order, two row parts; then silu(gate) * up. Where
|
||||
* `a_ffn` is fed, gated_had_quant_i8g writes down_proj's int8 pair, and the bf16
|
||||
* product only when the calibration taps read it (down_proj reads codes alone).
|
||||
@@ -1086,12 +1067,17 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_ARCH_TRY(m.vit.declare(b, meta, ctx, nm, g.n_embd, (int)g.n_layer));
|
||||
}
|
||||
|
||||
/* ---- the DFlash drafter, declared last: its passes run after the whole trunk's, and the
|
||||
* planner lays lifetimes out in declaration order. */
|
||||
/* ---- the drafter is declared last so its buffers cannot overlap trunk temporaries. */
|
||||
if (m.taps.n > 0) {
|
||||
RAD_ARCH_TRY(declare_muse_dflash(&m.df, &m.dfw, &m.kv_draft, b, nm, meta, ctx, g, m.taps,
|
||||
(int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df = true;
|
||||
if (muse_draft_is_dflash2(meta)) {
|
||||
RAD_ARCH_TRY(declare_muse_dflash2(&m.df2, &m.df2w, &m.kv_draft, b, nm, meta, ctx, g,
|
||||
m.taps, (int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df2 = true;
|
||||
} else {
|
||||
RAD_ARCH_TRY(declare_muse_dflash(&m.df, &m.dfw, &m.kv_draft, b, nm, meta, ctx, g,
|
||||
m.taps, (int)g.n_layer, m.w_tok, m.w_lm_head));
|
||||
m.have_df = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- notes for --debug-graph. */
|
||||
@@ -1117,11 +1103,11 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
if (m.g_rope.theta != g.theta)
|
||||
rad_note(b, "rotary runs on the sliding layers only (theta %g); the full-attention layers "
|
||||
"are NoPE", (double)m.g_rope.theta);
|
||||
if (m.iq8r)
|
||||
rad_note(b, "IQ8R trunk: every linear gemm_nt_q i8a8h over int8 codes rotated 128 wide, "
|
||||
"one scale a (row, %d) on both sides; the pre-norms %s, the gated product %s, "
|
||||
"o_proj quantises its own input; q, gate, k and v read one pair",
|
||||
RAD_I8_GROUP_WIDE,
|
||||
if (m.rotated_i8)
|
||||
rad_note(b, "%s trunk: gemm_nt_q i8a8h over 128-wide Hadamard codes, one activation scale "
|
||||
"per %lld K columns; the pre-norms %s, the gated product %s, o_proj quantises "
|
||||
"its own input; q, gate, k and v read one pair",
|
||||
m.iq8r ? "IQ8R" : "computed-trellis IQR", (long long)m.rot_group,
|
||||
m.a_h.q8_fed ? "write the codes (rmsnorm_had_quant_i8g)"
|
||||
: "are plain (q and gate/up quantise)",
|
||||
m.a_ffn.q8_fed ? "writes down_proj's codes (gated_had_quant_i8g)"
|
||||
@@ -1145,6 +1131,11 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
/* A draft pass runs only the drafter: >0 the query pass on the staged block, <0 the context
|
||||
* pass that projects and stores K/V for the tokens the trunk just committed. */
|
||||
if (batch->draft_pass != 0) {
|
||||
if (m.have_df2) {
|
||||
if (batch->draft_pass > 0) m.df2.step(c, batch);
|
||||
else m.df2.context(c, batch);
|
||||
return;
|
||||
}
|
||||
if (!m.have_df) {
|
||||
rad_step_fail(c, "this serve stages a draft pass but the container carries no drafter");
|
||||
return;
|
||||
@@ -1184,7 +1175,8 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
* declared a quantiser (op_q) issues it first, over the pair's bf16 plane. */
|
||||
if (l.nq_attn.op) l.nq_attn.step(c, T);
|
||||
else RAD_ISSUE(c, l.op_norm, brows(m.b_x, T), RAD_W(l.w_norm), brows(m.b_h, T));
|
||||
if (m.iq8r) {
|
||||
if (l.cs_in >= 0) m.calib.tap(c, (size_t)l.cs_in, T);
|
||||
if (m.rotated_i8) {
|
||||
l.rq.step(c, m.a_h, m.b_q, T);
|
||||
l.rgate.step(c, m.a_h, m.b_gate, T);
|
||||
l.rk.step(c, m.a_h, m.b_k, T);
|
||||
@@ -1214,7 +1206,8 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
brows(m.b_attn, T));
|
||||
RAD_ISSUE_N(c, l.op_sig, T * m.g.n_head, brows(m.b_gate, T), brows(m.b_gate, T));
|
||||
RAD_ISSUE(c, l.op_mul, brows(m.b_attn, T), brows(m.b_gate, T), brows(m.b_attn, T));
|
||||
if (m.iq8r) l.ro.step(c, m.a_attn, m.b_h, T);
|
||||
if (l.cs_o >= 0) m.calib.tap(c, (size_t)l.cs_o, T);
|
||||
if (m.rotated_i8) l.ro.step(c, m.a_attn, m.b_h, T);
|
||||
else l.lo.step(c, m.b_attn, m.b_h, T);
|
||||
if (l.op_ar) RAD_ISSUE_N(c, l.op_ar, T * m.g.n_embd, brows(m.b_h, T), RAD_NONE);
|
||||
RAD_ISSUE(c, l.op_post, brows(m.b_h, T), RAD_W(l.w_post), brows(m.b_h, T));
|
||||
@@ -1223,7 +1216,8 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
/* -- feed-forward. */
|
||||
if (l.nq_ffn.op) l.nq_ffn.step(c, T);
|
||||
else RAD_ISSUE(c, l.op_fnorm, brows(m.b_x, T), RAD_W(l.w_fnorm), brows(m.b_h, T));
|
||||
if (m.iq8r) {
|
||||
if (l.cs_mlp >= 0) m.calib.tap(c, (size_t)l.cs_mlp, T);
|
||||
if (m.rotated_i8) {
|
||||
l.rgu.step(c, m.a_h, m.b_gu, T);
|
||||
if (l.gq_ffn.op) l.gq_ffn.step(c, m.b_gu, T);
|
||||
else RAD_ISSUE(c, l.op_act, brows(m.b_gu, T), brows(m.b_ffn, T));
|
||||
@@ -1233,6 +1227,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
RAD_ISSUE(c, l.op_act, brows(m.b_gu, T), brows(m.b_ffn, T));
|
||||
l.ldown.step(c, m.b_ffn, m.b_h, T);
|
||||
}
|
||||
if (l.cs_down >= 0) m.calib.tap(c, (size_t)l.cs_down, T);
|
||||
if (l.op_far) RAD_ISSUE_N(c, l.op_far, T * m.g.n_embd, brows(m.b_h, T), RAD_NONE);
|
||||
RAD_ISSUE(c, l.op_fpost, brows(m.b_h, T), RAD_W(l.w_fpost), brows(m.b_h, T));
|
||||
RAD_ISSUE(c, l.op_fadd, brows(m.b_x, T), brows(m.b_h, T), brows(m.b_x, T));
|
||||
@@ -1243,6 +1238,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
|
||||
RAD_ISSUE(c, m.op_final_norm,
|
||||
brows(m.b_x, batch->n_tok), RAD_W(m.w_out_norm), brows(m.b_h, batch->n_tok));
|
||||
if (m.cs_head >= 0) m.calib.tap(c, (size_t)m.cs_head, T);
|
||||
m.calib.after_step(c, T);
|
||||
|
||||
/* The lm_head runs only on the rows the sampler asked for; a mid-prompt prefill chunk has
|
||||
@@ -1267,6 +1263,12 @@ static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
if (MuseTower::present(meta)) out->enc_merge = 4;
|
||||
/* The drafter denoises `block_size` positions, the anchor row proposes nothing. */
|
||||
if (muse_draft_is_dflash2(meta)) {
|
||||
const long long bs = rad_meta_geti(meta, "draft.dflash_config.block_size", 16);
|
||||
out->draft_depth = bs > 1 ? (int)(bs - 1) : 15;
|
||||
out->draft_depth_fixed = 1;
|
||||
return RAD_OK;
|
||||
}
|
||||
const long long bs = rad_meta_geti(meta, "draft.block_size", 0);
|
||||
if (bs > 1) {
|
||||
out->draft_depth = (int)(bs - 1);
|
||||
@@ -1287,9 +1289,9 @@ RAD_ARCH_PROBE(museglimmer_ct)
|
||||
RAD_ARCH_MULTI_INSTANCE()
|
||||
RAD_ARCH_PLUGIN(museglimmer_ct, "museglimmer", "compressed-tensors", "0.1.0",
|
||||
"Meta Muse Glimmer 30B dense under compressed-tensors: encoding-aware trunk "
|
||||
"linears (plain bf16, asymmetric int4/int5 a 128, int8 a 128, or an IQ8R trunk: "
|
||||
"rotated int8 a 256), gated attention "
|
||||
"alternating sliding-window (rotary) and NoPE full-attention layers, Gemma-2 "
|
||||
"style double norms, a bf16 vision tower")
|
||||
"linears (bf16, asymmetric/symmetric integer, IQ8R, or fwht128 computed-MAD "
|
||||
"IQR-V4 at i8a8h), gated attention alternating sliding-window (rotary) and NoPE "
|
||||
"full-attention layers, Gemma-2 style double norms, bf16 vision tower, and DFlash "
|
||||
"or DFlash2 drafter")
|
||||
RAD_ARCH_CHAT_FORMAT(museglimmer_ct)
|
||||
#endif
|
||||
@@ -217,7 +217,8 @@ struct Mamba {
|
||||
if (!op_conv || !op_prefill || !op_verify || !op_gate || !op_norm || !op_gain)
|
||||
return RAD_E_INVAL;
|
||||
const char* on = nm.f("blk.%d.ssm_out", l);
|
||||
RAD_ARCH_TRY(output.probe(b, nm, g, on, { nm.ckpt("%s.out_proj.weight", pre) }));
|
||||
if (!output.mapped)
|
||||
RAD_ARCH_TRY(output.probe(b, nm, g, on, { nm.ckpt("%s.out_proj.weight", pre) }));
|
||||
if (!output.reads_x) RAD_ARCH_TRY(out_quant.declare(b, g, w.core_out, W));
|
||||
RAD_ARCH_TRY(output.declare(b, nm, g, on, g.n_embd, W, RAD_SHARD_COL, grp,
|
||||
{ nm.ckpt("%s.out_proj.weight", pre) }, w.core_out, w.out));
|
||||
@@ -295,8 +296,10 @@ struct LatentMoe {
|
||||
RAD_ARCH_TRY(fc1.declare(b, nm, g, nm.f("blk.%d.ffn_latent_in", l), s.latent, g.n_embd,
|
||||
RAD_SHARD_NONE, grp,
|
||||
{ nm.ckpt("%s.fc1_latent_proj.weight", pre) }, w.h, w.lat.x));
|
||||
/* The routed arm reads the latent's codes unless its experts are bf16. */
|
||||
if (!ms.cfg.expert_bf16) RAD_ARCH_TRY(lat_in.declare(b, g, w.lat, s.latent));
|
||||
/* The routed arm reads the latent's E4M3 codes unless its experts are bf16 or rotated
|
||||
* (rotated ones read the int8 copy MoeFP8 writes, `hr`). */
|
||||
if (!ms.cfg.expert_bf16 && !ms.cfg.expert_rot)
|
||||
RAD_ARCH_TRY(lat_in.declare(b, g, w.lat, s.latent));
|
||||
Geom ge = g;
|
||||
ge.n_embd = s.latent;
|
||||
ge.n_ff_all = s.ff[(size_t)l];
|
||||
@@ -318,6 +321,9 @@ struct LatentMoe {
|
||||
RAD_SHARD_ROW, grp,
|
||||
{ nm.ckpt("%s.shared_experts.up_proj.weight", pre) }, w.h,
|
||||
w.sup, 0, {}, sh_lo, sh_hi));
|
||||
/* A down projection that reads the bf16 plane (an int8 one quantises it itself) takes
|
||||
* the product alone, without codes no op would read. */
|
||||
sh_act.silu_only = sh_down.reads_x;
|
||||
RAD_ARCH_TRY(sh_act.declare(b, g, w.sup, w.sff, sh_w, "relu2", 0, true, false));
|
||||
RAD_ARCH_TRY(sh_down.declare(b, nm, g, dn, g.n_embd, sh_w, RAD_SHARD_COL, grp,
|
||||
{ nm.ckpt("%s.shared_experts.down_proj.weight", pre) },
|
||||
@@ -367,6 +373,11 @@ struct Model {
|
||||
rad_kvgroup kv_attn = 0, kv_state = 0, kv_conv = 0;
|
||||
rad_buf x = 0, y = 0, final_hidden = 0, logit_input = 0, logits = 0;
|
||||
ActFP8 act{};
|
||||
/* An int8 trunk (i8 codes with a bf16 scale a [1 x 128], or IQ8R's 256): every activation a
|
||||
* trunk linear reads declares the int8 pair too, which that linear's own quant_act_i8g writes
|
||||
* from the bf16 plane. From the first Mamba block's out projection, probed in declare(). */
|
||||
bool trunk_i8 = false;
|
||||
int64_t trunk_g8 = RAD_FP8_BLOCK;
|
||||
Mamba::Wire mw{};
|
||||
AttnFP8::Wire aw{};
|
||||
LatentMoe::Wire ew{};
|
||||
@@ -513,7 +524,10 @@ static int buffers(RadBuilder* b, Model& m) {
|
||||
m.x = bf("residual", { T, E });
|
||||
m.y = bf("mixer_delta", { T, E });
|
||||
m.act.x = bf("normed", { T, E });
|
||||
RAD_ARCH_TRY(m.act.declare_qs(b, nm, g, "normed", E));
|
||||
/* An int8 trunk's linears read the int8 pair, each quantising the bf16 plane itself, so the
|
||||
* activations below declare no E4M3 pair. The block norms still write E4M3 codes here, which
|
||||
* no linear of an int8 trunk reads: NormQuantFP8 has no unrotated int8 form. */
|
||||
RAD_ARCH_TRY(m.act.declare_qs(b, nm, g, "normed", E, 0, m.trunk_i8, true, m.trunk_g8));
|
||||
m.final_hidden = decl_b(b, nm.f("final_hidden"), RAD_BF16, { T, E }, RAD_BUF_PERSIST);
|
||||
m.logit_input = bf("logit_input", { g.max_logit_rows, E });
|
||||
m.logits = decl_b(b, nm.f("logits"), RAD_F32, { g.max_logit_rows, g.n_vocab });
|
||||
@@ -528,7 +542,8 @@ static int buffers(RadBuilder* b, Model& m) {
|
||||
mw.dt = bf("ssm_dt", { T, H });
|
||||
mw.y = bf("ssm_y", { T, W });
|
||||
mw.core_out.x = bf("ssm_out", { T, W });
|
||||
RAD_ARCH_TRY(mw.core_out.declare_qs(b, nm, g, "ssm_out", W));
|
||||
RAD_ARCH_TRY(mw.core_out.declare_qs(b, nm, g, "ssm_out", W, 0, m.trunk_i8, !m.trunk_i8,
|
||||
m.trunk_g8));
|
||||
|
||||
auto& aw = m.aw;
|
||||
aw.x = m.x;
|
||||
@@ -536,7 +551,8 @@ static int buffers(RadBuilder* b, Model& m) {
|
||||
aw.qkv = bf("attn_qkv", { T, g.qkv_dim() });
|
||||
aw.q = bf("attn_q", { T, g.q_dim() });
|
||||
aw.attn.x = bf("attn_out", { T, g.q_dim() });
|
||||
RAD_ARCH_TRY(aw.attn.declare_qs(b, nm, g, "attn_out", g.q_dim()));
|
||||
RAD_ARCH_TRY(aw.attn.declare_qs(b, nm, g, "attn_out", g.q_dim(), 0, m.trunk_i8, !m.trunk_i8,
|
||||
m.trunk_g8));
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -552,13 +568,17 @@ static int moe_buffers(RadBuilder* b, Model& m, const std::vector<MoeFP8::Src>&
|
||||
};
|
||||
auto& ew = m.ew;
|
||||
ew.h = m.act;
|
||||
/* The latent keeps its E4M3 pair on an int8 trunk too: MoeFP8 takes it as a prepared input
|
||||
* and checks that it carries codes, also where rotated experts read their own copy `hr`
|
||||
* and lat_in writes none. */
|
||||
ew.lat.x = bf("latent", { T, L });
|
||||
RAD_ARCH_TRY(ew.lat.declare_qs(b, nm, g, "latent", L));
|
||||
RAD_ARCH_TRY(ew.lat.declare_qs(b, nm, g, "latent", L, 0, m.trunk_i8, true, m.trunk_g8));
|
||||
ew.routed = m.y;
|
||||
if (sh_w > 0) {
|
||||
ew.sup = bf("shared_up", { T, sh_w });
|
||||
ew.sff.x = bf("shared_ff", { T, sh_w });
|
||||
RAD_ARCH_TRY(ew.sff.declare_qs(b, nm, g, "shared_ff", sh_w));
|
||||
RAD_ARCH_TRY(ew.sff.declare_qs(b, nm, g, "shared_ff", sh_w, 0, m.trunk_i8, !m.trunk_i8,
|
||||
m.trunk_g8));
|
||||
ew.sout = bf("shared_out", { T, E });
|
||||
}
|
||||
Geom gl = g;
|
||||
@@ -580,12 +600,20 @@ static int moe_buffers(RadBuilder* b, Model& m, const std::vector<MoeFP8::Src>&
|
||||
w.sorted = decl_b(b, nm.f("%s.expert_sorted", tag), RAD_I32, { rows * k });
|
||||
w.egu = bf(nm.f("%s.expert_up", tag), { rows * k, F });
|
||||
w.eff.x = bf(nm.f("%s.expert_ff", tag), { rows * k, F });
|
||||
RAD_ARCH_TRY(w.eff.declare_qs(b, nm, gl, nm.f("%s.expert_ff", tag), F, rows * k));
|
||||
/* Rotated experts (w4nl64a8i8h and its kin) read rotated int8 codes, a scale per 128: the
|
||||
* block input's rotated copy `hr` and the relu^2 product, each written by
|
||||
* had_quant_act_i8g. This build has no rotated E4M3 quantiser. */
|
||||
const bool i8arm = c.expert_rot != 0;
|
||||
RAD_ARCH_TRY(w.eff.declare_qs(b, nm, gl, nm.f("%s.expert_ff", tag), F, rows * k, i8arm,
|
||||
!i8arm, RAD_FP8_BLOCK));
|
||||
w.eff.q8_fed = w.eff.q8_rot = i8arm;
|
||||
w.edn = bf(nm.f("%s.expert_down", tag), { rows * k, L });
|
||||
if (c.expert_rot) {
|
||||
w.hr.q = decl_b(b, nm.f("%s.latent_rot.q", tag), RAD_F8E4M3, { T, L });
|
||||
w.hr.s = decl_b(b, nm.f("%s.latent_rot.s", tag), RAD_F32, { T, L / RAD_FP8_BLOCK });
|
||||
if (!w.hr.q || !w.hr.s) return RAD_E_INVAL;
|
||||
if (i8arm) {
|
||||
w.hr.q8 = decl_b(b, nm.f("%s.latent_rot.q8", tag), RAD_I8, { T, L });
|
||||
w.hr.s8 = decl_b(b, nm.f("%s.latent_rot.s8", tag), RAD_F32, { T, L / RAD_FP8_BLOCK });
|
||||
w.hr.g8 = RAD_FP8_BLOCK;
|
||||
w.hr.q8_fed = w.hr.q8_rot = true;
|
||||
if (!w.hr.q8 || !w.hr.s8) return RAD_E_INVAL;
|
||||
}
|
||||
if (!w.logits || !w.ids || !w.ew || !w.eoff || !w.ecnt || !w.sorted || !w.egu ||
|
||||
!w.eff.x || !w.edn)
|
||||
@@ -692,16 +720,31 @@ static int declare_lilicorr(RadBuilder* b, const RadModelMeta* meta, const RadBu
|
||||
dw.attn = decl_b(b, nm.f("df_attn"), A, {qr, qd});
|
||||
dw.gate_up = decl_b(b, nm.f("df_gate_up"), A, {qr, 2 * dg.n_ff});
|
||||
dw.ffn = decl_b(b, nm.f("df_ffn"), A, {qr, dg.n_ff});
|
||||
dw.srcq = decl_b(b, nm.f("df_srcq"), RAD_F8E4M3, {dg.max_tok, dc.n_taps * E});
|
||||
dw.srcs = decl_b(b, nm.f("df_srcs"), RAD_F32, {dg.max_tok, fp8_blocks(dc.n_taps * E)});
|
||||
dw.cq = decl_b(b, nm.f("df_cq"), RAD_F8E4M3, {dg.max_tok, E});
|
||||
dw.cs = decl_b(b, nm.f("df_cs"), RAD_F32, {dg.max_tok, fp8_blocks(E)});
|
||||
dw.h2q = decl_b(b, nm.f("df_h2q"), RAD_F8E4M3, {qr, E});
|
||||
dw.h2s = decl_b(b, nm.f("df_h2s"), RAD_F32, {qr, fp8_blocks(E)});
|
||||
dw.atq = decl_b(b, nm.f("df_atq"), RAD_F8E4M3, {qr, qd});
|
||||
dw.ats = decl_b(b, nm.f("df_ats"), RAD_F32, {qr, fp8_blocks(qd)});
|
||||
dw.ffq = decl_b(b, nm.f("df_ffq"), RAD_F8E4M3, {qr, dg.n_ff});
|
||||
dw.ffs = decl_b(b, nm.f("df_ffs"), RAD_F32, {qr, fp8_blocks(dg.n_ff)});
|
||||
/* The codes the backbone's linears read: int8 with one f32 scale per (row, group) for linears
|
||||
* stored rotated int8, which the drafter's `fc` tells (Dflash2::probe_i8, as gemma4_bf16 asks
|
||||
* it); E4M3 with a scale per 128 for block fp8 or MXFP4 ones (rad_fp8.h's DenseFP8). radiance
|
||||
* 2.0 serves no block fp8, so a 2.0 container's backbone is the int8 form. */
|
||||
RAD_ARCH_TRY(Dflash2::probe_i8(b, nm, "draft", &dc.act_i8, &dc.act_g8));
|
||||
dc.fc_mapped = true;
|
||||
const uint32_t dqt = dc.act_i8 ? RAD_I8 : RAD_F8E4M3;
|
||||
const int64_t dqg = dc.act_i8 ? dc.act_g8 : (int64_t)RAD_FP8_BLOCK;
|
||||
if (dc.act_i8 && ((dc.n_taps * E) % dqg || E % dqg || qd % dqg || dg.n_ff % dqg)) {
|
||||
fprintf(stderr, "radiance: nemotronh: a rotated int8 LiLiCorr backbone takes widths in "
|
||||
"whole %lld-column scale groups; this one is n_embd %lld, q %lld, n_ff "
|
||||
"%lld\n", (long long)dqg, (long long)E, (long long)qd, (long long)dg.n_ff);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
auto dqs = [&](int64_t n) { return (n + dqg - 1) / dqg; };
|
||||
dw.srcq = decl_b(b, nm.f("df_srcq"), dqt, {dg.max_tok, dc.n_taps * E});
|
||||
dw.srcs = decl_b(b, nm.f("df_srcs"), RAD_F32, {dg.max_tok, dqs(dc.n_taps * E)});
|
||||
dw.cq = decl_b(b, nm.f("df_cq"), dqt, {dg.max_tok, E});
|
||||
dw.cs = decl_b(b, nm.f("df_cs"), RAD_F32, {dg.max_tok, dqs(E)});
|
||||
dw.h2q = decl_b(b, nm.f("df_h2q"), dqt, {qr, E});
|
||||
dw.h2s = decl_b(b, nm.f("df_h2s"), RAD_F32, {qr, dqs(E)});
|
||||
dw.atq = decl_b(b, nm.f("df_atq"), dqt, {qr, qd});
|
||||
dw.ats = decl_b(b, nm.f("df_ats"), RAD_F32, {qr, dqs(qd)});
|
||||
dw.ffq = decl_b(b, nm.f("df_ffq"), dqt, {qr, dg.n_ff});
|
||||
dw.ffs = decl_b(b, nm.f("df_ffs"), RAD_F32, {qr, dqs(dg.n_ff)});
|
||||
dw.sel_h = decl_b(b, nm.f("df_selh"), A, {sr, E});
|
||||
/* The proposal buffer (RadDrafterDecl::proposal), written by the walk. */
|
||||
dw.tokens = decl_b(b, nm.f("dflash_tokens"), RAD_I32, {dg.max_seqs, dc.steps()});
|
||||
@@ -854,14 +897,37 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
c.n_ff_exp = s.ff[(size_t)l];
|
||||
for (int q = 0; q < 4; ++q) c.ff_lo4[q] = c.ff_hi4[q] = 0;
|
||||
}
|
||||
/* The shared expert's slice: even, or slice_of's whole blocks. */
|
||||
/* Whether the trunk is int8, from the first Mamba block's out projection, before the
|
||||
* activations are declared: an int8 linear reads an int8 pair its input must hold. The probe
|
||||
* makes that linear's name map, so Mamba::declare does not probe it again. */
|
||||
m.layers.resize((size_t)s.n_layer);
|
||||
for (int l = 0; l < (int)s.n_layer; ++l) {
|
||||
if (s.kind[(size_t)l] != kMamba) continue;
|
||||
LinearFP8& out = m.layers[(size_t)l].mamba.output;
|
||||
RAD_ARCH_TRY(out.probe(b, nm, g, nm.f("blk.%d.ssm_out", l),
|
||||
{ nm.ckpt("language_model.backbone.layers.%d.mixer.out_proj.weight",
|
||||
l) }));
|
||||
m.trunk_i8 = out.probed_i8;
|
||||
m.trunk_g8 = out.probed_g8;
|
||||
break;
|
||||
}
|
||||
/* The shared expert's slice: even, or slice_of's whole scale groups. Its down projection
|
||||
* reads the slice along K, and an int8 trunk keeps one scale a group of K there: 128 columns,
|
||||
* or IQ8R's 256 (asked after the probe above). Bolt's 5376 is 42 blocks of 128 but 21 groups
|
||||
* of 256, so two ranks hold 11 and 10 groups, not 2688 columns each. */
|
||||
const int64_t sg = m.trunk_i8 ? m.trunk_g8 : (int64_t)RAD_FP8_BLOCK;
|
||||
if (s.ff_shared % sg) {
|
||||
fprintf(stderr, "radiance: nemotronh: the shared expert's %lld columns are not whole "
|
||||
"%lld-column scale groups\n", (long long)s.ff_shared, (long long)sg);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
int64_t sh_lo = 0, sh_hi = 0, sh_w = s.ff_shared / world;
|
||||
{
|
||||
const int64_t sb = s.ff_shared / RAD_FP8_BLOCK;
|
||||
const int64_t sb = s.ff_shared / sg;
|
||||
if (sb % world) {
|
||||
slice_of(sb, world, g.rank, 0, &sh_lo, &sh_hi);
|
||||
sh_lo *= RAD_FP8_BLOCK;
|
||||
sh_hi *= RAD_FP8_BLOCK;
|
||||
sh_lo *= sg;
|
||||
sh_hi *= sg;
|
||||
sh_w = sh_hi - sh_lo;
|
||||
}
|
||||
}
|
||||
@@ -942,7 +1008,6 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
}
|
||||
}
|
||||
|
||||
m.layers.resize((size_t)s.n_layer);
|
||||
for (int l = 0; l < (int)s.n_layer; ++l) {
|
||||
Layer& lay = m.layers[(size_t)l];
|
||||
lay.kind = s.kind[(size_t)l];
|
||||
|
||||
@@ -581,6 +581,22 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* `model.language_model.layers.N` and its MTP block separately under `mtp.`; subtracting it
|
||||
* would drop full-attention layer 63 and silently run a trunk one layer short. */
|
||||
m.n_main = g.n_layer;
|
||||
const bool calib_requested = ctx->calib_dir && *ctx->calib_dir;
|
||||
const bool calib_mtp_layer = QWEN35_W8A8 && !QWEN35_MOE && calib_requested && nextn > 0 &&
|
||||
ctx->calib_layer_lo == m.n_main && ctx->calib_layer_hi == m.n_main + 1;
|
||||
#if !QWEN35_MOE
|
||||
const bool calib_trunk_layers = calib_requested &&
|
||||
(!ctx->calib_layer_hi || ctx->calib_layer_lo < m.n_main);
|
||||
#endif
|
||||
if (calib_requested && !calib_mtp_layer && ctx->calib_layer_hi > m.n_main) {
|
||||
if (nextn > 0)
|
||||
fprintf(stderr, "radiance: qwen35: select only the virtual MTP layer for draft-head "
|
||||
"calibration on dense qwen35_w8a8\n");
|
||||
else
|
||||
fprintf(stderr, "radiance: qwen35: --calib-layers extends past the trunk, with no MTP "
|
||||
"layer to calibrate\n");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* Qwen3.5's norms are GemmaRMSNorm, `x_hat * (1 + w)` (vLLM imports GemmaRMSNorm as
|
||||
* Qwen3_5RMSNorm). This covers input_layernorm, post_attention_layernorm, the final norm and
|
||||
@@ -1110,12 +1126,15 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
m.layers.resize((size_t)m.n_main);
|
||||
#if !QWEN35_MOE
|
||||
/* GPTQ calibration over the trunk's own int8 codes (rad_calib_full.h, site_i8): one rank, the
|
||||
* serial step. The scratch is the widest input's square, the feed-forward's. */
|
||||
if (ctx->calib_dir && *ctx->calib_dir && g.world > 1) {
|
||||
fprintf(stderr, "radiance: qwen35: --calib-dir records an int8 trunk at --tp 1 only\n");
|
||||
* serial step. MTP-only calibration selects virtual layer n_main and does not touch this tap. */
|
||||
if (calib_trunk_layers && g.world > 1) {
|
||||
fprintf(stderr, "radiance: qwen35: --calib-dir records an int8 trunk at --tp 1 only; "
|
||||
"select only the MTP layer for replicated-head calibration\n");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
RAD_ARCH_TRY(m.calib.begin(b, nm, g, ctx, m.n_main, 0, std::max<int64_t>(g.n_ff, g.n_embd)));
|
||||
if (calib_trunk_layers)
|
||||
RAD_ARCH_TRY(m.calib.begin(b, nm, g, ctx, m.n_main, 0,
|
||||
std::max<int64_t>(g.n_ff, g.n_embd)));
|
||||
#endif
|
||||
for (int64_t l = 0; l < m.n_main; ++l) {
|
||||
Layer& lay = m.layers[(size_t)l];
|
||||
@@ -1280,8 +1299,23 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
*
|
||||
* Also only when there is no DFlash2 drafter (`n_taps` == 0): a deployment drafts with one,
|
||||
* and DFlash2 (one forward per block rather than one per token) is the better one here. */
|
||||
/* (A vocabulary-weighted head has no output.weight for the draft head to read.) */
|
||||
if (nextn > 0 && g.max_spec > 0 && m.n_taps == 0 && !m.n_vcls) {
|
||||
if (calib_mtp_layer && m.n_taps > 0) {
|
||||
fprintf(stderr, "radiance: qwen35: MTP draft-head calibration cannot use a DFlash2 drafter\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
const bool want_mtp = nextn > 0 && (g.max_spec > 0 || calib_mtp_layer) && !m.n_taps;
|
||||
const bool draft_q2 = want_mtp &&
|
||||
mtp_draft_head_q2(b, nm.f("mtp.draft_head.weight"), nm.ckpt("lm_head.weight"));
|
||||
if (calib_mtp_layer && !draft_q2) {
|
||||
fprintf(stderr, "radiance: qwen35: MTP draft-head calibration requires a U2 "
|
||||
"mtp.draft_head.weight\n");
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
/* A split target has no single output.weight. It can still verify the proposals of an
|
||||
* independent U2 head. Older split-head containers carry neither that head nor the MTP
|
||||
* block, even if the checkpoint metadata advertises NextN. Leave them trunk-only. */
|
||||
if (want_mtp && (m.w_lm_head || draft_q2 || ctx->draft_coupling)) {
|
||||
const int pitch = MtpHead::proposal_pitch(ctx->draft_coupling != 0);
|
||||
/* Sized at max_tok, not max_logit_rows: a draft round is one row per sequence, but the
|
||||
* history pass that fills the head's own K and V is one row per token over a whole prefill
|
||||
* chunk (26 MiB at a 512-token chunk, beside 477 MiB of head weights). */
|
||||
@@ -1290,19 +1324,18 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
m.b_mtp_c = decl_b(b, nm.f("mtp_c"), g.act_dtype, {g.max_tok, 2 * g.n_embd});
|
||||
m.b_mtp_x = decl_b(b, nm.f("mtp_x"), g.act_dtype, {g.max_tok, g.n_embd});
|
||||
|
||||
/* The 2-bit draft head's working set, at max_logit_rows, since only a draft round (one row
|
||||
* per sequence) uses it. `mtp_dsum` is quant_act_i8's group-major
|
||||
* [n_embd/128][ceil(M/16)*16] plane, first dimension the K group, not the token. */
|
||||
if (mtp_draft_head_q2(b, nm.f("mtp.draft_head.weight"), nm.ckpt("lm_head.weight"))) {
|
||||
const int64_t dmpad = ((g.max_logit_rows + 15) / 16) * 16;
|
||||
m.b_mtp_dq = decl_b(b, nm.f("mtp_dq"), RAD_I8, {g.max_logit_rows, g.n_embd});
|
||||
m.b_mtp_ds = decl_b(b, nm.f("mtp_ds"), RAD_F32, {g.max_logit_rows, 1});
|
||||
/* One row per drafting sequence, even if verification or KLD needs many more target
|
||||
* logits rows. mtp_dsum is quant_act_i8's group-major [n_embd/128][ceil(M/16)*16]. */
|
||||
if (draft_q2 && !calib_mtp_layer) {
|
||||
const int64_t dmpad = ((g.max_seqs + 15) / 16) * 16;
|
||||
m.b_mtp_dq = decl_b(b, nm.f("mtp_dq"), RAD_I8, {g.max_seqs, g.n_embd});
|
||||
m.b_mtp_ds = decl_b(b, nm.f("mtp_ds"), RAD_F32, {g.max_seqs, 1});
|
||||
m.b_mtp_dsum = decl_b(b, nm.f("mtp_dsum"), RAD_F32, {g.n_embd / 128, dmpad});
|
||||
m.b_mtp_dlog = decl_b(b, nm.f("mtp_dlog"), g.act_dtype, {g.max_logit_rows, g.n_vocab_all});
|
||||
m.b_mtp_dlog = decl_b(b, nm.f("mtp_dlog"), g.act_dtype, {g.max_seqs, g.n_vocab_all});
|
||||
/* A draft round's proposal comes out of row_topk here, never through the sampler's
|
||||
* token buffer. */
|
||||
m.b_mtp_didx = decl_b(b, nm.f("mtp_didx"), RAD_I32, {g.max_logit_rows, 1});
|
||||
m.b_mtp_dval = decl_b(b, nm.f("mtp_dval"), RAD_F32, {g.max_logit_rows, 1});
|
||||
m.b_mtp_didx = decl_b(b, nm.f("mtp_didx"), RAD_I32, {g.max_seqs, pitch});
|
||||
m.b_mtp_dval = decl_b(b, nm.f("mtp_dval"), RAD_F32, {g.max_seqs, pitch});
|
||||
}
|
||||
|
||||
/* The head reuses the trunk's working buffers (`attn_qg`, `attn_k`, the ffn planes, `h`),
|
||||
@@ -1318,6 +1351,11 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
tw.dq = m.b_mtp_dq; tw.ds = m.b_mtp_ds; tw.dsum = m.b_mtp_dsum;
|
||||
tw.dlog = m.b_mtp_dlog; tw.didx = m.b_mtp_didx; tw.dval = m.b_mtp_dval;
|
||||
tw.attn = tw_attn; tw.mlp = tw_mlp;
|
||||
tw.coupled = !calib_mtp_layer && ctx->draft_coupling != 0;
|
||||
if (calib_mtp_layer) {
|
||||
tw.calib_dir = ctx->calib_dir;
|
||||
tw.calib_tokens = ctx->calib_tokens;
|
||||
}
|
||||
|
||||
MtpHead::Src ts{};
|
||||
ts.fc = nm.ckpt("mtp.fc.weight");
|
||||
@@ -1349,10 +1387,6 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
ts.mlp.up = nm.ckpt("mtp.layers.0.mlp.up_proj.weight");
|
||||
ts.mlp.down = nm.ckpt("mtp.layers.0.mlp.down_proj.weight");
|
||||
#endif
|
||||
/* The trunk maps this same tensor as `output.weight`; the draft head maps it again under a
|
||||
* name of its own, which the recipe quantises to two bits (mtp_draft_head_q2). */
|
||||
ts.lm = nm.ckpt("lm_head.weight");
|
||||
|
||||
/* Bound as one more layer of the trunk's full-attention group, at absolute index n_main,
|
||||
* so a draft round writes its K and V at the slot of the trunk's token for that position.
|
||||
* A rejected draft is then overwritten rather than rolled back (rad_block_mtp_fp8.h). */
|
||||
@@ -1362,15 +1396,14 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
m.w_lm_head, final_wadd, tw, ts));
|
||||
m.have_mtp = true;
|
||||
|
||||
/* Serial drafter: `max_spec` dependent passes, each embedding the last one's proposal.
|
||||
* The 2-bit head writes its own argmax into `mtp_didx`; without it `mtp_didx` is 0 and the
|
||||
* bf16 head goes through the ordinary sampler chain. */
|
||||
/* A U2 drafter writes a greedy or coupled proposal to column zero. The BF16 fallback
|
||||
* uses the ordinary sampler. Calibration carries no projection, proposal or draft depth. */
|
||||
RadDrafterDecl dd{};
|
||||
dd.name = "mtp";
|
||||
dd.kind = RAD_DRAFT_SERIAL;
|
||||
dd.kind = calib_mtp_layer ? RAD_DRAFT_HISTORY : RAD_DRAFT_SERIAL;
|
||||
dd.depth = ctx->max_spec;
|
||||
dd.proposal = m.b_mtp_didx;
|
||||
dd.proposal_pitch = 1;
|
||||
dd.proposal_pitch = calib_mtp_layer ? 0 : pitch;
|
||||
dd.mask_token = -1;
|
||||
RAD_ARCH_TRY(rad_declare_drafter(b, &dd));
|
||||
}
|
||||
@@ -1418,7 +1451,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
rad_note(b, "MTP head: the first of %lld NextN layer(s) under `mtp.`, as absolute layer "
|
||||
"%lld of the full-attention KV group",
|
||||
(long long)nextn, (long long)m.n_main);
|
||||
else if (nextn > 0)
|
||||
else if (want_mtp && m.n_vcls)
|
||||
rad_note(b, "no native MTP: this split-head container has no independent U2 draft head");
|
||||
else if (nextn > 0 && !m.have_df)
|
||||
rad_note(b, "the %lld MTP/NextN layer(s) under `mtp.` are not loaded: this deployment "
|
||||
"does not speculate", (long long)nextn);
|
||||
|
||||
|
||||
@@ -114,11 +114,35 @@ using namespace rad::arch;
|
||||
* and 13.17): a read here pays ~2 us of launch for what it saves. */
|
||||
constexpr int64_t kGdnOutPrefetchBytes = (int64_t)8 << 20;
|
||||
constexpr int64_t kGdnOutPrefetchSeqs = 4;
|
||||
/* The rows from which a decode step is taken for a speculative verify, a step of several rows:
|
||||
* where the shared arm's place and the reads' workgroup count below help, against the one row of
|
||||
* a plain decode step, where both cost. ms a step at tp 2 with coupling, in one server with the
|
||||
* rounds interleaved, at two / three / four rows (chain 1 / 2 / 3) and at one: the arm's down
|
||||
* projection in front -0.28% / -0.21% / -0.25% and +0.38%; the reads at 32 workgroups -0.65% /
|
||||
* -0.35% / -0.31% and +0.41%. */
|
||||
constexpr int64_t kVerifyRows = 2;
|
||||
/* A full-attention layer's out projection likewise, read behind its q, k and v projections
|
||||
* (AttnGatedFP8::op_pf_o): the prologue and the attention between them and the projection are
|
||||
* short launches with the memory idle. Twelve layers, so less: five interleaved rounds, ms a step
|
||||
* without -> with, one stream 12.51 -> 12.45 (every round), two 16.88 -> 16.85. */
|
||||
constexpr int64_t kAttnOutPrefetchBytes = (int64_t)8 << 20;
|
||||
/* The workgroups of this model's weight reads on a verify step (the `prefetch` op's `blocks`, from
|
||||
* kVerifyRows rows): 32, half the kernel's own 64. The reads run beside the delta net's update,
|
||||
* the attention's prologue and the connections' reductions, all latency-bound kernels of a few
|
||||
* loads a block whose loads queue behind the read's, and at four rows the update lasts half again
|
||||
* as long as at one, so a slower read still lands. Chain 3 with coupling at tp 2, ms a step
|
||||
* against 64 in one server, interleaved: 16 +0.77%, 24 +0.14%, 32 -0.31%, 48 -0.24%, 128 +2.0%,
|
||||
* 256 +7.4%; -0.6% at 32 with the router's read beside. A one-row step keeps 64 (kVerifyRows). */
|
||||
constexpr int64_t kPrefetchBlocksVerify = 32;
|
||||
/* A layer's router likewise, read behind its mixer's out projection, beside the mixer's reduction
|
||||
* and the feed-forward's connection read (both latency, with the card's memory mostly idle): the
|
||||
* router is 2.5 MB of bf16 that its GEMM otherwise streams cold in front of a top-k that waits for
|
||||
* all of it. Chain 3 with coupling at tp 2, ms a step without -> with, each the mean of two
|
||||
* interleaved rounds in one server: 12.19 -> 12.13 (-0.42% and -0.93%); 12.14 -> 12.09 in another
|
||||
* session. The same read of the shared expert's two weights, or of the indexer's projection, moved
|
||||
* nothing (-0.02%, -0.04%, +0.04%), and of the mixer's first projection in front of its
|
||||
* connection read cost 1.0%: a read there takes the memory from the connection's own. */
|
||||
constexpr int64_t kRouterPrefetchBytes = (int64_t)4 << 20;
|
||||
|
||||
struct Layer {
|
||||
int full = 0;
|
||||
@@ -136,6 +160,11 @@ struct Layer {
|
||||
/* The layer's calibration inputs (rad_calib_full.h, site_i8), -1 where this run records none:
|
||||
* the mixer's input (the delta net's in projection, or q, k and v) and its output projection's. */
|
||||
int cs_in = -1, cs_o = -1;
|
||||
/* The router's weight read beside the mixer's reduction (kRouterPrefetchBytes); 0 where the
|
||||
* deployment reads no weights ahead. */
|
||||
rad_op op_pf_router = 0;
|
||||
/* The same at a verify step's workgroup count (kPrefetchBlocksVerify), from kVerifyRows rows. */
|
||||
rad_op op_pf_router_v = 0;
|
||||
};
|
||||
|
||||
struct Model {
|
||||
@@ -224,6 +253,16 @@ struct Model {
|
||||
* from the real declare, so it declares the same ops. */
|
||||
bool span_on = false;
|
||||
bool pipe_on = false;
|
||||
/* The rows of a piece of a spanned step: one checkpoint interval's, what the routed block's
|
||||
* pass is without --prefill-span-pass step (`moecfg.rows`). The connections' reads, the
|
||||
* indexer's windows, the delta net's pieces and the pipelined step's pieces are a piece tall
|
||||
* whatever the routed pass is. */
|
||||
int64_t piece_rows = 0;
|
||||
/* --prefill-span-pass step (RadBuildCtx::span_pass_step) on a deployment that spans and does
|
||||
* not pipeline: the routed block's pass is the whole step (`moecfg.rows` is max_tok), so a
|
||||
* spanned step sorts its slots once and each expert's run is the step's. A sizing declare
|
||||
* takes it from the real one, as span_on. */
|
||||
bool pass_step = false;
|
||||
/* {0, pass, T} for a step wider than a pass (pipe_bounds): the windows of the indexer's score
|
||||
* plane and the delta net's pieces. A transient (declare), uploaded by every step that reads
|
||||
* it -- the first two from the pinned host copy `pipe_cu_h`, made once. */
|
||||
@@ -235,6 +274,9 @@ struct Model {
|
||||
|
||||
rad_weight w_tok = 0, w_lm_head = 0;
|
||||
rad_op op_embed = 0, op_embed_ar = 0, op_rope_cs = 0, op_gather = 0, op_logits = 0;
|
||||
/* The indexer's within-step buffers store_keys touches are excluded from sharing (declare),
|
||||
* so a layer's keys may be issued behind its attention's launches (step_serial, QsaSide). */
|
||||
bool qsa_defer = false;
|
||||
|
||||
/* ---- media (arch/common/rad_block_vit.h): the vision tower and the scatter of its rows over
|
||||
* the token embeddings, declared only when the container carries a tower and the deployment
|
||||
@@ -484,6 +526,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* prefill chunk to, so the shipped configuration is one pass. It also sizes four buffers at
|
||||
* `rows * top_k`, so a smaller max_tok lowers it. */
|
||||
mc.rows = g.max_tok < 2048 ? g.max_tok : 2048;
|
||||
/* A piece of a spanned step; `mc.rows` itself grows to the step under
|
||||
* --prefill-span-pass step (below, once the span is known). */
|
||||
m.piece_rows = mc.rows;
|
||||
if (mc.n_expert <= 0 || mc.top_k <= 0 || mc.top_k > mc.n_expert) {
|
||||
fprintf(stderr, "radiance: qwen4exp: the container describes %lld expert(s) with "
|
||||
"top_k %lld\n", (long long)mc.n_expert, (long long)mc.top_k);
|
||||
@@ -774,21 +819,42 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
const int64_t v_dim = m.gcfg.v_dim();
|
||||
const int64_t conv_dim = m.gcfg.conv_dim();
|
||||
const int64_t T = g.max_tok;
|
||||
const int64_t ER = m.moecfg.rows * m.moecfg.top_k;
|
||||
|
||||
m.b_h = decl_b(b, nm.f("h_wide"), g.act_dtype, {T, HN});
|
||||
m.a_x.x = decl_b(b, nm.f("x"), g.act_dtype, {T, g.n_embd});
|
||||
if (ctx->shape_probe) {
|
||||
m.span_on = g_model[rad_build_slot(ctx)].span_on;
|
||||
m.pipe_on = g_model[rad_build_slot(ctx)].pipe_on;
|
||||
m.span_on = g_model[rad_build_slot(ctx)].span_on;
|
||||
m.pipe_on = g_model[rad_build_slot(ctx)].pipe_on;
|
||||
m.pass_step = g_model[rad_build_slot(ctx)].pass_step;
|
||||
} else {
|
||||
m.span_on = ctx->max_mixed_tok > 0 && ctx->max_mixed_tok < g.max_tok &&
|
||||
g.max_tok > m.moecfg.rows;
|
||||
g.max_tok > m.piece_rows;
|
||||
/* Only where the blocks issue their own all-reduce at a step wider than a pass: at two
|
||||
* ranks the gated residual's fused write takes every step's (ar_exact_write_rows), so such
|
||||
* a step runs serially. */
|
||||
m.pipe_on = m.span_on && g.world > 1 && ar_exact_write_rows(g) < g.max_tok;
|
||||
/* --prefill-span-pass step, where a spanned step runs serially: nothing there needs the
|
||||
* routed pass to be a piece (the pipelined step overlaps a piece's pass with the other
|
||||
* piece's all-reduce, and keeps them), and a pass over the whole step reads each expert's
|
||||
* weight once for two or four times the rows. A calibration run keeps its pieces: its
|
||||
* statistics are taken a pass at a time. */
|
||||
m.pass_step = ctx->span_pass_step != 0 && m.span_on && !m.pipe_on && !m.moecfg.calib;
|
||||
if (ctx->span_pass_step != 0 && !m.pass_step && g.rank == 0)
|
||||
rad_note(b, "--prefill-span-pass step: the routed pass stays one checkpoint interval "
|
||||
"(%s)", !m.span_on ? "this deployment has no step wider than an interval"
|
||||
: m.pipe_on ? "a spanned step is pipelined here, a pass a piece "
|
||||
"beside the other piece's all-reduce"
|
||||
: "a calibration run takes its statistics a pass at a "
|
||||
"time");
|
||||
}
|
||||
/* Every op of a pass is per row, but the grouped trellis GEMM takes a run of one or two rows
|
||||
* through its dot path and a longer one through its tiles, which agree only within f32
|
||||
* rounding before the bf16 store: the step's longer runs move rows between the two, so the
|
||||
* bytes are not those of piece-tall passes (the class of difference another chunk size makes,
|
||||
* GUIDE 4.5). The planes below at `rows * top_k` grow with it. A sizing declare's max_tok is
|
||||
* its level's, so a level holds one pass of its own rows. */
|
||||
if (m.pass_step) m.moecfg.rows = g.max_tok;
|
||||
const int64_t ER = m.moecfg.rows * m.moecfg.top_k;
|
||||
/* The pipelined step's all-reduces run on the second lane, in place over `x`, so it is the one
|
||||
* buffer that lane touches; it is live over the whole program anyway. */
|
||||
if (m.pipe_on) RAD_ARCH_TRY(rad_buf_concurrent(b, m.a_x.x));
|
||||
@@ -801,7 +867,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* Under a span every connection reads a step wider than a pass a pass at a time
|
||||
* (HyperConn::read_pieces, and the pipelined step's own reads), so the reads are declared no
|
||||
* wider than a pass and their scratch is sized for that band. */
|
||||
if (m.span_on) m.hccfg.read_rows = m.moecfg.rows;
|
||||
if (m.span_on) m.hccfg.read_rows = m.piece_rows;
|
||||
RAD_ARCH_TRY(m.a_x.declare_qs(b, nm, g, "x", g.n_embd, 0, m.trunk_i8));
|
||||
/* The connections write int8 codes themselves when every reader of their codes is an int8
|
||||
* linear: the trunk's are, and the routed experts then read the rotated copy or the bf16
|
||||
@@ -810,9 +876,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* A read's rotated copy takes its plain codes' dtype, so beside int8 codes the routed arm is
|
||||
* int8 too: the experts read had_quant_act_i8g's codes through the grouped GEMM's int8 rows
|
||||
* (MoeFP8::a8), which the rotated four-bit plane, the codebook at E4M3 scales a 64 or 32 of K
|
||||
* and rotated int8 experts have. The codebook at a bf16 scale a 128 and the five-bit one do
|
||||
* not: under them the connections keep E4M3 codes, as for unrotated experts. */
|
||||
const bool exp8 = m.moecfg.expert_rot && !m.moecfg.expert_w5 &&
|
||||
* and rotated int8 experts have. The codebook at a bf16 scale a 128 and the five- and six-bit
|
||||
* ones do not: under them the connections keep E4M3 codes, as for unrotated experts. */
|
||||
const bool exp8 = m.moecfg.expert_rot && !m.moecfg.expert_w5 && !m.moecfg.expert_w6 &&
|
||||
(!m.moecfg.expert_nl || m.moecfg.expert_g64);
|
||||
m.hccfg.codes_i8 = (m.trunk_i8 && (exp8 || m.moecfg.expert_bf16)) ? 1 : 0;
|
||||
m.a_x.q8_fed = m.hccfg.codes_i8 != 0;
|
||||
@@ -862,8 +928,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* pass (QsaIndexer::step, with the bounds in b_pipe_cu). The plane is the largest buffer
|
||||
* the span would otherwise grow, max_ctx / ratio floats a query row (512 MiB more at 4096
|
||||
* rows and 256K of context). */
|
||||
const int64_t qsa_rows = (m.span_on && ctx->max_mixed_tok <= m.moecfg.rows)
|
||||
? m.moecfg.rows : g.max_tok;
|
||||
const int64_t qsa_rows = (m.span_on && ctx->max_mixed_tok <= m.piece_rows)
|
||||
? m.piece_rows : g.max_tok;
|
||||
m.qsacfg.plane_rows = qsa_rows < g.max_tok ? qsa_rows : 0;
|
||||
/* One row per query, not per sequence (arch/common/rad_qsa.h). The score plane is the
|
||||
* only buffer whose size is the product of two deployment bounds, so an oversized one is
|
||||
@@ -884,6 +950,18 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
{ g.max_tok, m.qsacfg.topk + 1 });
|
||||
m.qsaw.nsel = decl_b(b, nm.f("qsa_nsel"), RAD_I32, { g.max_tok });
|
||||
m.qsaw.sequ = decl_b(b, nm.f("qsa_sequ"), RAD_I32, { g.max_tok });
|
||||
if (m.qsaw.qk && m.qsaw.stage && m.qsaw.page && m.qsaw.bpos && m.qsaw.nc) {
|
||||
/* What store_keys reads and writes is in use behind the attention's launches when a
|
||||
* layer's keys are deferred behind them (QsaSide), past the last use the linear order
|
||||
* gives these buffers, so the planner must not lay an attention buffer over them.
|
||||
* A few MiB of arena (qk is the largest, max_tok x 640 bf16). */
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.qsaw.qk));
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.qsaw.stage));
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.qsaw.page));
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.qsaw.bpos));
|
||||
RAD_ARCH_TRY(rad_buf_concurrent(b, m.qsaw.nc));
|
||||
m.qsa_defer = true;
|
||||
}
|
||||
if (!m.qsaw.qk || !m.qsaw.q || !m.qsaw.stage || !m.qsaw.page ||
|
||||
!m.qsaw.bpos || !m.qsaw.nc || !m.qsaw.score || !m.qsaw.sel || !m.qsaw.nsel ||
|
||||
!m.qsaw.sequ)
|
||||
@@ -936,8 +1014,11 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
if (m.arm8) {
|
||||
/* The int8 routed arm's two pairs, rotated at a scale a 128 and written by their
|
||||
* producers: the gated product's by gated_had_quant_i8g, the input's by the read. */
|
||||
RAD_ARCH_TRY(m.a_eff.declare_qs(b, nm, g, "moe_eff", m.moecfg.n_ff_exp, ER, true, false,
|
||||
RAD_FP8_BLOCK));
|
||||
/* A trellis gate_up may be paired with a codebook (W5NL, W6NL) down. Keep its E4M3 pair
|
||||
* as well so that the gated intermediate can use the down projection's own activation
|
||||
* format. */
|
||||
RAD_ARCH_TRY(m.a_eff.declare_qs(b, nm, g, "moe_eff", m.moecfg.n_ff_exp, ER, true,
|
||||
m.moecfg.expert_iqr != 0, RAD_FP8_BLOCK));
|
||||
m.a_eff.q8_fed = m.a_eff.q8_rot = true;
|
||||
if (!m.trunk_rot) {
|
||||
RAD_ARCH_TRY(m.a_hr.declare_qs(b, nm, g, "moe_hr", g.n_embd, 0, true, false,
|
||||
@@ -1170,10 +1251,17 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
lay.attn.qsa_nsel = m.qsaw.nsel;
|
||||
lay.attn.qsa_sequ = m.qsaw.sequ;
|
||||
lay.attn.qsa_topk = m.qsacfg.topk;
|
||||
/* The exactness bound, below which prefill issues the cheaper dense attention.
|
||||
* Decode ignores it and always takes the sparse path, keeping that path exercised
|
||||
* on every step. */
|
||||
/* The exactness bound, at or below which a step of several rows a sequence
|
||||
* (prefill, a verify) issues the cheaper dense attention. Plain decode keeps the
|
||||
* sparse row's launch at every context, so that kernel is exercised on every
|
||||
* step. */
|
||||
lay.attn.qsa_exact_to = m.qsacfg.budget + m.qsacfg.ratio - 1;
|
||||
/* At or below that bound the indexer scores nothing (AttnGatedFP8::qsa_use): a
|
||||
* row alone in its sequence is at the context's last position on this model (a
|
||||
* plain decode row; the core's and the card's `seqused` is its position + 1), and
|
||||
* pass_key() carries the exact bound's side of it. */
|
||||
lay.attn.qsa_table_rows = true;
|
||||
lay.attn.qsa_exact_host = true;
|
||||
}
|
||||
RAD_ARCH_TRY(rad_bind_layer_kv(b, (int)l, m.kv_full));
|
||||
/* An attention-zero rank keeps no attention cache: its block is a fill of zeros
|
||||
@@ -1238,6 +1326,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
|
||||
MoeFP8::Src ms{};
|
||||
ms.cfg = m.moecfg;
|
||||
/* The expert tap can be limited to selected layers (RADIANCE_CALIB_LAYERS), the MTP
|
||||
* layer below among them. The whole-expert placement m.moecfg.calib selects stays. */
|
||||
ms.cfg.calib = m.moecfg.calib && calib_layer_on((int)l);
|
||||
ms.router = nm.ckpt("%s.%lld.mlp.gate.weight", pre, (long long)l);
|
||||
RAD_ARCH_TRY(moe_expert_sources(b, nm, "layer",
|
||||
nm.ckpt("%s.%lld.mlp.experts", pre, (long long)l), &ms));
|
||||
@@ -1313,6 +1404,20 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
RAD_ARCH_TRY(m.mixer.declare(b, nm, g, nm.f("output_hc"), mc, mixw, mixs));
|
||||
}
|
||||
|
||||
/* ---- the issue order of a decode step's small launches (AttnGatedFP8::kv_first_rows,
|
||||
* MoeFP8::sh_down_first_lo): at decode and verify heights the k and v projections go in
|
||||
* front of the q|gate projection, and from kVerifyRows rows the shared down projection in
|
||||
* front of the routed down GEMM, so the card launches the small ones while the wide one is
|
||||
* still being placed. The same kernels on the same operands; only what a recorded pass
|
||||
* starts first changes. */
|
||||
{
|
||||
for (Layer& lay : m.layers) {
|
||||
if (lay.full) lay.attn.kv_first_rows = kPrefetchRows;
|
||||
lay.mlp.sh_down_first_lo = kVerifyRows;
|
||||
lay.mlp.sh_down_first_hi = kPrefetchRows;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- the delta nets' out projections, read beside their decode recurrent updates
|
||||
* (kGdnOutPrefetchBytes), and the full-attention layers' beside the attention
|
||||
* (kAttnOutPrefetchBytes). At more than one rank; --weight-prefetch off declares none. */
|
||||
@@ -1320,11 +1425,23 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
for (Layer& lay : m.layers) {
|
||||
if (lay.full) {
|
||||
lay.attn.op_pf_o = decl_prefetch(b, lay.attn.o.w, kAttnOutPrefetchBytes);
|
||||
lay.attn.op_pf_o_v = decl_prefetch(b, lay.attn.o.w, kAttnOutPrefetchBytes,
|
||||
kPrefetchBlocksVerify);
|
||||
lay.attn.pf_o_v_rows = kVerifyRows;
|
||||
continue;
|
||||
}
|
||||
lay.gdn.op_pf_out = decl_prefetch(b, lay.gdn.out.w, kGdnOutPrefetchBytes);
|
||||
lay.gdn.pf_out_rows = kPrefetchRows;
|
||||
lay.gdn.pf_out_seqs = kGdnOutPrefetchSeqs;
|
||||
lay.gdn.op_pf_out_v = decl_prefetch(b, lay.gdn.out.w, kGdnOutPrefetchBytes,
|
||||
kPrefetchBlocksVerify);
|
||||
lay.gdn.pf_out_v_rows = kVerifyRows;
|
||||
}
|
||||
for (Layer& lay : m.layers) {
|
||||
if (!lay.mlp.w_router) continue;
|
||||
lay.op_pf_router = decl_prefetch(b, lay.mlp.w_router, kRouterPrefetchBytes);
|
||||
lay.op_pf_router_v = decl_prefetch(b, lay.mlp.w_router, kRouterPrefetchBytes,
|
||||
kPrefetchBlocksVerify);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,6 +1579,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
ts.attn.o = nm.ckpt("%s.layers.0.self_attn.o_proj.weight", mpre);
|
||||
|
||||
ts.mlp.cfg = m.moecfg;
|
||||
ts.mlp.cfg.calib = m.moecfg.calib && calib_layer_on((int)g.n_layer);
|
||||
ts.mlp.router = nm.ckpt("%s.layers.0.mlp.gate.weight", mpre);
|
||||
RAD_ARCH_TRY(moe_expert_sources(b, nm, "mtp", nm.ckpt("%s.layers.0.mlp.experts", mpre),
|
||||
&ts.mlp));
|
||||
@@ -1473,12 +1591,20 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
/* Set before declare(), as for the trunk: `attn_paged` declares `sel` and `seqused` as
|
||||
* reads, which must precede the op. */
|
||||
m.mtp.attn.kv_block = 4;
|
||||
/* The head's layer takes the trunk's issue order at decode heights (declare, above). */
|
||||
m.mtp.attn.kv_first_rows = kPrefetchRows;
|
||||
m.mtp.mlp.sh_down_first_lo = kVerifyRows;
|
||||
m.mtp.mlp.sh_down_first_hi = kPrefetchRows;
|
||||
if (m.qsaw.qk) {
|
||||
m.mtp.attn.qsa_sel = m.qsaw.sel;
|
||||
m.mtp.attn.qsa_nsel = m.qsaw.nsel;
|
||||
m.mtp.attn.qsa_sequ = m.qsaw.sequ;
|
||||
m.mtp.attn.qsa_topk = m.qsacfg.topk;
|
||||
m.mtp.attn.qsa_exact_to = m.qsacfg.budget + m.qsacfg.ratio - 1;
|
||||
/* As the trunk's layers: a round's row is the head's context's last position
|
||||
* (ADV_ROUND), and the history pass is one row only where it commits one. */
|
||||
m.mtp.attn.qsa_table_rows = true;
|
||||
m.mtp.attn.qsa_exact_host = true;
|
||||
ts.qsa = m.qsacfg;
|
||||
ts.qsa.mode = m.mtp.attn.mode;
|
||||
ts.qsa.qk_proj = nm.ckpt("%s.layers.0.self_attn.indexer.index_qk_proj.weight", mpre);
|
||||
@@ -1562,7 +1688,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
* of the sharing pool (declare). The collectives there are declared at `overlap` 1, whose rows
|
||||
* leave the CUs to the work beside them. */
|
||||
static bool pipelined(const Model& m, int64_t T) {
|
||||
const int64_t R = m.moecfg.rows;
|
||||
const int64_t R = m.piece_rows;
|
||||
if (!m.pipe_on || R <= 0 || T <= R) return false;
|
||||
if (m.moecfg.calib || m.calib.on || dbg_resid_on() || !m.op_embed_ar) return false;
|
||||
for (const Layer& l : m.layers) {
|
||||
@@ -1600,7 +1726,7 @@ static const int32_t* pipe_bounds(RadCtx* c, const RadBatch* batch, Model& m) {
|
||||
m.pipe_cu_h = (int32_t*)rad_dev_alloc(2 * sizeof(int32_t), RAD_MEM_HOST_PINNED);
|
||||
if (m.pipe_cu_h) {
|
||||
m.pipe_cu_h[0] = 0;
|
||||
m.pipe_cu_h[1] = (int32_t)m.moecfg.rows;
|
||||
m.pipe_cu_h[1] = (int32_t)m.piece_rows;
|
||||
} else if (m.g.rank == 0) {
|
||||
fprintf(stderr, "radiance: qwen4exp: no pinned host memory for the window bounds; a "
|
||||
"step wider than a pass cannot run\n");
|
||||
@@ -1608,7 +1734,7 @@ static const int32_t* pipe_bounds(RadCtx* c, const RadBatch* batch, Model& m) {
|
||||
}
|
||||
if (!m.pipe_cu_h) return nullptr;
|
||||
int32_t* d = (int32_t*)rad_buf_ptr(c, m.b_pipe_cu);
|
||||
if (batch->n_tok > m.moecfg.rows && batch->n_seq == 1) {
|
||||
if (batch->n_tok > m.piece_rows && batch->n_seq == 1) {
|
||||
const RadStream s = rad_stream(c);
|
||||
if (rad_memcpy_async(d, m.pipe_cu_h, 2 * sizeof(int32_t), s) != RAD_OK ||
|
||||
rad_memcpy_async(d + 2, batch->cu_seqlens + 1, sizeof(int32_t), s) != RAD_OK)
|
||||
@@ -1619,7 +1745,7 @@ static const int32_t* pipe_bounds(RadCtx* c, const RadBatch* batch, Model& m) {
|
||||
|
||||
static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int32_t* pcu) {
|
||||
const Geom& g = m.g;
|
||||
const int64_t T = batch->n_tok, R = m.moecfg.rows;
|
||||
const int64_t T = batch->n_tok, R = m.piece_rows;
|
||||
const int64_t K = (T + R - 1) / R;
|
||||
auto r0 = [&](int64_t p) { return p * R; };
|
||||
auto rn = [&](int64_t p) { return T - p * R < R ? T - p * R : R; };
|
||||
@@ -1652,7 +1778,8 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
|
||||
|
||||
/* The delta net runs a piece at a time over the bounds (ArPieces::cu) in a step of one
|
||||
* prefill sequence in two pieces. */
|
||||
const int32_t* gcu = pcu && K == 2 && batch->n_seq == 1 && batch->phase == RAD_PHASE_PREFILL
|
||||
const int32_t* gcu = pcu && K == 2 && batch->n_seq == 1 && batch->phase == RAD_PHASE_PREFILL &&
|
||||
batch->ckpt_cut <= 0
|
||||
? pcu : nullptr;
|
||||
|
||||
const int64_t n = (int64_t)m.layers.size();
|
||||
@@ -1660,6 +1787,9 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
|
||||
if (m.ple_layer == 0) m.ple.step(c, batch);
|
||||
for (int64_t p = 0; p < K; ++p) m.layers[0].hc_mix.read(c, T, r0(p), rn(p));
|
||||
}
|
||||
/* The pass's first full-attention layer with an indexer makes what every such layer shares of
|
||||
* its step (QsaIndexer::step, `first`). */
|
||||
bool qsa_first = true;
|
||||
for (int64_t li = 0; li < n; ++li) {
|
||||
const Layer& l = m.layers[(size_t)li];
|
||||
/* The mixer finishes its output a piece at a time where its last stages are per row and
|
||||
@@ -1668,7 +1798,11 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
|
||||
MixAr ms{c, &l};
|
||||
ArPieces pc{};
|
||||
pc.rows = R; pc.done = mix_ar_piece; pc.u = &ms; pc.cu = gcu;
|
||||
if (l.full) { l.qsa.step(c, l.attn.w.h, batch, pcu); l.attn.step(c, batch, false, &pc); }
|
||||
if (l.full) {
|
||||
l.qsa.step(c, l.attn.w.h, batch, pcu, l.attn.qsa_use(batch), qsa_first);
|
||||
if (l.qsa.on()) qsa_first = false;
|
||||
l.attn.step(c, batch, false, &pc);
|
||||
}
|
||||
else l.gdn.step(c, batch, false, &pc);
|
||||
auto ar_mix = [&](int64_t p) {
|
||||
if (l.full) l.attn.issue_ar(c, r0(p), rn(p));
|
||||
@@ -1713,6 +1847,18 @@ static void step_pipelined(RadCtx* c, const RadBatch* batch, Model& m, const int
|
||||
}
|
||||
}
|
||||
|
||||
/* A full-attention layer's indexer keys behind its attention's launches (QsaIndexer::deferrable,
|
||||
* SideOps): store_keys's three stages in turn, one a call, and whatever is left at flush(). */
|
||||
struct QsaSide {
|
||||
RadCtx* c = nullptr;
|
||||
const QsaIndexer* q = nullptr;
|
||||
const RadBatch* batch = nullptr;
|
||||
int next = 1;
|
||||
void one() { if (next <= 3) q->step_part(c, batch, next++); }
|
||||
void flush() { while (next <= 3) one(); }
|
||||
static void at(void* u, int) { ((QsaSide*)u)->one(); }
|
||||
};
|
||||
|
||||
/* The trunk one stream at a time over the whole step: every step a span of 1 makes, and every
|
||||
* other where step_pipelined's conditions do not hold. */
|
||||
static void step_serial(RadCtx* c, const RadBatch* batch, Model& m, const int32_t* pcu) {
|
||||
@@ -1733,22 +1879,50 @@ static void step_serial(RadCtx* c, const RadBatch* batch, Model& m, const int32_
|
||||
if (m.op_rope_cs && T <= qk_fuse_rows(g) && !rope_mixed(batch))
|
||||
RAD_ISSUE_N(c, m.op_rope_cs, T, rope_pos1(batch, T), RAD_B(m.b_rope_cs));
|
||||
|
||||
/* The pass's first full-attention layer with an indexer makes what every such layer shares of
|
||||
* its step (QsaIndexer::step, `first`). */
|
||||
bool qsa_first = true;
|
||||
for (int64_t li = 0; li < (int64_t)m.layers.size(); ++li) {
|
||||
const Layer& l = m.layers[(size_t)li];
|
||||
/* Before the attention connection reads the stream, which is where the reference puts it. */
|
||||
if (li == m.ple_layer) m.ple.step(c, batch);
|
||||
l.hc_mix.read_pieces(c, T);
|
||||
/* A checkpoint inside the step (RadBatch::ckpt_cut) cuts the reads' pieces there. */
|
||||
l.hc_mix.read_pieces(c, T, batch->ckpt_cut);
|
||||
/* The calibration taps read the codes the mixer's GEMMs read: its input before it runs,
|
||||
* its output projection's input before the feed-forward's connection reuses the pair. */
|
||||
if (l.cs_in >= 0) m.calib.tap(c, (size_t)l.cs_in, T);
|
||||
/* The indexer runs first, since the attention reads its selection. The block's input is
|
||||
* already normed and quantised by the connection (`ext_in`), so `w.h` is final. */
|
||||
if (l.full) { l.qsa.step(c, l.attn.w.h, batch, pcu); l.attn.step(c, batch); }
|
||||
if (l.full) {
|
||||
const int use = l.attn.qsa_use(batch);
|
||||
/* At decode heights within the exactness bound nothing of the layer reads the
|
||||
* indexer's keys or tail (they are for later steps), so only the projection stays in
|
||||
* front, beside the attention's own, and the three launches behind it ride behind the
|
||||
* attention's (QsaSide) instead of holding its projections back in turn: -0.3% to
|
||||
* -0.8% a step on chain 3 with coupling at tp 2. */
|
||||
if (m.qsa_defer && T <= kPrefetchRows && batch->phase == RAD_PHASE_DECODE &&
|
||||
l.qsa.deferrable(batch, use, qsa_first)) {
|
||||
QsaSide sd{c, &l.qsa, batch};
|
||||
const SideOps so{QsaSide::at, &sd};
|
||||
l.qsa.step_proj(c, l.attn.w.h, batch);
|
||||
l.attn.step(c, batch, true, nullptr, &so);
|
||||
sd.flush();
|
||||
} else {
|
||||
l.qsa.step(c, l.attn.w.h, batch, pcu, use, qsa_first);
|
||||
l.attn.step(c, batch);
|
||||
}
|
||||
if (l.qsa.on()) qsa_first = false;
|
||||
}
|
||||
else l.gdn.step(c, batch);
|
||||
if (l.cs_o >= 0) m.calib.tap(c, (size_t)l.cs_o, T);
|
||||
/* The router's weight, read beside the write's reduction and the read behind it. */
|
||||
if (batch->phase == RAD_PHASE_DECODE)
|
||||
prefetch_beside(c, l.op_pf_router_v && T >= kVerifyRows ? l.op_pf_router_v
|
||||
: l.op_pf_router,
|
||||
l.mlp.w_router, T);
|
||||
l.hc_mix.write(c, T, 0, T);
|
||||
dbg_resid(c, (int)li, "mix", g.n_embd, m.b_h, m.a_x.x);
|
||||
l.hc_ffn.read_pieces(c, T);
|
||||
l.hc_ffn.read_pieces(c, T, batch->ckpt_cut);
|
||||
l.mlp.step(c, batch);
|
||||
l.hc_ffn.write(c, T, 0, T);
|
||||
/* The request's control vector, on the stream the write just finished. */
|
||||
@@ -1821,23 +1995,37 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) {
|
||||
if (!c || !batch) return 0;
|
||||
if (batch->enc) return 1;
|
||||
Model& m = g_model[rad_slot(c)];
|
||||
/* Which side of the indexer's exactness bound the step is on by the attention group's exact
|
||||
* host bound, by which the full-attention layers and the indexer decide whether the step
|
||||
* needs scores (AttnGatedFP8::qsa_within, qsa_exact_host). The core's key holds only the
|
||||
* rounded context bound, so the side is keyed here: one more recording of each pass kind as a
|
||||
* request crosses the bound. `sel` is 2 within the bound and 0 past it or where it is
|
||||
* unknown, which is where the blocks fall back to the rounded bound the core keys. */
|
||||
uint64_t sel = 0;
|
||||
if (used_max_h && batch->kv && m.kv_full && m.qsacfg.budget > 0 && m.qsacfg.ratio > 0)
|
||||
for (int i = 0; i < batch->n_kv_groups; ++i)
|
||||
if (batch->kv[i].group == m.kv_full) {
|
||||
if (used_max_h[i] > 0 &&
|
||||
used_max_h[i] <= m.qsacfg.budget + m.qsacfg.ratio - 1) sel = 2;
|
||||
break;
|
||||
}
|
||||
/* A decode pass, a speculative verify or an MTP draft included, issues every launch at the
|
||||
* step's keyed context bound (RadArgs::kv_used_max_h), never the live maximum, so the core's
|
||||
* key holds its geometry. */
|
||||
if (batch->phase == RAD_PHASE_DECODE) return 1;
|
||||
if (batch->phase == RAD_PHASE_DECODE) return 1 | sel;
|
||||
/* Mixed batches split the query rows into decode and prefill subsets before attention, which
|
||||
* read the live maximum. The whole-batch host summary cannot key those subset geometries
|
||||
* exactly, nor a drafter's or a verify's rows inside a prefill pass. */
|
||||
if (batch->phase == RAD_PHASE_MIXED || batch->draft_pass != 0 || batch->n_spec > 0) return 0;
|
||||
|
||||
Model& m = g_model[rad_slot(c)];
|
||||
bool has_full_attention = false;
|
||||
for (const Layer& layer : m.layers) {
|
||||
if (!layer.full) continue;
|
||||
if (layer.attn.kv_block != 4) return 0;
|
||||
has_full_attention = true;
|
||||
}
|
||||
if (!has_full_attention) return 1;
|
||||
if (!has_full_attention) return 1 | sel;
|
||||
if (m.g.head_dim != 256 || (m.g.gqa() != 6 && m.g.gqa() != 12) || !m.kv_full ||
|
||||
!used_max_h || !batch->kv || batch->n_kv_groups <= 0)
|
||||
return 0;
|
||||
@@ -1863,7 +2051,10 @@ uint64_t pass_key(RadCtx* c, const RadBatch* batch, const int32_t* used_max_h) {
|
||||
const int bq = nwarps * 16 / m.g.gqa();
|
||||
const int splits = rad_prefill_splits_for_live(bq, tile, q_len, total_q, num_seqs,
|
||||
kv_heads, m.g.max_ctx, used, wgps);
|
||||
return rad_prefill_grid_key(q_len, bq, splits, kv_heads, num_seqs, nwarps * 32);
|
||||
const uint64_t grid = rad_prefill_grid_key(q_len, bq, splits, kv_heads, num_seqs, nwarps * 32);
|
||||
/* 0 stays "unknown"; the side of the bound rides in a bit the grid key's mix does not leave
|
||||
* meaningful, so two sides are two keys. */
|
||||
return grid ? ((grid << 2) | 1 | sel) : 0;
|
||||
}
|
||||
|
||||
static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
@@ -1881,6 +2072,11 @@ static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
* have chained forms: on two R9700 a full pass under the draft head went from 13.9 to 12.5 ms
|
||||
* and the step without the head from 9.98 to 9.17 ms at one sequence. */
|
||||
out->chain_pays = RAD_CHAIN_ALWAYS;
|
||||
/* A step of one prefill sequence with its checkpoint inside it (RadBatch::ckpt_cut): the delta
|
||||
* net runs its recurrence in two pieces and snapshots between them (rad_block_gdn_fp8.h), and
|
||||
* the connection reads cut their pieces at the checkpoint (HyperConn::read_pieces), so the
|
||||
* rows before it read what a chunk ending there reads. */
|
||||
out->ckpt_snap_ok = 1;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,16 @@ enum { kMaxLanes = 16 };
|
||||
* rounding (the driver's bound, core/gen/driver.cpp). */
|
||||
static inline int64_t ref_tokens_max() { return (int64_t)kRefArea / 256 * 11 / 10 + 64; }
|
||||
|
||||
/* Every output side is a multiple of 32, so attainable areas are multiples of four
|
||||
* latent tokens. Keep the model's original bounds when the operator supplies none. */
|
||||
static int64_t image_tokens(int64_t pixels) {
|
||||
return pixels > 0 ? std::min<int64_t>(kMaxImageTokens, pixels / 1024 * 4) : kMaxImageTokens;
|
||||
}
|
||||
|
||||
static int64_t reference_count(int64_t refs) {
|
||||
return refs > 0 ? std::min<int64_t>(refs, kMaxRefs) : kMaxRefs;
|
||||
}
|
||||
|
||||
static const char* kSysPrompt = "Comprehend and analyze the provided prompt.";
|
||||
|
||||
|
||||
@@ -120,6 +130,8 @@ enum : int {
|
||||
struct Model {
|
||||
Names nm{""};
|
||||
Geom gt{}, gd{}; /* the language model's and the DiT's geometry, per rank */
|
||||
int64_t max_image_tokens = kMaxImageTokens;
|
||||
int64_t max_refs = kMaxRefs;
|
||||
int64_t max_ref_rows = 0; /* every reference picture's latent tokens together */
|
||||
bool media = false;
|
||||
VisionTower vit{};
|
||||
@@ -426,8 +438,8 @@ static int declare_encoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
v.scope = "venc";
|
||||
v.down = true;
|
||||
v.first_group = kGrpVaeEnc;
|
||||
/* The largest picture the encoder reads: a repainted one at the largest output size. */
|
||||
v.base_px = (int64_t)kMaxImageTokens * 256;
|
||||
/* Repaint inputs match the output. References keep their own resize area. */
|
||||
v.base_px = std::max(m.max_image_tokens, ref_tokens_max()) * 256;
|
||||
const int64_t base = rad_meta_geti(meta, "vae.base_dim", 96);
|
||||
const std::vector<double> mult = meta_list(meta, "vae.dim_mult");
|
||||
const std::vector<double> td = meta_list(meta, "vae.temperal_downsample");
|
||||
@@ -474,16 +486,16 @@ static int declare_encoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
{ m.enc_q.buf }, { m.b_reflat, m.b_encz });
|
||||
/* A repainted picture's latent and its mask, into every lane its images run in. */
|
||||
m.op_lstore_lat = rw(b, RAD_OP(b, "lane_store",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, (int64_t)kMaxImageTokens),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.max_image_tokens),
|
||||
RAD_INT("n", zd),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_encz, m.b_inp }, { m.b_inp });
|
||||
m.op_lstore_mask = rw(b, RAD_OP(b, "lane_store",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, (int64_t)kMaxImageTokens),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.max_image_tokens),
|
||||
RAD_INT("n", 1),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", m.max_image_tokens),
|
||||
RAD_STR("dtype", "f32")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_mask }, { m.b_mask });
|
||||
@@ -497,7 +509,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
v.scope = "vdec";
|
||||
v.down = false;
|
||||
v.first_group = kGrpVaeDec;
|
||||
v.base_px = kMaxImageTokens;
|
||||
v.base_px = m.max_image_tokens;
|
||||
const int64_t base = rad_meta_geti(meta, "vae.decoder_base_dim", 144);
|
||||
const std::vector<double> mult = meta_list(meta, "vae.dim_mult");
|
||||
const std::vector<double> td = meta_list(meta, "vae.temperal_downsample");
|
||||
@@ -541,10 +553,10 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
}
|
||||
x = v.norm(x, true, "vae.decoder.norm_out", 4);
|
||||
m.dec_out = v.conv(x, cout, 3, 1, 1, "same", "vae.decoder.conv_out");
|
||||
m.b_img = decl_b(b, nm.f("image_out"), RAD_U8, { (int64_t)kMaxImageTokens * 256 * cout },
|
||||
m.b_img = decl_b(b, nm.f("image_out"), RAD_U8, { m.max_image_tokens * 256 * cout },
|
||||
RAD_BUF_PERSIST);
|
||||
m.op_rgba = rw(b, RAD_OP(b, "to_rgba8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, (int64_t)kMaxImageTokens * 256),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.max_image_tokens * 256),
|
||||
RAD_INT("n", cout), RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.dec_out.buf }, { m.b_img });
|
||||
@@ -556,11 +568,11 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
}
|
||||
/* The bands, gathered. A band is ceil(H / world) latent rows, and the split is taken only where
|
||||
* a band plus its two halos is smaller than the whole, so H > 2 * halo, which bounds W and
|
||||
* thus the largest band: under kMaxImageTokens / world + kMaxImageTokens / (2 * halo)
|
||||
* thus the largest band: under m.max_image_tokens / world + m.max_image_tokens / (2 * halo)
|
||||
* tokens. */
|
||||
const int world = m.gt.world;
|
||||
if (world > 1) {
|
||||
const int64_t bpx = (kMaxImageTokens / world + kMaxImageTokens / (2 * v.halo) + 1) * 256;
|
||||
const int64_t bpx = (m.max_image_tokens / world + m.max_image_tokens / (2 * v.halo) + 1) * 256;
|
||||
m.b_rgbaf = decl_b(b, nm.f("vdec.bands"), RAD_BF16, { world * bpx, cout });
|
||||
m.op_bands = rw(b, RAD_OP(b, "all_gather",
|
||||
RAD_PARAMS(RAD_INT("world_size", world),
|
||||
@@ -569,7 +581,7 @@ static int declare_decoder(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.dec_out.buf }, { m.b_rgbaf });
|
||||
m.op_rgba_bands = rw(b, RAD_OP(b, "to_rgba8",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, (int64_t)kMaxImageTokens * 256),
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, m.max_image_tokens * 256),
|
||||
RAD_INT("n", cout), RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_rgbaf }, { m.b_img });
|
||||
@@ -628,13 +640,13 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
{ m.b_txt }, { m.b_h });
|
||||
m.op_randn = rw(b, RAD_OP(b, "randn_lanes",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_state }, { m.b_state });
|
||||
m.op_lgather = rw(b, RAD_OP(b, "lane_gather",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_state }, { m.b_lat });
|
||||
@@ -820,7 +832,7 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
C, D, T, m.a_hm.x, m.b_v, &m.w_pout, gx);
|
||||
m.op_euler = rw(b, RAD_OP(b, "flow_euler",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, T), RAD_INT("n", C),
|
||||
RAD_INT("stride", (int64_t)kMaxImageTokens),
|
||||
RAD_INT("stride", m.max_image_tokens),
|
||||
RAD_STR("dtype", "bf16")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_v, m.b_inp, m.b_mask, m.b_state, m.b_prev }, { m.b_state, m.b_prev });
|
||||
@@ -834,6 +846,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
Model& m = g_model[rad_build_slot(ctx)];
|
||||
m = Model{};
|
||||
m.nm = Names(ctx->scope);
|
||||
m.max_image_tokens = image_tokens(ctx->gen_max_pixels);
|
||||
m.max_refs = reference_count(ctx->gen_max_refs);
|
||||
if (m.max_image_tokens == 0) {
|
||||
fprintf(stderr, "radiance: qwenimage21: --image-gen-max-pixels must fit a 32x32 image\n");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
RAD_ARCH_TRY(check_format(meta));
|
||||
RAD_ARCH_TRY(geom_from(m.gt, meta, ctx, "bf16", RAD_BF16));
|
||||
Names& nm = m.nm;
|
||||
@@ -917,14 +935,14 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
|
||||
/* ---- the per-image state, a lane an image, and what the passes hand each other */
|
||||
const int64_t C = rad_meta_geti(meta, "transformer.in_channels", 64);
|
||||
const int64_t lane_rows = (int64_t)kMaxLanes * kMaxImageTokens;
|
||||
const int64_t lane_rows = (int64_t)kMaxLanes * m.max_image_tokens;
|
||||
m.b_state = decl_b(b, nm.f("lat_state"), RAD_BF16, { lane_rows, C }, RAD_BUF_PERSIST);
|
||||
m.b_prev = decl_b(b, nm.f("lat_preview"), RAD_BF16, { lane_rows, C }, RAD_BUF_PERSIST);
|
||||
m.b_inp = decl_b(b, nm.f("lat_repaint"), RAD_BF16, { lane_rows, C }, RAD_BUF_PERSIST);
|
||||
m.b_mask = decl_b(b, nm.f("lat_mask"), RAD_F32, { lane_rows, 1 }, RAD_BUF_PERSIST);
|
||||
m.max_ref_rows = (int64_t)kMaxRefs * ref_tokens_max();
|
||||
m.max_ref_rows = m.max_refs * ref_tokens_max();
|
||||
m.b_reflat = decl_b(b, nm.f("ref_lat"), RAD_BF16, { m.max_ref_rows, C }, RAD_BUF_PERSIST);
|
||||
m.b_encz = decl_b(b, nm.f("enc_lat"), RAD_BF16, { (int64_t)kMaxImageTokens, C });
|
||||
m.b_encz = decl_b(b, nm.f("enc_lat"), RAD_BF16, { m.max_image_tokens, C });
|
||||
m.C = C;
|
||||
|
||||
/* ---- in issue order: the tower, the language model, the encoder, the DiT, the decoder.
|
||||
@@ -974,11 +992,12 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
d.size_multiple = 32;
|
||||
d.pixel_channels = rad_meta_geti(meta, "vae.out_channels", 4);
|
||||
d.slot_rows = 4;
|
||||
d.max_tokens = kMaxImageTokens;
|
||||
d.max_refs = kMaxRefs;
|
||||
d.max_tokens = m.max_image_tokens;
|
||||
d.max_refs = m.max_refs;
|
||||
d.ref_area = kRefArea;
|
||||
d.default_width = 2048;
|
||||
d.default_height = 2048;
|
||||
const int64_t side = (int64_t)(std::sqrt(std::min<int64_t>(m.max_image_tokens, 16384)) / 2) * 32;
|
||||
d.default_width = side;
|
||||
d.default_height = side;
|
||||
d.default_steps = sig.empty() ? 40 : (int64_t)sig.size();
|
||||
d.n_sigmas = (int32_t)sig.size();
|
||||
d.sigmas = sig.empty() ? nullptr : sig.data();
|
||||
@@ -1215,15 +1234,19 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
const int64_t n = (int64_t)(ph / 16) * (pw / 16);
|
||||
const RadOperand pcu = praw(G->px_cu + 2 * i, RAD_I32, 2);
|
||||
if (i < n_ref) {
|
||||
if (n > ref_tokens_max() || n > m.max_ref_rows - lat_row) {
|
||||
rad_step_fail(c, "qwenimage21: reference pixels exceed the declared latent buffer");
|
||||
return;
|
||||
}
|
||||
step_encode(c, m, px, ph, pw, pcu, m.b_reflat, lat_row);
|
||||
lat_row += n;
|
||||
} else {
|
||||
step_encode(c, m, px, ph, pw, pcu, m.b_encz, 0);
|
||||
RAD_ISSUE_N(c, m.op_lstore_lat, n, brows(m.b_encz, n),
|
||||
praw(G->lane, RAD_I32, G->n_lane), brows(m.b_inp, kMaxLanes * (int64_t)kMaxImageTokens));
|
||||
praw(G->lane, RAD_I32, G->n_lane), brows(m.b_inp, kMaxLanes * m.max_image_tokens));
|
||||
RAD_ISSUE_N(c, m.op_lstore_mask, n, praw2(G->inp_mask, RAD_F32, n, 1),
|
||||
praw(G->lane, RAD_I32, G->n_lane),
|
||||
brows(m.b_mask, kMaxLanes * (int64_t)kMaxImageTokens));
|
||||
brows(m.b_mask, kMaxLanes * m.max_image_tokens));
|
||||
}
|
||||
}
|
||||
/* 4. the modulation at t = 0, which every conditioning row reads */
|
||||
@@ -1254,7 +1277,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
const int64_t N = batch->n_tok, S = batch->n_seq;
|
||||
const RadOperand cu = praw(batch->cu_seqlens, RAD_I32, S + 1);
|
||||
const RadOperand lanes = praw(G->lane, RAD_I32, S);
|
||||
const int64_t L = (int64_t)kMaxLanes * kMaxImageTokens;
|
||||
const int64_t L = (int64_t)kMaxLanes * m.max_image_tokens;
|
||||
step_temb(c, m, G->sigma, S);
|
||||
RAD_ISSUE_N(c, m.op_randn, N, praw(G->flags, RAD_I32, S), praw(G->seed, RAD_U32, 2 * S),
|
||||
lanes, cu, brows(m.b_state, L));
|
||||
@@ -1275,7 +1298,7 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
case RAD_GEN_PASS_DECODE: {
|
||||
const int64_t H = G->dec_height / 16, W = G->dec_width / 16, n = H * W;
|
||||
const rad_buf src = G->dec_preview ? m.b_prev : m.b_state;
|
||||
RAD_ISSUE_N(c, m.op_dec_aff, n, brow_slice(src, (int64_t)G->dec_lane * kMaxImageTokens, n, C),
|
||||
RAD_ISSUE_N(c, m.op_dec_aff, n, brow_slice(src, (int64_t)G->dec_lane * m.max_image_tokens, n, C),
|
||||
brows(m.b_decin, n));
|
||||
const RadOperand cu = praw(batch->cu_seqlens, RAD_I32, 2);
|
||||
const int64_t npx = (int64_t)G->dec_height * G->dec_width, ch = m.dec_out.ch;
|
||||
@@ -1309,12 +1332,21 @@ static void step(RadCtx* c, const RadBatch* batch) {
|
||||
}
|
||||
|
||||
/* ================================================================== the probe */
|
||||
/* The rows a pass carries (one image at the largest size with guidance, so two entries) and the
|
||||
* vision patches of ten reference pictures at 1024 x 1024 of area. */
|
||||
/* The denoiser can carry two copies of an image for guidance. With reduced output sizes
|
||||
* also leave room for the reference conditioning and prompt, within the original row budget. */
|
||||
static int probe(const RadModelMeta* meta, RadArchProbe* out) {
|
||||
if (!meta || !out) return RAD_E_INVAL;
|
||||
out->gen_rows = 2 * (int64_t)kMaxImageTokens;
|
||||
out->gen_patches = (int64_t)kMaxRefs * (kRefArea / 256) * 11 / 10;
|
||||
const int64_t tokens = image_tokens(out->gen_max_pixels);
|
||||
if (tokens == 0) return RAD_E_INVAL;
|
||||
const int64_t refs = reference_count(out->gen_max_refs);
|
||||
const int64_t conditioning_rows = std::min<int64_t>(
|
||||
2 * kMaxImageTokens, refs * ref_tokens_max() + 1024);
|
||||
out->gen_rows = std::max(2 * tokens, conditioning_rows);
|
||||
const int64_t merge = rad_meta_geti(meta, "vision_config.spatial_merge_size", 2);
|
||||
if (merge < 1 || merge > 16) return RAD_E_INVAL;
|
||||
const int64_t group = merge * merge;
|
||||
const int64_t patches = refs * (kRefArea / 256) * 11 / 10;
|
||||
out->gen_patches = (patches + group - 1) / group * group;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -2062,9 +2062,9 @@ int Builder::declare_drafter(const RadDrafterDecl* d) {
|
||||
if (d->kind == RAD_DRAFT_NONE) return RAD_OK; /* declaring nothing is declaring nothing */
|
||||
|
||||
const char* nm = d->name && *d->name ? d->name : "(unnamed)";
|
||||
if (d->kind != RAD_DRAFT_SERIAL && d->kind != RAD_DRAFT_BLOCK) {
|
||||
err(RAD_E_INVAL, "declare_drafter '%s': kind %d is neither RAD_DRAFT_SERIAL nor "
|
||||
"RAD_DRAFT_BLOCK", nm, d->kind);
|
||||
const bool history = d->kind == RAD_DRAFT_HISTORY;
|
||||
if (d->kind != RAD_DRAFT_SERIAL && d->kind != RAD_DRAFT_BLOCK && !history) {
|
||||
err(RAD_E_INVAL, "declare_drafter '%s': unknown kind %d", nm, d->kind);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (prog_.drafter.kind != RAD_DRAFT_NONE) {
|
||||
@@ -2074,9 +2074,16 @@ int Builder::declare_drafter(const RadDrafterDecl* d) {
|
||||
prog_.drafter_name.c_str(), nm);
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (d->depth <= 0) {
|
||||
err(RAD_E_INVAL, "declare_drafter '%s': depth %d. A drafter that proposes nothing is not "
|
||||
"declared at all -- leave the call out.", nm, d->depth);
|
||||
if (history && (d->depth != 0 || prog_.ctx.max_spec != 0 || d->proposal ||
|
||||
d->proposal_pitch || d->block || d->window || !prog_.ctx.calib_dir ||
|
||||
!*prog_.ctx.calib_dir || prog_.ctx.calib_tokens <= 0)) {
|
||||
err(RAD_E_INVAL, "declare_drafter '%s': HISTORY requires calibration, max_spec 0 and "
|
||||
"no proposal or block", nm);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (!history && d->depth <= 0) {
|
||||
err(RAD_E_INVAL, "declare_drafter '%s': depth %d. A speculative drafter must propose "
|
||||
"at least one token.", nm, d->depth);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (prog_.ctx.max_spec > 0 && d->depth != prog_.ctx.max_spec) {
|
||||
@@ -2152,7 +2159,7 @@ int Builder::declare_drafter(const RadDrafterDecl* d) {
|
||||
/* A block drafter's proposal row holds its whole block's tokens, and the engine reads row s
|
||||
* at s * pitch (a short block fills only its front), so its pitch defaults to depth; a serial
|
||||
* one writes a token a pass, at pitch 1 by default. */
|
||||
if (prog_.drafter.proposal_pitch == 0)
|
||||
if (!history && prog_.drafter.proposal_pitch == 0)
|
||||
prog_.drafter.proposal_pitch = prog_.drafter.kind == RAD_DRAFT_BLOCK ? prog_.drafter.depth : 1;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,10 @@ std::string dump_graph_str(const Program& p, const std::vector<std::string>* err
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- the drafter (spec §10) */
|
||||
if (p.drafter.kind != RAD_DRAFT_NONE) {
|
||||
if (p.drafter.kind == RAD_DRAFT_HISTORY) {
|
||||
s += fmt("---- drafter: '%s', RAD_DRAFT_HISTORY -- calibration pass, no proposals\n\n",
|
||||
p.drafter_name.c_str());
|
||||
} else if (p.drafter.kind != RAD_DRAFT_NONE) {
|
||||
const bool blk = p.drafter.kind == RAD_DRAFT_BLOCK;
|
||||
s += fmt("---- drafter: '%s', %s, %d token(s) a step\n",
|
||||
p.drafter_name.c_str(),
|
||||
@@ -729,7 +732,8 @@ std::string dump_graph_json(const Program& p, Registry* r) {
|
||||
if (p.drafter.kind != RAD_DRAFT_NONE) {
|
||||
json d;
|
||||
d["name"] = p.drafter_name;
|
||||
d["kind"] = p.drafter.kind == RAD_DRAFT_BLOCK ? "block" : "serial";
|
||||
d["kind"] = p.drafter.kind == RAD_DRAFT_HISTORY ? "history"
|
||||
: p.drafter.kind == RAD_DRAFT_BLOCK ? "block" : "serial";
|
||||
d["depth"] = p.drafter.depth;
|
||||
if (p.drafter.kind == RAD_DRAFT_BLOCK) {
|
||||
d["window"] = p.drafter.window;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
namespace rad {
|
||||
|
||||
@@ -481,6 +482,30 @@ int rad_tools_declare(const LoadedPlugins& lp, const RadModelMeta& meta, const R
|
||||
if (s < 0) {
|
||||
RAD_ERR("%s: rad_arch_declare returned %s", lp.arch_plugin.c_str(), rad_strerror(s));
|
||||
for (const auto& e : b.errors()) RAD_ERR(" %s", e.c_str());
|
||||
/* A plugin that needs an op it declared, and finds it resolved to no kernel, returns a
|
||||
* status and may say nothing more. The ops no library serves in either domain are the
|
||||
* usual reason on a card whose kernel library covers fewer forms, so they are listed with
|
||||
* the constraint that refused each: the device's line, which names the form the card
|
||||
* lacks. */
|
||||
const Program& p = b.program();
|
||||
std::set<std::pair<int32_t, std::string>> no_host;
|
||||
for (const Program::Miss& m : p.misses)
|
||||
if (m.domain == RAD_DOMAIN_HOST) no_host.emplace(m.index, m.span);
|
||||
std::vector<std::string> unserved;
|
||||
for (const Program::Miss& m : p.misses) {
|
||||
if (m.domain != RAD_DOMAIN_DEVICE || !no_host.count({ m.index, m.span })) continue;
|
||||
const std::string line = m.line();
|
||||
if (std::find(unserved.begin(), unserved.end(), line) == unserved.end())
|
||||
unserved.push_back(line);
|
||||
}
|
||||
if (!unserved.empty()) {
|
||||
const size_t shown = std::min<size_t>(unserved.size(), 16);
|
||||
RAD_ERR(" %zu op form(s) it declared before stopping have no kernel in the loaded "
|
||||
"libraries, on the card or on the host; a plugin that needs one of them stops "
|
||||
"where it finds that%s:", unserved.size(),
|
||||
shown < unserved.size() ? " (the first 16)" : "");
|
||||
for (size_t i = 0; i < shown; ++i) RAD_ERR(" %s", unserved[i].c_str());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
+362
-3
@@ -4,6 +4,7 @@
|
||||
* (spec §6).
|
||||
*/
|
||||
#include "rad_core.h"
|
||||
#include "sched/draft_depth.h" /* the --draft-depth-load lists */
|
||||
#include "kld.h"
|
||||
#include "format/rope_override.h"
|
||||
#include "sample/host_ref.h"
|
||||
@@ -79,6 +80,9 @@ static const Flag g_flags[] = {
|
||||
{ "--mixed-step-target-ms", "N", "soft duration target in milliseconds for a mixed prefill/decode\n"
|
||||
"step. The scheduler learns an aggregate prefill cap from\n"
|
||||
"completed mixed steps; 0 (default) is off" },
|
||||
{ "--prefill-room-gate", "MODE", "on: a fresh prefill starts only when its whole prompt plus one\n"
|
||||
"decode position fits beside every runner; off (the default)\n"
|
||||
"admits a prompt when its first chunk fits" },
|
||||
{ "--preempt-wait-ms", "N", "how long a preempted prefill may wait for the whole-\n"
|
||||
"recompute gate before reclaiming cache blocks and\n"
|
||||
"preempting the lowest-priority running request; 0\n"
|
||||
@@ -162,6 +166,10 @@ static const Flag g_flags[] = {
|
||||
" disabled -- the default, also with no flag at all -- loads\n"
|
||||
" nothing: no projection op is declared, and a request that\n"
|
||||
" asks for the vector is refused" },
|
||||
{ "--control-vector-variant", "NAME", "list MODEL:NAME, a name of this model whose\n"
|
||||
" requests run with the control vector on; the model's\n"
|
||||
" own name keeps --control-vector's default. Needs\n"
|
||||
" --control-vector off or on" },
|
||||
{ "--deterministic", nullptr, "pin placement to the plan the loader made, so the resident\n"
|
||||
" set cannot change under the heat engine. The sampler is\n"
|
||||
" already order-independent and needs no pinning; note that\n"
|
||||
@@ -170,10 +178,33 @@ static const Flag g_flags[] = {
|
||||
{ "--checkpoint-interval","N", "linear-attention state checkpoint interval, in tokens" },
|
||||
{ "--prefill-span", "N", "checkpoint intervals one step may carry of a prefill alone\n"
|
||||
" in its step, from the prompt's second interval on (default\n"
|
||||
" 1); needs --max-num-batched-tokens of N intervals. Every\n"
|
||||
" 1); needs --max-num-batched-tokens of N intervals. Prompts\n"
|
||||
" prefilling side by side with nothing decoding take such\n"
|
||||
" steps one at a time, the fewest tokens left first. Every\n"
|
||||
" other step is planned at the budget less the extra\n"
|
||||
" intervals, and the checkpoints inside a span are not\n"
|
||||
" written" },
|
||||
{ "--prefill-span-pass", "MODE", "piece (default) | step -- the routed (MoE) block's pass of a\n"
|
||||
" spanned step: a pass an interval, or one pass over the\n"
|
||||
" whole step where the model runs such a step serially\n"
|
||||
" (Flash-Next at one or two ranks). Each expert's weight is\n"
|
||||
" then read once for all the step's rows; the arena grows by\n"
|
||||
" the expert planes' extra rows and the output differs from\n"
|
||||
" piece passes at tie level. Needs --prefill-span above 1" },
|
||||
{ "--prefill-tail-snapshot", "MODE", "on (default): a prompt's last chunk ends where the\n"
|
||||
" next turn's linear-state snapshot goes (prefix resume\n"
|
||||
" nearest), leaving its last tokens a step of their own (a\n"
|
||||
" lone spanned prefill on a model that snapshots inside a step\n"
|
||||
" takes it inside the chunk, no step more); off: the last chunk\n"
|
||||
" runs to the prompt's end, one step fewer, and a next turn\n"
|
||||
" resumes up to an interval earlier" },
|
||||
{ "--prefill-span-first", "MODE", "off (default) | on -- whether a lone prefill may span from\n"
|
||||
" its first token; on: the first interval rides the span (its\n"
|
||||
" rows read QSA's selection, the same keys as the dense pass\n"
|
||||
" below the exactness bound, summed in another order)" },
|
||||
{ "--prefill-span-min", "N", "the shortest prompt, in tokens, a prefill spans for: auto\n"
|
||||
" (default) is 8 intervals where routed experts are read from\n"
|
||||
" host memory and 0 elsewhere; 0 spans every lone prefill" },
|
||||
/* A total, not per sequence: the snapshot store is one pool of N slots
|
||||
* (KVManager::set_checkpoint_store). */
|
||||
{ "--checkpoint-slots", "N", "linear-state or sliding-window snapshots the server holds in\n"
|
||||
@@ -212,6 +243,63 @@ static const Flag g_flags[] = {
|
||||
" couples the target's draw to it: more accepted drafts on sampled\n"
|
||||
" requests, the same output law, other tokens than off for a fixed\n"
|
||||
" seed" },
|
||||
{ "--draft-verify", "MODE", "token (default, alias rowwise) | block | traversal -- how a coupled draft chain is\n"
|
||||
" verified: token decides each row on its own (maximal coupling);\n"
|
||||
" block decides the whole chain at once (Block Verification, arXiv\n"
|
||||
" 2403.10444; switches --draft-coupling on); traversal decides a\n"
|
||||
" root-to-leaf path bottom-up (Traversal Verification, arXiv\n"
|
||||
" 2505.12398; needs --draft-coupling on). The same output law in\n"
|
||||
" every mode, more drafts accepted per step in block and traversal" },
|
||||
{ "--draft-depth", "MODE", "fixed (default) | adaptive -- a coupled serial chain stops within\n"
|
||||
" the step once the product of the head's probabilities along it falls\n"
|
||||
" below --draft-depth-stop, and the next verify carries only the drafts\n"
|
||||
" made (1 .. --draft-depth-max). Same output law (the rule reads the\n"
|
||||
" draft's own laws only); switches --draft-coupling on (an explicit\n"
|
||||
" off is refused) and needs --draft-window fixed (both choose the\n"
|
||||
" depth, so they are not served together)" },
|
||||
{ "--draft-depth-max", "N", "--draft-depth adaptive: the deepest chain (default 0 =\n"
|
||||
"num-speculative-tokens)" },
|
||||
{ "--draft-depth-min", "N", "--draft-depth adaptive: rounds that always run (default 1)" },
|
||||
{ "--draft-depth-stop", "P", "--draft-depth adaptive: the chain goes on while its confidence\n"
|
||||
"is at least P (default 0.85)" },
|
||||
{ "--draft-depth-lag", "K", "--draft-depth adaptive: rounds the decision trails the chain,\n"
|
||||
"0 or 1 (default 1: the host decides while the next round runs)" },
|
||||
{ "--draft-depth-stat", "S", "--draft-depth adaptive: top (default, each round's largest\n"
|
||||
"probability) | path (the probability of the token it drew)" },
|
||||
{ "--draft-depth-load", "MODE", "off (default) | on -- --draft-depth adaptive with several sequences\n"
|
||||
" in a step: draft round j only for the rows whose expected accepted\n"
|
||||
" drafts pay their verify\n"
|
||||
" rows, the kernel tile they open and the round, at the measured\n"
|
||||
" throughput; fewer sequences than --draft-depth-load-from keep the\n"
|
||||
" stop rule. Same output law" },
|
||||
{ "--draft-depth-load-from", "N", "--draft-depth-load: the fewest drafting sequences of a step the\n"
|
||||
"load-aware rule decides (default 5)" },
|
||||
{ "--draft-depth-load-min", "N", "--draft-depth-load: rounds a load-aware step always runs (default 2)" },
|
||||
{ "--draft-depth-load-late", "MODE", "on (default) | off -- --draft-depth-load: choose each row's verified\n"
|
||||
"drafts again when the next verify is issued, from the laws read by then" },
|
||||
{ "--draft-depth-load-calib", "MODE", "--draft-depth-load: online (default; acceptance by confidence,\n"
|
||||
" throughput and row/round/tile prices follow the running server) |\n"
|
||||
" static (the built-in or given tables only)" },
|
||||
{ "--draft-depth-load-tok-ms", "LIST", "--draft-depth-load: tokens a millisecond by drafting sequences\n"
|
||||
"1..8, comma-separated (a short list repeats its last; default built in)" },
|
||||
{ "--draft-depth-load-row-ms", "LIST", "--draft-depth-load: a verify row's milliseconds, by drafting\n"
|
||||
"sequences 1..8" },
|
||||
{ "--draft-depth-load-round-ms", "LIST", "--draft-depth-load: a draft round's milliseconds, by drafting\n"
|
||||
"sequences 1..8" },
|
||||
{ "--draft-depth-load-jump-ms", "LIST", "--draft-depth-load: what a verify of more than 16, 32, 48, 64\n"
|
||||
"rows costs on top, in milliseconds (four numbers)" },
|
||||
{ "--draft-suffix", "MODE", "off (default) | on -- SuffixDecoding as a step selector on a serial head's chain: when the\n"
|
||||
"sequence's last --draft-suffix-min-match tokens occurred earlier in\n"
|
||||
"its own prompt ++ output, a host-built step verifies the earlier\n"
|
||||
"continuation (a chain, up to --draft-suffix-max rows) instead of the\n"
|
||||
"head's draft. Lossless; works beside the fixed chain, --draft-verify\n"
|
||||
"traversal and --draft-depth adaptive, not --draft-verify block" },
|
||||
{ "--draft-suffix-min-match", "L", "shortest suffix match that selects a suffix step (default 6)" },
|
||||
{ "--draft-suffix-max", "N", "most rows of a suffix step (default 7; the verify window becomes\n"
|
||||
"max(--num-speculative-tokens, N), the head still drafts its own)" },
|
||||
{ "--draft-suffix-min-score", "D", "cut the suffix chain where its path score (the product of the\n"
|
||||
"follower frequencies along it, SuffixDecoding's D) falls under D\n"
|
||||
"(default 0.3)" },
|
||||
{ "--draft-model", "PATH", "NOT IMPLEMENTED -- merge the drafter at convert time" },
|
||||
|
||||
{ "--host", "ADDR", "listen address" },
|
||||
@@ -228,8 +316,9 @@ static const Flag g_flags[] = {
|
||||
" never access; repeatable" },
|
||||
{ "--served-model-name", "NAME", "the model id /v1/models lists and responses carry; default the container's name" },
|
||||
{ "--mm-max-patches", "N", "patches one encoder pass carries, and so the largest image (a patch is 16x16\n"
|
||||
"pixels). Default `auto`: 16384 when the container carries a vision tower. 0\n"
|
||||
"serves text only and keeps the tower off the card" },
|
||||
"pixels). Default `auto`: 16384 when the container carries a vision tower (0 in a build\n"
|
||||
"without a media decoder, which would refuse every media part). 0 serves text\n"
|
||||
"only and keeps the tower off the card" },
|
||||
{ "--image-gen-max-pixels", "N", "an image generator's largest image, in pixels (1048576: 1024 x 1024).\n"
|
||||
" Default: the model's. Its per-image buffers, and the activation\n"
|
||||
" arena with them, are sized for it; larger requests are refused" },
|
||||
@@ -548,6 +637,18 @@ static bool parse_template_kwargs(const char* v, std::map<std::string, std::stri
|
||||
return true;
|
||||
}
|
||||
|
||||
/* A name a request may give as `model`, by the rule a fleet applies to model ids and aliases
|
||||
* (fleet::valid_name, in a file this one does not include): not empty, and no ':' (reserved for
|
||||
* base:adapter), whitespace or control character. */
|
||||
static bool plain_name(const char* s) {
|
||||
if (!*s) return false;
|
||||
for (; *s; ++s) {
|
||||
const unsigned char ch = (unsigned char)*s;
|
||||
if (ch == ':' || std::isspace(ch) || std::iscntrl(ch)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Returns 0 on success, 1 for --help (caller exits 0), negative on a bad argument. An unknown flag
|
||||
* is an error, not a warning, since a mistyped budget flag changes the plan. */
|
||||
int config_parse(int argc, char** argv, Config* c) {
|
||||
@@ -631,6 +732,12 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
else if (!parse_int(a.c_str(), v, 0, 64, &c->prefill_interleave)) return RAD_E_INVAL;
|
||||
}
|
||||
else if (S("--mixed-step-target-ms")) { if (!num(0, 60000, &c->mixed_step_target_ms)) return RAD_E_INVAL; }
|
||||
else if (S("--prefill-room-gate")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "on")) c->prefill_room_gate = true;
|
||||
else if (!std::strcmp(v, "off")) c->prefill_room_gate = false;
|
||||
else { RAD_ERR("--prefill-room-gate takes on or off -- got '%s'", v); return RAD_E_INVAL; }
|
||||
}
|
||||
else if (S("--preempt-wait-ms")) { if (!num(0, INT64_MAX, &c->preempt_wait_ms)) return RAD_E_INVAL; }
|
||||
else if (S("--max-num-seqs")) { if (!num(1, INT64_MAX, &c->max_seqs)) return RAD_E_INVAL; }
|
||||
else if (S("--max-model-len")) { if (!num(0, INT64_MAX, &c->max_ctx)) return RAD_E_INVAL; }
|
||||
@@ -806,9 +913,50 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
}
|
||||
c->control_vector = v;
|
||||
}
|
||||
else if (S("--control-vector-variant")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!plain_name(v)) {
|
||||
RAD_ERR("--control-vector-variant takes a name with no ':' or whitespace -- "
|
||||
"got '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->control_vector_variant = v;
|
||||
}
|
||||
else if (S("--deterministic")) c->deterministic = true;
|
||||
else if (S("--checkpoint-interval")) { if (!num(0, INT64_MAX, &c->checkpoint_interval)) return RAD_E_INVAL; }
|
||||
else if (S("--prefill-span")) { if (!num(1, INT32_MAX, &c->prefill_span)) return RAD_E_INVAL; }
|
||||
else if (S("--prefill-span-pass")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "piece")) c->prefill_span_step = false;
|
||||
else if (!std::strcmp(v, "step")) c->prefill_span_step = true;
|
||||
else {
|
||||
RAD_ERR("--prefill-span-pass takes piece or step, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--prefill-tail-snapshot")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "on")) c->prefill_tail_snapshot = true;
|
||||
else if (!std::strcmp(v, "off")) c->prefill_tail_snapshot = false;
|
||||
else {
|
||||
RAD_ERR("--prefill-tail-snapshot takes on or off, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--prefill-span-first")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "on")) c->prefill_span_first = true;
|
||||
else if (!std::strcmp(v, "off")) c->prefill_span_first = false;
|
||||
else {
|
||||
RAD_ERR("--prefill-span-first takes on or off, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--prefill-span-min")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "auto")) c->prefill_span_min = -1;
|
||||
else if (!parse_int(a.c_str(), v, 0, INT64_MAX, &c->prefill_span_min)) return RAD_E_INVAL;
|
||||
}
|
||||
else if (S("--checkpoint-slots")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "auto")) {
|
||||
@@ -878,6 +1026,107 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-verify")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "token") || !std::strcmp(v, "rowwise")) {
|
||||
c->draft_verify_block = false;
|
||||
c->draft_verify_traversal = false;
|
||||
}
|
||||
else if (!std::strcmp(v, "block")) { c->draft_verify_block = true; c->draft_verify_traversal = false; }
|
||||
else if (!std::strcmp(v, "traversal")) { c->draft_verify_block = false; c->draft_verify_traversal = true; }
|
||||
else {
|
||||
RAD_ERR("--draft-verify takes token (rowwise), block or traversal, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-depth")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "fixed")) c->draft_depth_adaptive = false;
|
||||
else if (!std::strcmp(v, "adaptive")) c->draft_depth_adaptive = true;
|
||||
else {
|
||||
RAD_ERR("--draft-depth takes fixed or adaptive, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-depth-max")) { if (!num(0, 16, &c->draft_depth_max)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-depth-min")) { if (!num(1, 16, &c->draft_depth_min)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-depth-lag")) { if (!num(0, 1, &c->draft_depth_lag)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-depth-stop")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
double d = 0;
|
||||
if (!parse_num(a.c_str(), v, &d)) return RAD_E_INVAL;
|
||||
if (!(d >= 0.0 && d <= 1.0)) {
|
||||
RAD_ERR("--draft-depth-stop must be a probability in [0, 1], not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->draft_depth_stop = d;
|
||||
}
|
||||
else if (S("--draft-depth-stat")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "top")) c->draft_depth_stat = 0;
|
||||
else if (!std::strcmp(v, "path")) c->draft_depth_stat = 1;
|
||||
else {
|
||||
RAD_ERR("--draft-depth-stat takes top or path, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-depth-load") || S("--draft-depth-load-late")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
bool b = false;
|
||||
if (!std::strcmp(v, "off")) b = false;
|
||||
else if (!std::strcmp(v, "on")) b = true;
|
||||
else { RAD_ERR("%s takes off or on, not '%s'", a.c_str(), v); return RAD_E_INVAL; }
|
||||
(S("--draft-depth-load") ? c->draft_depth_load : c->draft_depth_load_late) = b;
|
||||
}
|
||||
else if (S("--draft-depth-load-from")) { if (!num(2, 64, &c->draft_depth_load_from)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-depth-load-min")) { if (!num(1, 16, &c->draft_depth_load_min)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-depth-load-calib")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "online")) c->draft_depth_load_online = true;
|
||||
else if (!std::strcmp(v, "static")) c->draft_depth_load_online = false;
|
||||
else {
|
||||
RAD_ERR("--draft-depth-load-calib takes online or static, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-depth-load-tok-ms") || S("--draft-depth-load-row-ms") ||
|
||||
S("--draft-depth-load-round-ms") || S("--draft-depth-load-jump-ms")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
const bool jump = S("--draft-depth-load-jump-ms");
|
||||
double probe[DraftDepthCfg::kLoadSeqs];
|
||||
const int cap = jump ? (int)DraftDepthCfg::kJumps : (int)DraftDepthCfg::kLoadSeqs;
|
||||
/* a price may be zero (a tile that costs nothing); a rate may not */
|
||||
if (*v && draft_depth_parse_list(v, probe, cap, jump ? 0.0 : 1e-6, 1000.0) < 1) {
|
||||
RAD_ERR("%s takes 1..%d comma-separated %s numbers, not '%s'", a.c_str(), cap,
|
||||
jump ? "non-negative" : "positive", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
(S("--draft-depth-load-tok-ms") ? c->draft_depth_load_tok_ms
|
||||
: S("--draft-depth-load-row-ms") ? c->draft_depth_load_row_ms
|
||||
: S("--draft-depth-load-round-ms") ? c->draft_depth_load_round_ms
|
||||
: c->draft_depth_load_jump_ms) = v;
|
||||
}
|
||||
else if (S("--draft-suffix")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!std::strcmp(v, "off")) c->draft_suffix = false;
|
||||
else if (!std::strcmp(v, "on")) c->draft_suffix = true;
|
||||
else {
|
||||
RAD_ERR("--draft-suffix takes off or on, not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
else if (S("--draft-suffix-min-match")) { if (!num(1, 12, &c->draft_suffix_min_match)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-suffix-max")) { if (!num(1, 32, &c->draft_suffix_max)) return RAD_E_INVAL; }
|
||||
else if (S("--draft-suffix-min-score")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
char* end = nullptr;
|
||||
const double d = std::strtod(v, &end);
|
||||
if (end == v || *end || !(d >= 0.0 && d <= 1.0)) {
|
||||
RAD_ERR("--draft-suffix-min-score takes a number in [0, 1], not '%s'", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->draft_suffix_min_score = (float)d;
|
||||
}
|
||||
else if (S("--draft-model")) {
|
||||
/* Refused, not ignored: separate draft models are not supported (spec §10), and the
|
||||
* drafter comes from the container (rad-convert --draft-model merges one in; an MTP
|
||||
@@ -1263,6 +1512,21 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
RAD_ERR("--calib-corpus records into --calib-dir; give one");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (!c->control_vector_variant.empty()) {
|
||||
if (c->control_vector == "disabled") {
|
||||
RAD_ERR("--control-vector-variant needs --control-vector off or on: with no vector "
|
||||
"loaded, '%s' would have nothing to switch on",
|
||||
c->control_vector_variant.c_str());
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* An adapter is named the same way, `base:name`, so the two must differ. */
|
||||
for (const auto& [name, dir] : c->lora.adapters)
|
||||
if (name == c->control_vector_variant) {
|
||||
RAD_ERR("--control-vector-variant '%s' is also a --lora adapter's name, so a "
|
||||
"request naming it could mean either; rename one", name.c_str());
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
if ((!c->calib_dir.empty() || c->calib_layer_hi) && !c->calib() && c->kld_record.empty()) {
|
||||
RAD_ERR("--calib-dir and --calib-layers belong to a --calib-corpus or --kld-record run");
|
||||
return RAD_E_INVAL;
|
||||
@@ -1370,6 +1634,69 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
RAD_ERR("--video-min-pixels is above --video-max-pixels"); return RAD_E_INVAL; }
|
||||
if (c->video_min_frames && c->video_max_frames && *c->video_min_frames > *c->video_max_frames) {
|
||||
RAD_ERR("--video-min-frames is above --video-max-frames"); return RAD_E_INVAL; }
|
||||
/* --prefill-span-pass step and --prefill-span-min shape a span, so they need one. */
|
||||
if (c->prefill_span_step && c->prefill_span <= 1) {
|
||||
RAD_ERR("--prefill-span-pass step is the routed pass of a spanned step and needs "
|
||||
"--prefill-span above 1");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (c->prefill_span_min >= 0 && c->prefill_span <= 1) {
|
||||
RAD_ERR("--prefill-span-min is the shortest prompt a span is taken for and needs "
|
||||
"--prefill-span above 1");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* --draft-depth adaptive reads the coupled chain's laws and chooses the chain's depth itself. */
|
||||
if (c->draft_depth_adaptive) {
|
||||
if (c->given.count("--draft-coupling") && !c->draft_coupling) {
|
||||
RAD_ERR("--draft-depth adaptive needs the coupled drafting (--draft-coupling on): the "
|
||||
"stop rule reads the law each draft was drawn from");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (c->draft_window == DraftWindow::Adaptive) {
|
||||
RAD_ERR("--draft-depth adaptive and --draft-window adaptive both choose the chain's "
|
||||
"depth; serve one of them");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (c->draft_verify_block) {
|
||||
RAD_ERR("--draft-depth adaptive is verified token by token or by traversal "
|
||||
"(--draft-verify token | traversal), not as a fixed block");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (c->draft_depth_min > 1 && c->draft_depth_max > 0 && c->draft_depth_min > c->draft_depth_max) {
|
||||
RAD_ERR("--draft-depth-min is above --draft-depth-max");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->draft_coupling = true;
|
||||
}
|
||||
/* --draft-depth-load weighs the adaptive chain's rounds; its late choice reads each round's
|
||||
* largest probability, the one statistic that is not the drawn token's own. */
|
||||
if (c->draft_depth_load) {
|
||||
if (!c->draft_depth_adaptive) {
|
||||
RAD_ERR("--draft-depth-load on needs --draft-depth adaptive: it decides the adaptive "
|
||||
"chain's rounds for a step of several sequences");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (c->draft_depth_stat != 0) {
|
||||
RAD_ERR("--draft-depth-load on needs --draft-depth-stat top: its tables and the late "
|
||||
"choice of the verify's rows read each round's largest probability");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
}
|
||||
/* --draft-verify block verifies a linear chain with the coupled drafting's states, so it
|
||||
* switches the coupling on; traversal needs it and says so rather than switching it on. */
|
||||
if (c->draft_verify_block) {
|
||||
if (c->given.count("--draft-coupling") && !c->draft_coupling) {
|
||||
RAD_ERR("--draft-verify block needs the coupled drafting (--draft-coupling on); "
|
||||
"--draft-coupling off contradicts it");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->draft_coupling = true;
|
||||
}
|
||||
if (c->draft_verify_traversal && !c->draft_coupling) {
|
||||
RAD_ERR("--draft-verify traversal requires --draft-coupling on: the walk needs the draft's "
|
||||
"law Q, which only a coupled draft carries");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* --host-pool-mib is what the model pins for its weights in all; Config::host_pool_mib is a
|
||||
* rank's share of it, whichever of the two options came first. */
|
||||
if (pool_all) c->host_pool_mib /= std::max(c->tp, 1);
|
||||
@@ -1432,6 +1759,8 @@ const ShowRow kShow[] = {
|
||||
: std::string("off"); } },
|
||||
{ "--mixed-step-target-ms", [](const Config& c) {
|
||||
return c.mixed_step_target_ms > 0 ? num(c.mixed_step_target_ms) : std::string("off"); } },
|
||||
{ "--prefill-room-gate", [](const Config& c) {
|
||||
return c.prefill_room_gate ? std::string("on") : std::string("off"); } },
|
||||
{ "--preempt-wait-ms", [](const Config& c) { return num(c.preempt_wait_ms); } },
|
||||
{ "--max-num-seqs", [](const Config& c) { return num(c.max_seqs); } },
|
||||
{ "--max-model-len", [](const Config& c) {
|
||||
@@ -1473,9 +1802,16 @@ const ShowRow kShow[] = {
|
||||
return o.empty() ? std::string(c.lora.enabled() ? "the adapters' own" : "-") : o; } },
|
||||
{ "--placement", [](const Config& c) { return c.placement; } },
|
||||
{ "--control-vector", [](const Config& c) { return c.control_vector; } },
|
||||
{ "--control-vector-variant", [](const Config& c) {
|
||||
return or_none(c.control_vector_variant, "none: no variant listed"); } },
|
||||
{ "--deterministic", [](const Config& c) { return onoff(c.deterministic); } },
|
||||
{ "--checkpoint-interval", [](const Config& c) { return num(c.checkpoint_interval); } },
|
||||
{ "--prefill-span", [](const Config& c) { return num(c.prefill_span); } },
|
||||
{ "--prefill-span-pass", [](const Config& c) { return std::string(c.prefill_span_step ? "step" : "piece"); } },
|
||||
{ "--prefill-tail-snapshot", [](const Config& c) { return onoff(c.prefill_tail_snapshot); } },
|
||||
{ "--prefill-span-first", [](const Config& c) { return onoff(c.prefill_span_first); } },
|
||||
{ "--prefill-span-min", [](const Config& c) {
|
||||
return c.prefill_span_min < 0 ? std::string("auto") : num(c.prefill_span_min); } },
|
||||
{ "--checkpoint-slots", [](const Config& c) {
|
||||
return c.checkpoint_slots < 0 ? std::string("auto") : num(c.checkpoint_slots); } },
|
||||
{ "--no-prefix-cache", [](const Config& c) {
|
||||
@@ -1493,6 +1829,29 @@ const ShowRow kShow[] = {
|
||||
return c.draft_short_from < 0 ? std::string("auto")
|
||||
: c.draft_short_from > 0 ? num(c.draft_short_from) : std::string("0 (never)"); } },
|
||||
{ "--draft-coupling", [](const Config& c) { return onoff(c.draft_coupling); } },
|
||||
{ "--draft-verify", [](const Config& c) {
|
||||
return std::string(c.draft_verify_block ? "block" : c.draft_verify_traversal ? "traversal" : "token"); } },
|
||||
{ "--draft-depth", [](const Config& c) { return std::string(c.draft_depth_adaptive ? "adaptive" : "fixed"); } },
|
||||
{ "--draft-depth-max", [](const Config& c) {
|
||||
return c.draft_depth_max > 0 ? num(c.draft_depth_max) : std::string("auto"); } },
|
||||
{ "--draft-depth-min", [](const Config& c) { return num(c.draft_depth_min); } },
|
||||
{ "--draft-depth-stop", [](const Config& c) { return fnum(c.draft_depth_stop); } },
|
||||
{ "--draft-depth-lag", [](const Config& c) { return num(c.draft_depth_lag); } },
|
||||
{ "--draft-depth-stat", [](const Config& c) { return std::string(c.draft_depth_stat == 1 ? "path" : "top"); } },
|
||||
{ "--draft-depth-load", [](const Config& c) { return onoff(c.draft_depth_load); } },
|
||||
{ "--draft-depth-load-from", [](const Config& c) { return num(c.draft_depth_load_from); } },
|
||||
{ "--draft-depth-load-min", [](const Config& c) { return num(c.draft_depth_load_min); } },
|
||||
{ "--draft-depth-load-late", [](const Config& c) { return onoff(c.draft_depth_load_late); } },
|
||||
{ "--draft-depth-load-calib", [](const Config& c) {
|
||||
return std::string(c.draft_depth_load_online ? "online" : "static"); } },
|
||||
{ "--draft-depth-load-tok-ms", [](const Config& c) { return or_none(c.draft_depth_load_tok_ms, "builtin"); } },
|
||||
{ "--draft-depth-load-row-ms", [](const Config& c) { return or_none(c.draft_depth_load_row_ms, "builtin"); } },
|
||||
{ "--draft-depth-load-round-ms", [](const Config& c) { return or_none(c.draft_depth_load_round_ms, "builtin"); } },
|
||||
{ "--draft-depth-load-jump-ms", [](const Config& c) { return or_none(c.draft_depth_load_jump_ms, "builtin"); } },
|
||||
{ "--draft-suffix", [](const Config& c) { return onoff(c.draft_suffix); } },
|
||||
{ "--draft-suffix-min-match", [](const Config& c) { return num(c.draft_suffix_min_match); } },
|
||||
{ "--draft-suffix-max", [](const Config& c) { return num(c.draft_suffix_max); } },
|
||||
{ "--draft-suffix-min-score", [](const Config& c) { return fnum(c.draft_suffix_min_score); } },
|
||||
{ "--draft-model", [](const Config&) { return std::string("not implemented (the container's own drafter)"); } },
|
||||
{ "--host", [](const Config& c) { return c.host; } },
|
||||
{ "--port", [](const Config& c) { return num(c.port); } },
|
||||
|
||||
+201
-24
@@ -21,11 +21,15 @@
|
||||
* an invalidation. A slot is rewritten one lap after it was last read, so a system-scope
|
||||
* acquire is placed at least once per half lap; without it every kernel after the first lap
|
||||
* reads its predecessor's arguments. Slots are 1 KiB so no argument fetch shares a cache line
|
||||
* with the next slot;
|
||||
* with the next slot. No fence makes a write through the BAR arrive: the card's host data
|
||||
* path is flushed in front of every doorbell (host_writes_out);
|
||||
* - host-written memory: the first dispatch after the host waits on any queue takes a
|
||||
* system-scope acquire, since host writes for the next step follow such a wait;
|
||||
* - copies touching host or peer memory carry the scope themselves, as do the barrier packets
|
||||
* that implement events and synchronisation.
|
||||
*
|
||||
* A chained kernel that has lost its barrier bit may go without the acquire (see "the acquire of a
|
||||
* chained launch"): it reads behind a wait in its own prologue, long after its packet's acquire.
|
||||
*/
|
||||
#include "device.h"
|
||||
|
||||
@@ -225,6 +229,9 @@ struct Dev {
|
||||
bool has_vram = false;
|
||||
uint32_t kfd_id = 0; /* the driver's gpu_id: its sysfs and ioctls name it so */
|
||||
bool host_kargs = false; /* no large BAR: the argument ring lives in host memory */
|
||||
/* The card's host data path flush register (HSA_AMD_AGENT_INFO_HDP_FLUSH), where the host
|
||||
* writes arguments into VRAM; see host_writes_out. */
|
||||
volatile uint32_t* hdp_flush = nullptr;
|
||||
};
|
||||
|
||||
struct Global {
|
||||
@@ -441,6 +448,18 @@ bool init_devices() {
|
||||
RAD_INFO("device: card %d (%s) keeps kernel arguments in pinned host memory, as a "
|
||||
"test asked", i, bus);
|
||||
}
|
||||
if (!g.dev[(size_t)i].host_kargs) {
|
||||
hsa_amd_hdp_flush_t hdp{};
|
||||
if (hsa_agent_get_info(g.dev[(size_t)i].agent,
|
||||
(hsa_agent_info_t)HSA_AMD_AGENT_INFO_HDP_FLUSH,
|
||||
&hdp) == HSA_STATUS_SUCCESS)
|
||||
g.dev[(size_t)i].hdp_flush = hdp.HDP_MEM_FLUSH_CNTL;
|
||||
if (!g.dev[(size_t)i].hdp_flush)
|
||||
RAD_WARN("device: card %d (%s) gives no host data path flush register, so a kernel "
|
||||
"may start before the arguments written for it through the BAR have "
|
||||
"reached VRAM; chained launches keep the packet processor's acquire, "
|
||||
"which leaves them the time they had", i, bus);
|
||||
}
|
||||
}
|
||||
/* Without the handler a fault falls back to the runtime's own handling, which the
|
||||
* memory-fault report below replaces; warn at startup. */
|
||||
@@ -600,6 +619,7 @@ struct Stream {
|
||||
hsa_queue_t* q = nullptr;
|
||||
uint64_t mask = 0;
|
||||
char* karg = nullptr; /* VRAM the CPU writes through the BAR, or host memory */
|
||||
volatile uint32_t* hdp = nullptr; /* Dev::hdp_flush where `karg` is VRAM */
|
||||
std::atomic<bool> busy{false};
|
||||
uint64_t wr = 0; /* next packet index */
|
||||
uint64_t rd = 0; /* last read index seen */
|
||||
@@ -662,7 +682,15 @@ uint32_t g_queue_gen[kMaxQueues];
|
||||
* card takes them over. A kept queue holds its context save area on the card, about 41 MiB on an
|
||||
* R9700 (24 of them 0.99 GiB, measured). The queues of a card are destroyed at process exit, and
|
||||
* where the caller answers for nothing computing on the card (a_stream_trim). Keyed by card and
|
||||
* priority. */
|
||||
* priority.
|
||||
*
|
||||
* Handed out oldest first. The firmware puts a card's queues on its pipes in the order they were
|
||||
* created, alternating; an engine's two compute lanes on one pipe run ~50% slower in decode than on
|
||||
* two (2x R9700 under MES, read from the driver's queue table: slow if and only if lane 0 and lane 1
|
||||
* shared a pipe, 119 of 119 requests). Bring-up keeps queues in an order where the newest two share
|
||||
* a pipe and the two oldest do not, so last-in first-out paired the lanes. Measured on jarvis with
|
||||
* the stock plugins (27B with DFlash2, Gemma 4 31B with MTP, tp 2): the same step times either way,
|
||||
* the second lane being nearly idle in decode there. */
|
||||
std::mutex g_spare_mu;
|
||||
std::vector<Stream*> g_spare[kMaxDevices][2];
|
||||
|
||||
@@ -958,7 +986,11 @@ void stuck_watch() {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
const int64_t ms = stuck_ms();
|
||||
const int64_t limit = rad::dev_stuck_exit_ms.load(std::memory_order_relaxed);
|
||||
if (limit > 0 && ms >= limit) {
|
||||
/* The load phase is exempt (device.h): a verdict standing before the first engine
|
||||
* finished bringup is a slow load, not a hang, and killing on it trades a patient
|
||||
* start for a crash loop. The dumps and the log line still fire -- an operator
|
||||
* watching a stuck load sees the queue state exactly as before. */
|
||||
if (limit > 0 && ms >= limit && rad::dev_engine_ready.load(std::memory_order_acquire)) {
|
||||
dump_queues("the device");
|
||||
fatal("the device has advanced nothing for %lld s (the queue dumps above name the "
|
||||
"packets it is stuck on); exiting so a restart can bring the server back",
|
||||
@@ -1008,11 +1040,21 @@ struct Stall {
|
||||
g_stuck_progress.store(p, std::memory_order_relaxed);
|
||||
g_stuck_at.store(steady_ns() - (uint64_t)kStallMs * 1000000u, std::memory_order_release);
|
||||
dump_queues(where);
|
||||
RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the "
|
||||
"packet named above -- a hung kernel, or a queue the driver evicted and could "
|
||||
"not restore (amdgpu cwsr_enable=0 is one cause). The process exits once this "
|
||||
"has stood for scheduler.stuck-exit (%lld s; 0 never)", kStallMs / 1000,
|
||||
(long long)(rad::dev_stuck_exit_ms.load(std::memory_order_relaxed) / 1000));
|
||||
/* The line says what follows the verdict. Before the first engine has finished
|
||||
* bring-up the exit is not armed: a stall standing during a load is taken for a slow
|
||||
* load (device.h's dev_engine_ready). */
|
||||
if (rad::dev_engine_ready.load(std::memory_order_acquire))
|
||||
RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the "
|
||||
"packet named above -- a hung kernel, or a queue the driver evicted and could "
|
||||
"not restore (amdgpu cwsr_enable=0 is one cause). The process exits once this "
|
||||
"has stood for scheduler.stuck-exit (%lld s; 0 never)", kStallMs / 1000,
|
||||
(long long)(rad::dev_stuck_exit_ms.load(std::memory_order_relaxed) / 1000));
|
||||
else
|
||||
RAD_ERR("device: nothing has advanced in the %u s since: the GPU is not running the "
|
||||
"packet named above -- a hung kernel, or a queue the driver evicted and could "
|
||||
"not restore (amdgpu cwsr_enable=0 is one cause). The engine is still in "
|
||||
"bringup, so scheduler.stuck-exit is not armed yet: this verdict is reported, "
|
||||
"not fatal, until the first engine has finished loading", kStallMs / 1000);
|
||||
if (!g_stuck_watch.exchange(true, std::memory_order_acq_rel))
|
||||
std::thread(stuck_watch).detach();
|
||||
return;
|
||||
@@ -1079,10 +1121,39 @@ inline int reserve(Stream* s, uint64_t* out) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* What the host wrote for the card, on its way before the packets that read it are announced.
|
||||
*
|
||||
* An argument slot in VRAM is written through the BAR: the bytes sit in the processor's
|
||||
* write-combining buffers until a store fence, and behind the link in the card's host data path,
|
||||
* which hands them on to memory in its own time unless it is told to flush. Nothing orders that
|
||||
* against the doorbell. A kernel the card starts soon enough after its packet was announced
|
||||
* reads the slot as the launch a lap of the ring before left it: first its chain record, which
|
||||
* it obeys (an old target, so no wait) or does not accept (so it counts nothing and the chained
|
||||
* launch behind it waits for good), then, behind its wait, its arguments.
|
||||
*
|
||||
* On an R9700 "soon enough" is a microsecond or two. The packet processor's acquire holds a
|
||||
* launch 0.9 us and an ordered launch waits for the kernel in front, which is all that keeps
|
||||
* such a launch from it; a chained launch whose packet goes without the acquire starts that much
|
||||
* sooner behind its doorbell. Runs of fourteen 256 KiB card-side copies issued one by one that
|
||||
* way: back to back, six runs in nine of 300 000 ended with a unit moved by another launch's
|
||||
* arguments; with the host quiet for 50 us behind each doorbell the queue stalled in its first
|
||||
* lap, four runs in four, on either card. With the flush below neither happened (fourteen runs
|
||||
* and four), nor did it with the acquire on the packets, with plain launches, or with a 2 us
|
||||
* pause in front of each doorbell.
|
||||
*
|
||||
* The register is the driver's (HSA_AMD_AGENT_INFO_HDP_FLUSH, the remapped page it gives a
|
||||
* process for this), and the store travels the link behind the slot's bytes and in front of the
|
||||
* doorbell's: the order the driver's own submissions use. It goes in front of every doorbell, a
|
||||
* chained launch's or not: no launch was ordered against the write. */
|
||||
inline void host_writes_out(Stream* s) {
|
||||
_mm_sfence();
|
||||
if (s->hdp) *s->hdp = 1;
|
||||
}
|
||||
|
||||
inline void publish(Stream* s, uint64_t idx, uint16_t header, uint16_t setup) {
|
||||
s->wr = idx + 1;
|
||||
hsa_queue_store_write_index_relaxed(s->q, idx + 1);
|
||||
_mm_sfence(); /* the argument slot, written before the header */
|
||||
host_writes_out(s); /* the argument slot, in VRAM before the header */
|
||||
__atomic_store_n(reinterpret_cast<uint32_t*>(
|
||||
static_cast<hsa_kernel_dispatch_packet_t*>(s->q->base_address) +
|
||||
(idx & s->mask)),
|
||||
@@ -1122,6 +1193,9 @@ struct TapeRec {
|
||||
uint8_t chain = 0;
|
||||
/* A collective's launch (a_peer_launch). */
|
||||
uint8_t peer = 0;
|
||||
/* A chained kernel whose library acquires for it in the kernel (chain_bare): played without
|
||||
* its barrier bit, its packet takes no acquire from the packet processor. */
|
||||
uint8_t bare = 0;
|
||||
};
|
||||
|
||||
struct Tape {
|
||||
@@ -1142,12 +1216,13 @@ inline bool capturing() { return t_tape && t_tape_pause == 0; }
|
||||
|
||||
/* A dispatch just written at `p` on `s`, with its argument block `ka`. */
|
||||
void tape_note_dispatch(Stream* s, const hsa_kernel_dispatch_packet_t* p, uint16_t setup,
|
||||
const unsigned char* ka, uint32_t n, uint8_t fence, bool chain) {
|
||||
const unsigned char* ka, uint32_t n, uint8_t fence, bool chain, bool bare) {
|
||||
Tape* t = t_tape;
|
||||
TapeRec r;
|
||||
r.kind = kTapeDispatch;
|
||||
r.fence = fence;
|
||||
r.chain = chain ? 1 : 0;
|
||||
r.bare = chain && bare ? 1 : 0;
|
||||
r.peer = t_peer ? 1 : 0;
|
||||
r.s = s;
|
||||
r.pkt = *p;
|
||||
@@ -1168,21 +1243,77 @@ inline uint16_t header(hsa_packet_type_t type, int acq, int rel, bool barrier =
|
||||
(rel << HSA_PACKET_HEADER_SCRELEASE_FENCE_SCOPE));
|
||||
}
|
||||
|
||||
/* Whether the packet at `idx` must acquire at system scope, and the bookkeeping if it does. */
|
||||
inline int acquire_scope(Stream* s, uint64_t idx, bool forced) {
|
||||
/* Whether the packet at `idx` must acquire at system scope, and the bookkeeping if it does.
|
||||
* `*asked` says the acquire is one the argument ring's half lap, a host write or the caller asks
|
||||
* for, at whichever scope it comes back, and not the agent scope every dispatch takes besides. */
|
||||
inline int acquire_scope(Stream* s, uint64_t idx, bool forced, bool* asked) {
|
||||
const uint64_t ep = G().host_epoch.load(std::memory_order_acquire);
|
||||
const bool lap = (int64_t)idx - s->last_sys_acq >= (int64_t)(kQueuePackets / 2);
|
||||
if (forced || lap || s->epoch != ep) {
|
||||
*asked = forced || lap || s->epoch != ep;
|
||||
if (*asked) {
|
||||
s->last_sys_acq = (int64_t)idx;
|
||||
s->epoch = ep;
|
||||
/* The prefetch stream reads nothing the host writes; a system acquire there would only
|
||||
* invalidate the L2 under the compute stream. */
|
||||
if (s->agent_only && !forced) return HSA_FENCE_SCOPE_AGENT;
|
||||
/* The prefetch stream reads no data the host writes, so a host write or epoch does not
|
||||
* make it acquire at system scope (that would only invalidate the L2 under the compute
|
||||
* stream). Its own kernel arguments are host-written into its ring like any stream's,
|
||||
* though: after the ring laps, an agent-scope acquire leaves the slot's old line in the
|
||||
* L2 and a launch could run with the previous lap's arguments. The half lap keeps the
|
||||
* system acquire: one in 2048 prefetch launches. */
|
||||
if (s->agent_only && !forced && !lap) return HSA_FENCE_SCOPE_AGENT;
|
||||
return HSA_FENCE_SCOPE_SYSTEM;
|
||||
}
|
||||
return HSA_FENCE_SCOPE_AGENT;
|
||||
}
|
||||
|
||||
/* The acquire of a chained launch.
|
||||
*
|
||||
* A packet's acquire runs when the packet processor launches the kernel. A chained kernel that has
|
||||
* lost its barrier bit is launched ahead and reads nothing then: it reads behind the wait in its
|
||||
* prologue, once the launches in front have written, and acquires there itself. The packet's
|
||||
* acquire guards nothing it reads, and the packet processor launches nothing else while it runs
|
||||
* one. Measured on an R9700, a chain of small dependent kernels issued behind a gate: 2.1 us a
|
||||
* launch with the agent-scope acquire, 1.2 us without (system scope costs what agent scope does;
|
||||
* the same hand-over inside one persistent kernel, with no launch between, 0.3 to 0.6 us). In a
|
||||
* pass that is time on the path only where a dependent launch reaches the card after the kernel
|
||||
* it waits for has ended: ~65 of a Qwen3.8-Flash-Next verify pass's 664 dependent launches, the
|
||||
* delta net's update behind its two overlapped launches first among them.
|
||||
*
|
||||
* The acquire did one thing by the way, for every kernel on the card: it emptied the scalar data
|
||||
* cache. No fence a compiler puts in a kernel does (an agent-scope acquire is a global_inv: the
|
||||
* vector caches), and a load whose address every lane shares is often a scalar one: a row's
|
||||
* scale, a routing count, the activation a head reads. A chained form that reads such a value
|
||||
* where the launch in front wrote it finds what an earlier launch read from that address, unless
|
||||
* a later packet's acquire happened to fall in between. With an acquire on every packet it nearly
|
||||
* always had (one launch in 1800 read stale in a probe of 1024-block readers); without, 1797 in
|
||||
* 1800 did, and the model's text changed. So the acquire goes only where every chained form the
|
||||
* engine can launch empties that cache itself behind its wait (RadKernelChainFn saying 2,
|
||||
* rad_dev_chain_unfenced; `s_dcache_inv` in r4d_chain.h and chain_kernel.h), which also closes
|
||||
* the window the fenced packets leave.
|
||||
*
|
||||
* Everything else keeps its acquire or release: the release (dropping it as well measured
|
||||
* nothing), a packet that keeps its bit, a plain kernel, every barrier packet, and every acquire
|
||||
* acquire_scope asks for: the argument ring's half lap, the first dispatch after a host wait, a
|
||||
* copy over the link. Those guard what the kernel reads of its own slot, its arguments and chain
|
||||
* record, which the host wrote where some launch read a lap ago and which the L2 would still
|
||||
* hold; they are kept at whichever scope they come. The prefetch stream keeps the acquire on
|
||||
* every packet: nothing waits for its launches, so there is nothing to gain.
|
||||
*
|
||||
* The acquire did a second thing by the way: it held the launch until the slot the host had
|
||||
* just written was in VRAM, which nothing else saw to (host_writes_out). Without the flush
|
||||
* there, a bare chained launch stopped a server: a chained card-side copy on a card's second
|
||||
* queue never finished, and the queue stood on it with 14 packets written behind. So a
|
||||
* card whose arguments are in VRAM and that gives no flush register keeps the acquire on its
|
||||
* chained launches. RADIANCE_AQL_CHAIN_FENCE=1 keeps it on every chained launch, to rule this
|
||||
* out. */
|
||||
inline bool chain_bare(const Stream* s) {
|
||||
static const bool keep = [] {
|
||||
const char* e = std::getenv("RADIANCE_AQL_CHAIN_FENCE");
|
||||
return e && *e == '1';
|
||||
}();
|
||||
if (keep || s->agent_only || rad_dev_chain_unfenced() == 0) return false;
|
||||
return s->hdp != nullptr || G().dev[(size_t)s->ord].host_kargs;
|
||||
}
|
||||
|
||||
/* Collectives on a shared card.
|
||||
*
|
||||
* A chained kernel launched behind a running one holds its wave slots while it waits in its
|
||||
@@ -1196,7 +1327,7 @@ inline int acquire_scope(Stream* s, uint64_t idx, bool forced) {
|
||||
* once. Nothing advances from there: Qwen3.8-27B prefilling beside Gemma 4 12B decoding, both on
|
||||
* the same two R9700, stopped within 12 s.
|
||||
*
|
||||
* So on a card that more than one multi-card engine has claimed (a_cards_claim), a chained packet
|
||||
* So on a card that more than one engine has claimed (a_cards_claim), a chained packet
|
||||
* keeps its barrier bit while a collective's packet may be running on its queue. Only the
|
||||
* collectives' own blocks then wait on the card for another card; everything else waiting there
|
||||
* waits for kernels that finish by themselves. An engine alone on its cards pays nothing. */
|
||||
@@ -1300,20 +1431,27 @@ int dispatch(Stream* s, const KernelRec* k, dim3 g, dim3 b, void** args, size_t
|
||||
const bool chain = k->chained && rad_dev_chain_enabled() && s->chain_ctr &&
|
||||
n <= RAD_CHAIN_KARG_OFF;
|
||||
if (k->chained) chain_record(s, slot, chain, s->chain_issued);
|
||||
if (capturing()) tape_note_dispatch(s, p, setup, ka, n, fence, chain);
|
||||
const bool bare = chain && chain_bare(s);
|
||||
if (capturing()) tape_note_dispatch(s, p, setup, ka, n, fence, chain, bare);
|
||||
/* Attach the ride after the tape copied the packet: a recorded packet carries no signal, and
|
||||
* a play attaches whichever ride is pending then (PlayRun::put). */
|
||||
if (s->ride.handle) {
|
||||
p->completion_signal = s->ride;
|
||||
s->ride.handle = 0;
|
||||
}
|
||||
const int acq = acquire_scope(s, idx, (fence & kFenceAcquireSystem) != 0);
|
||||
bool asked = false;
|
||||
const int acq = acquire_scope(s, idx, (fence & kFenceAcquireSystem) != 0, &asked);
|
||||
const int rel = (fence & kFenceReleaseSystem) ? HSA_FENCE_SCOPE_SYSTEM : HSA_FENCE_SCOPE_AGENT;
|
||||
/* Behind another chained kernel a chained one waits in its prologue; a completion signal keeps
|
||||
* the bit, since its completion must cover everything before it. */
|
||||
const bool keep = !(chain && s->prev_chained && !s->plain_inflight && !p->completion_signal.handle &&
|
||||
!(s->peer_inflight && card_shared(s)));
|
||||
publish(s, idx, header(HSA_PACKET_TYPE_KERNEL_DISPATCH, acq, rel, keep), setup);
|
||||
/* Without the bit, a kernel that acquires for itself takes none from the packet processor,
|
||||
* unless the ring or the host asked for this one. */
|
||||
publish(s, idx,
|
||||
header(HSA_PACKET_TYPE_KERNEL_DISPATCH,
|
||||
bare && !keep && !asked ? HSA_FENCE_SCOPE_NONE : acq, rel, keep),
|
||||
setup);
|
||||
s->chain_frontier = s->chain_issued;
|
||||
s->frontier_open = !keep;
|
||||
if (chain) s->chain_issued += blocks_of(p);
|
||||
@@ -1358,6 +1496,9 @@ struct PlayRun {
|
||||
|
||||
void ring() {
|
||||
if (!unrung) return;
|
||||
/* The chained records' argument slots (put) are VRAM the packets read as soon as they
|
||||
* are announced. */
|
||||
host_writes_out(s);
|
||||
hsa_queue_store_write_index_relaxed(s->q, next);
|
||||
hsa_signal_store_relaxed(s->q->doorbell_signal, (hsa_signal_value_t)(next - 1));
|
||||
unrung = 0;
|
||||
@@ -1434,7 +1575,8 @@ struct PlayRun {
|
||||
chain_record(s, slot, true, dependent ? s->chain_issued : s->chain_frontier);
|
||||
}
|
||||
}
|
||||
const int acq = acquire_scope(s, idx, (r.fence & kFenceAcquireSystem) != 0);
|
||||
bool asked = false;
|
||||
const int acq = acquire_scope(s, idx, (r.fence & kFenceAcquireSystem) != 0, &asked);
|
||||
int rel = (r.fence & kFenceReleaseSystem) ? HSA_FENCE_SCOPE_SYSTEM : HSA_FENCE_SCOPE_AGENT;
|
||||
if (rel < rel_min) rel = rel_min;
|
||||
/* A dispatch carrying a record keeps the bit: its completion must cover everything before
|
||||
@@ -1453,7 +1595,12 @@ struct PlayRun {
|
||||
stamp->ordered = ordered;
|
||||
stamp->chained = chain;
|
||||
}
|
||||
const uint16_t h = header(HSA_PACKET_TYPE_KERNEL_DISPATCH, acq, rel, ordered);
|
||||
/* Without the bit, a kernel that acquires for itself takes none from the packet
|
||||
* processor, unless the ring or the host asked for this one (see "the acquire of a
|
||||
* chained launch"). */
|
||||
const uint16_t h = header(HSA_PACKET_TYPE_KERNEL_DISPATCH,
|
||||
chain && r.bare && !ordered && !asked ? HSA_FENCE_SCOPE_NONE : acq,
|
||||
rel, ordered);
|
||||
__atomic_store_n(reinterpret_cast<uint32_t*>(p), (uint32_t)h | ((uint32_t)r.pkt.setup << 16),
|
||||
__ATOMIC_RELEASE);
|
||||
foreign = false;
|
||||
@@ -1730,7 +1877,7 @@ int a_stream_create(RadStream* out, int high_priority) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(g_spare_mu);
|
||||
auto& v = g_spare[ord][high_priority ? 1 : 0];
|
||||
if (!v.empty()) { r = v.back(); v.pop_back(); }
|
||||
if (!v.empty()) { r = v.front(); v.erase(v.begin()); }
|
||||
}
|
||||
if (r) {
|
||||
/* Every packet it held has completed (a_stream_destroy drained it), so its counters
|
||||
@@ -1781,6 +1928,7 @@ int a_stream_create(RadStream* out, int high_priority) {
|
||||
return RAD_E_DEVICE;
|
||||
}
|
||||
s->karg = static_cast<char*>(ka);
|
||||
s->hdp = d.host_kargs ? nullptr : d.hdp_flush;
|
||||
s->chain_ctr = reinterpret_cast<uint64_t*>(s->karg + (size_t)(s->mask + 1) * kKargSlot);
|
||||
*reinterpret_cast<volatile uint64_t*>(s->chain_ctr) = 0;
|
||||
_mm_sfence();
|
||||
@@ -4637,6 +4785,32 @@ bool ride_reusable(void* token) {
|
||||
std::lock_guard<std::mutex> lk(pool().mu);
|
||||
return reusable(g);
|
||||
}
|
||||
|
||||
int chain_probe(void* stream, unsigned* x, unsigned* seen, unsigned pairs, unsigned blocks) {
|
||||
if (!ours(stream) || !x || !seen) return RAD_E_INVAL;
|
||||
for (unsigned i = 0; i < pairs; ++i)
|
||||
if (rad_aql_probe_store(x, i + 1u, stream) < 0 ||
|
||||
rad_aql_probe_load(x, seen + (size_t)i * blocks, blocks, stream) < 0)
|
||||
return RAD_E_DEVICE;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int chain_asks(void* stream, const void* src, void* dst, uint64_t bytes, unsigned* seen, unsigned n) {
|
||||
Stream* s = ours(stream);
|
||||
if (!s || !src || !dst || !seen || !s->chain_ctr || bytes == 0 || (bytes & 15)) return RAD_E_INVAL;
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
if (rad_aql_probe_ask(src, dst, bytes, seen, i + 1u,
|
||||
reinterpret_cast<unsigned long long*>(s->chain_ctr), stream) < 0)
|
||||
return RAD_E_DEVICE;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int chain_marks(void* stream, unsigned* seen, unsigned n) {
|
||||
if (!ours(stream) || !seen) return RAD_E_INVAL;
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
if (rad_aql_probe_mark(seen, i + 1u, stream) < 0) return RAD_E_DEVICE;
|
||||
return RAD_OK;
|
||||
}
|
||||
} // namespace aql
|
||||
|
||||
size_t aql_code_registered(void) { return a_code_mark(); }
|
||||
@@ -4947,8 +5121,11 @@ hipError_t hipPeekAtLastError(void) {
|
||||
|
||||
namespace rad {
|
||||
namespace aql {
|
||||
/* A build without the AQL backend hands out no ride. */
|
||||
/* A build without the AQL backend hands out no ride and launches no chain. */
|
||||
bool ride_reusable(void*) { return false; }
|
||||
int chain_probe(void*, unsigned*, unsigned*, unsigned, unsigned) { return RAD_E_UNSUPPORTED; }
|
||||
int chain_marks(void*, unsigned*, unsigned) { return RAD_E_UNSUPPORTED; }
|
||||
int chain_asks(void*, const void*, void*, uint64_t, unsigned*, unsigned) { return RAD_E_UNSUPPORTED; }
|
||||
} // namespace aql
|
||||
} // namespace rad
|
||||
|
||||
|
||||
@@ -72,6 +72,25 @@ void set_next_fence(uint8_t f);
|
||||
/* Whether the signal behind a rad_ride token could be handed out again now (tests/device_test.cpp). */
|
||||
bool ride_reusable(void* token);
|
||||
|
||||
/* `pairs` launches of two chained kernels onto `stream`, one behind the other: the first stores
|
||||
* i + 1 over the 64 words at `x`; the second loads x[0] the way a kernel loads a value all its
|
||||
* lanes share (a scalar load) and each of its `blocks` blocks stores what it saw, at
|
||||
* seen[i * blocks + block]. Every reader must have seen the store in front of it
|
||||
* (tests/device_test.cpp). RAD_E_UNSUPPORTED in a build without the backend. */
|
||||
int chain_probe(void* stream, unsigned* x, unsigned* seen, unsigned pairs, unsigned blocks);
|
||||
|
||||
/* `n` chained launches onto `stream`, launch i storing i + 1 at seen[i]: each takes where to
|
||||
* store from its own arguments, so a launch that read another's leaves a word unwritten
|
||||
* (tests/device_test.cpp). RAD_E_UNSUPPORTED in a build without the backend. */
|
||||
int chain_marks(void* stream, unsigned* seen, unsigned n);
|
||||
|
||||
/* `n` chained launches onto `stream`, each a card-side copy of `bytes` (a multiple of 16) from
|
||||
* `src` to `dst` that also stores at seen[i] whether it found a chain record in its argument
|
||||
* slot: i + 1 if every block did, that with the top bit set if one did not. A block that found
|
||||
* none still counts, so the launches behind it are not left waiting (tests/device_test.cpp).
|
||||
* RAD_E_UNSUPPORTED in a build without the backend. */
|
||||
int chain_asks(void* stream, const void* src, void* dst, uint64_t bytes, unsigned* seen, unsigned n);
|
||||
|
||||
} // namespace aql
|
||||
} // namespace rad
|
||||
|
||||
@@ -90,4 +109,10 @@ int rad_aql_blit_fill(void* dst, int value, uint64_t bytes, void* stream);
|
||||
/* rad_memcpy_ranges_async's kernel: `prefix` a multiple of 16, both bases 16-byte aligned. */
|
||||
int rad_aql_blit_ranges(void* dst, const void* src, uint64_t prefix, const RadCopyRange* ranges,
|
||||
int n, void* stream);
|
||||
/* aql::chain_probe's two kernels, aql::chain_marks's one and aql::chain_asks's one. */
|
||||
int rad_aql_probe_store(unsigned* x, unsigned v, void* stream);
|
||||
int rad_aql_probe_load(const unsigned* x, unsigned* seen, unsigned blocks, void* stream);
|
||||
int rad_aql_probe_mark(unsigned* seen, unsigned v, void* stream);
|
||||
int rad_aql_probe_ask(const void* src, void* dst, uint64_t bytes, unsigned* seen, unsigned v,
|
||||
unsigned long long* ctr, void* stream);
|
||||
}
|
||||
@@ -250,6 +250,75 @@ extern "C" int rad_aql_blit_ranges(void* dst, const void* src, uint64_t prefix,
|
||||
return launched();
|
||||
}
|
||||
|
||||
/* aql::chain_probe's pair (aql.h). The reader's load has one address for the whole wave and
|
||||
* nothing in the kernel writes there, so the compiler makes it a scalar load: served from the
|
||||
* scalar data cache, which the wait must have emptied (chain_kernel.h) for the kernel to see the
|
||||
* store in front of it. */
|
||||
namespace {
|
||||
__global__ __launch_bounds__(64) void r4dchain_probe_store(unsigned* __restrict__ x, unsigned v) {
|
||||
rad_chain_wait();
|
||||
x[threadIdx.x] = v;
|
||||
rad_chain_done();
|
||||
}
|
||||
__global__ __launch_bounds__(32) void r4dchain_probe_load(const unsigned* __restrict__ x,
|
||||
unsigned* __restrict__ seen) {
|
||||
rad_chain_wait();
|
||||
const unsigned v = x[0];
|
||||
if (threadIdx.x == 0) seen[blockIdx.x] = v;
|
||||
rad_chain_done();
|
||||
}
|
||||
/* aql::chain_marks's kernel: where it stores comes from its arguments alone. */
|
||||
__global__ __launch_bounds__(32) void r4dchain_probe_mark(unsigned* __restrict__ seen, unsigned v) {
|
||||
rad_chain_wait();
|
||||
if (threadIdx.x == 0) seen[v - 1u] = v;
|
||||
rad_chain_done();
|
||||
}
|
||||
|
||||
/* aql::chain_asks's kernel: a card-side copy like r4dchain_copy16 that says whether there was a
|
||||
* chain record in its argument slot when it started. A block that found none counts nothing in
|
||||
* rad_chain_done, so it counts by the address in its arguments instead and the launches behind
|
||||
* it do not wait for it for good. */
|
||||
__global__ __launch_bounds__(kThreads) void r4dchain_probe_ask(const u32x4* __restrict__ src,
|
||||
u32x4* __restrict__ dst, uint64_t n,
|
||||
unsigned* __restrict__ seen, unsigned v,
|
||||
unsigned long long* __restrict__ ctr) {
|
||||
const bool found = rad_chain_rec() != nullptr;
|
||||
rad_chain_wait();
|
||||
const uint64_t stride = (uint64_t)gridDim.x * kThreads;
|
||||
for (uint64_t i = (uint64_t)blockIdx.x * kThreads + threadIdx.x; i < n; i += stride) dst[i] = src[i];
|
||||
if (threadIdx.x == 0)
|
||||
__hip_atomic_fetch_or(&seen[v - 1u], found ? v : (v | 0x80000000u), __ATOMIC_RELAXED,
|
||||
__HIP_MEMORY_SCOPE_AGENT);
|
||||
rad_chain_done();
|
||||
if (!found && threadIdx.x == 0)
|
||||
__hip_atomic_fetch_add(ctr, 1ull, __ATOMIC_RELEASE, __HIP_MEMORY_SCOPE_AGENT);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C" int rad_aql_probe_ask(const void* src, void* dst, uint64_t bytes, unsigned* seen, unsigned v,
|
||||
unsigned long long* ctr, void* stream) {
|
||||
const uint64_t n = bytes / 16;
|
||||
hipLaunchKernelGGL(r4dchain_probe_ask, dim3(blocks_for(n, 4 * kThreads)), dim3(kThreads), 0,
|
||||
(hipStream_t)stream, (const u32x4*)src, (u32x4*)dst, n, seen, v, ctr);
|
||||
return launched();
|
||||
}
|
||||
|
||||
extern "C" int rad_aql_probe_mark(unsigned* seen, unsigned v, void* stream) {
|
||||
hipLaunchKernelGGL(r4dchain_probe_mark, dim3(1), dim3(32), 0, (hipStream_t)stream, seen, v);
|
||||
return launched();
|
||||
}
|
||||
|
||||
extern "C" int rad_aql_probe_store(unsigned* x, unsigned v, void* stream) {
|
||||
hipLaunchKernelGGL(r4dchain_probe_store, dim3(1), dim3(64), 0, (hipStream_t)stream, x, v);
|
||||
return launched();
|
||||
}
|
||||
|
||||
extern "C" int rad_aql_probe_load(const unsigned* x, unsigned* seen, unsigned blocks, void* stream) {
|
||||
if (blocks == 0) return 0;
|
||||
hipLaunchKernelGGL(r4dchain_probe_load, dim3(blocks), dim3(32), 0, (hipStream_t)stream, x, seen);
|
||||
return launched();
|
||||
}
|
||||
|
||||
extern "C" int rad_aql_blit_fill(void* dst, int value, uint64_t bytes, void* stream) {
|
||||
if (bytes == 0) return 0;
|
||||
const hipStream_t s = (hipStream_t)stream;
|
||||
|
||||
@@ -37,6 +37,11 @@ __device__ __forceinline__ void rad_chain_wait() {
|
||||
__builtin_amdgcn_s_sleep(1);
|
||||
__syncthreads();
|
||||
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
|
||||
/* The fence empties the vector caches. A load every lane shares may be a scalar one, and the
|
||||
* scalar data cache still holds what a launch read from the address before the launch in front
|
||||
* of this one wrote it: only the packet processor's acquire empties that cache, and it runs
|
||||
* when the kernel is launched, before the launch in front has written. */
|
||||
asm volatile("s_dcache_inv" ::: "memory");
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void rad_chain_done() {
|
||||
|
||||
+20
-3
@@ -43,8 +43,18 @@ extern "C" void rad_dev_host_wrote(void);
|
||||
* lets a chained kernel (named r4dchain*) wait in its prologue instead of behind the barrier bit.
|
||||
* Only on the AQL backend, whose queues keep the completion counter, and only where the model's
|
||||
* plugin measured a gain (RadArchProbe::chain_pays): with its drafter decoding speculatively, or
|
||||
* with and without one (rad_dev_chain_infer, from the engine before any row resolves). */
|
||||
* with and without one (rad_dev_chain_infer, from the engine before any row resolves).
|
||||
*
|
||||
* rad_dev_chain_infer(2) says more: every chained form this engine can launch fences itself
|
||||
* (RadKernelChainFn saying 2, abi/rad_abi.h). rad_dev_chain_unfenced then answers 1, and the
|
||||
* backend issues a chained launch that has lost its barrier bit without the packet processor's
|
||||
* acquire as well (aql.cpp, "the acquire of a chained launch"). */
|
||||
extern "C" int rad_dev_chain_enabled(void);
|
||||
/* VRAM the runtime keeps resident as queue scratch on `props`' card once a kernel with a private
|
||||
* segment has run (0 on the host backend and on unified memory). Charged to the VRAM budget with
|
||||
* the hardware queues. */
|
||||
extern "C" int64_t rad_dev_resident_scratch_bytes(const RadDeviceProps* props);
|
||||
extern "C" int rad_dev_chain_unfenced(void);
|
||||
extern "C" void rad_dev_chain_infer(int pays);
|
||||
|
||||
/* One range of a ranged copy: `bytes` from source offset `src` to destination offset `dst`, all
|
||||
@@ -97,8 +107,8 @@ extern "C" int rad_link_hold(RadStream s, int on);
|
||||
/* The launches this thread issues between `on` 1 and `on` 0 are a collective's: their blocks wait
|
||||
* for the other ranks' blocks of the same launch on another card. A recorded pass keeps the mark.
|
||||
*
|
||||
* rad_dev_cards_claim tells the backend which cards an engine's collectives run on (`on` 1, once
|
||||
* per engine with more than one rank) and that the engine is gone (`on` 0). On a card more than one
|
||||
* rad_dev_cards_claim tells the backend which cards an engine uses (`on` 1, once per engine)
|
||||
* and that the engine is gone (`on` 0). On a card more than one
|
||||
* engine has claimed, nothing may wait on the card behind a collective except the collective's own
|
||||
* blocks (aql.cpp, "collectives on a shared card"). A claim that makes a card shared returns once
|
||||
* everything issued before it on that card's streams has finished. */
|
||||
@@ -454,6 +464,13 @@ int64_t dev_stuck_ms();
|
||||
* reported hangs stood for hours, and a stall that clears does so within seconds. */
|
||||
extern std::atomic<int64_t> dev_stuck_exit_ms;
|
||||
|
||||
/* Whether at least one engine has finished bringup. The stuck-exit watchdog reads it: a stall
|
||||
* verdict standing DURING load is a slow load -- a cold start faulting a mapped tier from disk
|
||||
* advances none of the counters the verdict watches, and that is legitimate work, not a hang.
|
||||
* A watchdog that fires there turns one patient start into a supervisor's crash loop. Nothing
|
||||
* disarms: the phase the flag exempts is only the engine's first. */
|
||||
extern std::atomic<bool> dev_engine_ready;
|
||||
|
||||
/* Longest run of dispatches a played tape leaves unordered. Of any kTapeOverlapRun + 1
|
||||
* consecutive packets on a queue one carries the barrier bit, so a launched packet still proves
|
||||
* that everything more than that many packets earlier has completed. Argument slots and tape
|
||||
|
||||
@@ -875,6 +875,7 @@ std::string dev_pci_address(int device) {
|
||||
return dev_string(64, [&](char* b, int n) { return dev()->pci_address(device, b, n); });
|
||||
}
|
||||
std::atomic<int64_t> dev_stuck_exit_ms{60000};
|
||||
std::atomic<bool> dev_engine_ready{false};
|
||||
int64_t dev_stuck_ms() {
|
||||
const auto f = dev()->stuck_ms;
|
||||
return f ? f() : 0;
|
||||
@@ -933,26 +934,40 @@ int rad_event_sync(RadEvent e) {
|
||||
}
|
||||
void rad_dev_host_wrote(void) { dev()->host_wrote(); }
|
||||
|
||||
/* The VRAM the runtime keeps as queue scratch on `p`'s card once kernels with a private segment
|
||||
* (spill, or a local array: step_advance's) have been dispatched: the runtime hands a queue
|
||||
* scratch memory at the first such dispatch, and the card showed +114 MiB after the first
|
||||
* speculative step and kept it, 150 MiB with a larger segment. Left out of the budget, it is
|
||||
* taken from the margin: serving ran with 27-65 MiB of a card free. 5 MiB a CU (the R9700 reports
|
||||
* 32), 160 MiB, over the measured. */
|
||||
extern "C" int64_t rad_dev_resident_scratch_bytes(const RadDeviceProps* p) {
|
||||
if (!p || p->is_host_backend || p->unified) return 0;
|
||||
return (int64_t)p->n_cu * (5LL * 1024 * 1024);
|
||||
}
|
||||
|
||||
/* Whether launches chain, by engine: rad_dev_chain_infer on a thread of an engine (EngineScope)
|
||||
* records that engine's answer and rad_dev_chain_enabled on any of its threads reads it. A process
|
||||
* serves several models, each with its own plugin's answer; a single answer for the process was
|
||||
* the answer of whichever model started last. Owner 0 is a thread outside every engine (a tool, a
|
||||
* test). Only where the backend chains: the AQL backend writes the record a chained form reads,
|
||||
* while a HIP launch carries only the kernel's own arguments. */
|
||||
* while a HIP launch carries only the kernel's own arguments. The answer is 2 where every chained
|
||||
* form the engine can launch fences itself (RadKernelChainFn saying 2), which
|
||||
* rad_dev_chain_unfenced reads. */
|
||||
static std::mutex g_chain_mu;
|
||||
static std::map<int, int> g_chain_pays; /* by owner */
|
||||
static std::map<int, int> g_chain_pays; /* by owner: 0, 1, or 2 (their packets unacquired) */
|
||||
static std::atomic<uint64_t> g_chain_gen{1};
|
||||
void rad_dev_chain_infer(int pays) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(g_chain_mu);
|
||||
g_chain_pays[rad::engine_owner()] = pays ? 1 : 0;
|
||||
g_chain_pays[rad::engine_owner()] = pays == 2 ? 2 : pays ? 1 : 0;
|
||||
}
|
||||
g_chain_gen.fetch_add(1, std::memory_order_release);
|
||||
}
|
||||
int rad_dev_chain_enabled(void) {
|
||||
/* Asked on every launch: a thread keeps its engine's answer until some answer changes. */
|
||||
/* The calling thread's engine's answer where the backend chains, else 0: asked on every launch,
|
||||
* so a thread keeps it until some answer changes. */
|
||||
static int chain_mode() {
|
||||
thread_local uint64_t seen = 0;
|
||||
thread_local int owner = -1, on = 0;
|
||||
thread_local int owner = -1, mode = 0;
|
||||
const uint64_t gen = g_chain_gen.load(std::memory_order_acquire);
|
||||
const int o = rad::engine_owner();
|
||||
if (seen != gen || owner != o) {
|
||||
@@ -962,12 +977,14 @@ int rad_dev_chain_enabled(void) {
|
||||
const auto it = g_chain_pays.find(o);
|
||||
if (it != g_chain_pays.end()) pays = it->second;
|
||||
}
|
||||
on = pays && std::strcmp(rad::device_backend_name(), "aql") == 0 ? 1 : 0;
|
||||
mode = pays && std::strcmp(rad::device_backend_name(), "aql") == 0 ? pays : 0;
|
||||
seen = gen;
|
||||
owner = o;
|
||||
}
|
||||
return on;
|
||||
return mode;
|
||||
}
|
||||
int rad_dev_chain_enabled(void) { return chain_mode() != 0; }
|
||||
int rad_dev_chain_unfenced(void) { return chain_mode() == 2; }
|
||||
|
||||
int rad_event_elapsed_ms(RadEvent a, RadEvent b, float* out) {
|
||||
return dev()->event_elapsed_ms(a, b, out);
|
||||
|
||||
+10
-8
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "diag/diag.h"
|
||||
|
||||
#include "rad_internal.h"
|
||||
#include "rad_runtime.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -943,15 +944,13 @@ std::vector<CorpusEntry> builtin_corpus() {
|
||||
}
|
||||
|
||||
int load_corpus(const std::string& path, std::vector<CorpusEntry>* out, std::string* why) {
|
||||
FILE* f = std::fopen(path.c_str(), "rb");
|
||||
if (!f) {
|
||||
*why = "cannot open " + path;
|
||||
/* A corpus is a file someone forwarded: the capped read and bounded parse every supplied
|
||||
* JSON file gets -- the size refusal lands before the bytes are read. */
|
||||
std::string text;
|
||||
if (read_text_file(path, text, kMaxContainerFile) != RAD_OK) {
|
||||
*why = "cannot open " + path + ", or it carries more than the largest accepted JSON file";
|
||||
return RAD_E_IO;
|
||||
}
|
||||
std::string text;
|
||||
char b[65536];
|
||||
for (size_t n; (n = std::fread(b, 1, sizeof b, f)) > 0;) text.append(b, n);
|
||||
std::fclose(f);
|
||||
std::vector<CorpusEntry> got;
|
||||
size_t line_no = 0;
|
||||
for (size_t pos = 0; pos <= text.size();) {
|
||||
@@ -962,11 +961,14 @@ int load_corpus(const std::string& path, std::vector<CorpusEntry>* out, std::str
|
||||
++line_no;
|
||||
const size_t a = line.find_first_not_of(" \t\r");
|
||||
if (a == std::string::npos || line[a] == '#') continue;
|
||||
const json j = json::parse(line, nullptr, /*allow_exceptions=*/false);
|
||||
bool over = false, deep = false;
|
||||
const json j = json::parse_container(line, &over, &deep);
|
||||
auto bad = [&](const char* what) {
|
||||
*why = path + ":" + std::to_string(line_no) + ": " + what;
|
||||
return RAD_E_INVAL;
|
||||
};
|
||||
if (over) return bad("carries far too many values for one prompt line");
|
||||
if (deep) return bad("nests far too deep for one prompt line");
|
||||
if (j.is_discarded() || !j.is_object()) return bad("not a JSON object");
|
||||
if (!j.contains("category") || !j["category"].is_string() || j["category"].get<std::string>().empty())
|
||||
return bad("needs a non-empty string \"category\"");
|
||||
|
||||
+198
-20
@@ -401,6 +401,7 @@ int Engine::park(int64_t drain_ms, const PageOut& req, PageResult* got, std::str
|
||||
spare.push_back({ (const char*)r->ctx.arena_base() + fixed, top - fixed });
|
||||
}
|
||||
if (!spare.empty()) dev_page_discard(owner_, spare);
|
||||
xflex_restore_.clear();
|
||||
(void)xflex_settle();
|
||||
if (cfg_.prefix_cache) (void)sched_.reset_prefix_cache();
|
||||
const auto t2 = clk::now();
|
||||
@@ -542,6 +543,7 @@ int64_t Engine::xflex_give(int64_t bytes) {
|
||||
}
|
||||
(void)rad_dev_set(ranks_[0]->device);
|
||||
const int64_t left = xflex_settle();
|
||||
xflex_restore_.recalled(cur, left);
|
||||
xflex_retry_ns_ = rad_mono_ns() + 5000000000ull;
|
||||
const int64_t got = std::max<int64_t>(cur - left, 0);
|
||||
if (got > 0)
|
||||
@@ -550,8 +552,10 @@ int64_t Engine::xflex_give(int64_t bytes) {
|
||||
return got;
|
||||
}
|
||||
|
||||
/* Every tenth of a second on the step loop. While the engine has been busy in the last five
|
||||
* seconds, the slab grows a GiB at a time into memory the fleet says no model holds, and grows
|
||||
/* Every tenth of a second on the step loop. While recently busy, or restoring backing a
|
||||
* peer's recall removed, the slab grows a GiB at a time into memory the fleet says no model
|
||||
* holds. Idle restoration stops at its previous watermark and never advertises eviction demand.
|
||||
* The slab grows
|
||||
* again only once the units fill what it already has, leaving no more than the turnover slots and
|
||||
* half a step empty (an empty slot is VRAM nothing uses). A refusal is remembered, so the fleet
|
||||
* can make room for it (expert_flex_wanted), and asked again a second later; a backing that fails
|
||||
@@ -563,20 +567,27 @@ void Engine::xflex_tick(bool busy) {
|
||||
if (now - xflex_ns_ < 100000000ull) return;
|
||||
xflex_ns_ = now;
|
||||
const int64_t cur = xflex_bytes_.load(std::memory_order_acquire);
|
||||
if (cur >= xflex_cap_ || now - xflex_busy_ns_ > 5000000000ull) {
|
||||
const bool idle_restore = now - xflex_busy_ns_ > 5000000000ull;
|
||||
const int64_t restore_limit = xflex_restore_.limit(cur, xflex_cap_);
|
||||
const int64_t limit = idle_restore ? restore_limit : xflex_cap_;
|
||||
// Clear a previous busy demand even when retry or occupancy stops this attempt.
|
||||
// Background restoration must not ask the fleet to evict an idle peer.
|
||||
if (idle_restore) xflex_want_.store(0, std::memory_order_release);
|
||||
if (cur >= limit) {
|
||||
xflex_want_.store(0, std::memory_order_release);
|
||||
return;
|
||||
}
|
||||
if (now < xflex_retry_ns_) return;
|
||||
if (now < xflex_retry_ns_ || (idle_restore && !xflex_restore_.ready(now))) return;
|
||||
const Mover& m0 = ranks_[0]->mover;
|
||||
const int64_t g = std::max<int64_t>(VMem::granularity(), 1);
|
||||
const int64_t step = std::min<int64_t>(((int64_t)1 << 30) / g * g, xflex_cap_ - cur);
|
||||
const int64_t step = std::min<int64_t>(((int64_t)1 << 30) / g * g, limit - cur);
|
||||
/* Still filling: what the loans offer and no unit holds, past the slots kept free for swaps. */
|
||||
const int64_t kept = m0.turnover_bytes();
|
||||
if (m0.flex_offered_bytes() - m0.flex_used_bytes() > kept + step / 2) return;
|
||||
if (!broker_->flex_grow(rank_devices(), step)) {
|
||||
xflex_want_.store(xflex_cap_ - cur, std::memory_order_release);
|
||||
xflex_retry_ns_ = now + 1000000000ull;
|
||||
xflex_want_.store(xflex_restore_.refused(now, idle_restore, xflex_cap_ - cur),
|
||||
std::memory_order_release);
|
||||
if (!idle_restore) xflex_retry_ns_ = now + 1000000000ull;
|
||||
return;
|
||||
}
|
||||
struct Landed { VramBroker* b; ~Landed() { b->flex_done(); } } landed{ broker_ };
|
||||
@@ -606,6 +617,10 @@ void Engine::xflex_tick(bool busy) {
|
||||
(void)rad_dev_set(ranks_[0]->device);
|
||||
xflex_bytes_.store(to, std::memory_order_release);
|
||||
xflex_want_.store(0, std::memory_order_release);
|
||||
(void)xflex_restore_.limit(to, xflex_cap_);
|
||||
if (idle_restore && to >= restore_limit)
|
||||
RAD_INFO("expert flex: restored previous %s of backing a card while idle; "
|
||||
"cached expert fill continues", humanb(to).c_str());
|
||||
if (to >= xflex_cap_ || cur == 0)
|
||||
RAD_INFO("expert flex: the slab grows into memory no model holds: %s a card of up to %s",
|
||||
humanb(to).c_str(), humanb(xflex_cap_).c_str());
|
||||
@@ -757,6 +772,7 @@ Engine::Readback::~Readback() {
|
||||
}
|
||||
|
||||
Engine::~Engine() {
|
||||
depth_log_stats("final");
|
||||
/* The control vector's per-rank direction copies. Uploaded at declare, outside any arena, so
|
||||
* nothing else frees them; each rank's copy is freed with that rank's device bound, since the
|
||||
* allocator is per device. */
|
||||
@@ -880,6 +896,8 @@ int Engine::declare_sampler(int rank, RadBuilder* b, int64_t logits_width, bool
|
||||
sc.rank = rank;
|
||||
sc.world_size = cfg_.tp;
|
||||
sc.draft_coupling = cfg_.draft_coupling;
|
||||
sc.draft_verify_block = cfg_.draft_verify_block;
|
||||
sc.draft_verify_traversal = cfg_.draft_verify_traversal;
|
||||
RAD_TRY(smp.declare(b, sc));
|
||||
|
||||
/* Where the chain writes the sampled ids. The engine declares it because rad-kbench drives the
|
||||
@@ -1017,6 +1035,9 @@ void Engine::tiering_dispatch(Rank& r, int step) {
|
||||
* credited; the next unstaged step swaps on them. */
|
||||
std::vector<Swap> swaps;
|
||||
if (!r.stager.staged() && r.heat.step(&swaps) < 0) return;
|
||||
/* What the turnover slots follow (MoverConfig::turnover_adaptive). A staged step proposes
|
||||
* nothing and holds the turnover filled anyway (below), so it is not a quiet step. */
|
||||
if (!r.stager.staged()) r.mover.swap_demand((int64_t)swaps.size());
|
||||
for (const Swap& s : swaps) {
|
||||
/* Contract: every proposed unit is busy until `issue` takes it or `abandon` returns it;
|
||||
* a dropped proposal stays busy forever. */
|
||||
@@ -1210,7 +1231,8 @@ int Engine::prepare_release(const RadBatch* b) {
|
||||
* parked, so no allocation races the read. */
|
||||
kvstream_step_runs(ranks_[0]->kv, b, sched_.step_seqs(b), &stage_runs_);
|
||||
for (auto& rk : ranks_) kvstream_bound_live(&rk->ctx, stage_runs_);
|
||||
return RAD_OK;
|
||||
/* A checkpoint inside the step: every rank's Ctx copies into its stage (Ctx::set_ckpt_snap). */
|
||||
return ckpt_stage_arm(b);
|
||||
}
|
||||
|
||||
int Engine::issue_ahead(const RadBatch** out) {
|
||||
@@ -1220,7 +1242,9 @@ int Engine::issue_ahead(const RadBatch** out) {
|
||||
if (flex_pending_.load(std::memory_order_acquire) || quiet_pending_.load(std::memory_order_acquire))
|
||||
return RAD_OK;
|
||||
for (int i = 0; i < serial_rows_ && serial_done_ > 0; ++i)
|
||||
sched_.expect_draft(serial_row_[(size_t)i].seq, serial_done_);
|
||||
/* --draft-depth adaptive: the row's own chain (Engine::depth_row_nodes); else the rounds
|
||||
* every row ran. */
|
||||
sched_.expect_draft(serial_row_[(size_t)i].seq, depth_row_nodes(i));
|
||||
for (int i = 0; i < block_rows_; ++i)
|
||||
sched_.expect_draft(block_row_[(size_t)i].seq, block_steps_);
|
||||
const RadBatch* nb = sched_.step_next();
|
||||
@@ -1665,6 +1689,8 @@ int Engine::step_loop() {
|
||||
* immediately for a kind that is not its own. */
|
||||
st = block_drafting() ? finish_block_drafter(so) : finish_serial_drafter(so);
|
||||
if (st < 0) return fail_loop(st);
|
||||
/* --draft-depth-load: the step's time and tokens, for the rule's rate and prices. */
|
||||
if (depth_load_on_) depth_step_note(b, so);
|
||||
/* The step ends here, after its draft rounds, so step timing includes them
|
||||
* (Scheduler::step_finished). */
|
||||
sched_.step_finished();
|
||||
@@ -1902,6 +1928,45 @@ int Engine::collect_pooled(const RadBatch* b, StepOut& so) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ the checkpoint stage */
|
||||
/* After the KV carve, the snapshot store and Scheduler::init. Every rank carved a stage or none
|
||||
* did (KVManager::plan_groups decides on the same config and plans). */
|
||||
int Engine::ckpt_stage_open() {
|
||||
bool staged = !ranks_.empty() && ck_store_.enabled();
|
||||
for (auto& rk : ranks_) staged = staged && rk->kv.ckpt_stage() != nullptr;
|
||||
if (!staged) return RAD_OK;
|
||||
ranks_[0]->kv.ckpt_stage_layout(&ck_stage_off_, &ck_stage_lb_);
|
||||
ckpt_inside_ = ckpt_snap_ok_;
|
||||
sched_.set_ckpt_inside(ckpt_inside_);
|
||||
RAD_INFO("checkpoint stage: %s a rank on the card; %s",
|
||||
humanb(ranks_[0]->kv.ckpt_stage_bytes()).c_str(),
|
||||
ckpt_inside_ ? "a prompt's tail snapshot is taken inside its last chunk"
|
||||
: "every snapshot at a chunk's end");
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int Engine::ckpt_stage_arm(const RadBatch* b) {
|
||||
if (ck_stage_off_.empty()) return RAD_OK;
|
||||
const StepEntry* in = nullptr;
|
||||
if (b && b->ckpt_cut > 0)
|
||||
for (const StepEntry& e : sched_.plan().e)
|
||||
if (e.ckpt_slot >= 0 && e.ckpt_tok >= 0 && e.ckpt_tok + 1 < e.n_tokens) in = &e;
|
||||
if (!in) {
|
||||
for (auto& rk : ranks_) rk->ctx.set_ckpt_snap(nullptr, ckpt_slots_, ck_stage_off_, ck_stage_lb_);
|
||||
return RAD_OK;
|
||||
}
|
||||
if (in->ckpt_tok + 1 != b->ckpt_cut || !state_slots_of(in->seq, &ckpt_slots_)) {
|
||||
RAD_ERR("step %d: sequence %llu's checkpoint inside the step (row %d) is not the batch's "
|
||||
"(%d), or its state slots are gone", b->step, (unsigned long long)in->seq,
|
||||
(int)in->ckpt_tok, (int)b->ckpt_cut);
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
/* The step writes the stage; the last snapshot left it on the same stream (save_checkpoints). */
|
||||
for (auto& rk : ranks_)
|
||||
rk->ctx.set_ckpt_snap(rk->kv.ckpt_stage(), ckpt_slots_, ck_stage_off_, ck_stage_lb_);
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* Snapshot after the step that produced the state. Linear state is what the chunk's last token
|
||||
* leaves, so the chunker ended the chunk at the checkpoint and copy 0 holds exactly that state; a
|
||||
* window snapshot is the window's rows behind the checkpoint, which may lie inside the chunk
|
||||
@@ -1930,12 +1995,26 @@ int Engine::save_checkpoints() {
|
||||
(unsigned long long)e.seq, (int)(e.ctx_len + e.ckpt_tok + 1));
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
for (auto& rk : ranks_) {
|
||||
/* A checkpoint inside the step is in the stage already (rad_ckpt_snap) and goes
|
||||
* to the host slot from there in one copy; one at the chunk's end is copied from
|
||||
* the live slots. */
|
||||
const bool inside = e.ckpt_tok + 1 < e.n_tokens && !ck_stage_off_.empty();
|
||||
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
||||
auto& rk = ranks_[ri];
|
||||
if (ranks_.size() > 1) (void)rad_dev_set(rk->device);
|
||||
const int s = rk->kv.checkpoint_save(ckpt_slots_.data(),
|
||||
(int)ckpt_slots_.size(),
|
||||
e.ckpt_slot, rk->ctx.stream(),
|
||||
&ckpt_win_);
|
||||
int s = RAD_OK;
|
||||
if (!inside) {
|
||||
s = rk->kv.checkpoint_save(ckpt_slots_.data(), (int)ckpt_slots_.size(),
|
||||
e.ckpt_slot, rk->ctx.stream(), &ckpt_win_);
|
||||
} else {
|
||||
/* The layers the step did not snapshot (rad_ckpt_snap) are the ones it did
|
||||
* not change: a drafter head's state, which moves only in the drafter's
|
||||
* passes behind this copy. */
|
||||
s = rk->kv.checkpoint_stage_rest(
|
||||
ckpt_slots_.data(), (int)ckpt_slots_.size(), rk->ctx.stream(),
|
||||
[&](size_t g, int64_t li) { return rk->ctx.ckpt_snapped(g, li); });
|
||||
if (s >= 0) s = rk->kv.checkpoint_stage_out(e.ckpt_slot, rk->ctx.stream());
|
||||
}
|
||||
if (s < 0) {
|
||||
RAD_ERR("rank %d could not snapshot sequence %llu into checkpoint slot "
|
||||
"%d: %s", rk->index, (unsigned long long)e.seq,
|
||||
@@ -1945,6 +2024,30 @@ int Engine::save_checkpoints() {
|
||||
}
|
||||
}
|
||||
if (ranks_.size() > 1) (void)rad_dev_set(ranks_[0]->device);
|
||||
/* RADIANCE_DEBUG_CKPT_HASH=1: wait for the snapshot and log a digest of each
|
||||
* rank's shard, to compare two builds' snapshots byte for byte. A debugging aid:
|
||||
* it drains the streams. */
|
||||
static const bool hash_on = [] {
|
||||
const char* h = std::getenv("RADIANCE_DEBUG_CKPT_HASH");
|
||||
return h && h[0] == '1';
|
||||
}();
|
||||
if (hash_on) {
|
||||
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
|
||||
auto& rk = ranks_[ri];
|
||||
if (ranks_.size() > 1) (void)rad_dev_set(rk->device);
|
||||
(void)rad_stream_sync(rk->ctx.stream());
|
||||
const unsigned char* p = (const unsigned char*)rk->kv.checkpoint_ptr(e.ckpt_slot);
|
||||
uint64_t h = 0xcbf29ce484222325ull;
|
||||
const int64_t nb = rk->kv.checkpoint_bytes();
|
||||
for (int64_t j = 0; p && j < nb; ++j) { h ^= p[j]; h *= 0x100000001b3ull; }
|
||||
RAD_INFO("ckpt-hash seq=%llu pos=%lld rank=%zu inside=%d bytes=%lld %016llx",
|
||||
(unsigned long long)e.seq,
|
||||
(long long)(e.ctx_len + e.ckpt_tok + 1), ri,
|
||||
(int)(e.ckpt_tok + 1 < e.n_tokens), (long long)nb,
|
||||
(unsigned long long)h);
|
||||
}
|
||||
if (ranks_.size() > 1) (void)rad_dev_set(ranks_[0]->device);
|
||||
}
|
||||
}
|
||||
return RAD_OK;
|
||||
});
|
||||
@@ -1993,6 +2096,24 @@ int Engine::stage_scored_rows(const StepPlan& plan, const StepOut& so,
|
||||
score_ids_.erase(std::unique(score_ids_.begin(), score_ids_.end()), score_ids_.end());
|
||||
}
|
||||
bool host_failed = false;
|
||||
/* The step-wide sibling of the scheduler's kMaxScoredCandidates. That cap bounds one
|
||||
* request's candidate list; this one bounds the step's union of them, which otherwise grows
|
||||
* toward the whole vocabulary. The readback below is pinned host memory sized by the union and
|
||||
* never shrinks, so a step is refused by its count before the allocation is tried: a
|
||||
* gigabyte-scale pin that succeeds would stay pinned. The cap is sixteen requests at the
|
||||
* per-request maximum; a scored request names a few dozen ids. A step past it is refused the
|
||||
* way an allocation failure is: the scored requests cancel and the engine goes on. */
|
||||
static const size_t kMaxScoredStepIds = 1u << 16;
|
||||
if (score_only_ && score_ids_.size() > kMaxScoredStepIds) {
|
||||
RAD_ERR("scored rows: the step names %zu candidate rows, over the step budget of %zu; "
|
||||
"cancelling the scored requests, not the engine",
|
||||
score_ids_.size(), kMaxScoredStepIds);
|
||||
cancel.insert(cancel.end(), scored.begin(), scored.end());
|
||||
score_rows_.clear();
|
||||
score_only_ = false;
|
||||
score_ids_.clear();
|
||||
return RAD_OK;
|
||||
}
|
||||
int64_t failed_rows = 0;
|
||||
for (auto& rk : ranks_) {
|
||||
const int64_t width = rk->sampler.config().n_vocab_local;
|
||||
@@ -2815,9 +2936,13 @@ int Engine::serve(std::unique_ptr<StallWatch> watch) {
|
||||
* Qwen3.8-Flash-Next at TP2 (two R9700, 12 GiB host pool) the span loses to one-interval
|
||||
* steps up to 12K tokens and wins from 18K, hence eight intervals. With every expert on
|
||||
* the card there is no such cost and every lone prefill spans. */
|
||||
sched_.set_span_min(stage_rows > 0 && arena_span_rows_ > 0
|
||||
? 8 * std::max<int64_t>(geo_.checkpoint_interval, 0) : 0);
|
||||
const int64_t span_auto = stage_rows > 0 && arena_span_rows_ > 0
|
||||
? 8 * std::max<int64_t>(geo_.checkpoint_interval, 0) : 0;
|
||||
/* --prefill-span-min N says it for the deployment: where the routed pass covers the whole
|
||||
* spanned step (--prefill-span-pass step) the span pays from the second interval on. */
|
||||
sched_.set_span_min(cfg_.prefill_span_min >= 0 ? cfg_.prefill_span_min : span_auto);
|
||||
}
|
||||
RAD_TRY(ckpt_stage_open());
|
||||
|
||||
for (auto& r : ranks_) r->sampler.attach_vocab(vocab_view_.get());
|
||||
|
||||
@@ -3130,6 +3255,26 @@ SamplingParams Engine::sampling_defaults() const {
|
||||
return resolve_sampling_defaults(meta_, file_ != nullptr, cfg_);
|
||||
}
|
||||
|
||||
/* A token the model's chat format writes as one of its call delimiters is a call boundary, not a
|
||||
* turn's: a reply that closes a call with it must be able to write the next call and text after
|
||||
* it. A checkpoint that also lists the token in generation_config.json's eos ids would end every
|
||||
* tool-calling turn there, so the id leaves the vocabulary's end-of-generation set. This runs
|
||||
* once the vocabulary and the plugins are both loaded (the reply format can be the architecture
|
||||
* plugin's) and before anything reads the set: the scheduler and the cards' step state, which cut
|
||||
* accepted drafts at it, the grammar index and the reply parser's terminators. */
|
||||
int Engine::demote_call_delimiters() {
|
||||
if (!vocab_own_ || vocab_own_->chat_template().empty()) return RAD_OK;
|
||||
const std::vector<int32_t> dropped = vocab_own_->drop_named_eog(
|
||||
server::ChatTemplateBridge::eog_call_markers(*vocab_own_,
|
||||
rad_tools_chat_format(plugins_, meta_)));
|
||||
if (dropped.empty()) return RAD_OK;
|
||||
for (int32_t id : dropped)
|
||||
RAD_WARN("vocab: token %d \"%s\" is listed as end-of-generation by the checkpoint's "
|
||||
"generation_config.json and is one of this model's tool-call delimiters; a turn "
|
||||
"does not end on it", id, vocab_->text(id).c_str());
|
||||
return build_vocab_view();
|
||||
}
|
||||
|
||||
/* The HTTP server over the engine. `/v1/completions`, `/v1/chat/completions`, `/v1/models`,
|
||||
* `/metrics` and `/health` are live. `/v1/embeddings` answers 501 unless the program is an
|
||||
* embedding program, and so do image, video and audio content parts unless the program declared an
|
||||
@@ -3427,6 +3572,13 @@ int Engine::run_server() {
|
||||
o.plugin_words = ranks_.empty() ? 0 : ranks_[0]->program.plugin_words;
|
||||
o.model_id = !cfg_.served_model_name.empty() ? cfg_.served_model_name
|
||||
: meta_.name && *meta_.name ? meta_.name : "radiance";
|
||||
o.control_vector_variant = cfg_.control_vector_variant;
|
||||
if (!o.control_vector_variant.empty() && o.control_vector_variant == o.model_id) {
|
||||
RAD_ERR("--control-vector-variant '%s' is the served model's own name, so a request "
|
||||
"naming it would run the default; rename it or give --served-model-name",
|
||||
o.model_id.c_str());
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
o.host = cfg_.host;
|
||||
o.port = cfg_.port;
|
||||
o.api_key = cfg_.api_key;
|
||||
@@ -3571,6 +3723,31 @@ int Engine::run_server() {
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (vc.family == mm::Family::Gemma4) {
|
||||
/* A two-sided paged window is exact for image spans no longer than the window.
|
||||
* Limit what the processor admits if a rank cannot run the long-span variant. */
|
||||
if (encd.bidirectional) {
|
||||
for (const auto& rank : ranks_) {
|
||||
long long window = 0;
|
||||
bool ahead = false;
|
||||
for (const OpInfo& op : rank->program.ops) {
|
||||
if (op.op == "attn_paged_ahead" || op.op == "attn_paged_qrow_ahead")
|
||||
for (const Band& b : op.bands)
|
||||
ahead = ahead || b.dom[RAD_DOMAIN_HOST] || b.dom[RAD_DOMAIN_DEVICE];
|
||||
if (op.op == "attn_paged" || op.op == "attn_paged_qrow") {
|
||||
long long causal = 1, w = 0;
|
||||
if (op.base.get_i("causal", &causal) && causal == 0 &&
|
||||
op.base.get_i("window", &w) && w > 0)
|
||||
window = window > 0 ? std::min(window, w) : w;
|
||||
}
|
||||
}
|
||||
if (!ahead && window > 0 && window < vc.max_patches / encd.merge)
|
||||
vc.max_patches = window * encd.merge;
|
||||
}
|
||||
if (vc.max_patches < encd.max_patches)
|
||||
RAD_INFO("media: image spans are limited to %lld soft tokens because the "
|
||||
"loaded kernels cannot attend beyond the sliding window",
|
||||
(long long)(vc.max_patches / encd.merge));
|
||||
}
|
||||
if (cfg_.image_min_pixels || cfg_.image_max_pixels || cfg_.video_min_pixels ||
|
||||
cfg_.video_max_pixels || cfg_.video_min_frames) {
|
||||
RAD_ERR("media: this model's processor sizes images and video frames by a token "
|
||||
@@ -3650,10 +3827,11 @@ int Engine::run_server() {
|
||||
}
|
||||
if (vc.family == mm::Family::Gemma4 &&
|
||||
(int64_t)std::max(vc.image_soft_tokens, vc.video_soft_tokens) * vc.merge * vc.merge >
|
||||
encd.max_patches) {
|
||||
RAD_ERR("media: an image of %d soft tokens or a video frame of %d is more patches than "
|
||||
"one encoder pass holds (--mm-max-patches %lld)", vc.image_soft_tokens,
|
||||
vc.video_soft_tokens, (long long)encd.max_patches);
|
||||
vc.max_patches) {
|
||||
RAD_ERR("media: an image of %d soft tokens or a video frame of %d exceeds this "
|
||||
"deployment's limit of %lld soft tokens per segment; lower --image-tokens "
|
||||
"or --video-max-frame-tokens", vc.image_soft_tokens, vc.video_soft_tokens,
|
||||
(long long)(vc.max_patches / encd.merge));
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
mm_proc = std::make_unique<mm::Processor>();
|
||||
|
||||
+90
-2
@@ -29,6 +29,7 @@
|
||||
#include "runtime/ctx.h" /* KVStageRun */
|
||||
#include "sched/mem_iface.h"
|
||||
#include "sched/scheduler.h"
|
||||
#include "sched/draft_depth.h" /* --draft-depth adaptive: the stop rule */
|
||||
#include "sample/vocab_view.h"
|
||||
#include "runtime/rank_barrier.h"
|
||||
#include "text/tokenizer.h"
|
||||
@@ -38,9 +39,11 @@
|
||||
#include "lora/adapter.h"
|
||||
#include "lora/slots.h"
|
||||
#include "fleet/broker.h"
|
||||
#include "place/expert_restore.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -272,7 +275,7 @@ private:
|
||||
/* The first of this engine's instance slots (RadBuildCtx::slot_base), held from load_plugins
|
||||
* to the destructor (rad_engine_claim); -1 while none is held. */
|
||||
int slot_base_ = -1;
|
||||
bool cards_claimed_ = false; /* rad_dev_cards_claim, for an engine of more than one rank */
|
||||
bool cards_claimed_ = false; /* rad_dev_cards_claim, balanced during teardown */
|
||||
|
||||
/* RadModelMeta holds bare char*, so the strings behind its key/value table must outlive
|
||||
* every declare. */
|
||||
@@ -419,6 +422,9 @@ private:
|
||||
/* The text frontend, loaded from the container. The sampler's grammars walk `vocab_view_`,
|
||||
* which references `vocab_` and must not outlive it. */
|
||||
std::shared_ptr<const Vocab> vocab_;
|
||||
/* `vocab_` itself, writable: bring-up takes call delimiters out of its end-of-generation set
|
||||
* (demote_call_delimiters) before anything is built from the set. Not written after that. */
|
||||
std::shared_ptr<Vocab> vocab_own_;
|
||||
std::unique_ptr<VocabView> vocab_view_;
|
||||
/* The container's second vocabulary (rad-convert --tokenizer2), which an image generator that
|
||||
* declares `aux_tokens` reads its prompt through; null without one. */
|
||||
@@ -487,10 +493,12 @@ private:
|
||||
void flex_room_tick(uint64_t now_ns);
|
||||
/* Expert flex (§6.7). Each rank's slab borrows from its own reserved range (Rank::xflex), the
|
||||
* top `xflex_bytes_` of it backed; the ceiling is the loan that covers every slot carved there.
|
||||
* xflex_tick grows it on the step loop while the engine is busy, a GiB at a time once the
|
||||
* xflex_tick grows it while busy, or restores surrendered backing while idle, a GiB
|
||||
* at a time once the
|
||||
* slab has filled what it holds; xflex_give recalls and unbacks it, between steps. */
|
||||
std::atomic<int64_t> xflex_bytes_{0};
|
||||
std::atomic<int64_t> xflex_want_{0};
|
||||
ExpertFlexRestore xflex_restore_; /* step-loop state, reset on park */
|
||||
int64_t xflex_cap_ = 0;
|
||||
int64_t xflex_claimed_ = 0; /* the claim's expert bytes a card */
|
||||
uint64_t xflex_ns_ = 0, xflex_busy_ns_ = 0, xflex_retry_ns_ = 0;
|
||||
@@ -540,6 +548,8 @@ private:
|
||||
bool state_slots_of(uint64_t seq, std::vector<int32_t>* out) const;
|
||||
|
||||
int load_vocab();
|
||||
int build_vocab_view();
|
||||
int demote_call_delimiters();
|
||||
int declare_sampler(int rank, RadBuilder* b, int64_t logits_width, bool sizing = false);
|
||||
/* The build context for every declare of rank `rank` at `max_tok`; the real declare and the
|
||||
* arena's sizing declares differ only in max_tok. */
|
||||
@@ -668,6 +678,70 @@ private:
|
||||
bool couple_evidence_ = false; /* the completed-verify line was written (once a process) */
|
||||
bool couple_host_note_ = false; /* the host-domain counterpart was written (once) */
|
||||
bool couple_malformed_note_ = false; /* a status -1 round was reported (once) */
|
||||
int64_t couple_planes_ = 0; /* the rounds the state plane holds */
|
||||
/* --draft-depth adaptive (sched/draft_depth.h, engine_draft.cpp): the chain of a step stops by
|
||||
* the head's own laws, so its rounds are issued one decision at a time. After the pass of
|
||||
* round r the engine copies that round's state rows to depth_rb_ and records depth_ev_[r - 1];
|
||||
* the driver waits for the event of the round a decision needs, reads the statistic and issues
|
||||
* the next round or ends the chain. depth_of_[i] is drafting row i's final depth, which
|
||||
* expect_draft, set_draft and the coupling's bind all take in place of the rounds that ran. */
|
||||
DraftDepthCfg depth_cfg_;
|
||||
RadEvent depth_ev_[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
|
||||
bool depth_issued_[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
|
||||
RadMtpCoupleState* depth_rb_ = nullptr; /* pinned [rounds, couple_rows_] */
|
||||
std::vector<DraftDepthRow> depth_row_;
|
||||
std::vector<int32_t> depth_of_;
|
||||
int depth_seen_ = 0; /* rounds observed this step */
|
||||
static constexpr int64_t kDepthSpinUs = 3000; /* poll this long for a round, then block */
|
||||
struct DepthStats {
|
||||
uint64_t steps = 0, rows = 0, rounds = 0, drafts = 0, lawless = 0, waits = 0, blocked = 0;
|
||||
uint64_t hist[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
|
||||
double wait_us = 0;
|
||||
uint64_t late = 0;
|
||||
/* By the drafts a step made (d): the card's cycle from that step's first statistic to the
|
||||
* next step's (its later rounds, the verify of d + 1 rows, the sampler, the next history
|
||||
* pass), and what the verify of d drafts accepted. */
|
||||
double cyc_us[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
|
||||
uint64_t cyc_n[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
|
||||
uint64_t acc[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {}, acc_n[RAD_MTP_COUPLE_MAX_ROUNDS + 1] = {};
|
||||
} depth_stats_;
|
||||
std::chrono::steady_clock::time_point depth_e1_{}; /* the last step's first statistic */
|
||||
uint64_t depth_logged_ = 0; /* depth_stats_.rows at the last line */
|
||||
int depth_last_ = 0; /* and the deepest chain that step made */
|
||||
/* --draft-depth-load (sched/draft_depth.h): the load-aware rule and the late choice of the
|
||||
* verify's rows, for a step that drafts for depth_cfg_.load_from sequences or more, and the
|
||||
* online calibration of the tables they read. */
|
||||
DraftDepthOnline depth_online_;
|
||||
bool depth_online_on_ = false; /* --draft-depth-load-calib online */
|
||||
int depth_other_rows_ = 0; /* the next verify's token rows that draft nothing */
|
||||
bool depth_load_step_ = false; /* this step's chains were decided by the load-aware rule */
|
||||
bool depth_load_on_ = false; /* --draft-depth-load on: the tables exist */
|
||||
/* A chain between the step that drafted it and the verify that settles it, by card slot: what
|
||||
* the online calibration counts once the accepted count is known. */
|
||||
struct DepthPend {
|
||||
uint64_t seq = 0;
|
||||
int32_t depth = 0, rule = 0, n_s = 0; /* depth 0: nothing pending */
|
||||
float s[RAD_MTP_COUPLE_MAX_ROUNDS] = {};
|
||||
};
|
||||
std::vector<DepthPend> depth_pend_;
|
||||
/* The step before this one, for the rule's rate and prices: when its passes ended, and whether
|
||||
* it was a pure decode step of how many drafting rows. */
|
||||
std::chrono::steady_clock::time_point depth_note_t_{};
|
||||
int depth_note_step_ = -2, depth_note_rows_ = 0;
|
||||
uint64_t depth_note_n_ = 0;
|
||||
void depth_step_note(const RadBatch* b, const StepOut& so);
|
||||
void depth_load_log(const char* when) const;
|
||||
/* RADIANCE_DEBUG_CONC_LOG=<file>, diagnostics of the load-aware rule: one line a decode step (rows,
|
||||
* rounds, each chain's depth and statistics, what the verify accepted) and one a refresh of
|
||||
* the tables. */
|
||||
std::FILE* depth_log_ = nullptr;
|
||||
void depth_log_step(const RadBatch* b, const StepOut& so);
|
||||
/* Drafting row i's depth after issue_serial_drafter: its own under the adaptive rule, else the
|
||||
* rounds every row ran. */
|
||||
int depth_row_nodes(int i) const;
|
||||
int depth_readback_issue(int round, int n);
|
||||
int depth_observe_upto(int round, int n, const StepOut& so);
|
||||
void depth_log_stats(const char* when);
|
||||
/* `rows` are serial_row_ or block_row_ (Scheduler::SerialRow / BlockRow). */
|
||||
template <class Row> int stage_couple_draws(const Row* rows, int n);
|
||||
int bind_couple(uint64_t seq, int i, int done, bool drafted, int32_t card);
|
||||
@@ -707,6 +781,20 @@ private:
|
||||
* the checkpoint save waits for its context pass (save_checkpoints). */
|
||||
bool drafter_snap_ = false;
|
||||
int save_checkpoints();
|
||||
/* Checkpoints through the stage (KVManager::ckpt_stage).
|
||||
*
|
||||
* ckpt_snap_ok_: the plugin snapshots inside a step (RadArchProbe::ckpt_snap_ok); with a
|
||||
* stage on every rank the scheduler then takes a prompt's tail snapshot inside its last chunk
|
||||
* (Scheduler::set_ckpt_inside). Such a
|
||||
* snapshot is the stage's one contiguous copy to the host slot rather than a pitched copy a
|
||||
* group. */
|
||||
bool ckpt_snap_ok_ = false;
|
||||
bool ckpt_inside_ = false;
|
||||
std::vector<int64_t> ck_stage_off_, ck_stage_lb_;
|
||||
int ckpt_stage_open();
|
||||
/* Before a step: a step with a checkpoint inside it arms every rank's Ctx
|
||||
* (Ctx::set_ckpt_snap); every other step disarms them. */
|
||||
int ckpt_stage_arm(const RadBatch* b);
|
||||
/* A tree drafter (rad_drafter_tree), driven on the card only: ADV_BTAKE takes its parents,
|
||||
* ADV_COMPACT moves the accepted path's K and V after the acceptance, and ADV_CTXTREE stages
|
||||
* the context pass by that path. */
|
||||
|
||||
+116
-20
@@ -26,6 +26,7 @@
|
||||
#include "mem/vram_budget.h"
|
||||
#include "kvstream/bringup.h"
|
||||
#include "kvstream/plan.h"
|
||||
#include "mm/media.h"
|
||||
#include "runtime/arena.h"
|
||||
#include "runtime/kvbind.h"
|
||||
#include "runtime/xprefetch.h"
|
||||
@@ -1013,6 +1014,9 @@ RadBuildCtx Engine::build_ctx(int rank, int64_t max_tok) const {
|
||||
/* Under --prefill-span every step but a lone prefill is planned at the shared budget
|
||||
* (Scheduler::step), so a wider step is one sequence; 0 without a span. */
|
||||
bc.max_mixed_tok = cfg_.prefill_span > 1 ? std::min(max_tok, prefill_shared_tok(cfg_)) : 0;
|
||||
/* --prefill-span-pass step: the routed block's pass is the whole spanned step where the plugin
|
||||
* runs such a step serially. */
|
||||
bc.span_pass_step = cfg_.prefill_span > 1 && cfg_.prefill_span_step ? 1 : 0;
|
||||
/* --kv-resident in tokens, raised to kStreamFloorTokens as kvstream_ring_shape raises it: the
|
||||
* arch declares kv_resolve's ring depth from this, and the kernel refuses a carve deeper than
|
||||
* the declared table. */
|
||||
@@ -1060,8 +1064,8 @@ int Engine::declare() {
|
||||
decide("--no-prefix-cache", "prefix caching off", prefix_off_why_);
|
||||
}
|
||||
/* --calib-corpus: every token of the corpus through prefill exactly once, so no prefix hit
|
||||
* skips any and no drafter adds rows; the corpus is loaded here, before the plugins declare,
|
||||
* because they are told its size. */
|
||||
* skips any and no drafter adds rows. Load it before declaration so a plugin knows its size
|
||||
* and can opt into a separate, proposal-free history pass (RAD_DRAFT_HISTORY). */
|
||||
if (cfg_.calib()) {
|
||||
if (cfg_.n_spec > 0) {
|
||||
RAD_ERR("--num-speculative-tokens %d: a calibration run drafts nothing; leave it at "
|
||||
@@ -1071,7 +1075,7 @@ int Engine::declare() {
|
||||
cfg_.n_spec = 0;
|
||||
cfg_.prefix_cache = false;
|
||||
if (cfg_.mm_max_patches < 0) cfg_.mm_max_patches = 0;
|
||||
decide("--num-speculative-tokens", "0", "a calibration run records the trunk's rows only");
|
||||
decide("--num-speculative-tokens", "0", "a calibration run does not propose draft tokens");
|
||||
prefix_off_why_ = "a calibration run: a prefix hit would skip tokens the statistics must count";
|
||||
decide("--no-prefix-cache", "prefix caching off", prefix_off_why_);
|
||||
calib_ = std::make_unique<Kld>();
|
||||
@@ -1266,7 +1270,14 @@ int Engine::declare() {
|
||||
(void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs);
|
||||
const bool always = pb.chain_pays == RAD_CHAIN_ALWAYS;
|
||||
const bool pays = always || (cfg_.n_spec > 0 && pb.chain_pays != RAD_CHAIN_NONE);
|
||||
rad_dev_chain_infer(pays);
|
||||
/* Their packets go without the packet processor's acquire where every row that can chain
|
||||
* acquires in the kernel for all it reads (RadKernelChainFn saying 2): one row that does
|
||||
* not, from any library this engine loaded, keeps the acquire on all of them, since a
|
||||
* queue's packets are not told apart by library. */
|
||||
bool fenced = pays;
|
||||
for (const KernelRow& row : reg_->rows())
|
||||
if (row.chain && !row.chain_fenced) fenced = false;
|
||||
rad_dev_chain_infer(pays ? (fenced ? 2 : 1) : 0);
|
||||
const bool on = rad_dev_chain_enabled() != 0;
|
||||
const char* why = on ? (always ? "the model's plugin measured a gain with them"
|
||||
: "the model's plugin measured a gain with its "
|
||||
@@ -1274,7 +1285,12 @@ int Engine::declare() {
|
||||
: pays ? "the device backend does not chain"
|
||||
: "no drafter whose plugin measured a gain with them decodes "
|
||||
"speculatively";
|
||||
RAD_INFO("chained launches: %s -- %s", on ? "on" : "off", why);
|
||||
RAD_INFO("chained launches: %s -- %s%s", on ? "on" : "off", why,
|
||||
!on ? ""
|
||||
: rad_dev_chain_unfenced() ? "; their packets take no acquire from the packet processor"
|
||||
: "; their packets keep the packet processor's acquire "
|
||||
"(a row that chains does not acquire for its scalar "
|
||||
"loads itself)");
|
||||
decide("chained launches", on ? "on" : "off", why);
|
||||
}
|
||||
/* Trees: a block drafter's proposals verified as a tree, where the model's plugin measured a
|
||||
@@ -1287,12 +1303,55 @@ int Engine::declare() {
|
||||
/* A tree is verified only behind a step issued ahead (step_loop). The KL mode, which issues
|
||||
* none, drafts nothing either (n_spec is 0 there by now), so this never runs under it. */
|
||||
draft_tree_ = cfg_.n_spec > 0 && pb.tree_pays != 0;
|
||||
ckpt_snap_ok_ = pb.ckpt_snap_ok != 0;
|
||||
/* The checkpoint stage (KVManager::ckpt_stage), planned before any KV plan is made, where
|
||||
* a tail snapshot can be taken inside the last chunk: the plugin cuts its step for it and
|
||||
* a hit resumes at the nearest snapshot (the exact grid snapshots where a chunk starts). */
|
||||
cfg_.ckpt_stage = ckpt_snap_ok_ && !cfg_.prefix_exact;
|
||||
if (draft_tree_) {
|
||||
const char* why = "the model's plugin measured a gain with them";
|
||||
RAD_INFO("draft trees: asked -- %s", why);
|
||||
decide("draft trees", "asked", why);
|
||||
}
|
||||
}
|
||||
/* --draft-suffix: SuffixDecoding's selector (core/sched/suffix.h). A suffix step verifies up to
|
||||
* `draft_suffix_max` rows of the sequence's own history while the head still drafts its own
|
||||
* `n_spec` rounds, so the verify window every consumer of `n_spec` sees (buffers, rings, the
|
||||
* scheduler's window) becomes the larger of the two and the head's rounds are kept apart in
|
||||
* `n_spec_head`. A serial head's chain only: a block drafter's block is fixed. It works with
|
||||
* the fixed chain, with --draft-depth adaptive (whose depth stays within the head's rounds)
|
||||
* and with the traversal verify (a suffix row binds no coupled state, so it is a leaf of the
|
||||
* walk); the block verify decides a head chain as a whole and is refused. */
|
||||
cfg_.n_spec_head = 0;
|
||||
if (cfg_.draft_suffix) {
|
||||
RadArchProbe pb{};
|
||||
(void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs);
|
||||
const char* bad = nullptr;
|
||||
if (cfg_.n_spec <= 0) bad = "speculation is off (this container carries no draft head)";
|
||||
else if (draft_tree_) bad = "it needs the head's chain, not a block drafter's tree";
|
||||
else if (pb.draft_depth_fixed) bad = "this drafter is a block drafter, not a serial head";
|
||||
else if (cfg_.draft_window == DraftWindow::Adaptive)
|
||||
bad = "it needs the fixed window (--draft-window fixed)";
|
||||
else if (cfg_.draft_verify_block) bad = "it cannot be combined with --draft-verify block "
|
||||
"(a suffix chain is no block; --draft-verify token | traversal)";
|
||||
if (bad) {
|
||||
RAD_ERR("--draft-suffix on: %s", bad);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
const int window = std::max(cfg_.n_spec, cfg_.draft_suffix_max);
|
||||
if (window > (int)RAD_SCHED_MAX_SPEC) {
|
||||
RAD_ERR("--draft-suffix-max %d is past the largest verify window (%d)", cfg_.draft_suffix_max,
|
||||
(int)RAD_SCHED_MAX_SPEC);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
cfg_.n_spec_head = cfg_.n_spec;
|
||||
cfg_.n_spec = window;
|
||||
RAD_INFO("draft suffix: on -- a host-built step verifies up to %d row(s) of the sequence's own "
|
||||
"history when its last %d token(s) recur (path score >= %.2f); the head drafts %d "
|
||||
"round(s), the verify window is %d", cfg_.draft_suffix_max, cfg_.draft_suffix_min_match,
|
||||
(double)cfg_.draft_suffix_min_score, cfg_.n_spec_head, window);
|
||||
decide("draft suffix", "on", "--draft-suffix on");
|
||||
}
|
||||
/* The audio encoder's pass: the plugin's longest clip, when the model file carries an audio
|
||||
* encoder (`radiance.encoder` names one) and the deployment is not text-only. */
|
||||
if (cfg_.mm_audio_frames < 0) {
|
||||
@@ -1315,18 +1374,32 @@ int Engine::declare() {
|
||||
const bool tower = rad_meta_geti(&meta_, "vision_config.patch_size", 0) > 0 ||
|
||||
rad_meta_geti(&meta_, "vision_config.image_size", 0) > 0;
|
||||
cfg_.mm_max_patches = (enc && *enc) || (!file_ && tower) ? 16384 : 0;
|
||||
/* A build with no media decoder (RAD_WITH_FFMPEG) refuses every media part, so a tower it
|
||||
* loaded could never run a pass: it would only hold card memory the routed experts are
|
||||
* short of. Qwen3.8-Flash-Next at tp 2 on two R9700: 857 MiB a rank, about 800 expert
|
||||
* units a rank that the routed GEMMs then read from the pinned pool over the link instead
|
||||
* of from the card. An explicit --mm-max-patches still loads the tower. */
|
||||
const bool undecodable = cfg_.mm_max_patches > 0 && !mm::decoder_available();
|
||||
if (undecodable) cfg_.mm_max_patches = 0;
|
||||
/* Whole output rows a pass: the plugin's merge, when it states one. */
|
||||
RadArchProbe pb{};
|
||||
(void)rad_tools_probe(plugins_, meta_, &pb, cfg_.image_gen_max_pixels, cfg_.image_gen_max_refs);
|
||||
if (cfg_.mm_max_patches > 0 && pb.enc_merge > 1)
|
||||
cfg_.mm_max_patches -= cfg_.mm_max_patches % pb.enc_merge;
|
||||
if (cfg_.mm_max_patches == 0 && tower)
|
||||
if (undecodable)
|
||||
RAD_INFO("media: off -- the model carries a vision tower, but this build has no media "
|
||||
"decoder (RAD_WITH_FFMPEG) and would refuse every media part, so the tower "
|
||||
"is not loaded and its card memory goes to the experts and the cache; "
|
||||
"--mm-max-patches N loads it all the same");
|
||||
else if (cfg_.mm_max_patches == 0 && tower)
|
||||
RAD_INFO("media: off -- the checkpoint has a vision tower but this container was "
|
||||
"converted without its weights; convert again to serve images and video");
|
||||
decide("--mm-max-patches", std::to_string(cfg_.mm_max_patches),
|
||||
cfg_.mm_max_patches > 0
|
||||
? "the model carries a vision tower: 16384 patches is a 2048 x 2048 image, the "
|
||||
"largest one encoder pass takes"
|
||||
: undecodable ? "the model carries a vision tower, but this build has no media "
|
||||
"decoder to feed it"
|
||||
: tower ? "the checkpoint has a vision tower but this container was converted "
|
||||
"without its weights"
|
||||
: "the model carries no vision tower");
|
||||
@@ -1531,7 +1604,13 @@ int Engine::declare() {
|
||||
drafter_ = p0.drafter;
|
||||
drafter_name_ = p0.drafter_name;
|
||||
drafter_.name = drafter_name_.c_str();
|
||||
if (cfg_.n_spec <= 0) drafter_ = RadDrafterDecl{};
|
||||
const bool calib_history = drafter_.kind == RAD_DRAFT_HISTORY;
|
||||
if (calib_history && !cfg_.calib()) {
|
||||
RAD_ERR("'%s' history calibration requires --calib-corpus; it cannot run with "
|
||||
"--kld-record", drafter_.name);
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
if (cfg_.n_spec <= 0 && !calib_history) drafter_ = RadDrafterDecl{};
|
||||
/* A tree drafter (rad_drafter_tree): its parents plane rides with the proposal. */
|
||||
tree_ = drafter_.kind == RAD_DRAFT_BLOCK && drafter_.depth > 0 && p0.drafter_tree;
|
||||
tree_parents_ = tree_ ? p0.drafter_parents : 0;
|
||||
@@ -1572,7 +1651,9 @@ int Engine::declare() {
|
||||
"for the sequences the head declines", drafter_.name);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (drafter_.kind != RAD_DRAFT_NONE) {
|
||||
if (calib_history) {
|
||||
RAD_INFO("calib: '%s' history only; no draft proposals", drafter_.name);
|
||||
} else if (drafter_.kind != RAD_DRAFT_NONE) {
|
||||
/* A zero proposal handle means the sampler's token buffer: the head's logits go through
|
||||
* the ordinary sampler chain. */
|
||||
RAD_INFO("speculation: %s",
|
||||
@@ -1753,6 +1834,7 @@ int Engine::plan() {
|
||||
for (RadStream s : q) if (s) rad_stream_destroy(s);
|
||||
}
|
||||
f.n_queues = 2 + (r->program.scratch_regions > 1 ? 1 : 0);
|
||||
f.queue_scratch = 0; /* set below, once props are read */
|
||||
/* The weights' cost, split into the fixed floor and the elastic plane
|
||||
* (weight_footprint in core/place/planner.h). Per rank, so already this card's share
|
||||
* under TP. */
|
||||
@@ -1773,6 +1855,7 @@ int Engine::plan() {
|
||||
}
|
||||
RadDeviceProps props{};
|
||||
rad_dev_props(r->device, &props);
|
||||
f.queue_scratch = rad_dev_resident_scratch_bytes(&props);
|
||||
f.capacity = props.vram_bytes;
|
||||
f.free = props.vram_free;
|
||||
/* Unified memory: the pinned host pool is the same RAM as the card, so the
|
||||
@@ -3708,6 +3791,9 @@ int Engine::load_weights() {
|
||||
* aligned (rad_format.h), DirectFile's alignment, so stages take the no-bounce path. */
|
||||
MoverConfig mc{};
|
||||
mc.container_path = file_ ? cfg_.model : std::string();
|
||||
/* The lent slots kept free for swaps follow the swaps asked for (mover.h): a rank that
|
||||
* holds nearly all its experts gets the idle ones back as residents. */
|
||||
mc.turnover_adaptive = true;
|
||||
RAD_TRY(r->mover.init(r->program, r->plan, mc, &r->pools));
|
||||
/* What the mover took, before the first copy. Its slabs are allocated in init, so the pool
|
||||
* is as full as it will get; a load stopping with zero free is a placement failure, not
|
||||
@@ -4710,6 +4796,7 @@ int Engine::start() {
|
||||
if (vocab_ex) std::rethrow_exception(vocab_ex);
|
||||
if (vocab_st < 0) return vocab_st;
|
||||
if (plugins_st < 0) return plugins_st;
|
||||
RAD_TRY(demote_call_delimiters());
|
||||
{
|
||||
/* The loaded libraries in selection order: as --kernels named them, or every library in
|
||||
* the home. */
|
||||
@@ -4732,15 +4819,14 @@ int Engine::start() {
|
||||
r->device = devs[i];
|
||||
ranks_.push_back(std::move(r));
|
||||
}
|
||||
/* Collectives run on these cards from here on; another engine's on the same cards must not be
|
||||
* able to starve them of wave slots (rad_dev_cards_claim). */
|
||||
if (cfg_.tp > 1) {
|
||||
const int cs = rad_dev_cards_claim(devs.data(), cfg_.tp, 1);
|
||||
if (cs < 0) {
|
||||
RAD_ERR("device: the ranks' cards could not be claimed: %s", rad_strerror(cs));
|
||||
return cs;
|
||||
}
|
||||
cards_claimed_ = true;
|
||||
/* A single-rank engine can occupy wave slots on one of a peer engine's collective cards.
|
||||
* Claim every engine's cards before it creates any work on them. The backend records the
|
||||
* claim before draining outstanding work, so teardown also releases it on a drain failure. */
|
||||
cards_claimed_ = true;
|
||||
const int cs = rad_dev_cards_claim(devs.data(), cfg_.tp, 1);
|
||||
if (cs < 0) {
|
||||
RAD_ERR("device: the ranks' cards could not be claimed: %s", rad_strerror(cs));
|
||||
return cs;
|
||||
}
|
||||
|
||||
/* Peer access, measured before selection. Kernels that touch another card's memory constrain
|
||||
@@ -5261,6 +5347,10 @@ int Engine::start() {
|
||||
* restore reads it again (refill_weights). */
|
||||
if (file_) dev_page_refilled(base);
|
||||
}
|
||||
/* Bringup done: everything this engine loads is loaded. From here the stuck-exit watchdog
|
||||
* treats a device that advances nothing as a hang; before here it treats it as a slow load
|
||||
* (device.h's dev_engine_ready). */
|
||||
dev_engine_ready.store(true, std::memory_order_release);
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
@@ -5353,6 +5443,7 @@ int Engine::load_vocab() {
|
||||
auto v = std::make_shared<Vocab>();
|
||||
RAD_TRY(v->load(std::move(vb)));
|
||||
vocab_ = v;
|
||||
vocab_own_ = v;
|
||||
if (file_ && file_->aux_vocab()) {
|
||||
VocabBuild ab;
|
||||
RAD_TRY(vocab_deserialize(file_->base(), (uint64_t)file_->size(), file_->aux_vocab().h, ab));
|
||||
@@ -5362,13 +5453,18 @@ int Engine::load_vocab() {
|
||||
RAD_INFO("vocab: a second vocabulary of %d tokens", aux_vocab_->n_tokens());
|
||||
}
|
||||
|
||||
RAD_INFO("vocab: %d tokens, bos=%d eos=%d%s", vocab_->n_tokens(), vocab_->bos(), vocab_->eos(),
|
||||
vocab_->chat_template().empty() ? ", no chat template" : "");
|
||||
return build_vocab_view();
|
||||
}
|
||||
|
||||
/* The sampler's view of the vocabulary and the grammar engine's index over it. The index sorts
|
||||
* end-of-generation ids apart from text, so both are built again when that set changes. */
|
||||
int Engine::build_vocab_view() {
|
||||
auto view = std::make_unique<TokenView>();
|
||||
RAD_TRY(view->init(vocab_));
|
||||
vocab_view_ = std::move(view);
|
||||
|
||||
RAD_INFO("vocab: %d tokens, bos=%d eos=%d%s", vocab_->n_tokens(), vocab_->bos(), vocab_->eos(),
|
||||
vocab_->chat_template().empty() ? ", no chat template" : "");
|
||||
|
||||
/* Build the grammar engine's vocabulary index now rather than on the first grammar request
|
||||
* (nearly every tool-calling request has one), so admission pays only for its own grammar. */
|
||||
GbnfVocabInfo gi;
|
||||
|
||||
+42
-24
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "build/startup.h"
|
||||
#include "device/device.h"
|
||||
#include "place/xstats.h"
|
||||
#include "server/adapters.h"
|
||||
#include "server/sink.h"
|
||||
|
||||
@@ -652,19 +653,39 @@ int Engine::run_diagnose() {
|
||||
|
||||
bool parity_ok = true;
|
||||
if (!cfg_.diagnose_baseline.empty()) {
|
||||
std::ifstream f(cfg_.diagnose_baseline);
|
||||
const json base = json::parse(f, nullptr, /*allow_exceptions=*/false);
|
||||
/* A baseline is a report another run wrote, possibly on another machine: it is read as
|
||||
* a supplied file (a capped read and a bounded parse), and a baseline that is not shaped
|
||||
* like a report is a refusal of the comparison, said in the report, with the run's own
|
||||
* measurements kept. */
|
||||
std::string why;
|
||||
json cmp;
|
||||
if (!f.is_open() || base.is_discarded()) {
|
||||
std::string base_text;
|
||||
bool over = false, deep = false;
|
||||
const bool base_read =
|
||||
read_text_file(cfg_.diagnose_baseline, base_text, kMaxContainerFile) == RAD_OK;
|
||||
const json base = base_read ? json::parse_container(base_text, &over, &deep) : json();
|
||||
if (!base_read) {
|
||||
why = "the baseline file cannot be read";
|
||||
} else if (over || deep || base.is_discarded()) {
|
||||
why = "the baseline file is not readable JSON";
|
||||
} else if (diag::compare_outputs(rep, base, &cmp, &why) == RAD_OK) {
|
||||
cmp["baseline"] = "an earlier report";
|
||||
rep["parity"] = cmp;
|
||||
parity_ok = cmp["verdict"] == "identical" && cmp["acceptance_verdict"] == "no drop";
|
||||
RAD_INFO("diagnose: parity %s, %lld of %lld requests identical; draft acceptance: %s",
|
||||
cmp["verdict"].get<std::string>().c_str(), (long long)cmp["identical"].get<int64_t>(),
|
||||
(long long)cmp["compared"].get<int64_t>(), cmp["acceptance_verdict"].get<std::string>().c_str());
|
||||
} else {
|
||||
int cmp_rc = RAD_E_FORMAT;
|
||||
try {
|
||||
cmp_rc = diag::compare_outputs(rep, base, &cmp, &why);
|
||||
} catch (const json::exception& e) {
|
||||
why = std::string("the baseline is not shaped like a report: ") + e.what();
|
||||
cmp_rc = RAD_E_FORMAT;
|
||||
}
|
||||
if (cmp_rc == RAD_OK) {
|
||||
cmp["baseline"] = "an earlier report";
|
||||
rep["parity"] = cmp;
|
||||
parity_ok = cmp["verdict"] == "identical" && cmp["acceptance_verdict"] == "no drop";
|
||||
RAD_INFO("diagnose: parity %s, %lld of %lld requests identical; draft acceptance: %s",
|
||||
cmp["verdict"].get<std::string>().c_str(),
|
||||
(long long)cmp["identical"].get<int64_t>(),
|
||||
(long long)cmp["compared"].get<int64_t>(),
|
||||
cmp["acceptance_verdict"].get<std::string>().c_str());
|
||||
}
|
||||
}
|
||||
if (!why.empty()) {
|
||||
rep["parity"] = { { "baseline", "an earlier report" },
|
||||
@@ -675,21 +696,18 @@ int Engine::run_diagnose() {
|
||||
}
|
||||
|
||||
const fs::path dir(cfg_.diagnose);
|
||||
{
|
||||
std::ofstream f(dir / "diagnose.json");
|
||||
f << rep.dump(2) << "\n";
|
||||
if (!f) {
|
||||
RAD_ERR("diagnose: cannot write %s", (dir / "diagnose.json").c_str());
|
||||
return RAD_E_IO;
|
||||
}
|
||||
/* Both reports go through the expert-stats writer's discipline (xstats.h): a temp file and a
|
||||
* rename, the link not followed. A report dir is shared in practice -- /srv/reports, a peer's
|
||||
* mount -- where a plain ofstream let a pre-created symlink make the run overwrite some other
|
||||
* file, and a reader polling the dir saw half a report. */
|
||||
if (const int rc = xs_write_atomic((dir / "diagnose.json").string(), rep.dump(2) + "\n")) {
|
||||
RAD_ERR("diagnose: cannot write %s", (dir / "diagnose.json").c_str());
|
||||
return rc;
|
||||
}
|
||||
{
|
||||
std::ofstream f(dir / "diagnose.md");
|
||||
f << diag::render_markdown(rep);
|
||||
if (!f) {
|
||||
RAD_ERR("diagnose: cannot write %s", (dir / "diagnose.md").c_str());
|
||||
return RAD_E_IO;
|
||||
}
|
||||
if (const int rc =
|
||||
xs_write_atomic((dir / "diagnose.md").string(), diag::render_markdown(rep))) {
|
||||
RAD_ERR("diagnose: cannot write %s", (dir / "diagnose.md").c_str());
|
||||
return rc;
|
||||
}
|
||||
RAD_INFO("diagnose: report in %s", (dir / "diagnose.md").c_str());
|
||||
return problems.empty() && parity_ok ? RAD_OK : RAD_E_STATE;
|
||||
|
||||
+487
-7
@@ -20,6 +20,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace rad {
|
||||
|
||||
/* ------------------------------------------------------------------ the card's step state */
|
||||
@@ -59,6 +60,11 @@ int Engine::step_state_init() {
|
||||
* pinned staging beside them. A program without them is refused rather than served
|
||||
* uncoupled. */
|
||||
mtp_couple_ = cfg_.draft_coupling;
|
||||
if (cfg_.draft_verify_traversal && !mtp_couple_) {
|
||||
RAD_ERR("--draft-verify traversal requires --draft-coupling on: the walk needs the draft's "
|
||||
"law Q, which only a coupled draft carries");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (mtp_couple_) {
|
||||
/* Coupling is defined on a linear chain of drafts: a serial head's rounds, or a block
|
||||
* drafter whose walk samples each position in turn (DFlash2, dflash_couple_propose), its
|
||||
@@ -95,6 +101,7 @@ int Engine::step_state_init() {
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
couple_rows_ = sd.shape[1];
|
||||
couple_planes_ = sd.shape[0];
|
||||
/* One entry per card slot, indexed by StepEntry::card as slots_host_ is. */
|
||||
couple_by_card_.assign((size_t)n_slot, RadMtpCoupleDraw{});
|
||||
couple_draw_stage_ = static_cast<RadMtpCoupleDraw*>(
|
||||
@@ -107,11 +114,104 @@ int Engine::step_state_init() {
|
||||
RAD_INFO("DFlash coupled LIVE: %d position(s), x~Q along the candidate walk, maximal "
|
||||
"coupling at the verify; fixed-seed tokens are NOT preserved", drafter_.depth);
|
||||
else
|
||||
RAD_INFO("MTP coupled LIVE: %d linear round(s), x~Q from the final reranked top8, "
|
||||
RAD_INFO("MTP coupled LIVE: %d linear round(s), x~Q from the draft shortlist, "
|
||||
"maximal coupling at the verify; fixed-seed tokens are NOT preserved",
|
||||
drafter_.depth);
|
||||
}
|
||||
|
||||
/* --draft-depth adaptive: the rule, the per-round readback of the chain's states and one host
|
||||
* event a round. Refused wherever the chain it stops does not exist, rather than served fixed. */
|
||||
depth_cfg_ = DraftDepthCfg{};
|
||||
if (cfg_.draft_depth_adaptive) {
|
||||
if (!mtp_couple_ || drafter_.kind != RAD_DRAFT_SERIAL) {
|
||||
RAD_ERR("--draft-depth adaptive needs a coupled serial draft chain (--draft-coupling on, a "
|
||||
"serial head); this deployment's drafter is '%s'",
|
||||
drafter_.name ? drafter_.name : "(none)");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* --draft-window adaptive picks a window from the acceptance and the cost of the steps
|
||||
* before (sched/draft.h); this rule picks the depth inside the step from the head's laws.
|
||||
* Two controllers on one chain would fight over it. */
|
||||
if (cfg_.draft_window == DraftWindow::Adaptive) {
|
||||
RAD_ERR("--draft-depth adaptive and --draft-window adaptive both choose the chain's "
|
||||
"depth; serve one of them");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
depth_cfg_.on = true;
|
||||
depth_cfg_.max = (int)std::min<int64_t>(drafter_.depth, couple_planes_);
|
||||
/* --draft-suffix widens the verify window (and the depth the plugin declares) past the head's
|
||||
* own rounds: the chain never goes deeper than the head's num-speculative-tokens. */
|
||||
if (cfg_.n_spec_head > 0) depth_cfg_.max = std::min(depth_cfg_.max, cfg_.n_spec_head);
|
||||
if (cfg_.draft_depth_max > 0) depth_cfg_.max = std::min(depth_cfg_.max, cfg_.draft_depth_max);
|
||||
depth_cfg_.max = std::min(depth_cfg_.max, (int)RAD_MTP_COUPLE_MAX_ROUNDS);
|
||||
depth_cfg_.min = std::min(std::max(cfg_.draft_depth_min, 1), depth_cfg_.max);
|
||||
depth_cfg_.lag = cfg_.draft_depth_lag;
|
||||
depth_cfg_.stat = cfg_.draft_depth_stat;
|
||||
depth_cfg_.stop = cfg_.draft_depth_stop;
|
||||
depth_cfg_.lawless = std::min(3, depth_cfg_.max);
|
||||
/* --draft-depth-load: the rule's tables (built in, or the configured lists) and the online
|
||||
* calibration that keeps them. */
|
||||
if (cfg_.draft_depth_load) {
|
||||
draft_depth_load_defaults(&depth_cfg_);
|
||||
depth_cfg_.load = true;
|
||||
depth_load_on_ = true;
|
||||
depth_cfg_.load_from = std::max(2, cfg_.draft_depth_load_from);
|
||||
depth_cfg_.load_min = std::min(std::max(cfg_.draft_depth_load_min, 1), depth_cfg_.max);
|
||||
depth_cfg_.late = cfg_.draft_depth_load_late;
|
||||
depth_cfg_.late_lag = 1;
|
||||
const int kN = DraftDepthCfg::kLoadSeqs, kJ = DraftDepthCfg::kJumps;
|
||||
/* a list by drafting rows 1 .. 8; a short one repeats its last number */
|
||||
auto by_rows = [&](const std::string& l, double* dst) {
|
||||
double v[DraftDepthCfg::kLoadSeqs];
|
||||
const int k = l.empty() ? 0 : draft_depth_parse_list(l.c_str(), v, kN, 0.0, 1000.0);
|
||||
for (int i = 0; i < kN && k > 0; ++i) dst[1 + i] = v[std::min(i, k - 1)];
|
||||
dst[0] = dst[1];
|
||||
};
|
||||
by_rows(cfg_.draft_depth_load_tok_ms, depth_cfg_.load_lam);
|
||||
by_rows(cfg_.draft_depth_load_row_ms, depth_cfg_.load_row_ms);
|
||||
by_rows(cfg_.draft_depth_load_round_ms, depth_cfg_.load_round_ms);
|
||||
if (!cfg_.draft_depth_load_jump_ms.empty()) {
|
||||
double v[DraftDepthCfg::kJumps] = {};
|
||||
const int k = draft_depth_parse_list(cfg_.draft_depth_load_jump_ms.c_str(), v, kJ, 0.0, 1000.0);
|
||||
for (int nn = 0; nn <= kN && k > 0; ++nn)
|
||||
for (int j = 0; j < kJ; ++j) depth_cfg_.load_jump_ms[nn][j] = j < k ? v[j] : 0.0;
|
||||
}
|
||||
depth_online_on_ = cfg_.draft_depth_load_online;
|
||||
draft_depth_online_begin(depth_cfg_, &depth_online_);
|
||||
depth_pend_.assign((size_t)n_slot, DepthPend{});
|
||||
if (const char* e = std::getenv("RADIANCE_DEBUG_CONC_LOG"); e && *e) {
|
||||
depth_log_ = std::fopen(e, "w");
|
||||
if (depth_log_) std::setvbuf(depth_log_, nullptr, _IOFBF, 1 << 20);
|
||||
}
|
||||
}
|
||||
depth_rb_ = static_cast<RadMtpCoupleState*>(rad_dev_alloc(
|
||||
(int64_t)RAD_MTP_COUPLE_MAX_ROUNDS * couple_rows_ * (int64_t)sizeof(RadMtpCoupleState),
|
||||
RAD_MEM_HOST_PINNED));
|
||||
if (!depth_rb_) return RAD_E_NOMEM;
|
||||
for (RadEvent& e : depth_ev_)
|
||||
RAD_TRY(rad_event_create_as(&e, RAD_EVENT_LOCAL | RAD_EVENT_HOST_WAIT));
|
||||
depth_row_.assign((size_t)n_slot, DraftDepthRow{});
|
||||
depth_of_.assign((size_t)n_slot, 0);
|
||||
RAD_INFO("draft depth adaptive: 1..%d draft(s) a step, the chain goes on while the product of "
|
||||
"the head's %s probabilities is >= %.3f (decided %d round(s) behind, %d round(s) "
|
||||
"always run); a row with no law drafts %d",
|
||||
depth_cfg_.max, depth_cfg_.stat == DRAFT_DEPTH_PATH ? "drawn-token" : "top",
|
||||
depth_cfg_.stop, depth_cfg_.lag, depth_cfg_.min, depth_cfg_.lawless);
|
||||
if (depth_cfg_.load)
|
||||
RAD_INFO("draft depth load-aware: a step drafting for %d sequence(s) or more runs a round "
|
||||
"for the rows whose expected accepted drafts pay their verify rows, the tile "
|
||||
"they open and the round (%d round(s) always run; late choice of the verify's "
|
||||
"rows %s); tables %s (at 8 sequences: %.3f tok/ms, a row %.3f ms, a round "
|
||||
"%.3f ms, past %d/%d/%d/%d rows +%.2f/%.2f/%.2f/%.2f ms)",
|
||||
depth_cfg_.load_from, depth_cfg_.load_min, depth_cfg_.late ? "on" : "off",
|
||||
depth_online_on_ ? "calibrated online from these" : "static",
|
||||
depth_cfg_.load_lam[8], depth_cfg_.load_row_ms[8], depth_cfg_.load_round_ms[8],
|
||||
depth_cfg_.load_jump_at[0], depth_cfg_.load_jump_at[1], depth_cfg_.load_jump_at[2],
|
||||
depth_cfg_.load_jump_at[3], depth_cfg_.load_jump_ms[8][0],
|
||||
depth_cfg_.load_jump_ms[8][1], depth_cfg_.load_jump_ms[8][2],
|
||||
depth_cfg_.load_jump_ms[8][3]);
|
||||
}
|
||||
|
||||
RAD_TRY(rad_event_create_as(&step_end_, RAD_EVENT_LOCAL | RAD_EVENT_HOST_WAIT));
|
||||
RAD_TRY(rad_event_create_as(&tok_end_, RAD_EVENT_LOCAL | RAD_EVENT_HOST_WAIT));
|
||||
return RAD_OK;
|
||||
@@ -131,6 +231,11 @@ void Engine::step_state_fini() {
|
||||
if (couple_readback_) rad_dev_free(couple_readback_, RAD_MEM_HOST_PINNED);
|
||||
couple_draw_stage_ = nullptr;
|
||||
couple_readback_ = nullptr;
|
||||
if (depth_rb_) rad_dev_free(depth_rb_, RAD_MEM_HOST_PINNED);
|
||||
depth_rb_ = nullptr;
|
||||
for (RadEvent& e : depth_ev_) { if (e) rad_event_destroy(e); e = nullptr; }
|
||||
if (depth_log_) std::fclose(depth_log_);
|
||||
depth_log_ = nullptr;
|
||||
if (step_end_) rad_event_destroy(step_end_);
|
||||
step_end_ = nullptr;
|
||||
if (tok_end_) rad_event_destroy(tok_end_);
|
||||
@@ -239,6 +344,248 @@ int Engine::tree_compact(int rows) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ --draft-depth adaptive
|
||||
*
|
||||
* The chain's depth is decided while it is drafted (sched/draft_depth.h), so the rounds cannot all
|
||||
* be queued behind the step as a fixed chain's are: round j is issued once the statistic of round
|
||||
* j - 1 - lag is known. That costs the host one tiny readback a round (the round's state rows of
|
||||
* the drafting sequences, rank 0's copy; every rank holds the same) and a wait for it. With lag 1
|
||||
* the card is running round j - 1 meanwhile, so nothing idles as long as the host answers within a
|
||||
* round (about 0.5 ms; reading the row and issuing a recorded pass takes about 0.1 ms). The next
|
||||
* verify is issued the same way, right after the chain's last decision, with exactly the rows the
|
||||
* chain has (Engine::issue_ahead): each row count is its own recorded pass.
|
||||
*
|
||||
* The commit of the step in flight moves behind those decisions (the step loop collects after
|
||||
* issue_ahead), so its tokens are streamed up to the chain's rounds later than with a fixed chain;
|
||||
* the card is not held up by that. */
|
||||
int Engine::depth_row_nodes(int i) const {
|
||||
if (!depth_cfg_.on) return serial_done_;
|
||||
if (i < 0 || (size_t)i >= depth_of_.size()) return 0;
|
||||
return depth_of_[(size_t)i];
|
||||
}
|
||||
|
||||
/* Behind the pass of round `round`: its state rows of the `n` drafting sequences to the host, and
|
||||
* the event the driver waits on. */
|
||||
int Engine::depth_readback_issue(int round, int n) {
|
||||
if (round < 1 || round > (int)RAD_MTP_COUPLE_MAX_ROUNDS || round > (int)couple_planes_ || n <= 0)
|
||||
return RAD_OK;
|
||||
Rank& r0 = *ranks_[0];
|
||||
const char* state = static_cast<const char*>(r0.ctx.buf_ptr(couple_state_buf_));
|
||||
if (!state) return RAD_E_STATE;
|
||||
const int64_t plane = couple_rows_ * (int64_t)sizeof(RadMtpCoupleState);
|
||||
RAD_TRY(rad_memcpy_async(depth_rb_ + (int64_t)(round - 1) * couple_rows_,
|
||||
state + (int64_t)(round - 1) * plane,
|
||||
(int64_t)n * (int64_t)sizeof(RadMtpCoupleState), r0.ctx.stream()));
|
||||
RAD_TRY(rad_event_record(depth_ev_[round - 1], r0.ctx.stream()));
|
||||
depth_issued_[round - 1] = true;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* Waits for the statistics of every round up to `round` and feeds them to the rows. A round whose
|
||||
* readback was never issued (its pass did not run) leaves the rows without a law. */
|
||||
int Engine::depth_observe_upto(int round, int n, const StepOut& so) {
|
||||
while (depth_seen_ < round) {
|
||||
const int r = depth_seen_ + 1;
|
||||
const bool have = r <= (int)RAD_MTP_COUPLE_MAX_ROUNDS && depth_issued_[r - 1];
|
||||
if (have) {
|
||||
RadEvent ev = depth_ev_[r - 1];
|
||||
const auto t0 = std::chrono::steady_clock::now();
|
||||
int q = rad_event_query(ev);
|
||||
if (q < 0) return q;
|
||||
if (q == 0) {
|
||||
/* The ids' copy sits ahead of every draft pass: block for it (the trunk's whole
|
||||
* forward pass may be in front), then poll, which answers within a microsecond of
|
||||
* the card where an interrupt takes tens. */
|
||||
if (so.early && depth_seen_ == 0) RAD_TRY(rad_event_sync(tok_end_));
|
||||
const auto t1 = std::chrono::steady_clock::now();
|
||||
bool blocked = false;
|
||||
for (uint32_t spin = 0;; ++spin) {
|
||||
q = rad_event_query(ev);
|
||||
if (q != 0) break;
|
||||
if ((spin & 255u) == 255u &&
|
||||
std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - t1)
|
||||
.count() > (double)kDepthSpinUs) {
|
||||
blocked = true;
|
||||
break;
|
||||
}
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
__builtin_ia32_pause();
|
||||
#endif
|
||||
}
|
||||
if (q < 0) return q;
|
||||
if (blocked) ++depth_stats_.blocked;
|
||||
++depth_stats_.waits;
|
||||
} else {
|
||||
/* Already there: the host was behind the card by the time it asked. */
|
||||
++depth_stats_.late;
|
||||
}
|
||||
/* The wait proper: what a host wait does to the fences of the dispatches that follow
|
||||
* (the copy wrote host memory), and the block when the poll gave up. */
|
||||
RAD_TRY(rad_event_sync(ev));
|
||||
const auto t2 = std::chrono::steady_clock::now();
|
||||
depth_stats_.wait_us += std::chrono::duration<double, std::micro>(t2 - t0).count();
|
||||
/* The card's cycle by the last step's depth: the host waits for every step's first
|
||||
* statistic, so two of them in a row are one cycle apart. A gap of 30 ms or more is
|
||||
* no decode cycle (an idle engine, or the next request's prefill, in between). */
|
||||
if (r == 1) {
|
||||
const double us = std::chrono::duration<double, std::micro>(t2 - depth_e1_).count();
|
||||
if (q == 1 && depth_last_ >= 1 && depth_last_ <= (int)RAD_MTP_COUPLE_MAX_ROUNDS &&
|
||||
us > 0 && us < 30000.0) {
|
||||
depth_stats_.cyc_us[depth_last_] += us;
|
||||
++depth_stats_.cyc_n[depth_last_];
|
||||
}
|
||||
depth_e1_ = t2;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; ++i) {
|
||||
DraftDepthRow& row = depth_row_[(size_t)i];
|
||||
double st = -1.0;
|
||||
if (have && !row.lawless) {
|
||||
const RadMtpCoupleState& cs = depth_rb_[(int64_t)(r - 1) * couple_rows_ + i];
|
||||
/* this step's draw for this row, or a stale plane: no law */
|
||||
if (!std::memcmp(&cs.draw, &couple_draw_stage_[(size_t)i], sizeof cs.draw))
|
||||
st = draft_depth_stat(cs, r, depth_cfg_.stat);
|
||||
}
|
||||
draft_depth_observe(&row, r, st);
|
||||
}
|
||||
depth_seen_ = r;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* The adaptive chain's tuning line: the shares of each depth and what the host waits cost, then
|
||||
* by the drafts a step made, the card's cycle and the drafts its verify accepted. Logged every
|
||||
* 4096 drafting rows and at shutdown. */
|
||||
void Engine::depth_log_stats(const char* when) {
|
||||
const DepthStats& ds = depth_stats_;
|
||||
if (!depth_cfg_.on || ds.rows == 0 || (depth_logged_ == ds.rows && !std::strcmp(when, "final"))) return;
|
||||
depth_logged_ = ds.rows;
|
||||
std::string h;
|
||||
for (int d2 = 1; d2 <= depth_cfg_.max; ++d2)
|
||||
h += fmt("%s%d:%.3f", d2 > 1 ? " " : "", d2, (double)ds.hist[d2] / (double)ds.rows);
|
||||
RAD_INFO("draft depth adaptive (%s): %llu drafting step(s), drafts/row %.3f, rounds/step %.3f, "
|
||||
"depth shares [%s], lawless rows %llu; host waits %llu (%.1f us each, %llu ended "
|
||||
"blocked), statistics already there %llu",
|
||||
when, (unsigned long long)ds.steps, (double)ds.drafts / (double)ds.rows,
|
||||
(double)ds.rounds / (double)ds.steps, h.c_str(), (unsigned long long)ds.lawless,
|
||||
(unsigned long long)ds.waits,
|
||||
ds.waits + ds.late ? ds.wait_us / (double)(ds.waits + ds.late) : 0.0,
|
||||
(unsigned long long)ds.blocked, (unsigned long long)ds.late);
|
||||
std::string by;
|
||||
for (int d2 = 1; d2 <= depth_cfg_.max; ++d2)
|
||||
by += fmt("%s%d: %.0f us (%llu), %.3f accepted (%llu)", d2 > 1 ? "; " : "", d2,
|
||||
ds.cyc_n[d2] ? ds.cyc_us[d2] / (double)ds.cyc_n[d2] : 0.0,
|
||||
(unsigned long long)ds.cyc_n[d2],
|
||||
ds.acc_n[d2] ? (double)ds.acc[d2] / (double)ds.acc_n[d2] : 0.0,
|
||||
(unsigned long long)ds.acc_n[d2]);
|
||||
RAD_INFO("draft depth adaptive (%s): by drafts made, the card's cycle and the drafts the "
|
||||
"verify accepted -- %s", when, by.c_str());
|
||||
if (depth_load_on_) depth_load_log(when);
|
||||
}
|
||||
|
||||
/* --draft-depth-load, once a step, after its draft passes ended and its verify was committed:
|
||||
* the step's milliseconds (since the step before it ended, when both were pure decode steps of the
|
||||
* same drafting rows), its verify rows, rounds and tokens for the rule's rate and prices; every 64
|
||||
* steps the tables again from what was measured. Between steps: the next step's chain is decided
|
||||
* after this returns, from tables that nothing of that step went into (sched/draft_depth.h). */
|
||||
void Engine::depth_step_note(const RadBatch* b, const StepOut& so) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
const StepPlan& plan = sched_.plan();
|
||||
bool pure = b->phase == RAD_PHASE_DECODE;
|
||||
int tokens = 0;
|
||||
for (size_t i = 0; i < plan.e.size(); ++i) {
|
||||
if (plan.e[i].is_prefill) pure = false;
|
||||
if (i < so.first_row.size() && so.first_row[i] >= 0)
|
||||
tokens += 1 + std::max(0, i < so.accepted.size() ? so.accepted[i] : 0);
|
||||
}
|
||||
const int n = serial_rows_;
|
||||
if (depth_online_on_ && pure && n >= 1 && serial_done_ >= 1 && tokens > 0 &&
|
||||
depth_note_step_ == b->step - 1 && depth_note_rows_ == n) {
|
||||
const double ms = std::chrono::duration<double, std::milli>(now - depth_note_t_).count();
|
||||
draft_depth_online_step(depth_cfg_, &depth_online_, n, (int)b->n_tok, serial_done_, ms, tokens);
|
||||
}
|
||||
depth_note_t_ = now;
|
||||
depth_note_step_ = pure ? b->step : -2;
|
||||
depth_note_rows_ = n;
|
||||
if (depth_log_) depth_log_step(b, so);
|
||||
if (depth_online_on_ && (++depth_note_n_ & 63u) == 0) {
|
||||
draft_depth_online_refresh(&depth_cfg_, &depth_online_);
|
||||
if ((depth_note_n_ & 32767u) == 0) depth_load_log("running");
|
||||
if (depth_log_) {
|
||||
/* K: the tables after a refresh, at the step's drafting rows */
|
||||
const int nn = draft_depth_seqs(std::max(n, 1));
|
||||
std::string k = fmt("K %d %d %.4f %.4f %.4f", b->step, nn, depth_cfg_.load_lam[nn],
|
||||
depth_cfg_.load_row_ms[nn], depth_cfg_.load_round_ms[nn]);
|
||||
for (int j = 0; j < DraftDepthCfg::kJumps; ++j) k += fmt(" %.3f", depth_cfg_.load_jump_ms[nn][j]);
|
||||
for (int t = 0; t < 3; ++t)
|
||||
for (int j = 2; j <= depth_cfg_.max && j <= DraftDepthCfg::kCalRounds; ++j) {
|
||||
k += fmt(" | %d,%d", t, j);
|
||||
for (int x = 0; x < draft_depth_knots(depth_cfg_); ++x)
|
||||
k += fmt(" %.3f", depth_cfg_.cal_p[t][j][x]);
|
||||
}
|
||||
std::fprintf(depth_log_, "%s\n", k.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* What the load-aware rule's tables hold now, by drafting rows that were measured. */
|
||||
void Engine::depth_load_log(const char* when) const {
|
||||
const DraftDepthOnline& o = depth_online_;
|
||||
std::string t;
|
||||
for (int n = 1; n <= DraftDepthCfg::kLoadSeqs; ++n) {
|
||||
if (o.reg[n].n < 64 && o.lam[n].n < 32) continue;
|
||||
t += fmt("%s%d seq: %.3f tok/ms, row %.3f ms, round %.3f ms, tiles +%.2f/%.2f/%.2f/%.2f ms "
|
||||
"(%lld steps)", t.empty() ? "" : "; ", n, depth_cfg_.load_lam[n],
|
||||
depth_cfg_.load_row_ms[n], depth_cfg_.load_round_ms[n], depth_cfg_.load_jump_ms[n][0],
|
||||
depth_cfg_.load_jump_ms[n][1], depth_cfg_.load_jump_ms[n][2],
|
||||
depth_cfg_.load_jump_ms[n][3], (long long)o.reg[n].n);
|
||||
}
|
||||
std::string c;
|
||||
for (int j = 2; j <= depth_cfg_.max && j <= DraftDepthCfg::kCalRounds; ++j) {
|
||||
c += fmt("%sdraft %d:", j > 2 ? "; " : "", j);
|
||||
for (int x = 0; x < draft_depth_knots(depth_cfg_); ++x) c += fmt(" %.2f", depth_cfg_.cal_p[2][j][x]);
|
||||
}
|
||||
RAD_INFO("draft depth load-aware (%s): %s calibration, %lld chain(s) and %lld step(s) counted "
|
||||
"(%lld stalled step(s) left out), %lld refresh(es); %s; acceptance by the confidence "
|
||||
"that includes the draft's own law, at %.2f .. %.2f -- %s", when,
|
||||
depth_online_on_ ? "online" : "static", (long long)o.chains, (long long)o.steps,
|
||||
(long long)o.outliers, (long long)o.refreshes, t.empty() ? "no step count measured yet" : t.c_str(),
|
||||
depth_cfg_.cal_x[0], depth_cfg_.cal_x[draft_depth_knots(depth_cfg_) - 1], c.c_str());
|
||||
}
|
||||
|
||||
/* RADIANCE_DEBUG_CONC_LOG: the step just finished, one line.
|
||||
* S step ns phase n_seq n_tok rounds drafting_rows load_step | entry;... | chain;...
|
||||
* An entry is a sequence of the step's verify: seq,is_prefill,n_tokens,drafts verified,drafts
|
||||
* accepted (-1: no token row),ctx_len. A chain is what a drafting row made behind the step, for
|
||||
* the next verify: seq,depth,the rule's round,rounds that ran for it,lawless, then each of those
|
||||
* rounds' top mass. Called after finish_serial_drafter, while plan() still describes the step. */
|
||||
void Engine::depth_log_step(const RadBatch* b, const StepOut& so) {
|
||||
const StepPlan& plan = sched_.plan();
|
||||
std::string e, d;
|
||||
for (size_t i = 0; i < plan.e.size(); ++i) {
|
||||
const StepEntry& x = plan.e[i];
|
||||
e += fmt("%s%llu,%d,%d,%d,%d,%d", i ? ";" : "", (unsigned long long)x.seq, (int)x.is_prefill,
|
||||
(int)x.n_tokens, (int)x.n_spec,
|
||||
i < so.accepted.size() && so.first_row[i] >= 0 ? (int)so.accepted[i] : -1,
|
||||
(int)x.ctx_len);
|
||||
}
|
||||
for (int i = 0; i < serial_rows_ && serial_done_ > 0; ++i) {
|
||||
const DraftDepthRow& row = depth_row_[(size_t)i];
|
||||
const int ran = serial_done_;
|
||||
d += fmt("%s%llu,%d,%d,%d,%d", i ? ";" : "", (unsigned long long)serial_row_[(size_t)i].seq,
|
||||
depth_row_nodes(i), depth_load_step_ ? row.rule : 0, ran, (int)row.lawless);
|
||||
if (mtp_couple_ && couple_readback_)
|
||||
for (int r = 1; r <= ran && r <= (int)couple_planes_; ++r)
|
||||
d += fmt(",%.4f", draft_depth_stat(couple_readback_[(int64_t)(r - 1) * couple_rows_ + i],
|
||||
r, DRAFT_DEPTH_TOP));
|
||||
}
|
||||
const uint64_t ns = (uint64_t)std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||
std::fprintf(depth_log_, "S %d %llu %d %lld %lld %d %d %d | %s | %s\n", b->step,
|
||||
(unsigned long long)ns, (int)b->phase, (long long)b->n_seq, (long long)b->n_tok,
|
||||
serial_done_, serial_rows_, (int)depth_load_step_, e.c_str(), d.c_str());
|
||||
}
|
||||
|
||||
/* Issue the step's draft passes behind it, without waiting. After the trunk's ranks join: the
|
||||
* acceptance on every rank, the sampled-id readback (before a round can overwrite them), the
|
||||
* history pass and every round, then the final proposal into the slots and their readback.
|
||||
@@ -248,8 +595,9 @@ int Engine::issue_serial_drafter(int step, StepOut& so) {
|
||||
serial_rounds_ = 0;
|
||||
serial_rows_ = 0;
|
||||
serial_done_ = 0;
|
||||
const bool history_only = drafter_.kind == RAD_DRAFT_HISTORY;
|
||||
/* A step issued ahead continues from the card's acceptance, so run it even without drafts. */
|
||||
if (!serial_drafting()) {
|
||||
if (!serial_drafting() && !history_only) {
|
||||
if (pipelining_) RAD_TRY(advance_all(ADV_ACCEPT, 0, false));
|
||||
return RAD_OK;
|
||||
}
|
||||
@@ -257,7 +605,11 @@ int Engine::issue_serial_drafter(int step, StepOut& so) {
|
||||
RAD_TRY(advance_all(ADV_ACCEPT, 0, false));
|
||||
RAD_TRY(collect_issue(so, /*fence=*/true));
|
||||
|
||||
int rounds = drafter_.depth;
|
||||
/* serial_begin needs a pass budget even for history alone. The scheduler's speculative
|
||||
* depth is still zero there, so it stages history rows but never reserves a proposal row. */
|
||||
int rounds = history_only ? 1 : drafter_.depth;
|
||||
/* --draft-depth-max below the head's declared depth: no round past it is ever asked for. */
|
||||
if (depth_cfg_.on && rounds > depth_cfg_.max) rounds = depth_cfg_.max;
|
||||
serial_row_.resize((size_t)cfg_.max_seqs);
|
||||
/* `n` counts rows that can draft. It can be zero while the history pass still has work (a
|
||||
* mid-prompt sequence has hidden states the head needs but no token to propose from). */
|
||||
@@ -275,17 +627,59 @@ int Engine::issue_serial_drafter(int step, StepOut& so) {
|
||||
static double a_batch = 0, a_samp = 0, a_rel = 0, a_iss = 0;
|
||||
static long n_pass = 0;
|
||||
|
||||
/* --draft-depth adaptive: every row starts a chain; a greedy row (no draw) has no law. */
|
||||
const bool adepth = depth_cfg_.on && n > 0;
|
||||
depth_load_step_ = false;
|
||||
if (adepth) {
|
||||
depth_seen_ = 0;
|
||||
for (bool& b : depth_issued_) b = false;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
draft_depth_begin(depth_cfg_, &depth_row_[(size_t)i], couple_draw_stage_[(size_t)i].mode != 1);
|
||||
depth_of_[(size_t)i] = 0;
|
||||
}
|
||||
/* --draft-depth-load: the next verify's rows beside the drafting sequences' (the plan's
|
||||
* other token rows), and whether this step has the sequences for the load-aware rule. */
|
||||
depth_other_rows_ = 0;
|
||||
for (const StepEntry& pe : sched_.plan().e) depth_other_rows_ += pe.produces_token;
|
||||
depth_other_rows_ = std::max(0, depth_other_rows_ - n);
|
||||
depth_load_step_ = depth_cfg_.load && n >= depth_cfg_.load_from;
|
||||
}
|
||||
|
||||
/* Pass 0, then rounds 2..rounds: round 1 has no pass of its own. */
|
||||
for (int rd = 0; rd <= rounds; rd += rd == 0 ? 2 : 1) {
|
||||
if (rd > 0 && n <= 0) break;
|
||||
/* The adaptive chain: round rd runs only for a row whose confidence up to round
|
||||
* rd - 1 - lag holds (sched/draft_depth.h); the pass runs while any row goes on. */
|
||||
if (adepth && rd >= 2) {
|
||||
const int need = draft_depth_need(depth_cfg_, rd);
|
||||
if (need >= 1) RAD_TRY(depth_observe_upto(need, n, so));
|
||||
bool any = false;
|
||||
if (depth_load_step_)
|
||||
any = draft_depth_go_load(depth_cfg_, depth_row_.data(), n, rd, depth_other_rows_);
|
||||
else
|
||||
for (int i = 0; i < n; ++i)
|
||||
any = draft_depth_go(depth_cfg_, &depth_row_[(size_t)i], rd) || any;
|
||||
if (!any) break;
|
||||
}
|
||||
const auto tA = std::chrono::steady_clock::now();
|
||||
const RadBatch* db = sched_.serial_batch(rd, step);
|
||||
if (!db) { if (rd == 0) continue; break; }
|
||||
if (!db) {
|
||||
if (history_only) {
|
||||
RAD_ERR("'%s' calibration: missing history batch for step %d", drafter_.name, step);
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (rd == 0) continue;
|
||||
break;
|
||||
}
|
||||
/* Pass 0 is the history pass, writing the head's own K and V (nothing else does). It is
|
||||
* also draft round 1 for drafting rows, whose inputs are the last row of their history run
|
||||
* (RadBatch::draft_out_ids), so it ends in the lm_head over those rows. Round r >= 2 embeds
|
||||
* round r-1's proposal, which the advance takes from the proposal buffer on the card. */
|
||||
const int drafted = rd == 0 ? (int)db->n_draft_out : n;
|
||||
if (history_only && (n != 0 || drafted != 0 || rd != 0)) {
|
||||
RAD_ERR("'%s' history-only calibration cannot reserve draft proposals", drafter_.name);
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
RAD_TRY(advance_all(rd == 0 ? ADV_HIST : ADV_ROUND, rd, rd > 0));
|
||||
const auto tB = std::chrono::steady_clock::now();
|
||||
|
||||
@@ -330,8 +724,41 @@ int Engine::issue_serial_drafter(int step, StepOut& so) {
|
||||
}
|
||||
if (rd > 0) serial_done_ = rd;
|
||||
else if (drafted > 0) serial_done_ = 1;
|
||||
/* This round's states to the host, when a later round's decision reads them. */
|
||||
/* The late choice reads every round but the last. */
|
||||
if (adepth && serial_done_ == (rd > 0 ? rd : 1) &&
|
||||
(serial_done_ <= draft_depth_need(depth_cfg_, rounds) ||
|
||||
(depth_load_step_ && depth_cfg_.late)))
|
||||
RAD_TRY(depth_readback_issue(serial_done_, n));
|
||||
}
|
||||
if (serial_done_ <= 0 || n <= 0) return RAD_OK;
|
||||
/* The late choice (--draft-depth-load-late): every row's verified prefix again, from the
|
||||
* rounds read by now and the wait for all but the last (it is still running, so the card is
|
||||
* not held up as long as the wait and the next step's issue fit in it). */
|
||||
if (adepth && depth_load_step_ && depth_cfg_.late && serial_done_ >= 2) {
|
||||
const int upto = std::max(depth_seen_, serial_done_ - std::max(0, depth_cfg_.late_lag));
|
||||
if (upto > depth_seen_) RAD_TRY(depth_observe_upto(upto, n, so));
|
||||
draft_depth_select(depth_cfg_, depth_row_.data(), n, serial_done_, depth_other_rows_);
|
||||
}
|
||||
if (adepth) {
|
||||
DepthStats& ds = depth_stats_;
|
||||
++ds.steps;
|
||||
ds.rounds += (uint64_t)serial_done_;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const DraftDepthRow& row = depth_row_[(size_t)i];
|
||||
const int d = std::max(1, std::min(row.depth, serial_done_));
|
||||
depth_of_[(size_t)i] = d;
|
||||
++ds.rows;
|
||||
ds.drafts += (uint64_t)d;
|
||||
ds.lawless += row.lawless;
|
||||
++ds.hist[std::min(d, (int)RAD_MTP_COUPLE_MAX_ROUNDS)];
|
||||
}
|
||||
depth_last_ = 0;
|
||||
for (int i = 0; i < n; ++i) depth_last_ = std::max(depth_last_, (int)depth_of_[(size_t)i]);
|
||||
if (ds.rows >= depth_logged_ + 4096) depth_log_stats("running");
|
||||
} else {
|
||||
depth_last_ = 0;
|
||||
}
|
||||
|
||||
/* The last round's proposal into the slots, then rank 0's slots back to the host. Only the
|
||||
* drafting rows: at depth 1 the last pass is the history pass, whose later rows only carried
|
||||
@@ -356,7 +783,12 @@ int Engine::issue_serial_drafter(int step, StepOut& so) {
|
||||
* set_draft, and move the history watermark. The card's acceptance positioned every draft pass,
|
||||
* so a disagreement is a defect and the step is refused. */
|
||||
int Engine::finish_serial_drafter(const StepOut& so) {
|
||||
if (!serial_drafting() || serial_rounds_ <= 0) return RAD_OK;
|
||||
if (serial_rounds_ <= 0) return RAD_OK;
|
||||
if (drafter_.kind == RAD_DRAFT_HISTORY) {
|
||||
sched_.serial_end(0); /* advance the history watermark, not the draft chain */
|
||||
return RAD_OK;
|
||||
}
|
||||
if (!serial_drafting()) return RAD_OK;
|
||||
const StepPlan& plan = sched_.plan();
|
||||
if (serial_done_ > 0 && serial_rows_ > 0) {
|
||||
for (size_t i = 0; i < plan.e.size(); ++i) {
|
||||
@@ -372,7 +804,29 @@ int Engine::finish_serial_drafter(const StepOut& so) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* --draft-depth adaptive: what the verify of d drafts accepted, by d (the tuning line). */
|
||||
if (depth_cfg_.on) {
|
||||
for (size_t i = 0; i < plan.e.size(); ++i) {
|
||||
const StepEntry& e = plan.e[i];
|
||||
if (so.first_row[i] < 0 || e.n_spec <= 0 || e.n_spec > (int)RAD_MTP_COUPLE_MAX_ROUNDS ||
|
||||
e.suffix || e.card < 0 || (size_t)e.card >= couple_by_card_.size())
|
||||
continue;
|
||||
const RadMtpCoupleDraw& d = couple_by_card_[(size_t)e.card];
|
||||
if (d.seq != e.seq || d.mode != 1) continue;
|
||||
/* --draft-depth-load: the chain this verify settled, with the confidences its
|
||||
* decisions read, for the online calibration. */
|
||||
if (depth_online_on_ && (size_t)e.card < depth_pend_.size()) {
|
||||
const DepthPend& pd = depth_pend_[(size_t)e.card];
|
||||
if (pd.depth > 0 && pd.seq == e.seq && pd.depth == e.n_spec)
|
||||
draft_depth_online_chain(depth_cfg_, &depth_online_, pd.depth, pd.rule,
|
||||
std::max(0, so.accepted[i]), pd.s, pd.n_s);
|
||||
}
|
||||
depth_stats_.acc[e.n_spec] += (uint64_t)std::max(0, so.accepted[i]);
|
||||
++depth_stats_.acc_n[e.n_spec];
|
||||
}
|
||||
}
|
||||
sched_.serial_end(serial_done_);
|
||||
for (DepthPend& pd : depth_pend_) pd.depth = 0; /* settled above, or never verified */
|
||||
if (serial_done_ <= 0 || serial_rows_ <= 0) return RAD_OK;
|
||||
|
||||
Rank& r0 = *ranks_[0];
|
||||
@@ -388,9 +842,35 @@ int Engine::finish_serial_drafter(const StepOut& so) {
|
||||
* cannot snapshot its state); the sampler would refuse the next step otherwise. */
|
||||
if (!r0.sampler.allows_speculation(serial_row_[(size_t)i].seq)) continue;
|
||||
const uint64_t seq = serial_row_[(size_t)i].seq;
|
||||
const int rc = sched_.set_draft(seq, &draft_out_[(size_t)i * (size_t)rounds], done);
|
||||
/* Under --draft-depth adaptive the row's own chain: the drafts the step issued ahead was
|
||||
* planned with (issue_ahead's expect_draft), a prefix of the rounds that ran. */
|
||||
const int row_nodes = depth_cfg_.on ? depth_row_nodes(i) : done;
|
||||
const int rc = sched_.set_draft(seq, &draft_out_[(size_t)i * (size_t)rounds], row_nodes);
|
||||
/* --draft-depth-load: the chain as the next verify will settle it -- its depth, the round
|
||||
* the rule sent it to, and the statistics of the rounds that ran for it. */
|
||||
if (depth_online_on_ && rc == RAD_OK && mtp_couple_ && couple_readback_ && row_nodes >= 1 &&
|
||||
!depth_row_[(size_t)i].lawless) {
|
||||
const int32_t card = serial_row_[(size_t)i].card;
|
||||
if (card >= 0 && (size_t)card < depth_pend_.size()) {
|
||||
DepthPend& pd = depth_pend_[(size_t)card];
|
||||
pd.seq = seq;
|
||||
pd.depth = row_nodes;
|
||||
pd.rule = depth_load_step_ ? depth_row_[(size_t)i].rule : 0;
|
||||
pd.n_s = 0;
|
||||
const int ran = std::min(done, (int)std::min<int64_t>(RAD_MTP_COUPLE_MAX_ROUNDS, couple_planes_));
|
||||
for (int r = 1; r <= ran; ++r) {
|
||||
const RadMtpCoupleState& cs = couple_readback_[(int64_t)(r - 1) * couple_rows_ + i];
|
||||
if (std::memcmp(&cs.draw, &couple_draw_stage_[(size_t)i], sizeof cs.draw)) break;
|
||||
const double st = draft_depth_stat(cs, r, DRAFT_DEPTH_TOP);
|
||||
if (st < 0.0) break;
|
||||
pd.s[r - 1] = (float)st;
|
||||
pd.n_s = r;
|
||||
}
|
||||
if (pd.n_s < row_nodes) pd.depth = 0; /* a round with no law: not counted */
|
||||
}
|
||||
}
|
||||
if (mtp_couple_)
|
||||
RAD_TRY(bind_couple(seq, i, done, rc == RAD_OK, serial_row_[(size_t)i].card));
|
||||
RAD_TRY(bind_couple(seq, i, row_nodes, rc == RAD_OK, serial_row_[(size_t)i].card));
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
+64
-3
@@ -54,7 +54,7 @@ const Replaced kReplaced[] = {
|
||||
const char* const kRepeatable[] = { "lora", "allow-host", "trusted-proxy" };
|
||||
|
||||
/* The fleet's own keys on a model. `defaults:` may carry every one but aliases (read_model_keys). */
|
||||
const char* const kModelFleetKeys[] = { "aliases", "priority", "pin", "ttl", "flex", "park" };
|
||||
const char* const kModelFleetKeys[] = { "aliases", "priority", "pin", "ttl", "flex", "park", "cards" };
|
||||
|
||||
const char* const kTopKeys[] = { "server", "cards", "memory", "scheduler", "defaults", "models", "groups" };
|
||||
|
||||
@@ -309,7 +309,7 @@ private:
|
||||
if (level != "server" && (in(kServerKeys, key) || key == "log")) return key + " belongs under server:";
|
||||
if (level != "memory" && level != "model" && in(kMemoryFlagKeys, key))
|
||||
return key + " belongs under memory: or a model";
|
||||
if (level != "memory" && (key == "host-mib" || key == "disk-tier"))
|
||||
if (level != "memory" && (key == "host-mib" || key == "disk-tier" || key == "card-headroom-mib"))
|
||||
return key + " belongs under memory:";
|
||||
if (level != "model" && flags_.count(key))
|
||||
return key + " is a per-model key; put it under the model or defaults:";
|
||||
@@ -382,10 +382,27 @@ int Reader::read_memory(const Item& sec, FleetConfig* out) {
|
||||
if (int s = scalar_text(it, &out->disk_tier); s < 0) return s;
|
||||
continue;
|
||||
}
|
||||
if (k == "card-headroom-mib") {
|
||||
if (!it.node.is_map())
|
||||
return fail(it.node, it.path + " takes a map of card ordinal to MiB, as {0: 4096}");
|
||||
std::vector<Item> cards;
|
||||
if (int s = children(it.node, it.path, &cards); s < 0) return s;
|
||||
for (const Item& c : cards) {
|
||||
char* end = nullptr;
|
||||
const long card = std::strtol(c.key.c_str(), &end, 10);
|
||||
if (c.key.empty() || *end || card < 0 || card > 255)
|
||||
return fail(c.node, c.path + ": a card is named by its ordinal, 0 or above");
|
||||
int64_t mib = 0;
|
||||
if (int s = integer(c, 0, INT64_MAX / (1 << 20), &mib); s < 0) return s;
|
||||
out->card_headroom_mib[(int)card] = mib;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!in(kMemoryFlagKeys, k)) {
|
||||
std::vector<std::string> valid = as_vector(kMemoryFlagKeys);
|
||||
valid.push_back("host-mib");
|
||||
valid.push_back("disk-tier");
|
||||
valid.push_back("card-headroom-mib");
|
||||
return refuse_key(it, "memory", "memory", valid);
|
||||
}
|
||||
if (int s = flag_args(it, &memory_args_); s < 0) return s;
|
||||
@@ -466,6 +483,9 @@ int Reader::read_model_keys(const Item& sec, bool is_defaults, std::vector<Item>
|
||||
const std::string& k = it.key;
|
||||
if (in(kModelFleetKeys, k)) {
|
||||
if (is_defaults && k == "aliases") return fail(it.node, "aliases name one model; they cannot be a default");
|
||||
if (is_defaults && k == "cards")
|
||||
return fail(it.node, "cards under defaults would pin every model; the top-level "
|
||||
"cards: names the cards the fleet uses");
|
||||
continue;
|
||||
}
|
||||
std::string m = misplaced(k, "model");
|
||||
@@ -495,6 +515,20 @@ int Reader::read_fleet_key(const Item& it, ModelEntry* e) {
|
||||
return RAD_OK;
|
||||
}
|
||||
if (k == "pin") return boolean(it, &e->pin);
|
||||
if (k == "cards") {
|
||||
e->cards.clear();
|
||||
if (scalar(it.node) && str(it.node.val()) == "all") return RAD_OK;
|
||||
if (!it.node.is_seq() || it.node.num_children() == 0)
|
||||
return fail(it.node, it.path + " takes all or a list of card indices");
|
||||
for (Node c : it.node.children()) {
|
||||
int64_t idx = 0;
|
||||
if (int s = integer({ c, it.path, "cards" }, 0, 63, &idx); s < 0) return s;
|
||||
if (std::find(e->cards.begin(), e->cards.end(), (int)idx) != e->cards.end())
|
||||
return fail(c, "card " + std::to_string(idx) + " is listed twice");
|
||||
e->cards.push_back((int)idx);
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
if (k == "ttl") return duration(it, &e->ttl_ms);
|
||||
if (k == "flex") {
|
||||
std::vector<Item> parts;
|
||||
@@ -690,6 +724,20 @@ int Reader::run(FleetConfig* out) {
|
||||
out->models.push_back(std::move(e));
|
||||
}
|
||||
|
||||
/* A model's own cards are among the fleet's and are enough for its ranks. */
|
||||
for (const ModelEntry& e : out->models) {
|
||||
if (e.cards.empty()) continue;
|
||||
for (int c : e.cards)
|
||||
if (!out->cards.empty() &&
|
||||
std::find(out->cards.begin(), out->cards.end(), c) == out->cards.end())
|
||||
return fail(doc, "models." + e.name + ".cards lists " + std::to_string(c) +
|
||||
", which the top-level cards: leaves out");
|
||||
if (std::max(e.cfg.tp, 1) > (int)e.cards.size())
|
||||
return fail(doc, "models." + e.name + ": tp " + std::to_string(std::max(e.cfg.tp, 1)) +
|
||||
" needs that many cards and its cards: lists " +
|
||||
std::to_string(e.cards.size()));
|
||||
}
|
||||
|
||||
std::map<std::pair<std::string, std::string>, Group::Kind> pairs;
|
||||
for (const Group& g : out->groups) {
|
||||
for (const std::string& m : g.members)
|
||||
@@ -844,6 +892,7 @@ void print_reference(FILE* to) {
|
||||
" aliases: [NAME, ...] more ids for this model\n"
|
||||
" priority: N higher keeps VRAM and takes flex from lower\n"
|
||||
" pin: true|false never leaves VRAM\n"
|
||||
" cards: all | [N, ...] the cards this model may be placed on (all)\n"
|
||||
" ttl: DURATION park after this long without requests\n"
|
||||
" flex: {kv: {min-tokens, max-tokens, weight}, experts: {min-mib, max-mib}}\n"
|
||||
" park: {vram: none|statics|MIB, ram: required|allowed|never, restore: auto|full|live}\n");
|
||||
@@ -952,7 +1001,19 @@ std::string yaml_from_args(int argc, char** argv) {
|
||||
y += std::string(indent) + e.key + ": " + rad::Json::parse(e.vals[0]).dump() + "\n";
|
||||
continue;
|
||||
}
|
||||
if (e.vals.size() == 1) { y += std::string(indent) + e.key + ": " + yaml_scalar(e.vals[0]) + "\n"; continue; }
|
||||
if (e.vals.size() == 1) {
|
||||
y += std::string(indent) + e.key + ": " + yaml_scalar(e.vals[0]);
|
||||
/* A value an earlier release took and this one refuses is written as given, so
|
||||
* the file says what the command line said, with what replaces it beside it. */
|
||||
if (e.key == "kv-cache-dtype") {
|
||||
if (e.vals[0] == "fp8_v4" || e.vals[0] == "k6_v4")
|
||||
y += " # not served: i8 is the 8-bit cache, bf16 the other";
|
||||
else if (e.vals[0] == "fp8")
|
||||
y += " # served for few models: i8 is the 8-bit cache of the others";
|
||||
}
|
||||
y += "\n";
|
||||
continue;
|
||||
}
|
||||
y += std::string(indent) + e.key + ":\n";
|
||||
for (const std::string& v : e.vals) y += std::string(indent) + " - " + yaml_scalar(v) + "\n";
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -67,6 +68,9 @@ struct ModelEntry {
|
||||
std::vector<std::string> aliases;
|
||||
int priority = 0;
|
||||
bool pin = false;
|
||||
/* The cards this model may be placed on, in the file's order; empty means any of the
|
||||
* fleet's. Not part of `args`: it decides where the engine runs, not how it is configured. */
|
||||
std::vector<int> cards;
|
||||
int64_t ttl_ms = 0; /* idle time before parking; 0 = never */
|
||||
FlexSpec flex;
|
||||
ParkSpec park;
|
||||
@@ -99,6 +103,9 @@ struct FleetConfig {
|
||||
/* memory: the per-card keys travel inside every model's flag list; these are the fleet's own. */
|
||||
int64_t host_mib = 0; /* 0 = not set */
|
||||
std::string disk_tier;
|
||||
/* memory.card-headroom-mib: a card's own reserve, in MiB by card ordinal, in place of the
|
||||
* gpu-headroom-mib every other card keeps (the card that drives a desktop). */
|
||||
std::map<int, int64_t> card_headroom_mib;
|
||||
|
||||
/* scheduler: */
|
||||
int64_t load_timeout_ms = 120000;
|
||||
|
||||
+157
-30
@@ -287,10 +287,7 @@ private:
|
||||
Model* m = nullptr;
|
||||
int grant(const VramAsk& ask, int64_t* g, std::string* why) override { return f->grant(*m, ask, g, why); }
|
||||
bool host_room(int64_t bytes) override {
|
||||
if (!f->load_host_room(*m, bytes)) return false;
|
||||
m->pools_held.fetch_add(bytes);
|
||||
f->host_reserve_.fetch_add(bytes);
|
||||
return true;
|
||||
return f->load_host_room(*m, bytes, 0, /*reserve=*/true);
|
||||
}
|
||||
bool host_pools_room() override {
|
||||
const int64_t own = m->pools_held.load();
|
||||
@@ -445,7 +442,7 @@ private:
|
||||
bool take_busy = false, int64_t own = 0, bool evict = true);
|
||||
/* Parked models give back their snapshot stores, in `parked` order, until `need` is free. */
|
||||
bool release_spares(const std::vector<Model*>& parked, int64_t need);
|
||||
bool load_host_room(Model& m, int64_t need, int64_t own = 0);
|
||||
bool load_host_room(Model& m, int64_t need, int64_t own = 0, bool reserve = false);
|
||||
bool loading_beside(const Model& m);
|
||||
bool alone_on_host(const Model& m);
|
||||
int64_t host_held();
|
||||
@@ -463,9 +460,14 @@ private:
|
||||
|
||||
void fail(Model& m, const std::string& why);
|
||||
bool choose_cards(Model& m, const Config& cfg, std::vector<int>* out, std::string* why);
|
||||
/* The cards `m` may be placed on: its own list (models.NAME.cards), else the fleet's. */
|
||||
const std::vector<int>& cards_of(const Model& m) const {
|
||||
return m.entry.cards.empty() ? cards_ : m.entry.cards;
|
||||
}
|
||||
std::vector<CardRoom> rooms();
|
||||
/* The bytes a model may still claim on `card`: free past the headroom and what is pending. */
|
||||
int64_t room_on(int card);
|
||||
int64_t headroom_on(int card) const;
|
||||
int64_t pending_on(int card);
|
||||
/* rooms() covers `need` on every card in it, without anything leaving. */
|
||||
bool fits_free(const std::map<int, int64_t>& need);
|
||||
@@ -477,10 +479,16 @@ private:
|
||||
std::string reload();
|
||||
void stop_all();
|
||||
void add_routes();
|
||||
/* Whether `q`'s caller may reach the fleet's admin routes: everyone who pays the api key, or
|
||||
* -- keyless -- the local operator on the three-leg rule (loopback, no foreign Origin, pinned
|
||||
* Host). One predicate, read by add_routes' guard and the front's operator rule alike. */
|
||||
bool operator_ok(const server::HttpRequest& q) const;
|
||||
json status();
|
||||
void history_loop();
|
||||
json placement(const std::string& name);
|
||||
std::string describe(const std::string& name);
|
||||
/* Adapters a resident model serves from memory: the names /v1/models lists as its cards. */
|
||||
std::vector<std::string> adapters_of(const std::string& name);
|
||||
std::string metrics();
|
||||
std::vector<std::string> group_partners(const std::string& name, Group::Kind kind) const;
|
||||
void keep_partners(const Model& m, std::vector<Resident>* res) const;
|
||||
@@ -583,8 +591,15 @@ int64_t Fleet::pending_on(int card) {
|
||||
return n;
|
||||
}
|
||||
|
||||
/* What a card keeps free: its own reserve where memory.card-headroom-mib names it, else the
|
||||
* headroom every card keeps. */
|
||||
int64_t Fleet::headroom_on(int card) const {
|
||||
const auto it = fc_.card_headroom_mib.find(card);
|
||||
return it == fc_.card_headroom_mib.end() ? headroom_ : it->second * kMiB;
|
||||
}
|
||||
|
||||
int64_t Fleet::room_on(int card) {
|
||||
return std::max<int64_t>(free_on(card) - headroom_ - pending_on(card), 0);
|
||||
return std::max<int64_t>(free_on(card) - headroom_on(card) - pending_on(card), 0);
|
||||
}
|
||||
|
||||
std::vector<CardRoom> Fleet::rooms() {
|
||||
@@ -708,27 +723,33 @@ std::vector<size_t> Fleet::exclusive_victims(const Model& m) {
|
||||
|
||||
bool Fleet::choose_cards(Model& m, const Config& cfg, std::vector<int>* out, std::string* why) {
|
||||
const int tp = std::max(cfg.tp, 1);
|
||||
if (tp > (int)cards_.size()) {
|
||||
const std::vector<int>& may = cards_of(m);
|
||||
if (tp > (int)may.size()) {
|
||||
*why = "tp " + std::to_string(tp) + " needs " + std::to_string(tp) + " cards; " +
|
||||
std::to_string(cards_.size()) + " are available";
|
||||
std::to_string(may.size()) + " are available";
|
||||
return false;
|
||||
}
|
||||
if (!use_broker()) {
|
||||
out->assign(cards_.begin(), cards_.begin() + tp);
|
||||
out->assign(may.begin(), may.begin() + tp);
|
||||
return true;
|
||||
}
|
||||
/* The room plan and the fallback below see only the cards this model may use, so a model
|
||||
* with its own list is never planned onto another card, whatever room that card has. */
|
||||
std::vector<CardRoom> open;
|
||||
for (const CardRoom& c : rooms())
|
||||
if (std::find(may.begin(), may.end(), c.card) != may.end()) open.push_back(c);
|
||||
const int64_t guess = first_guess(m.claim, cfg);
|
||||
std::vector<Resident> res = residents(&m);
|
||||
keep_partners(m, &res);
|
||||
RoomPlan plan;
|
||||
std::string w;
|
||||
if (plan_room(rooms(), res, tp, guess, m.entry.priority, exclusive_victims(m), m.last_cards,
|
||||
if (plan_room(open, res, tp, guess, m.entry.priority, exclusive_victims(m), m.last_cards,
|
||||
nullptr, &plan, &w)) {
|
||||
*out = plan.cards;
|
||||
return true;
|
||||
}
|
||||
std::vector<std::pair<int64_t, int>> by;
|
||||
for (const CardRoom& c : rooms()) {
|
||||
for (const CardRoom& c : open) {
|
||||
int64_t room = c.free;
|
||||
for (const Resident& r : res)
|
||||
if (!r.pin && !r.keep && r.priority <= m.entry.priority) room += r.gives(c.card);
|
||||
@@ -751,9 +772,9 @@ int64_t Fleet::flex_room(const std::vector<int>& cards) {
|
||||
for (auto& m : models_)
|
||||
if (m->waiting.load(std::memory_order_acquire)) return 0;
|
||||
}
|
||||
const int64_t margin = headroom_ + 512 * kMiB;
|
||||
int64_t room = INT64_MAX;
|
||||
for (int c : cards) room = std::min(room, free_on(c) - margin - pending_on(c));
|
||||
for (int c : cards)
|
||||
room = std::min(room, free_on(c) - (headroom_on(c) + 512 * kMiB) - pending_on(c));
|
||||
return room == INT64_MAX ? 0 : std::max<int64_t>(room, 0);
|
||||
}
|
||||
|
||||
@@ -1420,11 +1441,21 @@ bool Fleet::alone_on_host(const Model& m) {
|
||||
|
||||
/* Room to pin `need` during a load. As in the load's first wait, beside another load in flight
|
||||
* parked and idle models go only after ten seconds, once a load counted twice has passed. */
|
||||
bool Fleet::load_host_room(Model& m, int64_t need, int64_t own) {
|
||||
bool Fleet::load_host_room(Model& m, int64_t need, int64_t own, bool reserve) {
|
||||
// A new pool must reserve the room in the same critical section that found it. A check
|
||||
// of already reserved pools (own) does not count them a second time.
|
||||
auto commit_reservation = [&] {
|
||||
if (!reserve) return;
|
||||
m.pools_held.fetch_add(need);
|
||||
host_reserve_.fetch_add(need);
|
||||
};
|
||||
{
|
||||
/* There already: a warm-up needs no budget for a pin that leaves the host its floor. */
|
||||
std::lock_guard<std::recursive_mutex> room(room_mu_);
|
||||
if (host_available() - host_reserve_.load() + own - kHostFloor >= need) return true;
|
||||
if (host_available() - host_reserve_.load() + own - kHostFloor >= need) {
|
||||
commit_reservation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* Before its grant a load holds a guess of VRAM, which what pins this memory may be waiting
|
||||
* for (a parked model coming back): they would wait for each other. The guess goes while it
|
||||
@@ -1446,8 +1477,12 @@ bool Fleet::load_host_room(Model& m, int64_t need, int64_t own) {
|
||||
/* As in load_op: without a load in flight beside this one the figure is exact, and parked
|
||||
* and idle models give their host memory at once. */
|
||||
const bool exact = !warm && !loading_beside(m);
|
||||
ok = make_host_room(need, &m, !warm, !warm && (exact || i >= 50),
|
||||
!warm && (i >= 150 || (exact && i >= 10)), own);
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> room(room_mu_);
|
||||
ok = make_host_room(need, &m, !warm, !warm && (exact || i >= 50),
|
||||
!warm && (i >= 150 || (exact && i >= 10)), own);
|
||||
if (ok) commit_reservation();
|
||||
}
|
||||
if (ok || i + 1 >= tries) break;
|
||||
if (i == 0)
|
||||
RAD_INFO("model %s: waiting for %s of host memory to pin (%s available, %s of it kept "
|
||||
@@ -1684,6 +1719,9 @@ void Fleet::park_op(Model& m, const std::string& why) {
|
||||
* copies of copies: make_host_room lets them go first. */
|
||||
void Fleet::fill_op(Model& m) {
|
||||
if (!m.engine || !m.parked) return;
|
||||
// Size and reserve the fill together with parks and load reservations. The transfer itself
|
||||
// runs without room_mu_: a slow drive must not hold up another model's room decision.
|
||||
std::unique_lock<std::recursive_mutex> room_lock(room_mu_);
|
||||
/* A GiB at a time: a restore asked for meanwhile waits for one batch at most. */
|
||||
constexpr int64_t kBatch = (int64_t)1 << 30;
|
||||
if (host_room() - kFillSlack - Engine::kRefillHost < kBatch) {
|
||||
@@ -1701,8 +1739,20 @@ void Fleet::fill_op(Model& m) {
|
||||
fill_wait_ns_.store(rad_mono_ns() + 5000000000ull);
|
||||
return;
|
||||
}
|
||||
const int64_t budget = std::min(room, kBatch);
|
||||
const int64_t reserved = budget + Engine::kRefillHost;
|
||||
host_reserve_.fetch_add(reserved);
|
||||
room_lock.unlock();
|
||||
const auto t0 = std::chrono::steady_clock::now();
|
||||
const int64_t n = m.engine->fill_host(std::min(room, kBatch));
|
||||
int64_t n;
|
||||
{
|
||||
struct FillReservation {
|
||||
std::atomic<int64_t>& total;
|
||||
int64_t bytes;
|
||||
~FillReservation() { total.fetch_sub(bytes); }
|
||||
} hold{ host_reserve_, reserved };
|
||||
n = m.engine->fill_host(budget);
|
||||
}
|
||||
if (n < 0) {
|
||||
RAD_WARN("model %s: reading its parked copy into host memory failed: %s", m.entry.name.c_str(),
|
||||
rad_dev_last_error());
|
||||
@@ -1745,7 +1795,7 @@ void Fleet::restore_op(Model& m) {
|
||||
std::string why;
|
||||
/* A parked model comes back on its own cards. A fresh load could pick others, but needs as
|
||||
* much room; it is worth it only where other cards exist, and only after a while. */
|
||||
const bool elsewhere = (int)cards_.size() > (int)m.cards.size();
|
||||
const bool elsewhere = (int)cards_of(m).size() > (int)m.cards.size();
|
||||
std::unique_lock<std::recursive_mutex> room(room_mu_, std::defer_lock);
|
||||
int rrc = RAD_OK;
|
||||
bool yielded = false;
|
||||
@@ -2274,6 +2324,15 @@ std::string Fleet::reload() {
|
||||
if (a.host != b.host || a.port != b.port || a.api_key != b.api_key ||
|
||||
a.http_threads != b.http_threads || a.cors != b.cors || nf.cards != fc_.cards)
|
||||
return "server: and cards: changes need a restart";
|
||||
for (const ModelEntry& e : nf.models)
|
||||
for (int c : e.cards)
|
||||
if (std::find(cards_.begin(), cards_.end(), c) == cards_.end())
|
||||
return "models." + e.name + ": cards lists " + std::to_string(c) +
|
||||
", which is not a usable card here";
|
||||
for (const auto& [c, mib] : nf.card_headroom_mib)
|
||||
if (std::find(cards_.begin(), cards_.end(), c) == cards_.end())
|
||||
return "memory.card-headroom-mib names card " + std::to_string(c) +
|
||||
", which is not a card this fleet uses";
|
||||
if (nf.log_set) log_set_level(nf.log);
|
||||
/* Work in flight finishes first. */
|
||||
for (auto& m : models_) {
|
||||
@@ -2306,7 +2365,7 @@ std::string Fleet::reload() {
|
||||
RAD_INFO("model %s: added", e.name.c_str());
|
||||
continue;
|
||||
}
|
||||
if (m->entry.args != e.args) {
|
||||
if (m->entry.args != e.args || m->entry.cards != e.cards) {
|
||||
unload(*m, fc_.drain_timeout_ms, "its configuration changed");
|
||||
RAD_INFO("model %s: reconfigured", e.name.c_str());
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
@@ -2384,6 +2443,15 @@ std::string Fleet::describe(const std::string& name) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
/* The adapter names a resident model serves from memory. A parked or loading engine serves none
|
||||
* through this name: nothing answers a request to a child while the parent is not open. */
|
||||
std::vector<std::string> Fleet::adapters_of(const std::string& name) {
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
for (auto& mp : models_)
|
||||
if (mp->entry.name == name && mp->resident && mp->engine) return mp->engine->lora_names();
|
||||
return {};
|
||||
}
|
||||
|
||||
/* What /admin/fleet says beyond describe(), which also feeds every /v1/models card: where the
|
||||
* model's bytes are, its file and the policy it was configured with. */
|
||||
json Fleet::placement(const std::string& name) {
|
||||
@@ -2483,6 +2551,9 @@ void Fleet::history_loop() {
|
||||
using clock = std::chrono::steady_clock;
|
||||
auto next_row = clock::now();
|
||||
std::set<std::string> open; /* the models that had a row since they last opened */
|
||||
/* The adapter children sampled under each model's name, so that their series close with the
|
||||
* model and a child no longer served is dropped. */
|
||||
std::map<std::string, std::set<std::string>> kids;
|
||||
while (!g_stop.load() && !front_.stopping()) {
|
||||
const double t = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
const bool watched = history_.watched(3.0);
|
||||
@@ -2495,7 +2566,10 @@ void Fleet::history_loop() {
|
||||
for (const std::string& n : front_.names()) {
|
||||
const bool is_open = front_.activity(n).state == server::Front::State::Open;
|
||||
if (!is_open) {
|
||||
if (open.erase(n) || row) history_.model_closed(n);
|
||||
if (open.erase(n) || row) {
|
||||
history_.model_closed(n);
|
||||
for (const std::string& c : kids[n]) history_.model_closed(c);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const bool first = !open.count(n);
|
||||
@@ -2504,6 +2578,16 @@ void Fleet::history_loop() {
|
||||
if (body.empty()) continue;
|
||||
const json s = json::parse(body, nullptr, false);
|
||||
if (!s.is_object()) continue;
|
||||
/* status() lists each adapter of this model as a child; a child owns no engine, and
|
||||
* the parent's stats are exactly what a request to the child runs on -- the same
|
||||
* tokens, the same queue, the same seconds. Sample the child under its own name with
|
||||
* the parent's body so the child's charts draw what its name actually drives. */
|
||||
std::set<std::string> now;
|
||||
for (const std::string& a : adapters_of(n)) now.insert(n + ":" + a);
|
||||
for (const std::string& c : kids[n])
|
||||
if (!now.count(c)) history_.forget(c);
|
||||
for (const std::string& c : now) history_.model_sample(c, s, t, body);
|
||||
kids[n] = std::move(now);
|
||||
history_.model_sample(n, s, t, std::move(body));
|
||||
open.insert(n);
|
||||
}
|
||||
@@ -2536,6 +2620,21 @@ json Fleet::status() {
|
||||
if (j.contains("waiting_for") && a.state != server::Front::State::Open) j["state"] = "waiting";
|
||||
if (const std::string caps = front_.capabilities(n); !caps.empty()) j["capabilities"] = json::parse(caps, nullptr, false);
|
||||
models.push_back(j);
|
||||
/* Runtime LoRA: an adapter is a model as far as choosing one goes, and /v1/models lists
|
||||
* each as a child under `base:adapter` (server.cpp). The fleet view must say the same,
|
||||
* or a view built on it is blind to what this machine answers to. A child owns nothing:
|
||||
* no cards, no bytes, no policy of its own; its state and counters are the parent's,
|
||||
* because the parent is what serves it. */
|
||||
for (const std::string& a : adapters_of(n)) {
|
||||
json ad;
|
||||
ad["id"] = n + ":" + a;
|
||||
ad["parent"] = n;
|
||||
ad["adapter"] = true;
|
||||
ad["state"] = j["state"];
|
||||
ad["in_flight"] = j["in_flight"];
|
||||
ad["waiting"] = j["waiting"];
|
||||
models.push_back(std::move(ad));
|
||||
}
|
||||
}
|
||||
json cards = json::array();
|
||||
for (int c : cards_) {
|
||||
@@ -2580,14 +2679,22 @@ json Fleet::status() {
|
||||
{ "cards", cards }, { "groups", groups }, { "host", host }, { "warm_up", warm } };
|
||||
}
|
||||
|
||||
bool Fleet::operator_ok(const server::HttpRequest& q) const {
|
||||
const Config& c = fc_.models.front().cfg;
|
||||
return !c.api_key.empty() || server::local_operator(q, c.host, c.allow_hosts);
|
||||
}
|
||||
|
||||
void Fleet::add_routes() {
|
||||
/* The fleet's own routes. Without a bearer key they answer loopback callers only, as the
|
||||
* engine's other admin routes do. */
|
||||
/* The fleet's own routes. Without a bearer key they answer the local operator only, on the
|
||||
* very rule the engine's other admin routes apply: loopback socket, no foreign Origin, and a
|
||||
* Host that names this box. The socket alone forges -- a rebinding page or a localhost proxy
|
||||
* is loopback for any caller -- so all three legs are read here too (docs/GUIDE.md). */
|
||||
auto guard = [this](const server::HttpRequest& q) -> std::optional<server::HttpResponse> {
|
||||
if (!fc_.models.front().cfg.api_key.empty() || q.peer_is_loopback()) return std::nullopt;
|
||||
if (operator_ok(q))
|
||||
return std::nullopt;
|
||||
return server::HttpResponse::json_body(
|
||||
403, server::error_body(q.path, 403, "permission_error",
|
||||
"the fleet's admin routes answer loopback callers only "
|
||||
"the fleet's admin routes answer the local operator only "
|
||||
"unless an api key is configured"));
|
||||
};
|
||||
auto ok = [](json j) { return server::HttpResponse::json_body(200, j.dump()); };
|
||||
@@ -2603,7 +2710,8 @@ void Fleet::add_routes() {
|
||||
* /admin/fleet's object as `live`. `since` (unix seconds) asks for what came after. Every byte
|
||||
* comes from the sampler's last read, so a page that polls this reads nothing of the engine:
|
||||
* it neither brings a model back nor costs a running one anything. A model's history is as
|
||||
* open as its /stats, the fleet's as /admin/fleet. */
|
||||
* open as its /stats, whose figures it repeats, and the fleet's as guarded as /admin/fleet:
|
||||
* a browser the fleet view is refused to still draws the server's own model from it. */
|
||||
front_.route("GET", "/history", [this, guard, ok](const server::HttpRequest& q) {
|
||||
double since = 0;
|
||||
if (auto it = q.query.find("since"); it != q.query.end()) since = std::strtod(it->second.c_str(), nullptr);
|
||||
@@ -2775,12 +2883,28 @@ int Fleet::run() {
|
||||
cards_.push_back(c);
|
||||
}
|
||||
}
|
||||
for (const ModelEntry& e : fc_.models)
|
||||
if (std::max(e.cfg.tp, 1) > (int)cards_.size()) {
|
||||
RAD_ERR("models.%s: tp %d needs %d cards; %zu are available", e.name.c_str(), e.cfg.tp,
|
||||
e.cfg.tp, cards_.size());
|
||||
for (const auto& [c, mib] : fc_.card_headroom_mib) {
|
||||
if (std::find(cards_.begin(), cards_.end(), c) == cards_.end()) {
|
||||
RAD_ERR("%s: memory.card-headroom-mib names card %d, which is not a card this fleet "
|
||||
"uses", fc_.path.c_str(), c);
|
||||
return 2;
|
||||
}
|
||||
RAD_INFO("fleet: card %d keeps %lld MiB free (memory.card-headroom-mib)", c, (long long)mib);
|
||||
}
|
||||
for (const ModelEntry& e : fc_.models) {
|
||||
for (int c : e.cards)
|
||||
if (std::find(cards_.begin(), cards_.end(), c) == cards_.end()) {
|
||||
RAD_ERR("models.%s: cards lists %d, which is not a usable card here",
|
||||
e.name.c_str(), c);
|
||||
return 2;
|
||||
}
|
||||
const size_t have = e.cards.empty() ? cards_.size() : e.cards.size();
|
||||
if (std::max(e.cfg.tp, 1) > (int)have) {
|
||||
RAD_ERR("models.%s: tp %d needs %d cards; %zu are available", e.name.c_str(), e.cfg.tp,
|
||||
e.cfg.tp, have);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Park files a process that died left in the disk tier: radiance-park-PID-N.bin (pageable
|
||||
* chunks) and radiance-vmem-PID-N.bin (elastic ranges) of a PID that no longer runs. */
|
||||
@@ -2819,6 +2943,9 @@ int Fleet::run() {
|
||||
if (required) preload.push_back(e.name);
|
||||
}
|
||||
front_.set_demand([this](const std::string& n) { demand(n); });
|
||||
/* The guarded routes wake models only for callers their own handlers would admit: the same
|
||||
* operator_ok predicate add_routes' guard reads, keyed deployments always. */
|
||||
front_.set_operator_rule([this](const server::HttpRequest& q) { return operator_ok(q); });
|
||||
front_.set_describe([this](const std::string& n) { return describe(n); });
|
||||
front_.set_metrics([this] { return metrics(); });
|
||||
add_routes();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "checkpoint.h"
|
||||
#include "ggml_planes.h"
|
||||
#include "rad_plugin.h"
|
||||
#include "../rad_internal.h"
|
||||
|
||||
#include "util/json.h"
|
||||
|
||||
@@ -450,8 +451,14 @@ int meta_from_gguf(GgufFile& g, MetaOwn* out) {
|
||||
* config.json names, so the reader re-spells them here and one plugin serves both
|
||||
* formats. eps and rope_theta take the generic paths above. Four of the family's
|
||||
* design choices the GGUF does not carry are Ling 3.0's, stated as constants. */
|
||||
if (gi("kda.head_dim", 0) <= 0 || gi("rope.dimension_count", 0) <= 0 ||
|
||||
gi("attention.key_length_mla", 0) <= gi("rope.dimension_count", 0))
|
||||
/* Bounds on the family gates too (see bailingmoe3_layouts): the layout rebuild's
|
||||
* products -- heads * (nope + rope) rows, the fused kv's heads * 256 * latent -- are
|
||||
* int64 products of these values handed to sized allocations, so the widths they are
|
||||
* built from may not roam free. 128/64 is the shipped geometry. */
|
||||
if (gi("kda.head_dim", 0) <= 0 || gi("kda.head_dim", 0) > 512 ||
|
||||
gi("rope.dimension_count", 0) <= 0 || gi("rope.dimension_count", 0) > 256 ||
|
||||
gi("attention.key_length_mla", 0) <= gi("rope.dimension_count", 0) ||
|
||||
gi("attention.key_length_mla", 0) > 65536)
|
||||
return RAD_E_FORMAT;
|
||||
out->kv("num_attention_heads", fmt("%lld", (long long)m.n_head));
|
||||
/* The typed head_dim the generic pass fell back to (the MLA query width) is not the
|
||||
@@ -592,6 +599,28 @@ int Checkpoint::add_shard(const std::string& p, const std::string& prefix,
|
||||
|
||||
namespace {
|
||||
|
||||
/* Whether an index may name `f` as a shard. The index is data the checkpoint supplies, and its
|
||||
* names are joined under the model directory and opened as the serving user, so a name must stay
|
||||
* under that directory: relative, with no empty component, "." or "..". Subdirectories are legal.
|
||||
* Only the name is screened. A shard that is a symbolic link is followed like any file the
|
||||
* operator points the engine at: a Hugging Face cache snapshot is a directory of links into its
|
||||
* blob store. */
|
||||
bool shard_name_ok(const std::string& f) {
|
||||
if (f.empty() || f.front() == '/') return false;
|
||||
size_t i = 0;
|
||||
while (i < f.size()) {
|
||||
size_t j = f.find('/', i);
|
||||
if (j == std::string::npos) j = f.size();
|
||||
if (j == i) return false; /* empty component, "//" */
|
||||
if (j - i == 2 && f.compare(i, 2, "..") == 0) return false;
|
||||
if (j - i == 1 && f[i] == '.') return false;
|
||||
i = j + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool path_exists(const std::string& p) { std::ifstream f(p); return (bool)f; }
|
||||
|
||||
/* Every shard an index names, once each and in name order, or the one model.safetensors; `map`
|
||||
* is the index's weight_map, empty without one. */
|
||||
int shard_list(const std::string& dir, const std::string& index, bool index_given,
|
||||
@@ -600,6 +629,13 @@ int shard_list(const std::string& dir, const std::string& index, bool index_give
|
||||
if (s == RAD_OK) {
|
||||
for (auto& [t, f] : *map)
|
||||
if (std::find(out->begin(), out->end(), f) == out->end()) out->push_back(f);
|
||||
for (const std::string& f : *out)
|
||||
if (!shard_name_ok(f)) {
|
||||
RAD_ERR("%s: the index names the shard '%s'; shards must live under the model "
|
||||
"directory",
|
||||
index.c_str(), log_sanitize(f).c_str());
|
||||
return RAD_E_FORMAT;
|
||||
}
|
||||
std::sort(out->begin(), out->end());
|
||||
for (auto& f : *out) f = dir + "/" + f;
|
||||
return RAD_OK;
|
||||
@@ -632,8 +668,6 @@ static int meta_merge_json_file(const std::string& path, const std::string& pref
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
static bool path_exists(const std::string& p) { std::ifstream f(p); return (bool)f; }
|
||||
|
||||
/* Whether an FP8 piece of `rows` rows has one scale for the whole tensor: a rank-0 scale
|
||||
* (ModelOpt's) or a one-element [1] (compressed-tensors' tensor strategy). A [1, 1] scale is a
|
||||
* block plane. */
|
||||
@@ -3556,7 +3590,20 @@ int Checkpoint::bailingmoe3_layouts() {
|
||||
const int64_t emb = meta_.m.n_embd;
|
||||
const char* nexp_s = meta_.get("num_experts");
|
||||
const int64_t n_expert = nexp_s ? std::stoll(nexp_s) : 0;
|
||||
if (n_layer < 1 || group < 2 || heads < 1 || latent < 1 || ff < 1 || emb < 1)
|
||||
/* Every loop below walks to n_layer on the open path, so the counts must be bounded HERE:
|
||||
* a GGUF claiming 2^62 layers would spend centuries in name probes, never answering, never
|
||||
* refusing -- a hostile container's hang, not a slow load. No real model of this family is
|
||||
* near 4096 layers. And the MoE suffix loop starts at the dense prefix, so the prefix must
|
||||
* lie inside the stack: negative opens a walk of twice the range, beyond the end is a
|
||||
* container that means nothing by it. The head and rank caps are the same discipline one
|
||||
* order down: the rebuild's products (heads * (nope + rope) rows, heads * 256 * latent
|
||||
* bytes of fused kv) are computed in int64 and handed to vectors sized through size_t, and
|
||||
* a product past that type's range truncates to a small allocation the copy then overruns.
|
||||
* No family model is near 4096 heads or ranks; 256 rope dimensions is already
|
||||
* far past what the rope kernel addresses. */
|
||||
if (n_layer < 1 || n_layer > 4096 || dense < 0 || dense > n_layer ||
|
||||
group < 2 || group > n_layer || heads < 1 || heads > 4096 ||
|
||||
latent < 1 || latent > 4096 || ff < 1 || emb < 1)
|
||||
return RAD_E_FORMAT;
|
||||
|
||||
/* Decode a whole source tensor to f32: a block type row by row, a plain one a copy. */
|
||||
@@ -3627,9 +3674,14 @@ int Checkpoint::bailingmoe3_layouts() {
|
||||
const char* nps = meta_.get("qk_nope_head_dim"), *rps = meta_.get("qk_rope_head_dim");
|
||||
const int64_t qn = nps ? std::stoll(nps) : 0, qr = rps ? std::stoll(rps) : 0;
|
||||
const SrcTensor* qb = find(fmt("blk.%lld.attn_q_b.weight", (long long)l));
|
||||
/* The row product is checked, not trusted: heads and the two rope widths arrive from
|
||||
* the container, and a wrapped product that happened to equal the tensor's rows would
|
||||
* run the split at the wrong per-head boundary. */
|
||||
int64_t w = 0, qb_rows = 0;
|
||||
if (qb && qb->shape.size() == 2 && qb->shape[1] > 0 && qn > 0 && qr > 0 &&
|
||||
qb->shape[0] == heads * (qn + qr)) {
|
||||
const int64_t ql = qb->shape[1], w = qn + qr;
|
||||
!__builtin_add_overflow(qn, qr, &w) && !__builtin_mul_overflow(heads, w, &qb_rows) &&
|
||||
qb->shape[0] == qb_rows) {
|
||||
const int64_t ql = qb->shape[1];
|
||||
std::vector<float> q3, nblk, rblk;
|
||||
RAD_TRY(whole(qb, q3));
|
||||
nblk.assign((size_t)(heads * qn) * ql, 0.0f);
|
||||
|
||||
@@ -221,6 +221,12 @@ int Driver::submit(std::unique_ptr<Request> r, std::string* why) {
|
||||
" pixels");
|
||||
const int64_t tokens = (int64_t)(r->width / d.latent_scale) * (r->height / d.latent_scale);
|
||||
const int nb = r->has_neg ? 2 : 1;
|
||||
// Guidance branches must run together. Waiting cannot make an undersized
|
||||
// deployment schedulable; reject it without changing its memory budget.
|
||||
if (nb > max_seqs_)
|
||||
return no("this request needs " + std::to_string(nb) +
|
||||
" simultaneous image branches (--max-num-seqs must be at least " +
|
||||
std::to_string(nb) + ")");
|
||||
if (tokens > d.max_tokens)
|
||||
return no("the image is " + std::to_string(r->width) + "x" + std::to_string(r->height) +
|
||||
"; the largest this model makes is " + std::to_string(d.max_tokens) +
|
||||
|
||||
@@ -1264,7 +1264,11 @@ const RadBatch* VideoDriver::build_encode(Job& j, int step) {
|
||||
for (size_t r = 0; r < ranks_.size(); ++r) {
|
||||
const int ri = (int)r;
|
||||
RadVideoGenBatch& V = vout_[(size_t)r];
|
||||
V.enc_geom_d = dptr<int32_t>(ri, R_ENCG);
|
||||
/* The encoder mixes device kernels with host-only k=1 convolutions and snake
|
||||
* activations. Those host ops dereference their raw geometry operand directly;
|
||||
* a rank's VRAM copy segfaults on discrete GPUs. The pinned staging table is
|
||||
* readable by both execution sites and lives until this pass has completed. */
|
||||
V.enc_geom_d = hptr<int32_t>(R_ENCG);
|
||||
V.enc_kind = it.kind;
|
||||
V.enc_slot = it.slot;
|
||||
if (audio) {
|
||||
|
||||
+27
-12
@@ -93,9 +93,16 @@ std::vector<GenFieldSource> gen_sampling_sources(const GenSampling& stated, cons
|
||||
}
|
||||
|
||||
bool gen_sampling_parse(const std::string& json_text, const char* src, GenSampling* out) {
|
||||
Json j;
|
||||
try { j = Json::parse(json_text); }
|
||||
catch (const std::exception& e) { RAD_WARN("%s: %s; ignoring it", src, e.what()); return false; }
|
||||
/* A model-repo file, and container metadata reaches here too. Read it with the container's
|
||||
* bounds: a file that is refused never becomes a tree -- an unbounded read of a hostile one
|
||||
* could overflow this process's stack on the way to the dump or destructor below. */
|
||||
bool over = false, deep = false;
|
||||
Json j = Json::parse_container(json_text, &over, &deep);
|
||||
if (over || deep) {
|
||||
RAD_WARN("%s: %s; ignoring it", src, Json::bound_why(over, deep));
|
||||
return false;
|
||||
}
|
||||
if (j.is_discarded()) { RAD_WARN("%s: not valid JSON; ignoring it", src); return false; }
|
||||
if (!j.is_object()) { RAD_WARN("%s: not a JSON object; ignoring it", src); return false; }
|
||||
|
||||
/* `do_sample: false` means greedy, and transformers then ignores every other sampler field,
|
||||
@@ -178,12 +185,16 @@ bool gen_sampling_parse(const std::string& json_text, const char* src, GenSampli
|
||||
}
|
||||
|
||||
bool gen_sampling_from_file(const std::string& path, bool required, GenSampling* out) {
|
||||
std::ifstream f(path);
|
||||
if (!f) {
|
||||
std::string text;
|
||||
const int rst = read_text_file(path, text, kMaxContainerFile);
|
||||
if (rst == RAD_E_IO) {
|
||||
if (required) RAD_ERR("%s: cannot be read", path.c_str());
|
||||
return false;
|
||||
}
|
||||
std::string text((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||
if (rst != RAD_OK) {
|
||||
RAD_ERR("%s: larger than the 256 MiB a container file may be", path.c_str());
|
||||
return false;
|
||||
}
|
||||
return gen_sampling_parse(text, path.c_str(), out);
|
||||
}
|
||||
|
||||
@@ -204,13 +215,17 @@ bool gen_sampling_from_kv(const std::function<const char*(const char*)>& get, Ge
|
||||
}
|
||||
if (std::strcmp(k, "no_repeat_ngram_whitelist") == 0) {
|
||||
/* Not a number: the container's metadata is string-valued, and the whitelist is a
|
||||
* JSON array spelled as JSON text. */
|
||||
try {
|
||||
j[k] = Json::parse(v);
|
||||
} catch (const std::exception& e) {
|
||||
* JSON array spelled as JSON text. Bounded like every other container input. */
|
||||
bool over = false, deep = false;
|
||||
Json w = Json::parse_container(v, &over, &deep);
|
||||
if (over || deep)
|
||||
RAD_WARN("the container states generation.%s as \"%s\", which is not a JSON "
|
||||
"array of ids (%s); ignoring it", k, v, e.what());
|
||||
}
|
||||
"array of ids (%s); ignoring it",
|
||||
k, log_sanitize(v).c_str(), Json::bound_why(over, deep));
|
||||
else if (!w.is_discarded()) j[k] = std::move(w);
|
||||
else
|
||||
RAD_WARN("the container states generation.%s as \"%s\", which is not a JSON "
|
||||
"array of ids; ignoring it", k, log_sanitize(v).c_str());
|
||||
continue;
|
||||
}
|
||||
if (std::strcmp(k, "suppress_tokens") == 0) {
|
||||
|
||||
+15
-3
@@ -97,18 +97,30 @@ std::string hf_default_download_dir() {
|
||||
|
||||
std::string hf_served_path(const std::string& dir, std::string* why) {
|
||||
std::vector<std::string> rad;
|
||||
int64_t other_fmt = 0;
|
||||
std::error_code ec;
|
||||
for (const fs::directory_entry& e : fs::directory_iterator(dir, ec)) {
|
||||
std::error_code fe;
|
||||
if (e.is_regular_file(fe) && e.path().filename().string().ends_with(".rad"))
|
||||
rad.push_back(e.path().filename().string());
|
||||
if (!e.is_regular_file(fe)) continue;
|
||||
const std::string name = e.path().filename().string();
|
||||
if (name.ends_with(".rad")) rad.push_back(name);
|
||||
/* A repo fetched with hfget holds its source weights beside anything the operator or a
|
||||
* conversion added later; a container sitting among them is not self-appointing. */
|
||||
else if (name.ends_with(".safetensors") || name.ends_with(".gguf")) ++other_fmt;
|
||||
}
|
||||
if (ec) {
|
||||
*why = dir + ": " + ec.message();
|
||||
return std::string();
|
||||
}
|
||||
if (rad.empty()) return dir;
|
||||
if (rad.size() == 1) return dir + "/" + rad[0];
|
||||
if (rad.size() == 1) {
|
||||
if (other_fmt > 0) {
|
||||
*why = dir + " holds the container " + rad[0] + " beside safetensors or gguf weights; " +
|
||||
"pass the one to serve as --model " + dir + "/<file>";
|
||||
return std::string();
|
||||
}
|
||||
return dir + "/" + rad[0];
|
||||
}
|
||||
std::string names;
|
||||
for (size_t i = 0; i < rad.size(); ++i) names += (i ? ", " : "") + rad[i];
|
||||
*why = dir + " holds " + std::to_string(rad.size()) + " containers (" + names +
|
||||
|
||||
+16
-1
@@ -6,6 +6,7 @@
|
||||
#include "runtime/wtab.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace rad {
|
||||
@@ -202,8 +203,10 @@ bool stage_src(Ctx* ctx, int group, const RadKVGroupBatch* kvb, int layer, Stage
|
||||
if (end <= 0 || end > st->host_layer_stride) end = st->host_layer_stride;
|
||||
o->src.clear(); o->dst.clear(); o->len.clear();
|
||||
o->bytes = 0;
|
||||
bool clamped = false;
|
||||
auto add = [&](int64_t off, int64_t n) {
|
||||
if (off >= end) return;
|
||||
if (off >= end) { clamped = true; return; }
|
||||
if (n > end - off) clamped = true;
|
||||
n = std::min(n, end - off);
|
||||
if (n <= 0) return;
|
||||
o->src.push_back((uint64_t)(uintptr_t)(row + off));
|
||||
@@ -214,6 +217,18 @@ bool stage_src(Ctx* ctx, int group, const RadKVGroupBatch* kvb, int layer, Stage
|
||||
/* Only the step's ranges (stage.h, "Volume"); none set copies the row. */
|
||||
if (b->stage_runs.empty()) add(0, end);
|
||||
for (const KVStageRun& r : b->stage_runs) add(r.off, r.bytes);
|
||||
if (clamped) {
|
||||
/* Once, not per step: a run naming a block past the mirror row means pool and host
|
||||
* layer disagree on the layout, and the bytes past the clamp silently never stage --
|
||||
* attention then reads a row that is part copy and part stale. The clamp is the
|
||||
* memory-safe answer; this is the promise that it is never a silent one. */
|
||||
static std::atomic<bool> said{false};
|
||||
if (log_once(said))
|
||||
RAD_WARN("kvstream: group %d stage runs reach past the host layer's end (%lld of "
|
||||
"%lld bytes): the stage drops what lies past it, and staged attention "
|
||||
"reads stale bytes there (first of possibly many)",
|
||||
group, (long long)end, (long long)st->host_layer_stride);
|
||||
}
|
||||
return o->bytes > 0;
|
||||
}
|
||||
|
||||
|
||||
+20
-8
@@ -10,6 +10,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <regex>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
@@ -133,16 +134,27 @@ void mm_tn(const float* A, const float* B, float* C, int64_t m, int64_t k, int64
|
||||
void orth(float* Y, int64_t n, int64_t l) {
|
||||
std::vector<double> col((size_t)n);
|
||||
for (int64_t j = 0; j < l; ++j) {
|
||||
double original_norm2 = 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) {
|
||||
col[(size_t)r] = Y[r * l + j];
|
||||
original_norm2 += col[(size_t)r] * col[(size_t)r];
|
||||
}
|
||||
// Keep both projection passes in double scratch. Rounding each subtraction
|
||||
// to float can turn a dependent column's residue into a spurious basis vector.
|
||||
for (int pass = 0; pass < 2; ++pass)
|
||||
for (int64_t i = 0; i < j; ++i) {
|
||||
double d = 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) d += (double)Y[r * l + i] * Y[r * l + j];
|
||||
for (int64_t r = 0; r < n; ++r) Y[r * l + j] -= (float)(d * Y[r * l + i]);
|
||||
double dot = 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) dot += Y[r * l + i] * col[(size_t)r];
|
||||
for (int64_t r = 0; r < n; ++r) col[(size_t)r] -= dot * Y[r * l + i];
|
||||
}
|
||||
double nn = 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) nn += (double)Y[r * l + j] * Y[r * l + j];
|
||||
const double inv = nn > 1e-30 ? 1.0 / std::sqrt(nn) : 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) Y[r * l + j] = (float)(Y[r * l + j] * inv);
|
||||
double norm2 = 0.0;
|
||||
for (const double value : col) norm2 += value * value;
|
||||
// The tolerance follows the original column's scale and projection count,
|
||||
// rather than the number of zero rows used to pad the matrix.
|
||||
const double tolerance = std::numeric_limits<float>::epsilon() * std::max<int64_t>(1, j);
|
||||
const double inverse = norm2 > original_norm2 * tolerance * tolerance
|
||||
? 1.0 / std::sqrt(norm2) : 0.0;
|
||||
for (int64_t r = 0; r < n; ++r) Y[r * l + j] = (float)(col[(size_t)r] * inverse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +544,7 @@ void truncate(const Delta& d, int64_t r, std::vector<float>* B, std::vector<floa
|
||||
mm_tn(d.B.data(), Y, t.data(), d.r, N, l);
|
||||
mm_tn(d.A.data(), t.data(), X, K, d.r, l);
|
||||
};
|
||||
const int64_t l = std::min({ r + 8, N, K });
|
||||
const int64_t l = std::min({ r + 8, N, K, d.rank_bound > 0 ? d.rank_bound : r + 8 });
|
||||
/* A fixed sketch: the same adapter composes to the same bytes on every rank and every load. */
|
||||
std::vector<float> Om((size_t)(K * l));
|
||||
uint64_t st = 0x2545F4914F6CDD1Dull ^ (uint64_t)(N * 1315423911ull + K);
|
||||
|
||||
+22
-3
@@ -616,7 +616,13 @@ bool op_is_site(const Program& prog, const OpInfo& op, rad_weight* b_out, std::s
|
||||
return no(fmt("%s reads K=%lld against a weight of %lld columns (a widened, rotated "
|
||||
"input)", op.op.c_str(), k, (long long)w.decl.shape[1]));
|
||||
}
|
||||
if (w.enc_known && w.enc.transform[0])
|
||||
/* A quantised GEMM over a transformed weight is fed had_quant's rotated codes, so the adapter
|
||||
* epilogue would multiply A against a transformed activation. A plain fp GEMM (gemm_nt,
|
||||
* gemm_nt_bias) is fed what the architecture hands it: plain activations, with the kernel
|
||||
* library's layout/relayout hooks presenting the planes in the plain basis at load (a plain
|
||||
* kernel with no such hook is refused at declare by its own layout, RAD_E_DTYPE). A resolved
|
||||
* plain GEMM over a transformed encoding is therefore basis-safe for the adapter epilogue. */
|
||||
if ((gq || gqb) && w.enc_known && w.enc.transform[0])
|
||||
return no(fmt("weight '%s' is stored in the '%.*s' transform basis, so its GEMM is fed a "
|
||||
"transformed activation", w.name.c_str(), (int)RAD_ENC_STR, w.enc.transform));
|
||||
return true;
|
||||
@@ -631,6 +637,10 @@ int find_unsupported_uses(const Program& prog, const TargetSet& targets,
|
||||
for (size_t i = 1; i < prog.ops.size(); ++i) {
|
||||
const OpInfo& op = prog.ops[i];
|
||||
if (op.weights.empty() || !op_live(op)) continue;
|
||||
/* A prefetch only stages a weight's planes for the GEMMs that read them; the adapter's
|
||||
* delta is applied at the site's expand op, so staging the base planes stays correct.
|
||||
* A prefetch neither carries nor invalidates an adapter. */
|
||||
if (op.op == "prefetch") continue;
|
||||
rad_weight b = 0;
|
||||
std::string why;
|
||||
const bool site = op_is_site(prog, op, &b, &why);
|
||||
@@ -804,9 +814,18 @@ int load_adapter(const std::string& dir, const std::vector<Site>& sites, int max
|
||||
/* ---- the config */
|
||||
const std::string cfg_path = dir + "/adapter_config.json";
|
||||
std::string text;
|
||||
if (!read_file(cfg_path, &text))
|
||||
const int rst = read_text_file(cfg_path, text, kMaxContainerFile);
|
||||
if (rst == RAD_E_FORMAT)
|
||||
return fail(err, RAD_E_FORMAT,
|
||||
cfg_path + ": larger than the 256 MiB a container file may be");
|
||||
if (rst != RAD_OK)
|
||||
return fail(err, RAD_E_IO, cfg_path + ": cannot read (a PEFT adapter directory has one)");
|
||||
const ojson cfg = ojson::parse(text, nullptr, false);
|
||||
/* Container-supplied like the generation config, so read with the container's bounds: a
|
||||
* file past them is refused during the read, never grown into a tree to be walked. */
|
||||
bool over = false, deep = false;
|
||||
const ojson cfg = ojson::parse_container(text, &over, &deep);
|
||||
if (over || deep)
|
||||
return fail(err, RAD_E_FORMAT, cfg_path + ": " + ojson::bound_why(over, deep));
|
||||
if (cfg.is_discarded() || !cfg.is_object())
|
||||
return fail(err, RAD_E_FORMAT, cfg_path + ": not a JSON object");
|
||||
auto truthy = [&](const char* k) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "kvstream/carve.h"
|
||||
#include "kvstream/plan.h"
|
||||
#include "device/device.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -303,6 +304,21 @@ int KVManager::plan_groups(const std::vector<KVGroupInfo>& groups, const Config&
|
||||
if (p.runtime_win && !p.zero)
|
||||
fixed += align_up(max_seqs_ * p.ring_blocks_max() * p.bytes_per_block, RAD_ALIGN_UNIT);
|
||||
|
||||
/* The checkpoint stage (ckpt_stage): one snapshot of the linear state, where a lone spanned
|
||||
* prefill may take its tail snapshot inside its last chunk (--prefill-span above 1,
|
||||
* --prefill-tail-snapshot on), the engine snapshots into a prefix cache and the slot carries
|
||||
* no window. */
|
||||
stage_bytes_ = 0;
|
||||
{
|
||||
int64_t lin = 0;
|
||||
for (const auto& p : plans_) if (p.stateful() && !p.zero) lin += p.bytes_per_state;
|
||||
if (cfg.ckpt_stage && cfg.prefill_span > 1 && cfg.prefill_tail_snapshot &&
|
||||
cfg.prefix_cache && cfg.checkpoint_slots != 0 && window_ck_bytes_ == 0 && lin > 0 &&
|
||||
lin == checkpoint_bytes_)
|
||||
stage_bytes_ = lin;
|
||||
}
|
||||
if (stage_bytes_ > 0) fixed += align_up(stage_bytes_, RAD_ALIGN_UNIT);
|
||||
|
||||
fixed_ = fixed;
|
||||
ckpts_ = budget_ckpts;
|
||||
return RAD_OK;
|
||||
@@ -418,6 +434,8 @@ void KVManager::forget() {
|
||||
live_.clear(); free_usable_.clear(); bucket_blocks_.clear(); held_hist_.clear();
|
||||
chunk_blocks_.clear(); short_peak_.clear();
|
||||
pool_ = nullptr;
|
||||
stage_ = nullptr;
|
||||
stage_off_ = 0;
|
||||
clears_.clear();
|
||||
seqs_.clear(); pending_.clear();
|
||||
configured_ = false;
|
||||
@@ -589,6 +607,15 @@ int KVManager::carve_into(Pool& kv_pool) {
|
||||
p.pool_offset = off;
|
||||
p.pool_bytes = bytes;
|
||||
}
|
||||
/* The checkpoint stage, after the groups (its bytes are in fixed_). */
|
||||
if (stage_bytes_ > 0) {
|
||||
stage_ = kv_pool.reserve("checkpoint stage", stage_bytes_, RAD_ALIGN_UNIT, &stage_off_);
|
||||
if (!stage_) {
|
||||
RAD_ERR("the checkpoint stage (%s) did not fit the KV pool",
|
||||
humanb(stage_bytes_).c_str());
|
||||
return RAD_E_NOMEM;
|
||||
}
|
||||
}
|
||||
/* --checkpoint-slots does nothing on a model with no recurrent state; say so. */
|
||||
if (ckpts_ > 0 && checkpoint_bytes_ <= 0)
|
||||
RAD_WARN("--checkpoint-slots %lld ignored: this model declares no linear-attention state, "
|
||||
@@ -672,6 +699,10 @@ int KVManager::carve_into(Pool& kv_pool) {
|
||||
const int rc = lendable(p.index) ? 0 : pool_->commit(p.pool_offset, p.pool_bytes);
|
||||
if (rc < 0) return rc;
|
||||
}
|
||||
if (stage_) {
|
||||
const int rc = pool_->commit(stage_off_, stage_bytes_);
|
||||
if (rc < 0) return rc;
|
||||
}
|
||||
if (const int rc = flex_span(flex_floor_loan_, carved + 1, true); rc < 0) {
|
||||
RAD_ERR("KV pool: the card would not back the cache's floor of %s",
|
||||
humanb(flex_backed_).c_str());
|
||||
@@ -1817,6 +1848,50 @@ int KVManager::checkpoint_restore(const int32_t* slots, int n, int32_t ck, RadSt
|
||||
return checkpoint_copy(slots, n, ck, /*save=*/false, s, win);
|
||||
}
|
||||
|
||||
void KVManager::ckpt_stage_layout(std::vector<int64_t>* off, std::vector<int64_t>* lb) const {
|
||||
off->assign(plans_.size(), -1);
|
||||
lb->assign(plans_.size(), 0);
|
||||
int64_t at = 0;
|
||||
for (size_t g = 0; g < plans_.size(); ++g) {
|
||||
const KVGroupPlan& p = plans_[g];
|
||||
if (!p.stateful()) continue;
|
||||
(*off)[g] = at;
|
||||
(*lb)[g] = p.layer_bytes_per_state();
|
||||
at += p.layer_bytes_per_state() * p.n_layers;
|
||||
}
|
||||
}
|
||||
|
||||
int KVManager::checkpoint_stage_rest(const int32_t* slots, int n, RadStream s,
|
||||
const std::function<bool(size_t, int64_t)>& skip) {
|
||||
if (!stage_) return RAD_E_STATE;
|
||||
if (!slots || n < (int)plans_.size()) return RAD_E_INVAL;
|
||||
int64_t off = 0;
|
||||
for (size_t g = 0; g < plans_.size(); ++g) {
|
||||
const KVGroupPlan& p = plans_[g];
|
||||
if (!p.stateful()) continue;
|
||||
const int64_t nbytes = p.layer_bytes_per_state();
|
||||
for (int64_t l = 0; l < p.n_layers; ++l) {
|
||||
if (skip(g, l)) continue;
|
||||
void* st = slots[g] >= 0 ? state_ptr((int32_t)g, (int32_t)l, slots[g]) : nullptr;
|
||||
if (!st) return RAD_E_STATE;
|
||||
RAD_TRY(rad_memcpy_async((char*)stage_ + off + l * nbytes, st, nbytes, s));
|
||||
}
|
||||
off += nbytes * p.n_layers;
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
int KVManager::checkpoint_stage_out(int32_t ck, RadStream s) {
|
||||
if (!stage_) return RAD_E_STATE;
|
||||
if (!ck_store_ || !ck_store_->in_use(ck)) {
|
||||
RAD_ERR("checkpoint stage: the store does not hold slot %d", (int)ck);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
char* dst = (char*)checkpoint_ptr(ck);
|
||||
if (!dst) return RAD_E_INVAL;
|
||||
return rad_memcpy_async(dst, stage_, stage_bytes_, s);
|
||||
}
|
||||
|
||||
bool KVManager::window_rows(uint64_t id, int64_t pos, std::vector<int32_t>* out) const {
|
||||
out->clear();
|
||||
const Seq* s = find(id);
|
||||
|
||||
@@ -627,6 +627,32 @@ public:
|
||||
int checkpoint_restore(const int32_t* state_slots, int n_slots, int32_t ck_slot, RadStream s,
|
||||
const std::vector<int32_t>* win = nullptr);
|
||||
|
||||
/* ---------------- the checkpoint stage ----------------
|
||||
*
|
||||
* One snapshot of the linear state on the card, laid out as a checkpoint slot's linear section
|
||||
* (checkpoint_copy's walk: group by group in plans() order, a layer after another), carved
|
||||
* from the KV pool as a fixed cost. A checkpoint inside a step (RadBatch::ckpt_cut): the
|
||||
* plugin copies each layer's state there between the recurrence's two pieces (rad_ckpt_snap,
|
||||
* Ctx::set_ckpt_snap), since the live slot has moved on by the step's end; the engine then
|
||||
* copies the layers the step left alone in (checkpoint_stage_rest) and the stage to the host
|
||||
* slot in one copy (checkpoint_stage_out, Engine::save_checkpoints).
|
||||
*
|
||||
* Planned (plan_groups) where the engine snapshots linear state into a prefix cache and the
|
||||
* slot has no window section, under Config::ckpt_stage (the plugin cuts its step at a tail
|
||||
* snapshot and --prefix-resume is nearest); 0 bytes and a null stage otherwise, which keeps
|
||||
* every checkpoint at a chunk's end. */
|
||||
int64_t ckpt_stage_bytes() const { return stage_bytes_; }
|
||||
void* ckpt_stage() const { return stage_; }
|
||||
/* Per group (by index): the group's offset in the stage and its bytes a layer, -1 / 0 for a
|
||||
* group with no state. */
|
||||
void ckpt_stage_layout(std::vector<int64_t>* off, std::vector<int64_t>* lb) const;
|
||||
/* The live slots' state of every stateful (group, layer) `skip` does not name into the stage,
|
||||
* on `s`: the layers a step with a checkpoint inside it left alone. */
|
||||
int checkpoint_stage_rest(const int32_t* state_slots, int n_slots, RadStream s,
|
||||
const std::function<bool(size_t, int64_t)>& skip);
|
||||
/* The stage into checkpoint slot `ck`, as one copy on `s`. */
|
||||
int checkpoint_stage_out(int32_t ck, RadStream s);
|
||||
|
||||
/* ---------------- window snapshots (the sliding-window half of a prefix hit) ----------------
|
||||
* A WINDOW group keeps only the blocks its window can still read, so the prefix cache's block
|
||||
* lists do not describe it. A prompt extending a cached prefix at position P needs blocks
|
||||
@@ -720,6 +746,9 @@ private:
|
||||
int64_t ck_rank_off_ = 0;
|
||||
int64_t checkpoint_bytes_ = 0;
|
||||
int64_t window_ck_bytes_ = 0; /* the window section of checkpoint_bytes_ */
|
||||
int64_t stage_bytes_ = 0; /* ckpt_stage_bytes */
|
||||
void* stage_ = nullptr;
|
||||
int64_t stage_off_ = 0; /* in the pool */
|
||||
std::vector<StateClear> clears_; /* grabbed slots the engine must zero */
|
||||
void* pool_base_ = nullptr;
|
||||
BundleComparison bundling_;
|
||||
|
||||
@@ -51,8 +51,8 @@ static int resolve(Config& cfg, const std::vector<VramFacts>& per_rank, VramBudg
|
||||
b.arena = std::max(b.arena, f.arena);
|
||||
b.staging = std::max(b.staging, f.staging);
|
||||
b.prefetch = std::max(b.prefetch, f.prefetch);
|
||||
if ((int64_t)f.n_queues * f.queue_bytes > b.queues) {
|
||||
b.queues = (int64_t)f.n_queues * f.queue_bytes;
|
||||
if ((int64_t)f.n_queues * f.queue_bytes + f.queue_scratch > b.queues) {
|
||||
b.queues = (int64_t)f.n_queues * f.queue_bytes + f.queue_scratch;
|
||||
b.n_queues = f.n_queues;
|
||||
b.queue_bytes = f.queue_bytes;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ static int resolve(Config& cfg, const std::vector<VramFacts>& per_rank, VramBudg
|
||||
" --gpu-headroom-mib %10s\n"
|
||||
" activation arena %10s (buffer plan + kernel scratch)\n"
|
||||
" step staging %10s (block tables, media and KV tier staging)\n"
|
||||
" hardware queues %10s (%d at %s each, measured)\n"
|
||||
" hardware queues %10s (%d at %s each, measured, + resident queue scratch)\n"
|
||||
" expert prefetch %10s (its ring of expert units and buffers)\n"
|
||||
" ------------------------------\n"
|
||||
" short by %10s\n"
|
||||
@@ -461,7 +461,7 @@ void vram_budget_need(const std::vector<VramFacts>& per_rank, int64_t* need, int
|
||||
arena = std::max(arena, f.arena);
|
||||
staging = std::max(staging, f.staging);
|
||||
prefetch = std::max(prefetch, f.prefetch);
|
||||
queues = std::max(queues, (int64_t)f.n_queues * f.queue_bytes);
|
||||
queues = std::max(queues, (int64_t)f.n_queues * f.queue_bytes + f.queue_scratch);
|
||||
statics = std::max(statics, f.statics);
|
||||
floor = std::max(floor, f.expert_floor);
|
||||
kv_one = std::max(kv_one, f.kv_one);
|
||||
|
||||
@@ -65,6 +65,7 @@ struct VramFacts {
|
||||
* per queue on an R9700, 8x the ring). */
|
||||
int n_queues = 0;
|
||||
int64_t queue_bytes = 0;
|
||||
int64_t queue_scratch = 0; /* resident queue scratch (rad_dev_resident_scratch_bytes), once a card */
|
||||
/* The next-layer expert prefetch's ring and buffers (xprefetch.h), when enabled; its stream is
|
||||
* one of `n_queues`. */
|
||||
int64_t prefetch = 0;
|
||||
|
||||
@@ -1238,10 +1238,6 @@ void resize_lanczos_torch(const Frame& in, int32_t w, int32_t h, Frame* out) {
|
||||
resize_bicubic_impl(in, w, h, out, true, lanczos, 3.0);
|
||||
}
|
||||
|
||||
/* Python's round(): the nearest integer, a tie to the even one. The default floating-point
|
||||
* environment rounds that way, which nearbyint follows. */
|
||||
static inline int64_t py_round(double x) { return (int64_t)std::nearbyint(x); }
|
||||
|
||||
void radio_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp) {
|
||||
const int64_t div = c.merge, lo = c.radio_min_patches;
|
||||
const int64_t hi = c.radio_max_patches > 0 ? c.radio_max_patches : INT64_MAX;
|
||||
@@ -1249,8 +1245,8 @@ void radio_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_
|
||||
const int64_t avail = std::max<int64_t>(std::min<int64_t>(budget, hi), lo);
|
||||
/* round(x + 0.5): x + 1 rounded down for a fraction, and for a whole x, x or x + 1 by parity
|
||||
* (Python's tie to even), which the reference's comment does not say but its code does. */
|
||||
const int64_t ch = py_round((double)h / (double)c.patch + 0.5);
|
||||
const int64_t cw = py_round((double)w / (double)c.patch + 0.5);
|
||||
const int64_t ch = pyround((double)h / (double)c.patch + 0.5);
|
||||
const int64_t cw = pyround((double)w / (double)c.patch + 0.5);
|
||||
const double factor = std::min(std::sqrt((double)avail / (double)(ch * cw)), 1.0);
|
||||
int64_t th = (int64_t)std::floor(factor * (double)ch);
|
||||
int64_t tw = (int64_t)std::floor(factor * (double)cw);
|
||||
@@ -1270,8 +1266,8 @@ void radio_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_
|
||||
void radio_video_size(int64_t w, int64_t h, const VisionConfig& c, int32_t* wp, int32_t* hp) {
|
||||
const int64_t div = c.merge, target = c.radio_video_patches;
|
||||
const double aspect = (double)w / (double)std::max<int64_t>(h, 1);
|
||||
int64_t ph = std::max<int64_t>(py_round(std::sqrt((double)target / aspect)), 1);
|
||||
int64_t pw = std::max<int64_t>(py_round(std::sqrt((double)target * aspect)), 1);
|
||||
int64_t ph = std::max<int64_t>(pyround(std::sqrt((double)target / aspect)), 1);
|
||||
int64_t pw = std::max<int64_t>(pyround(std::sqrt((double)target * aspect)), 1);
|
||||
if (div > 1) {
|
||||
const int64_t rh = ph % div, rw = pw % div;
|
||||
const int64_t phu = ph + (rh ? div - rh : 0), pwu = pw + (rw ? div - rw : 0);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Remember backing an expert cache surrendered to another model. Idle restoration
|
||||
* reclaims only previously used capacity; the ordinary mover chooses the experts.
|
||||
* Owned by the engine step loop, including its quiescent recall/park callbacks. */
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
namespace rad {
|
||||
struct ExpertFlexRestore {
|
||||
void recalled(int64_t before, int64_t after) {
|
||||
if (after < before) previous_bytes_ = std::max(previous_bytes_, before);
|
||||
}
|
||||
// A changed ceiling cannot turn remembered capacity into an oversized request.
|
||||
int64_t limit(int64_t current, int64_t ceiling) {
|
||||
previous_bytes_ = std::min(previous_bytes_, std::max<int64_t>(ceiling, 0));
|
||||
if (current >= previous_bytes_) clear();
|
||||
return previous_bytes_;
|
||||
}
|
||||
bool ready(uint64_t now) const { return now >= retry_ns_; }
|
||||
// An idle cache may take free memory, but must not demand eviction of a peer.
|
||||
// Its backoff is separate so a new user request keeps the existing busy policy.
|
||||
int64_t refused(uint64_t now, bool idle_restore, int64_t remaining) {
|
||||
if (!idle_restore) return remaining;
|
||||
retry_ns_ = now + 1000000000ull;
|
||||
return 0;
|
||||
}
|
||||
void clear() { previous_bytes_ = 0; retry_ns_ = 0; }
|
||||
private:
|
||||
int64_t previous_bytes_ = 0;
|
||||
uint64_t retry_ns_ = 0;
|
||||
};
|
||||
} // namespace rad
|
||||
+37
-5
@@ -8,6 +8,7 @@
|
||||
#include "../device/device.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
@@ -174,6 +175,12 @@ int Mover::init(const Program& prog, const Plan& plan, const MoverConfig& cfg, P
|
||||
cp.n_work = shadow + sc.n_stage;
|
||||
cp.n_turn = std::min<int64_t>(std::max(cfg.turnover_slots, 0),
|
||||
shadow * RAD_PLACE_TURNOVER_SLOTS / RAD_PLACE_SHADOW_SLOTS);
|
||||
/* Under MoverConfig::turnover_adaptive the kept-free count starts at its floor: a fresh
|
||||
* placement fills what it can at once, and the first burst of swaps lands in the shadow
|
||||
* slots and these while balance() frees the rest. */
|
||||
cp.turn_now = cfg.turnover_adaptive
|
||||
? std::min<int64_t>(cp.n_turn, std::max(cfg.turnover_floor, 0))
|
||||
: cp.n_turn;
|
||||
total_turn += cp.n_turn;
|
||||
cp.slab.init(slab_slots, sc.stride);
|
||||
total_slab += slab_slots;
|
||||
@@ -379,9 +386,10 @@ int Mover::init(const Program& prog, const Plan& plan, const MoverConfig& cfg, P
|
||||
republish(u);
|
||||
}
|
||||
|
||||
RAD_INFO("mover: %lld slab slots (%lld shadow, %lld more kept free out of a loan), %lld pinned "
|
||||
"pool slots, %s static vram%s",
|
||||
(long long)total_slab, (long long)total_shadow, (long long)total_turn,
|
||||
RAD_INFO("mover: %lld slab slots (%lld shadow, %s%lld more kept free out of a loan%s), %lld "
|
||||
"pinned pool slots, %s static vram%s",
|
||||
(long long)total_slab, (long long)total_shadow, cfg.turnover_adaptive ? "up to " : "",
|
||||
(long long)total_turn, cfg.turnover_adaptive ? " as swaps ask for them" : "",
|
||||
(long long)total_pool,
|
||||
humanb(static_bytes_).c_str(), file_.ok() ? ", file tier open" : "");
|
||||
/* The pageable region is charged to no budget, so this is the only place it is reported. */
|
||||
@@ -1126,7 +1134,13 @@ int Mover::issue(const Swap& s, HeatEngine* heat) {
|
||||
|
||||
if (promote) {
|
||||
const int64_t slot = cp.slab.take();
|
||||
if (slot < 0) { ++stats_.starved_slab; return false; }
|
||||
if (slot < 0) {
|
||||
++stats_.starved_slab;
|
||||
/* The slots kept free were too few for this step's swaps: all of them, for a
|
||||
* while (balance). */
|
||||
if (cfg_.turnover_adaptive) turn_boost_ = kTurnBoost;
|
||||
return false;
|
||||
}
|
||||
if (promote_to(unit, slot) < 0) { cp.slab.add_free(slot); return false; }
|
||||
return true;
|
||||
}
|
||||
@@ -1625,7 +1639,19 @@ int Mover::balance(HeatEngine* heat, bool turnover) {
|
||||
if (unit_[(size_t)m.unit].klass != (int32_t)c || !cp.slab.covered(m.slab_slot)) continue;
|
||||
if (m.frees_slab()) ++pending;
|
||||
}
|
||||
const int64_t turn = turnover ? cp.n_turn : 0;
|
||||
if (cfg_.turnover_adaptive) {
|
||||
/* Three steps of the mean swaps a step (a swap holds its slot about three steps,
|
||||
* RAD_PLACE_TURNOVER_SLOTS), between the floor and the configured count; all of
|
||||
* them while a starved promotion is recent. The mean is over every class, so a
|
||||
* class keeps a little more than its own share asks for. */
|
||||
const int64_t floor_ = std::min<int64_t>(cp.n_turn, std::max(cfg_.turnover_floor, 0));
|
||||
const int64_t want = turn_boost_ > 0 ? cp.n_turn : std::min<int64_t>(
|
||||
cp.n_turn, std::max<int64_t>(floor_, (int64_t)std::lround(3.0f * demand_mean_)));
|
||||
cp.turn_now = want >= cp.turn_now ? want : std::max(want, cp.turn_now - kTurnShrink);
|
||||
} else {
|
||||
cp.turn_now = cp.n_turn;
|
||||
}
|
||||
const int64_t turn = turnover ? cp.turn_now : 0;
|
||||
int64_t short_by = cp.n_work + turn - (cp.slab.n_free() + pending);
|
||||
if (short_by > 0) {
|
||||
drop_cand_.clear();
|
||||
@@ -1683,6 +1709,12 @@ int Mover::balance(HeatEngine* heat, bool turnover) {
|
||||
return flush_moves();
|
||||
}
|
||||
|
||||
void Mover::swap_demand(int64_t proposed) {
|
||||
if (!cfg_.turnover_adaptive) return;
|
||||
demand_mean_ += ((float)std::max<int64_t>(proposed, 0) - demand_mean_) / kTurnMean;
|
||||
if (turn_boost_ > 0) --turn_boost_;
|
||||
}
|
||||
|
||||
int Mover::idle_tick(HeatEngine* heat) {
|
||||
if (!plan_ || !plan_->dynamic) return RAD_OK;
|
||||
RAD_TRY(retire(heat));
|
||||
|
||||
@@ -307,6 +307,23 @@ struct MoverConfig {
|
||||
* gets proportionally fewer, so a small loan is not left emptier than it is filled. */
|
||||
int turnover_slots = RAD_PLACE_TURNOVER_SLOTS;
|
||||
|
||||
/* Whether the turnover slots a class keeps free follow the swaps the engine lately asked for
|
||||
* (Mover::swap_demand) instead of always being all of them, and the fewest it keeps then.
|
||||
*
|
||||
* The count above is three steps of the full move budget, what a placement that changes
|
||||
* every step needs (the planner.h figures are for a rank with 40% of its experts on the
|
||||
* card). A rank that holds nearly all its experts swaps a few units a step once it has
|
||||
* warmed up, and the 160 free slots a class are then experts left in the pool for nothing:
|
||||
* Qwen3.8-Flash-Next at tp 2 keeps 640 slots a rank free (0.8 GiB) beside ~1000 units read
|
||||
* over the link. Following demand, a class keeps three steps of the swaps a step the engine
|
||||
* has lately proposed (a running mean, so one step's burst lands in the slots already free
|
||||
* and moves nothing), never fewer than `turnover_floor`; the rest is filled like any other
|
||||
* lent slot. A promotion that finds no free slot takes all of them back for a while, by
|
||||
* dropping the coldest lent units, an address change (balance). Off by default, so a caller
|
||||
* that sizes the turnover itself gets what it set. */
|
||||
bool turnover_adaptive = false;
|
||||
int turnover_floor = RAD_PLACE_SHADOW_SLOTS;
|
||||
|
||||
/* The container, for the file tier. Empty means no file tier; a unit planned there is then
|
||||
* an error. */
|
||||
std::string container_path;
|
||||
@@ -577,6 +594,17 @@ public:
|
||||
/* Whether idle ticks keep the turnover slots filled; the engine holds them through a prompt
|
||||
* and the few steps after it (Engine::tiering_dispatch). */
|
||||
void hold_turnover(bool held) { hold_turnover_ = held; }
|
||||
/* The swaps the heat engine proposed this step (all classes), once a step before they are
|
||||
* issued: what the kept-free turnover follows under MoverConfig::turnover_adaptive, as a
|
||||
* running mean over about kTurnMean steps. */
|
||||
void swap_demand(int64_t proposed);
|
||||
/* The turnover slots kept free now, summed over the slab classes: turnover_slots(), or under
|
||||
* MoverConfig::turnover_adaptive what the demand asks for. */
|
||||
int64_t turnover_now() const {
|
||||
int64_t n = 0;
|
||||
for (const ClassPools& cp : pools_) n += cp.turn_now;
|
||||
return n;
|
||||
}
|
||||
/* Each class's pinned pool as the card addresses it: [lo, hi) and the unit stride. At most `max`. */
|
||||
int pool_ranges(uint64_t* lo, uint64_t* hi, uint64_t* stride, int max) const {
|
||||
int n = 0;
|
||||
@@ -746,6 +774,8 @@ private:
|
||||
int64_t n_turn = 0; /* lent slots kept free past those: the fill stops short
|
||||
* of them and balance() drops lent units to rebuild them
|
||||
* (MoverConfig::turnover_slots) */
|
||||
int64_t turn_now = 0; /* of n_turn, the slots kept free now: all of them, or
|
||||
* what the recent swaps ask for (swap_demand) */
|
||||
int64_t n_donated = 0; /* units in lent slots that gave their host copy away
|
||||
* (Mover::donor_slot); at most n_turn of them */
|
||||
std::vector<char*> flex_ptr;
|
||||
@@ -803,6 +833,16 @@ private:
|
||||
/* balance()'s drop candidates, (heat, unit), kept between calls so a step allocates nothing. */
|
||||
std::vector<std::pair<float, int32_t>> drop_cand_;
|
||||
bool hold_turnover_ = false;
|
||||
/* The running mean of swaps proposed a step (swap_demand), and the steps left for which a
|
||||
* promotion that found no free slab slot keeps every turnover slot free. */
|
||||
float demand_mean_ = 0.0f;
|
||||
int64_t turn_boost_ = 0;
|
||||
static constexpr float kTurnMean = 64.0f;
|
||||
static constexpr int64_t kTurnBoost = 512;
|
||||
/* The most slots a class's kept-free count falls by in one balance(): each slot given up is
|
||||
* a unit copied in over the link, and all of them at once would be hundreds of copies behind
|
||||
* one step. Growing is immediate (drops cost nothing). */
|
||||
static constexpr int64_t kTurnShrink = 8;
|
||||
/* donor_slot()'s candidates per class, by layer, each layer sorted coldest first (hottest at
|
||||
* the back). Ranked once per dispatch; `at` is that dispatch. */
|
||||
struct DonorRank { int at = -1; std::vector<std::vector<std::pair<float, int32_t>>> by_layer; };
|
||||
|
||||
@@ -1146,7 +1146,7 @@ void Planner::pin_hot(const Config& cfg, Plan* p) const {
|
||||
const double keep = (double)cfg.expert_pin_top * (double)shares.size();
|
||||
const size_t hot = keep <= 0.0 ? 0 : std::min(shares.size(), (size_t)std::ceil(keep));
|
||||
const float threshold = hot == 0 ? shares.back() + 1.0f
|
||||
: shares[shares.size() - hot] - 1.0f;
|
||||
: (hot < shares.size() ? shares[shares.size() - hot - 1] : -1.0f);
|
||||
p->pin_threshold = threshold;
|
||||
p->profile_units = (int64_t)shares.size();
|
||||
int64_t pinned = 0, left = 0;
|
||||
|
||||
+70
-17
@@ -7,9 +7,11 @@
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <fcntl.h>
|
||||
#include <set>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -347,21 +349,40 @@ std::string xs_json(const XsSnapshot& s) {
|
||||
|
||||
int xs_write_atomic(const std::string& path, const std::string& text) {
|
||||
const std::string tmp = path + ".tmp." + std::to_string((long long)getpid());
|
||||
FILE* f = std::fopen(tmp.c_str(), "w");
|
||||
/* Created exclusively and never through a symbolic link: the name is predictable (the pid is
|
||||
* public), and opening it for writing in the ordinary way would follow a link another local
|
||||
* user placed there and truncate the file it names. The mode is the one fopen gives, less the
|
||||
* umask, so whoever could read the file before can read it after the rename. */
|
||||
int fd = ::open(tmp.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0666);
|
||||
if (fd < 0 && errno == EEXIST) {
|
||||
/* A crash can leave this name behind and a later process can have the same pid. The
|
||||
* name is removed, never written through, and the second create is exclusive as well:
|
||||
* it fails if the name could not be removed or was created again in between. */
|
||||
::unlink(tmp.c_str());
|
||||
fd = ::open(tmp.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0666);
|
||||
}
|
||||
if (fd < 0) {
|
||||
RAD_WARN("cannot create %s: %s", tmp.c_str(), std::strerror(errno));
|
||||
return RAD_E_IO;
|
||||
}
|
||||
FILE* f = ::fdopen(fd, "w");
|
||||
if (!f) {
|
||||
RAD_WARN("--expert-stats: cannot write %s: %s", tmp.c_str(), std::strerror(errno));
|
||||
const int err = errno;
|
||||
::close(fd);
|
||||
::unlink(tmp.c_str());
|
||||
RAD_WARN("cannot open %s: %s", tmp.c_str(), std::strerror(err));
|
||||
return RAD_E_IO;
|
||||
}
|
||||
const bool wrote = std::fwrite(text.data(), 1, text.size(), f) == text.size() &&
|
||||
std::fflush(f) == 0 && fsync(fileno(f)) == 0;
|
||||
const int err = errno;
|
||||
if (std::fclose(f) != 0 || !wrote) {
|
||||
RAD_WARN("--expert-stats: writing %s failed: %s", tmp.c_str(), std::strerror(wrote ? errno : err));
|
||||
RAD_WARN("writing %s failed: %s", tmp.c_str(), std::strerror(wrote ? errno : err));
|
||||
::unlink(tmp.c_str());
|
||||
return RAD_E_IO;
|
||||
}
|
||||
if (std::rename(tmp.c_str(), path.c_str()) != 0) {
|
||||
RAD_WARN("--expert-stats: %s -> %s: %s", tmp.c_str(), path.c_str(), std::strerror(errno));
|
||||
RAD_WARN("renaming %s to %s failed: %s", tmp.c_str(), path.c_str(), std::strerror(errno));
|
||||
::unlink(tmp.c_str());
|
||||
return RAD_E_IO;
|
||||
}
|
||||
@@ -492,17 +513,33 @@ int xs_profile_load(const std::string& path, std::vector<RadFileProfile>* out, i
|
||||
}
|
||||
std::string text;
|
||||
char buf[1 << 16];
|
||||
while (const size_t n = std::fread(buf, 1, sizeof buf, f)) text.append(buf, n);
|
||||
/* Capped while reading, so memory never grows with whatever file the path names. A profile
|
||||
* is a handful of integers per layer and expert even for the largest MoE; anything far past
|
||||
* that is not a profile. */
|
||||
static const size_t kMaxProfileBytes = 64u << 20;
|
||||
bool too_big = false;
|
||||
while (const size_t n = std::fread(buf, 1, sizeof buf, f)) {
|
||||
text.append(buf, n);
|
||||
if (text.size() > kMaxProfileBytes) { too_big = true; break; }
|
||||
}
|
||||
const bool bad = std::ferror(f) != 0;
|
||||
std::fclose(f);
|
||||
if (too_big) {
|
||||
RAD_ERR("--expert-profile: %s is past %zu MiB; an expert profile is a handful of "
|
||||
"integers per layer and expert, and this is not one",
|
||||
path.c_str(), (size_t)(kMaxProfileBytes >> 20));
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (bad) {
|
||||
RAD_ERR("--expert-profile: reading %s failed", path.c_str());
|
||||
return RAD_E_IO;
|
||||
}
|
||||
Json j;
|
||||
try { j = Json::parse(text); }
|
||||
catch (const Json::exception& e) {
|
||||
RAD_ERR("--expert-profile: %s is not JSON: %s", path.c_str(), e.what());
|
||||
/* A file like any other the container or a colleague supplies: bounded read, so a hostile
|
||||
* one is refused during the read instead of grown into a tree. */
|
||||
bool over = false, deep = false;
|
||||
Json j = Json::parse_container(text, &over, &deep);
|
||||
if (over || deep || j.is_discarded()) {
|
||||
RAD_ERR("--expert-profile: %s %s", path.c_str(), Json::bound_why(over, deep));
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (!j.is_object() || j.value("format", "") != "radiance-expert-stats/1" ||
|
||||
@@ -512,21 +549,37 @@ int xs_profile_load(const std::string& path, std::vector<RadFileProfile>* out, i
|
||||
path.c_str());
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (n_trunk && j.contains("n_trunk_layers") && j["n_trunk_layers"].is_number_integer())
|
||||
*n_trunk = j["n_trunk_layers"].get<int32_t>();
|
||||
if (n_trunk && j.contains("n_trunk_layers") && j["n_trunk_layers"].is_number_integer()) {
|
||||
/* int64, range-checked: read through int32, a value that wraps past 2^32 can land on
|
||||
* exactly the layer count the "this profile is another model" refusal compares
|
||||
* against -- the check the file would be escaping. */
|
||||
const int64_t t = j["n_trunk_layers"].get<int64_t>();
|
||||
if (t < 0 || t > INT32_MAX) {
|
||||
RAD_ERR("--expert-profile: %s carries n_trunk_layers %lld, outside 0..%d",
|
||||
path.c_str(), (long long)t, (int)INT32_MAX);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
*n_trunk = (int32_t)t;
|
||||
}
|
||||
const auto& rows = j["counts"]["decode"];
|
||||
int64_t kept = 0;
|
||||
for (size_t l = 0; l < rows.size(); ++l) {
|
||||
if (!rows[l].is_array()) continue;
|
||||
/* Counts are unsigned. The arithmetic read casts: a negative read as uint64_t wraps to
|
||||
* nearly 2^64, and a wrapped count reads as a share near 100%, steering the planner's
|
||||
* pinning at whatever the file's author named. The file is refused by name instead. */
|
||||
for (size_t e = 0; e < rows[l].size(); ++e)
|
||||
if (!rows[l][e].is_number_unsigned()) {
|
||||
RAD_ERR("--expert-profile: %s carries a negative or fractional count at decode "
|
||||
"layer %zu expert %zu; the format's counts are unsigned",
|
||||
path.c_str(), l, e);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
uint64_t sum = 0;
|
||||
for (const auto& c : rows[l])
|
||||
if (c.is_number_unsigned() || c.is_number_integer())
|
||||
sum += c.get<uint64_t>();
|
||||
for (const auto& c : rows[l]) sum += c.get<uint64_t>();
|
||||
if (sum == 0) continue;
|
||||
for (size_t e = 0; e < rows[l].size(); ++e) {
|
||||
const auto& c = rows[l][e];
|
||||
if (!(c.is_number_unsigned() || c.is_number_integer())) continue;
|
||||
const uint64_t n = c.get<uint64_t>();
|
||||
const uint64_t n = rows[l][e].get<uint64_t>();
|
||||
if (n == 0) continue;
|
||||
RadFileProfile p{};
|
||||
p.layer = (int32_t)l;
|
||||
|
||||
@@ -538,7 +538,9 @@ int Registry::commit_(Staged& s, int order) {
|
||||
row.collective = coll != 0;
|
||||
row.releases_link = coll == 2;
|
||||
row.reference = kern_ref ? kern_ref(sr.second) != 0 : p.reference;
|
||||
row.chain = chainable && chainable(sr.second) != 0;
|
||||
const int chains = chainable ? chainable(sr.second) : 0;
|
||||
row.chain = chains != 0;
|
||||
row.chain_fenced = chains == 2;
|
||||
set_->rows.push_back(row);
|
||||
}
|
||||
|
||||
|
||||
+111
@@ -64,6 +64,9 @@ struct KernelRow {
|
||||
bool reference = false;
|
||||
/* rad_kernel_chain: its launches can wait in the kernel instead of behind the barrier bit. */
|
||||
bool chain = false;
|
||||
/* rad_kernel_chain said 2: its chained forms' acquire covers their scalar loads too, so their
|
||||
* packets need no acquire from the packet processor. */
|
||||
bool chain_fenced = false;
|
||||
};
|
||||
|
||||
/* A kernel bound to one geometry, one domain and one variant, with init() already run. */
|
||||
@@ -740,6 +743,10 @@ struct Request {
|
||||
/* A tree drafter's parents for `draft` (StepEntry::draft_parent): draft[j]'s parent node,
|
||||
* 0 the bonus token. Null for a chain. The sampler reads each row's ancestors from it. */
|
||||
const int32_t* draft_parent = nullptr;
|
||||
/* The draft is a SuffixDecoding chain (--draft-suffix, sched/suffix.h): copied from the
|
||||
* sequence's own history, not drawn from the head's law. The coupled sampler binds no state to
|
||||
* its rows, whatever stale states the head's own draft for the same positions left. */
|
||||
bool draft_suffix = false;
|
||||
int32_t n_accepted = 0; /* from the previous verify */
|
||||
|
||||
/* Whether this request may be speculated on. Written by the engine after every step, read by
|
||||
@@ -852,6 +859,10 @@ struct Config {
|
||||
/* --mixed-step-target-ms: soft duration target for a mixed prefill/decode step. The scheduler
|
||||
* learns an aggregate prefill-row cap from completed mixed steps; 0 keeps the fixed policy. */
|
||||
int64_t mixed_step_target_ms = 0;
|
||||
/* --prefill-room-gate: a fresh prefill starts only when its whole prompt plus one decode
|
||||
* position fits beside every runner. Off (the default) admits the first chunk alone, which
|
||||
* can fill the pool and be preempted back to zero at the first decode step. */
|
||||
bool prefill_room_gate = false;
|
||||
/* --preempt-wait-ms: how long a preempted prefill may wait for the whole-recompute gate
|
||||
* before the scheduler evicts cache blocks and preempts a lower-priority running request to
|
||||
* make room for it. 0 = fall back on the next step; default 5000 ms. */
|
||||
@@ -943,6 +954,12 @@ struct Config {
|
||||
* default on. The graph is declared once, so this flag is the deployment's only decision about
|
||||
* whether the op exists at all; the value names the startup switch. */
|
||||
std::string control_vector = "disabled";
|
||||
/* --control-vector-variant NAME: a second name for this model, listed as MODEL:NAME the way an
|
||||
* adapter is, whose requests run with the vector on whatever the default; the model's own name
|
||||
* keeps the default. Empty -- the default -- lists nothing, so a deployment that does not pick
|
||||
* the vector by name sees no extra entry. A client that can only choose a model sends nothing
|
||||
* else, and a gateway can allow or refuse the name. Needs --control-vector off or on. */
|
||||
std::string control_vector_variant;
|
||||
int64_t checkpoint_interval = 2048; /* linear-state checkpoints (spec §7.3) */
|
||||
/* Checkpoint intervals one step may carry of a prefill alone in its step, from an interval
|
||||
* boundary past the first (--prefill-span; 1 splits at every interval). The step's rows stay
|
||||
@@ -952,6 +969,37 @@ struct Config {
|
||||
* inside a span are not written; those at its end and at a prompt's tail are, where a span of
|
||||
* 1 writes them. */
|
||||
int64_t prefill_span = 1;
|
||||
/* --prefill-span-pass piece|step. `step`: where the architecture runs a spanned step serially
|
||||
* (it pipelines none of it), its routed block takes the whole step in one pass instead of one
|
||||
* pass an interval (RadBuildCtx::span_pass_step), so the step sorts its slots once and each
|
||||
* expert's weight is read -- and a trellis expert decoded -- once for all its rows. The expert
|
||||
* planes are then a step tall (on Qwen3.8-Flash-Next at a 4096 budget 165 MiB more arena a
|
||||
* rank), and the output differs from piece passes at tie level, as a spanned step's at one or
|
||||
* two ranks already does. Off (piece): a routed pass a piece. */
|
||||
bool prefill_span_step = false;
|
||||
/* --prefill-span-min auto|N: the shortest prompt, in tokens, a lone prefill spans for
|
||||
* (Scheduler::set_span_min). -1 is auto, which Engine::serve resolves: eight intervals where
|
||||
* routed experts are staged from host memory (a spanned step runs at the full plan, which lends
|
||||
* the expert slab nothing), 0 elsewhere. 0 spans every lone prefill from its second interval
|
||||
* on. */
|
||||
int64_t prefill_span_min = -1;
|
||||
/* --prefill-tail-snapshot on|off: whether a prompt's last chunk is cut where the linear state
|
||||
* is snapshotted for the next turn under --prefix-resume nearest (Scheduler::plan_chunk): at
|
||||
* the last quantum boundary (Scheduler::tail_checkpoint), or, a spanned last chunk, at the last
|
||||
* interval boundary it crosses. The cut leaves the prompt's last few tokens (up to a quantum,
|
||||
* or a quarter interval) a step of their own, which on a routed model reads most of the
|
||||
* experts once more (some 60 ms a prompt on Flash-Next at two ranks). Off ends the last chunk
|
||||
* at the prompt's end: the next turn resumes from the deepest snapshot a chunk end left (the
|
||||
* last interval or span boundary) and recomputes up to an interval more. On (the default):
|
||||
* the tail snapshot at its own boundary. Output of a cold prompt differs only as another
|
||||
* chunking does. */
|
||||
bool prefill_tail_snapshot = true;
|
||||
/* --prefill-span-first on|off: whether a span may start at a prompt's first token (off, the
|
||||
* default: from its second interval on, Scheduler::plan_chunk). On, the first interval is no
|
||||
* step of its own: its rows read the indexer's selection where the dense pass served them,
|
||||
* the same keys below QSA's exactness bound summed in another order, and on routed models the
|
||||
* first interval's experts are read once with the span's rows. */
|
||||
bool prefill_span_first = false;
|
||||
/* Cap on linear-state (or sliding-window) snapshots held at once, for the whole server. The
|
||||
* slots are pinned host memory, all allocated at startup and never on the card (spec §7.3).
|
||||
* A slot is a sizeable fraction of a gigabyte on a linear-attention model, so raising the cap
|
||||
@@ -959,6 +1007,10 @@ struct Config {
|
||||
* store is opened (checkpoint_slots_auto in core/mem/prefix.h). */
|
||||
int64_t checkpoint_slots = -1;
|
||||
bool prefix_cache = true;
|
||||
/* Engine-internal, not a flag: plan a checkpoint stage on the card (KVManager::ckpt_stage).
|
||||
* The engine sets it at startup where the plugin can cut a step at a tail snapshot and
|
||||
* --prefix-resume is nearest; a KVManager planned without it (a test, a tool) carves none. */
|
||||
bool ckpt_stage = false;
|
||||
/* --prefix-resume exact|nearest.
|
||||
* - exact (the default): a prefix hit resumes only on the grid an idle server's cold prefill
|
||||
* chunks the same prompt on (ChunkGeometry::grid), and a prompt's tail snapshot is taken
|
||||
@@ -1029,6 +1081,65 @@ struct Config {
|
||||
* (RadBuildCtx::draft_coupling, abi/rad_spechub.h).
|
||||
* Off by default; on changes which tokens a fixed seed yields, not their law. */
|
||||
bool draft_coupling = false;
|
||||
/* --draft-verify token|block|traversal: how a coupled draft chain is verified. token (default):
|
||||
* each row's maximal coupling (above). block: Block Verification (arXiv 2403.10444,
|
||||
* abi/rad_mtp_block.h), the chain's drafts accepted jointly; the same output law, at least as
|
||||
* many accepted tokens. block switches --draft-coupling on (the drafting half is shared).
|
||||
* traversal: Traversal Verification (arXiv 2505.12398, abi/rad_mtp_traversal.h) walks the
|
||||
* chain from its last draft back to its first; the same output law, never fewer accepted
|
||||
* tokens than token-wise, and it needs --draft-coupling on. */
|
||||
bool draft_verify_block = false;
|
||||
bool draft_verify_traversal = false;
|
||||
/* --draft-depth fixed|adaptive (core/sched/draft_depth.h): adaptive stops a coupled serial
|
||||
* chain within the step as soon as the head's own laws make the next draft unlikely, so a step
|
||||
* drafts 1 .. draft_depth_max tokens (0: num-speculative-tokens) and its verify carries that
|
||||
* many rows. The chain goes on while the product of the rounds' statistic (stat 0: the largest
|
||||
* mass of each round's law, 1: the mass of the token it drew) stays >= draft_depth_stop; the
|
||||
* decision trails the chain by draft_depth_lag rounds (0 or 1; 1 hides the host's readback
|
||||
* behind a running round), draft_depth_min rounds always run. Switches --draft-coupling on
|
||||
* and needs a serial head's chain and --draft-window fixed. Lossless: the rule reads draft-side
|
||||
* quantities only. Off by default: the fixed chain. */
|
||||
bool draft_depth_adaptive = false;
|
||||
int draft_depth_max = 0;
|
||||
int draft_depth_min = 1;
|
||||
int draft_depth_lag = 1;
|
||||
int draft_depth_stat = 0;
|
||||
double draft_depth_stop = 0.85;
|
||||
/* --draft-depth-load on|off (core/sched/draft_depth.h): the load-aware depth rule. A step that
|
||||
* drafts for draft_depth_load_from sequences or more runs round j only for the rows whose
|
||||
* expected accepted drafts pay their verify rows, the kernel tile those rows open and the
|
||||
* round, at the throughput the engine has; and, with draft_depth_load_late, chooses each
|
||||
* row's verified prefix again when the next verify is issued, from the laws read by then.
|
||||
* draft_depth_load_min rounds always run. The tables (acceptance by confidence, tokens a
|
||||
* millisecond, a row's, a round's and a tile's milliseconds) start from built-in ones -- or
|
||||
* the comma lists below, by drafting rows 1 .. 8 (jumps: past 16, 32, 48, 64 verify rows) --
|
||||
* and with draft_depth_load_online follow the running server. Needs --draft-depth adaptive
|
||||
* with --draft-depth-stat top. A step with fewer sequences is the stop rule's, bit for bit.
|
||||
* Lossless: the rule reads draft-side laws of the step and tables fixed before it. */
|
||||
bool draft_depth_load = false;
|
||||
int draft_depth_load_from = 5;
|
||||
int draft_depth_load_min = 2;
|
||||
bool draft_depth_load_late = true;
|
||||
bool draft_depth_load_online = true;
|
||||
std::string draft_depth_load_tok_ms;
|
||||
std::string draft_depth_load_row_ms;
|
||||
std::string draft_depth_load_round_ms;
|
||||
std::string draft_depth_load_jump_ms;
|
||||
/* --draft-suffix on (core/sched/suffix.h): SuffixDecoding as a step SELECTOR on a serial head's
|
||||
* chain. On a host-built step, when the sequence's own history (prompt ++ output) ends in a
|
||||
* pattern of at least `draft_suffix_min_match` tokens that occurred before, the step verifies
|
||||
* that earlier occurrence's continuation (a chain of at most `draft_suffix_max` rows (7: the
|
||||
* delta-net fold's register window serves 8 query rows, so a Flash-Next verify window past 7
|
||||
* drafts leaves its kernels unsupported), cut where the path score falls under
|
||||
* `draft_suffix_min_score`) in place of the head's draft. Lossless: the proposal's rows are never
|
||||
* coupled. Off by default: every step is the head's. */
|
||||
bool draft_suffix = false;
|
||||
int draft_suffix_min_match = 6;
|
||||
int draft_suffix_max = 7;
|
||||
float draft_suffix_min_score = 0.3f;
|
||||
/* The head's own rounds when --draft-suffix raised `n_spec` (the verify window) past them; 0 =
|
||||
* `n_spec` (set by the engine, not a flag). */
|
||||
int n_spec_head = 0;
|
||||
|
||||
/* ---------------- KL DIVERGENCE AGAINST A REFERENCE (core/kld.h) ----------------
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -35,6 +36,25 @@ uint64_t log_last_line_ns();
|
||||
* Multi-byte UTF-8 is left alone; only control bytes are replaced. */
|
||||
std::string log_sanitize(const std::string& s);
|
||||
|
||||
/* The once-log idiom: true on the first call for this flag, false forever after -- a warning
|
||||
* that would otherwise repeat every step logs its first occurrence and stays quiet. Thread-safe
|
||||
* by compare_exchange, so exactly one thread wins. */
|
||||
inline bool log_once(std::atomic<bool>& flag) {
|
||||
bool expected = false;
|
||||
return flag.compare_exchange_strong(expected, true);
|
||||
}
|
||||
|
||||
/* The whole text of a file, refused before it is read when it is bigger than `cap`. Files a
|
||||
* container supplies are screened by size as well as by JSON budget: the bounded parse counts
|
||||
* values, not bytes, so without the size screen a multi-gigabyte tokenizer.json would be read
|
||||
* into memory whole before anything refused it. RAD_E_IO when unreadable, RAD_E_FORMAT when past
|
||||
* the cap; nothing is read then. */
|
||||
int read_text_file(const std::string& path, std::string& out, size_t cap);
|
||||
|
||||
/* What one container-supplied JSON file may be: past the largest real tokenizer.json by wide
|
||||
* margin, far below what turns a load into an OOM. Weight files are not read this way. */
|
||||
inline constexpr size_t kMaxContainerFile = 1u << 28; /* 256 MiB */
|
||||
|
||||
/* Rank tags on log lines. Per-rank components (pools, planner, mover, sampler) print the same
|
||||
* line once per rank, so under TP each line needs its rank. LogRank sets the tag as a scope
|
||||
* because the printers are several layers down, where threading a rank argument through every
|
||||
|
||||
@@ -998,8 +998,9 @@ int Ctx::lane_join(int from, int to) {
|
||||
* size here. The ABI-35 host mirrors are used by issue-time split selection; unsupported dynamic
|
||||
* geometries fail closed via the pass-key contract, while Qwen keys its full-group maximum in the
|
||||
* architecture callback. `agen_b`, `vgen_b` and `sgen_b` are set only on generator passes, which are
|
||||
* never recorded (below). */
|
||||
static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 480,
|
||||
* never recorded (below). `ckpt_cut` and `ckpt_cu`: a pass carrying them is never recorded.
|
||||
*/
|
||||
static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 496,
|
||||
"RadBatch changed: check that Ctx::pass_key reads every new field a pass depends on");
|
||||
static_assert(sizeof(void*) != 8 || sizeof(RadKVGroupBatch) == 88,
|
||||
"RadKVGroupBatch changed: check that Ctx::pass_key reads every new field");
|
||||
@@ -1026,6 +1027,9 @@ uint64_t Ctx::pass_key(const RadBatch* b) const {
|
||||
/* A generator pass is shaped by what RadBatch::gen_b, agen_b, vgen_b or sgen_b carries, which
|
||||
* no key below reads. */
|
||||
if (b->gen) return 0;
|
||||
/* A step with a checkpoint inside it copies from addresses the engine armed for it
|
||||
* (Ctx::set_ckpt_snap), which no recording could replay. */
|
||||
if (b->ckpt_cut > 0) return 0;
|
||||
uint64_t h = 0x9e3779b97f4a7c15ull;
|
||||
auto mix = [&](uint64_t v) {
|
||||
h ^= v + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2);
|
||||
|
||||
+53
-1
@@ -21,6 +21,7 @@
|
||||
#include "rank_barrier.h"
|
||||
#include "residency.h"
|
||||
#include "stager.h"
|
||||
#include "wtab.h"
|
||||
#include "device/device.h"
|
||||
|
||||
#include <atomic>
|
||||
@@ -289,6 +290,32 @@ public:
|
||||
return g < kv_.size() ? &kv_[(size_t)g] : nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- a checkpoint inside the step
|
||||
* (RadBatch::ckpt_cut, rad_ckpt_snap). The engine arms the rank before it releases such a
|
||||
* step: `stage` is this rank's checkpoint stage (KVManager::ckpt_stage), laid out as a
|
||||
* checkpoint slot; per KV group, the sequence's committed state slot (-1: not stateful), the
|
||||
* group's offset in the stage and its bytes a layer. Disarmed (stage null) for every other
|
||||
* step. */
|
||||
void set_ckpt_snap(void* stage, const std::vector<int32_t>& slot,
|
||||
const std::vector<int64_t>& off, const std::vector<int64_t>& lb) {
|
||||
snap_stage_ = stage;
|
||||
snap_slot_ = slot;
|
||||
snap_off_ = off;
|
||||
snap_lb_ = lb;
|
||||
snap_done_.resize(kv_.size());
|
||||
for (size_t g = 0; g < kv_.size(); ++g) snap_done_[g].assign(kv_[g].layer_slot.size(), 0);
|
||||
}
|
||||
int ckpt_snap(rad_kvgroup g, int layer);
|
||||
/* Whether the armed step snapshotted group `g`'s pool layer `li` (a group-local index, as the
|
||||
* stage lays it out); a layer the step left alone holds the snapshot's state at the step's end
|
||||
* and the engine copies it in (Engine::save_checkpoints). */
|
||||
bool ckpt_snapped(size_t g, int64_t li) const {
|
||||
if (g >= snap_done_.size()) return false;
|
||||
for (size_t i = 0; i < kv_[g].layer_slot.size(); ++i)
|
||||
if (kv_[g].layer_slot[i] == li && snap_done_[g][i]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- routing (spec §5.5) */
|
||||
int route_report(int layer, const RadRouting* r);
|
||||
/* Layer `layer`'s row of the card-side histogram, when it holds `n_expert` counts; null
|
||||
@@ -355,6 +382,9 @@ public:
|
||||
void dump_profile() const; /* spec §16, opt-in, with its caveat printed */
|
||||
const char* step_error() const { return step_fail_.c_str(); }
|
||||
int64_t stream_waits() const { return n_stream_waits_; }
|
||||
/* Weight-table patch dispatches issued so far (runtime/wtab.h): one for an op's tables where
|
||||
* their changed entries fit one block. Tests read it. */
|
||||
int64_t wtab_patches() const { return n_wtab_patches_; }
|
||||
/* Lane 1 has work lane 0 has not joined (lane1_pending_). */
|
||||
bool lane1_pending() const { return lane1_pending_; }
|
||||
/* Host synchronisations on the step path. Always zero unless per-op timing is on (spec §16);
|
||||
@@ -485,6 +515,22 @@ private:
|
||||
/* Brings the table's device array up to date on the current stream: every entry on the first
|
||||
* issue, afterwards the queued ones. */
|
||||
int table_refresh(rad_op h, int operand, WeightTable& t);
|
||||
/* The patches of one op's tables, gathered (runtime/wtab.h). A routed GEMM names four to eight
|
||||
* tables (a class of experts each, weights and scales), and in a pass the stager armed for
|
||||
* each of them changes a few entries at every issue; a dispatch a table put four ordered
|
||||
* launches in front of every routed GEMM of a prefill chunk (384 a chunk on Flash-Next at two
|
||||
* ranks, each a packet the card's processor takes in turn). While `wtab_gather_` is set
|
||||
* (issue_body, over its operands) table_refresh appends to `wtab_acc_` and dispatches only a
|
||||
* full block; wtab_flush dispatches the rest on the current stream before the op is launched.
|
||||
* The writes and their order against every reader are the same: they are behind the stream's
|
||||
* earlier work and in front of the op that reads the tables, whichever dispatch carries them,
|
||||
* and no two of them name one entry (an entry is patched once an issue).
|
||||
*
|
||||
* Not while recording: there a refresh is host work the tape names (kTapeTable) and replays
|
||||
* per table, and a gathered dispatch would land on the tape as a packet. */
|
||||
WtabPatch wtab_acc_;
|
||||
bool wtab_gather_ = false;
|
||||
int wtab_flush();
|
||||
/* ------------------------------------------------------------------ recorded passes
|
||||
*
|
||||
* A decode pass repeats step after step: same kernels, arguments and queues. The host work
|
||||
@@ -568,7 +614,7 @@ private:
|
||||
int rec1);
|
||||
int haz_mark(PassTape& t);
|
||||
|
||||
static constexpr size_t kTapes = 24; /* recorded passes kept, least recently used out */
|
||||
static constexpr size_t kTapes = 48; /* recorded passes kept, least recently used out */
|
||||
static constexpr int64_t kAuditPlays = 1024;
|
||||
|
||||
std::vector<PassTape> tapes_;
|
||||
@@ -671,6 +717,11 @@ private:
|
||||
Program* program_ = nullptr;
|
||||
Registry* registry_ = nullptr; /* CtxDesc::registry */
|
||||
std::vector<KVPoolBinding> kv_; /* by rad_kvgroup; RAD_OPK_KV resolves through it */
|
||||
/* set_ckpt_snap */
|
||||
void* snap_stage_ = nullptr;
|
||||
std::vector<int32_t> snap_slot_;
|
||||
std::vector<int64_t> snap_off_, snap_lb_;
|
||||
std::vector<std::vector<uint8_t>> snap_done_; /* [group][model layer] snapshotted */
|
||||
ResidencyTable* residency_ = nullptr;
|
||||
OpStager* stager_ = nullptr;
|
||||
bool staging_ = false; /* the stager armed for the pass being issued */
|
||||
@@ -849,6 +900,7 @@ private:
|
||||
|
||||
int64_t n_issues_ = 0;
|
||||
int64_t n_stream_waits_ = 0;
|
||||
int64_t n_wtab_patches_ = 0;
|
||||
int64_t n_host_syncs_ = 0;
|
||||
std::atomic<int64_t> ar_calls_{0}, ar_bytes_{0};
|
||||
std::atomic<int64_t> pc_played_{0}, pc_recorded_{0}, pc_audited_{0};
|
||||
|
||||
+83
-8
@@ -423,8 +423,10 @@ int Ctx::table_refresh(rad_op h, int operand, WeightTable& t) {
|
||||
t.checked = true;
|
||||
} else {
|
||||
/* Entries that may have moved: resolve each (which also orders the stream behind an
|
||||
* in-flight transfer) and patch only those whose pointer differs. */
|
||||
WtabPatch pt;
|
||||
* in-flight transfer) and patch only those whose pointer differs. Into the op's gather
|
||||
* when there is one (wtab_flush), else a dispatch of this table's own. */
|
||||
WtabPatch own;
|
||||
WtabPatch& pt = wtab_gather_ ? wtab_acc_ : own;
|
||||
auto one = [&](int64_t e) -> int {
|
||||
void* p = nullptr;
|
||||
RAD_TRY(resolve(e, &p));
|
||||
@@ -435,6 +437,7 @@ int Ctx::table_refresh(rad_op h, int operand, WeightTable& t) {
|
||||
pt.val[pt.n] = p;
|
||||
if (++pt.n == (uint32_t)kWtabPatch) {
|
||||
RAD_TRY(wtab_patch(pt, cur_stream()));
|
||||
++n_wtab_patches_;
|
||||
pt.n = 0;
|
||||
}
|
||||
return RAD_OK;
|
||||
@@ -444,10 +447,14 @@ int Ctx::table_refresh(rad_op h, int operand, WeightTable& t) {
|
||||
} else {
|
||||
for (int32_t e : t.pend) RAD_TRY(one(e));
|
||||
}
|
||||
const int rc = wtab_patch(pt, cur_stream());
|
||||
if (rc < 0)
|
||||
return abort_step_msg(h, rc,
|
||||
fmt("operand %d: the weight table could not be patched", operand));
|
||||
if (!wtab_gather_) {
|
||||
if (pt.n > 0) ++n_wtab_patches_;
|
||||
const int rc = wtab_patch(pt, cur_stream());
|
||||
if (rc < 0)
|
||||
return abort_step_msg(h, rc,
|
||||
fmt("operand %d: the weight table could not be patched",
|
||||
operand));
|
||||
}
|
||||
}
|
||||
t.full = false;
|
||||
t.pend.clear();
|
||||
@@ -459,6 +466,15 @@ int Ctx::table_refresh(rad_op h, int operand, WeightTable& t) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* Dispatches what the op's tables gathered (ctx.h, wtab_acc_) on the current stream. */
|
||||
int Ctx::wtab_flush() {
|
||||
if (wtab_acc_.n == 0) return RAD_OK;
|
||||
++n_wtab_patches_;
|
||||
const int rc = wtab_patch(wtab_acc_, cur_stream());
|
||||
wtab_acc_.n = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Queues the residency table's changes against every table holding each weight. A weight also
|
||||
* resolved directly into an operand bumps `dense_epoch_`. */
|
||||
void Ctx::sync_residency() {
|
||||
@@ -784,6 +800,10 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
|
||||
* never after it. Loop-invariant, so computed once here rather than per buffer operand. */
|
||||
const int32_t at_op = p.info && p.info->anchor >= 0 ? p.info->anchor : (int32_t)h;
|
||||
|
||||
/* The op's tables patch into one gather (ctx.h, wtab_acc_), dispatched below once every
|
||||
* operand is resolved; a refusal on the way dispatches what was gathered (abort_step_msg), so
|
||||
* the device arrays hold what `cur` says they do. */
|
||||
wtab_gather_ = rec_ == nullptr;
|
||||
for (int i = 0; i < n_opd; ++i) {
|
||||
const RadOperand& o = opd[i];
|
||||
RadTensor& tt = t[i];
|
||||
@@ -907,7 +927,11 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
|
||||
"a column slice; neither has a meaning for a table -- "
|
||||
"slice the entries at declare instead", i));
|
||||
const int rc = resolve_weight_table(h, i, (rad_weight)w0, cnt, &tt);
|
||||
if (rc < 0) return rc;
|
||||
if (rc < 0) {
|
||||
wtab_gather_ = false;
|
||||
(void)wtab_flush(); /* what the tables gathered still goes out (wtab_acc_) */
|
||||
return rc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -990,6 +1014,10 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
|
||||
}
|
||||
}
|
||||
|
||||
wtab_gather_ = false;
|
||||
if (const int ws = wtab_flush(); ws < 0)
|
||||
return abort_step_msg(h, ws, "the op's weight tables could not be patched");
|
||||
|
||||
/* The rest of RadArgs was filled in at prepare; args.t already points at tbuf_. There is one
|
||||
* entry per schema operand, the trailing optional ones the issue left out null. */
|
||||
ip.args.n_t = std::max(n_opd, (int)p.n_opd_schema);
|
||||
@@ -1265,7 +1293,12 @@ void Ctx::haz_note(const OpPlan& p, const IssuePlan& ip, const RadTensor* t, int
|
||||
o.rec1 = rec1;
|
||||
o.op = (uint32_t)(&p - plans_.data());
|
||||
const RadOpSchema* sc = p.info ? p.info->schema : nullptr;
|
||||
o.opaque = p.collective || !sc || sc->n_operands != n_opd || !ip.row || !ip.row->concurrent;
|
||||
/* The operand counts issue_body accepts: trailing optional operands may be left out, and an
|
||||
* absent one is a null tensor that reaches nothing (skipped below). Requiring the full schema
|
||||
* count here made every issue that omits one opaque, which orders it behind its neighbours in
|
||||
* a recorded pass (the routed MoE GEMMs without their prefill-only `split`, for example). */
|
||||
const bool count_ok = sc && n_opd <= sc->n_operands && n_opd >= p.n_opd_required;
|
||||
o.opaque = p.collective || !count_ok || !ip.row || !ip.row->concurrent;
|
||||
std::pair<uintptr_t, uintptr_t> rd[MAX_OPERANDS + 1], wr[MAX_OPERANDS + 1];
|
||||
int n_rd = 0, n_wr = 0;
|
||||
for (int i = 0; i < n_opd && !o.opaque; ++i) {
|
||||
@@ -1338,6 +1371,9 @@ int Ctx::host_join_wait(bool drain) {
|
||||
/* ================================================================== the cold paths */
|
||||
|
||||
int Ctx::abort_step(rad_op h, int band, int dom, const IssuePlan& ip, int64_t n, int status) {
|
||||
/* What the op's tables gathered before the refusal still goes out (ctx.h, wtab_acc_). */
|
||||
wtab_gather_ = false;
|
||||
(void)wtab_flush();
|
||||
const OpInfo& o = *plans_[h].info;
|
||||
const char* kname = ip.row && ip.row->info ? ip.row->info->name : "<unnamed>";
|
||||
const char* pname = ip.row ? ip.row->plugin.c_str() : "<unknown plugin>";
|
||||
@@ -1370,6 +1406,9 @@ int Ctx::step_fail(const char* what) {
|
||||
}
|
||||
|
||||
int Ctx::abort_step_msg(rad_op h, int status, std::string what) {
|
||||
/* What the op's tables gathered before the refusal still goes out (ctx.h, wtab_acc_). */
|
||||
wtab_gather_ = false;
|
||||
(void)wtab_flush();
|
||||
const OpInfo* o = (h != RAD_NULL_HANDLE && (size_t)h < plans_.size()) ? plans_[h].info : nullptr;
|
||||
step_fail_ = o ? fmt("op '%s' {%s}: %s", o->op.c_str(), o->base.str().c_str(), what.c_str())
|
||||
: fmt("op handle %u: %s", h, what.c_str());
|
||||
@@ -1432,6 +1471,42 @@ int64_t rad::Ctx::kv_layer_index(rad_kvgroup g, int layer) const {
|
||||
return ls[(size_t)layer];
|
||||
}
|
||||
|
||||
/* rad_ckpt_snap: one layer of a stateful group, the sequence's slot to the stage's row for that
|
||||
* layer, on the current lane. The stage is laid out as KVManager::checkpoint_copy lays a slot out
|
||||
* (group by group in plan order, a layer's state after another), so the engine moves it to the
|
||||
* host slot in one copy (Engine::save_checkpoints). */
|
||||
int rad::Ctx::ckpt_snap(rad_kvgroup g, int layer) {
|
||||
if (!snap_stage_ || !batch_ || batch_->ckpt_cut <= 0) return RAD_OK;
|
||||
if (g >= kv_.size() || g >= snap_slot_.size() || snap_slot_[g] < 0 || snap_off_[g] < 0 ||
|
||||
!kv_[g].base) {
|
||||
step_fail_ = fmt("rank %d: rad_ckpt_snap names KV group %u, which holds no state the "
|
||||
"checkpoint stage carries", rank_, (unsigned)g);
|
||||
step_status_ = RAD_E_STATE;
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
const KVPoolBinding& b = kv_[g];
|
||||
const int64_t li = kv_layer_index(g, layer);
|
||||
const int64_t lb = snap_lb_[g];
|
||||
if (li < 0 || lb <= 0) {
|
||||
step_fail_ = fmt("rank %d: rad_ckpt_snap: KV group %u holds no layer %d", rank_,
|
||||
(unsigned)g, layer);
|
||||
step_status_ = RAD_E_STATE;
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
const char* src = static_cast<const char*>(b.base) + kv_binding_offset(b, li) +
|
||||
(int64_t)snap_slot_[g] * lb;
|
||||
char* dst = static_cast<char*>(snap_stage_) + snap_off_[g] + li * lb;
|
||||
const int rc = rad_memcpy_async(dst, src, lb, cur_stream());
|
||||
if (rc < 0 && step_status_ >= 0) step_status_ = rc;
|
||||
if (rc >= 0 && g < snap_done_.size() && (size_t)layer < snap_done_[g].size())
|
||||
snap_done_[g][(size_t)layer] = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int rad_ckpt_snap(RadCtx* c, rad_kvgroup group, int layer) {
|
||||
return c ? static_cast<rad::Ctx*>(c)->ckpt_snap(group, layer) : RAD_E_INVAL;
|
||||
}
|
||||
|
||||
int rad_kv_layer_index(RadCtx* c, rad_kvgroup group, int layer) {
|
||||
return c ? (int)static_cast<rad::Ctx*>(c)->kv_layer_index(group, layer) : -1;
|
||||
}
|
||||
|
||||
+6
-2
@@ -14,8 +14,12 @@
|
||||
namespace rad {
|
||||
|
||||
/* One dispatch's worth of writes: dst[i] = val[i] for i < n. Sized so the argument block stays
|
||||
* inside the backend's per-dispatch argument slot with the implicit arguments beside it. */
|
||||
constexpr int kWtabPatch = 24;
|
||||
* inside the backend's per-dispatch argument slot with the implicit arguments beside it (648 of
|
||||
* the AQL backend's 768 bytes), and within the kernel's one 64-thread workgroup. A staged prefill
|
||||
* chunk patches every routed GEMM's tables, four to eight tables an op (Ctx::wtab_flush gathers
|
||||
* them): at 24 writes a Flash-Next chunk at two ranks took two dispatches a GEMM where 40 take
|
||||
* one. */
|
||||
constexpr int kWtabPatch = 40;
|
||||
|
||||
struct WtabPatch {
|
||||
uint32_t n = 0;
|
||||
|
||||
+19
-1
@@ -103,7 +103,25 @@ int grammar_from_json_schema(const std::string& schema_json, const std::string&
|
||||
}
|
||||
if (schema_cache().find(schema_json, out_gbnf)) return RAD_OK;
|
||||
try {
|
||||
const auto schema = Json::parse(schema_json);
|
||||
/* A bounded read: this entry point takes any text, whether or not its caller parsed
|
||||
* it under bounds before. The depth bound fires during the read, before a nested tree
|
||||
* exists to be dumped or destroyed, either of which recurses once per level. */
|
||||
bool over = false, deep = false;
|
||||
const auto schema = Json::parse_bounded(schema_json, 1 << 20, (int)kMaxSchemaDepth,
|
||||
&over, &deep);
|
||||
if (deep) {
|
||||
if (err) *err = "the schema nests more than " + std::to_string(kMaxSchemaDepth) +
|
||||
" levels deep";
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (over) {
|
||||
if (err) *err = "the schema carries more than 2^20 values";
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (schema.is_discarded()) {
|
||||
if (err) *err = "the schema is not valid JSON";
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (json_depth(schema) > kMaxSchemaDepth) {
|
||||
if (err) *err = "the schema nests more than " + std::to_string(kMaxSchemaDepth) +
|
||||
" levels deep";
|
||||
|
||||
+53
-6
@@ -164,6 +164,7 @@ int Sampler::declare(RadBuilder* b, const SamplerConfig& cfg) {
|
||||
|
||||
cfg_ = cfg;
|
||||
couple_ = cfg.draft_coupling;
|
||||
trav_ = cfg.draft_coupling && cfg.draft_verify_traversal;
|
||||
if (cfg_.n_vocab_local <= 0) cfg_.n_vocab_local = cfg_.n_vocab / cfg_.world_size;
|
||||
|
||||
/* The staged mask covers this rank's shard; the grammar's covers the whole vocabulary.
|
||||
@@ -223,6 +224,10 @@ int Sampler::declare(RadBuilder* b, const SamplerConfig& cfg) {
|
||||
buf_couple_ = decl("sampler.mtp_couple", RAD_U32, rows, RAD_MTP_COUPLE_STATE_WORDS,
|
||||
RAD_BUF_PERSIST);
|
||||
if (!buf_couple_) return RAD_E_NOMEM;
|
||||
if (trav_) {
|
||||
buf_trav_ = decl("sampler.mtp_trav", RAD_I32, rows, 2, RAD_BUF_PERSIST);
|
||||
if (!buf_trav_) return RAD_E_NOMEM;
|
||||
}
|
||||
}
|
||||
buf_cand_i_ = decl("sampler.cand_idx", RAD_I32, rows, ncand, RAD_BUF_TRANSIENT);
|
||||
buf_cand_v_ = decl("sampler.cand_val", RAD_F32, rows, ncand, RAD_BUF_TRANSIENT);
|
||||
@@ -304,8 +309,13 @@ int Sampler::declare(RadBuilder* b, const SamplerConfig& cfg) {
|
||||
RadParam{ "n_cand", RAD_P_INT, (long long)ncand, 0, nullptr },
|
||||
RadParam{ "n_vocab", RAD_P_INT, (long long)cfg_.n_vocab, 0, nullptr },
|
||||
};
|
||||
op_couple_ = rad_decl_op(b, "mtp_couple_verify", pc, 3, nullptr, 0);
|
||||
if (!op_couple_) return RAD_E_NOKERNEL;
|
||||
if (trav_) {
|
||||
op_trav_ = rad_decl_op(b, "mtp_trav_verify", pc, 3, nullptr, 0);
|
||||
if (!op_trav_) return RAD_E_NOKERNEL;
|
||||
} else {
|
||||
op_couple_ = rad_decl_op(b, "mtp_couple_verify", pc, 3, nullptr, 0);
|
||||
if (!op_couple_) return RAD_E_NOKERNEL;
|
||||
}
|
||||
/* No rad_op_reads: the other sampler ops declare no lists, and a list on this op alone
|
||||
* would narrow the candidate planes' lifetime to it and refuse the first sample_topk. */
|
||||
}
|
||||
@@ -391,6 +401,8 @@ int Sampler::stage_alloc() {
|
||||
if (couple_)
|
||||
couple_stage_ = (RadMtpCoupleState*)rad_dev_alloc(
|
||||
rows * (int64_t)sizeof(RadMtpCoupleState), RAD_MEM_HOST_PINNED);
|
||||
if (trav_)
|
||||
trav_stage_ = (int32_t*)rad_dev_alloc(rows * 2 * (int64_t)sizeof(int32_t), RAD_MEM_HOST_PINNED);
|
||||
|
||||
/* Logprobs readback; only rank 0 reads it. */
|
||||
if (cfg_.rank == 0) {
|
||||
@@ -407,7 +419,8 @@ int Sampler::stage_alloc() {
|
||||
}
|
||||
|
||||
if (!params_stage_ || !greedy_stage_ || !late_stage_ || !hist_stage_ || !brk_stage_ ||
|
||||
!ngram_stage_ || !ngram_wl_stage_ || !mask_stage_ || (couple_ && !couple_stage_)) {
|
||||
!ngram_stage_ || !ngram_wl_stage_ || !mask_stage_ || (couple_ && !couple_stage_) ||
|
||||
(trav_ && !trav_stage_)) {
|
||||
RAD_ERR("sampler: could not pin %s of staging",
|
||||
humanb(rows * (3 * (int64_t)sizeof(DeviceSampleParams) + cfg_.max_hist * 5 +
|
||||
mask_words_ * 8 + 8)).c_str());
|
||||
@@ -428,6 +441,8 @@ void Sampler::stage_free() {
|
||||
if (mask_stage_) rad_dev_free(mask_stage_, RAD_MEM_HOST_PINNED);
|
||||
if (couple_stage_) rad_dev_free(couple_stage_, RAD_MEM_HOST_PINNED);
|
||||
couple_stage_ = nullptr;
|
||||
if (trav_stage_) rad_dev_free(trav_stage_, RAD_MEM_HOST_PINNED);
|
||||
trav_stage_ = nullptr;
|
||||
if (lp_host_) rad_dev_free(lp_host_, RAD_MEM_HOST_PINNED);
|
||||
if (lp_ci_host_) rad_dev_free(lp_ci_host_, RAD_MEM_HOST_PINNED);
|
||||
if (lp_cv_host_) rad_dev_free(lp_cv_host_, RAD_MEM_HOST_PINNED);
|
||||
@@ -790,6 +805,11 @@ int Sampler::build_step(const std::vector<Request*>& reqs, int64_t step) {
|
||||
think = st->think;
|
||||
}
|
||||
const ReasoningCount think0 = think;
|
||||
/* --draft-verify block: the chain rows bound from round 1 on, consecutively, are one block
|
||||
* (abi/rad_mtp_block.h); each carries the block's length in `blk` so the verify's round-1
|
||||
* row decides them together. */
|
||||
int64_t blk_row0 = -1;
|
||||
int blk_len = 0;
|
||||
|
||||
for (int k = 0; k < n_pos; ++k) {
|
||||
/* Row k's drafts before it: 0..k-1 on a chain, its ancestors (root first) on a tree. */
|
||||
@@ -822,20 +842,40 @@ int Sampler::build_step(const std::vector<Request*>& reqs, int64_t step) {
|
||||
think.push(sp.reasoning, r->draft[k - 1]);
|
||||
}
|
||||
const int64_t row = n_seq_++;
|
||||
/* The traversal verify's tree: this row's parent row in the step (-1 for the
|
||||
* request's first row) and its own draft token. A chain's row k hangs off row k - 1. */
|
||||
if (trav_) {
|
||||
int32_t pk = -1;
|
||||
if (k > 0) {
|
||||
pk = k - 1;
|
||||
if (tpar) { const int32_t pj = tpar[k - 1]; if (pj >= 0 && pj < k) pk = pj; }
|
||||
}
|
||||
trav_stage_[2 * row] = pk < 0 ? -1 : (int32_t)(row - k + pk);
|
||||
trav_stage_[2 * row + 1] = k > 0 && r->draft ? r->draft[k - 1] : 0;
|
||||
}
|
||||
/* Row k verifies draft k against the state its round left. A row with no bound state
|
||||
* (the bonus row, a greedy row, an uncoupled step) gets a zeroed one, and the verify
|
||||
* leaves the pick's token alone. */
|
||||
if (couple_) {
|
||||
couple_stage_[row] = RadMtpCoupleState{};
|
||||
const auto sit = seqs_.find(r->id);
|
||||
if (sit != seqs_.end() && !sp.greedy() && r->draft && k + 1 < n_pos &&
|
||||
k < sit->second.couple_n) {
|
||||
/* A suffix chain (Request::draft_suffix) was not drawn from the head's law: no row of
|
||||
* it binds a state, so each is the target's plain draw. */
|
||||
if (sit != seqs_.end() && !sp.greedy() && r->draft && !r->draft_suffix &&
|
||||
k + 1 < n_pos && k < sit->second.couple_n) {
|
||||
const RadMtpCoupleState& c = sit->second.couple[k];
|
||||
/* Same request and seed, this row's round, position and proposed token
|
||||
* (rad_mtp_couple_binds); anything else is a stale state from another step. */
|
||||
if (rad_mtp_couple_binds(c, r->id, sp.seed, (uint64_t)n_out, k, r->draft[k],
|
||||
cfg_.n_vocab)) {
|
||||
couple_stage_[row] = c;
|
||||
if (cfg_.draft_verify_block && !tpar) {
|
||||
if (k == 0) { blk_row0 = row; blk_len = 0; }
|
||||
if (blk_row0 >= 0 && k == blk_len) {
|
||||
++blk_len;
|
||||
for (int64_t j = blk_row0; j <= row; ++j) couple_stage_[j].blk = blk_len;
|
||||
}
|
||||
}
|
||||
any_couple_ = true;
|
||||
++couple_build_.rows;
|
||||
auto& q = couple_build_.seqs;
|
||||
@@ -1219,6 +1259,9 @@ int Sampler::run(RadCtx* c, rad_buf logits, rad_buf out_tokens) {
|
||||
if (any_couple_)
|
||||
RAD_TRY(rad_memcpy_async(rad_buf_ptr(c, buf_couple_), couple_stage_,
|
||||
n_seq_ * (int64_t)sizeof(RadMtpCoupleState), s));
|
||||
if (any_couple_ && trav_)
|
||||
RAD_TRY(rad_memcpy_async(rad_buf_ptr(c, buf_trav_), trav_stage_,
|
||||
n_seq_ * 2 * (int64_t)sizeof(int32_t), s));
|
||||
|
||||
const RadOperand o_logits = opd_rows(logits, n_seq_);
|
||||
const RadOperand o_params = opd_rows(buf_params_, n_seq_);
|
||||
@@ -1317,7 +1360,11 @@ int Sampler::run(RadCtx* c, rad_buf logits, rad_buf out_tokens) {
|
||||
/* After the pick, over the same plane: a coupled row replaces the pick's token and an unbound
|
||||
* row keeps it. The issued step is recorded for the evidence line. */
|
||||
if (any_couple_) {
|
||||
RAD_TRY(issue(op_couple_, { o_ci, o_cv, o_params, opd_rows(buf_couple_, n_seq_), o_tok }));
|
||||
if (trav_)
|
||||
RAD_TRY(issue(op_trav_, { o_ci, o_cv, o_params, opd_rows(buf_couple_, n_seq_), o_tok,
|
||||
opd_rows(buf_trav_, n_seq_) }));
|
||||
else
|
||||
RAD_TRY(issue(op_couple_, { o_ci, o_cv, o_params, opd_rows(buf_couple_, n_seq_), o_tok }));
|
||||
couple_issued_step_ = couple_build_.step;
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -127,6 +127,12 @@ struct SamplerConfig {
|
||||
/* --draft-coupling: declare the coupled verify (`mtp_couple_verify`) behind the pick and the
|
||||
* per-row state plane it reads. */
|
||||
bool draft_coupling = false;
|
||||
/* --draft-verify block: the chain rows of a coupled request are verified as one block
|
||||
* (abi/rad_mtp_block.h) instead of one at a time. Needs draft_coupling. */
|
||||
bool draft_verify_block = false;
|
||||
/* --draft-verify traversal: `mtp_trav_verify` replaces the row-wise verify behind the pick
|
||||
* (needs draft_coupling) and a per-row topology plane rides with the state plane. */
|
||||
bool draft_verify_traversal = false;
|
||||
};
|
||||
|
||||
/* ================================================================== the driver */
|
||||
@@ -234,7 +240,7 @@ public:
|
||||
* verify op at all. Cleared by build_greedy: a gate for run(), not for evidence. */
|
||||
bool staged_any_couple() const { return any_couple_; }
|
||||
/* The verify op the last build resolved, for naming its kernel in a log line. */
|
||||
rad_op staged_couple_op() const { return op_couple_; }
|
||||
rad_op staged_couple_op() const { return trav_ ? op_trav_ : op_couple_; }
|
||||
|
||||
/* What build_step staged for the coupled verify. build_greedy, which runs between that build
|
||||
* and the step's wait, clears any_couple_ but leaves this snapshot. */
|
||||
@@ -303,6 +309,10 @@ private:
|
||||
rad_op op_allgather_ = RAD_NULL_HANDLE;
|
||||
rad_op op_merge_ = RAD_NULL_HANDLE; /* the candidate merge, under tensor parallel */
|
||||
rad_op op_couple_ = RAD_NULL_HANDLE; /* --draft-coupling only */
|
||||
rad_op op_trav_ = RAD_NULL_HANDLE; /* --draft-verify traversal: replaces op_couple_ */
|
||||
rad_buf buf_trav_ = RAD_NULL_HANDLE; /* [rows, 2] i32: parent row (-1 root), draft token */
|
||||
int32_t* trav_stage_ = nullptr; /* pinned, 2 words a sampled row */
|
||||
bool trav_ = false;
|
||||
rad_op op_logprobs_ = RAD_NULL_HANDLE; /* summary of the raw distribution */
|
||||
rad_op op_lp_gather_ = RAD_NULL_HANDLE; /* every rank's summary, under a split vocabulary */
|
||||
|
||||
|
||||
+69
-4
@@ -8,6 +8,7 @@
|
||||
#include "util/simd.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
@@ -117,6 +118,7 @@ void BatchBuilder::carve(Set& s, char* h) {
|
||||
pair(&s.h_acc, &s.d_acc, S);
|
||||
pair(&s.h_cktok, &s.d_cktok, S);
|
||||
pair(&s.h_ckslot, &s.d_ckslot, S);
|
||||
pair(&s.h_ckcu, &s.d_ckcu, 4);
|
||||
pair(&s.h_out, &s.d_out, O);
|
||||
pair(&s.h_dout, &s.d_dout, S);
|
||||
pair(&s.h_rows, &s.d_rows, 4 * S);
|
||||
@@ -213,13 +215,17 @@ int BatchBuilder::alloc_set(Set& s, const std::vector<KVGroupInfo>& groups) {
|
||||
}
|
||||
RAD_TRY(rad_dev_set(ranks_[0].device));
|
||||
|
||||
/* The ring holds three worst-case builds before a long-context prefill waits on an upload two
|
||||
* builds back. A decode build's span is far smaller, so hundreds fit. */
|
||||
/* The ring holds kRingBuilds worst-case builds. A speculative step takes four or more builds
|
||||
* (history pass, draft rounds, the next verify), and reserve() must not wait on an upload of
|
||||
* the step being issued (that would hold step_next back until the card ran this step's draft
|
||||
* uploads): two steps of builds fit with room over. A decode build's span is far smaller than
|
||||
* the worst case, so many more fit; this is pinned host memory only, the device slab stays
|
||||
* one build. */
|
||||
int64_t worst_pay = 0;
|
||||
for (const Group& g : s.groups) worst_pay += max_seqs_ * g.max_blocks * (int64_t)sizeof(int32_t);
|
||||
const int64_t worst_ranges = worst_pay / k_range_max + max_seqs_ * (int64_t)s.groups.size() + 1;
|
||||
ranges_.reserve((size_t)worst_ranges);
|
||||
ring_.bytes = 3 * (s.host_bytes + worst_ranges * (int64_t)sizeof(RadCopyRange) + k_carve_align);
|
||||
ring_.bytes = kRingBuilds * (s.host_bytes + worst_ranges * (int64_t)sizeof(RadCopyRange) + k_carve_align);
|
||||
ring_.host = static_cast<char*>(rad_dev_alloc(ring_.bytes, RAD_MEM_HOST_PINNED));
|
||||
if (!ring_.host) {
|
||||
RAD_ERR("step batch staging: could not reserve %s of pinned host staging",
|
||||
@@ -485,6 +491,10 @@ int BatchBuilder::layout(Program& prog, const Config& cfg) {
|
||||
|
||||
mm_on_ = prog.encoder.modalities != 0 || prog.audio_encoder.modalities != 0;
|
||||
bidi_on_ = prog.encoder.modalities != 0 && prog.encoder.bidirectional != 0;
|
||||
bidi_grp_ = -1;
|
||||
for (size_t i = 0; bidi_on_ && bidi_grp_ < 0 && i < prog.kv_groups.size(); ++i)
|
||||
if (prog.kv_groups[i].decl.kind == RAD_KV_WINDOW && !prog.kv_groups[i].drafter)
|
||||
bidi_grp_ = (int32_t)i;
|
||||
lora_on_ = cfg.lora.enabled();
|
||||
pw_cap_ = prog.plugin_words;
|
||||
return RAD_OK;
|
||||
@@ -969,6 +979,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
* band for separately issued decode rows. */
|
||||
int32_t max_q_dec = 0, max_q_pf = 0;
|
||||
int n_ck = 0;
|
||||
int32_t ck_cut = 0; /* RadBatch::ckpt_cut */
|
||||
int64_t n_out = 0, n_dout = 0;
|
||||
int32_t rope_mixed = 0;
|
||||
int64_t n_mm = 0;
|
||||
@@ -1067,17 +1078,59 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
* chunk's where a run longer than any step was cut (Scheduler::bidi_fit). */
|
||||
if (bidi_on_ && plan.draft_pass == 0 && shift == 0 && e.req && e.req->media) {
|
||||
const mm::PromptMedia& pm = *e.req->media;
|
||||
/* The run's rows are attended again on sliding layers, over the window group's block
|
||||
* table. That table starts at first_block_pos once the window has recycled the blocks
|
||||
* below it (trim_window after each chunk), and the group's seqused counts from there
|
||||
* (build_groups). bidi_used counts the same way, after the loop: the absolute end would
|
||||
* point the rows past the keys this pass wrote, so a picture after the first chunk was
|
||||
* read as nothing. A full group starts at 0, so without a window group the end stays
|
||||
* absolute. */
|
||||
const int64_t w0 = bidi_grp_ >= 0 ? kv.first_block_pos(e.seq, bidi_grp_) : 0;
|
||||
const int64_t n0 = n_bidi;
|
||||
const int64_t c0 = e.ctx_len, c1 = c0 + e.n_tokens, T = max_tok_;
|
||||
/* RopeLayout::runs is documented ascending and pairwise disjoint, and the slice
|
||||
* bound (h_bidi is 4*max_tok_ wide, one slot per token this step can carry) leans
|
||||
* on exactly that: overlapping runs would count one token twice. The layout comes
|
||||
* from request-side placement, so the promise is checked here rather than
|
||||
* trusted -- an overlapping run drops its media rows' bidirectionality, which the
|
||||
* acceptance path treats as an ordinary miss, where a slot overrun is a fault. */
|
||||
int64_t prev_b = c0;
|
||||
for (const mm::RopeLayout::Run& run : pm.rope.runs) {
|
||||
const int64_t a = std::max<int64_t>(run.tok, c0);
|
||||
const int64_t b = std::min<int64_t>((int64_t)run.tok + run.n, c1);
|
||||
if (a >= b || pm.items[(size_t)run.item].item->kind == mm::Kind::Audio) continue;
|
||||
if (a < prev_b) {
|
||||
static std::atomic<bool> said{false};
|
||||
if (log_once(said))
|
||||
RAD_WARN("step batch: a rope layout overlaps at token %lld; that run is "
|
||||
"not staged bidirectionally (first of possibly many)",
|
||||
(long long)a);
|
||||
continue;
|
||||
}
|
||||
prev_b = b;
|
||||
if (n_bidi >= T) {
|
||||
/* Belt: the disjoint check makes this unreachable; the slice says so
|
||||
* rather than letting an overrun reach the card. */
|
||||
static std::atomic<bool> said2{false};
|
||||
if (log_once(said2))
|
||||
RAD_WARN("step batch: bidi runs overflowed the %lld-token plane "
|
||||
"(first of possibly many)", (long long)T);
|
||||
break;
|
||||
}
|
||||
s.h_bidi[n_bidi] = (int32_t)b;
|
||||
s.h_bidi[T + n_bidi] = (int32_t)(k + a - c0);
|
||||
s.h_bidi[2 * T + n_bidi] = (int32_t)(b - a);
|
||||
s.h_bidi[3 * T + n_bidi] = (int32_t)i;
|
||||
++n_bidi;
|
||||
}
|
||||
for (int64_t q = n0; q < n_bidi; ++q) s.h_bidi[q] -= (int32_t)w0;
|
||||
}
|
||||
if (e.ckpt_tok >= 0 && e.ckpt_slot >= 0 && e.ckpt_tok + 1 < e.n_tokens &&
|
||||
plan.draft_pass == 0) {
|
||||
/* A checkpoint inside the chunk (RadBatch::ckpt_cut), where the step is the one shape
|
||||
* a plugin snapshots inside: one prefill alone (the scheduler plans a linear-state
|
||||
* one nowhere else). A window snapshot inside a chunk needs no cut. */
|
||||
if (ckpt_cut_on_ && n_seq == 1 && e.is_prefill) ck_cut = e.ckpt_tok + 1;
|
||||
}
|
||||
if (e.ckpt_tok >= 0 && e.ckpt_slot >= 0) {
|
||||
/* checkpoint_tok indexes this step's tokens: the sequence's base plus the offset the
|
||||
@@ -1132,7 +1185,12 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
s.h_q[i] = e.n_tokens;
|
||||
s.h_ctx[i] = e.ctx_len;
|
||||
s.h_acc[i] = e.n_accepted;
|
||||
s.h_arow[i] = -1;
|
||||
/* Row 0, not -1: the query pass gathers the context state by these values, and the
|
||||
* gather's index plane is validated in shape only -- a row that reaches the correlator
|
||||
* without having advanced would gather one row BEFORE the context buffer (device OOB).
|
||||
* Row 0 is always in range; a row that skipped its advance reads a wrong anchor, which
|
||||
* the acceptance path discards, instead of faulting or reading a neighbour's state. */
|
||||
s.h_arow[i] = 0;
|
||||
if (e.is_prefill) { if (e.n_tokens > max_q_pf) max_q_pf = e.n_tokens; }
|
||||
else { if (e.n_tokens > max_q_dec) max_q_dec = e.n_tokens; }
|
||||
}
|
||||
@@ -1141,6 +1199,11 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
(long long)n_tok, (long long)k);
|
||||
return nullptr;
|
||||
}
|
||||
/* The two pieces' bounds of a checkpoint inside the step. */
|
||||
s.h_ckcu[0] = 0;
|
||||
s.h_ckcu[1] = ck_cut;
|
||||
s.h_ckcu[2] = (int32_t)n_tok;
|
||||
s.h_ckcu[3] = 0;
|
||||
|
||||
/* Scored rows (Request::score): one per token of a scoring entry's prefill chunk, in entry
|
||||
* order (the order Engine::score_rows maps back). Appended after the sampled rows so the
|
||||
@@ -1323,6 +1386,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
B.n_checkpoints = n_ck;
|
||||
B.checkpoint_tok = n_ck ? on_rank(base, b0, s.d_cktok) : nullptr;
|
||||
B.checkpoint_slot = n_ck ? on_rank(base, b0, s.d_ckslot) : nullptr;
|
||||
B.ckpt_cut = ck_cut;
|
||||
B.ckpt_cu = ck_cut > 0 ? on_rank(base, b0, s.d_ckcu) : nullptr;
|
||||
B.n_ahead = n_ahead;
|
||||
}
|
||||
/* Record the flight behind everything reading this span: the upload and the derivation
|
||||
|
||||
@@ -62,6 +62,10 @@ struct StepEntry {
|
||||
* acceptance but not the adaptive window's estimate of the draft head (DraftController,
|
||||
* draft.h). */
|
||||
bool ngram = false;
|
||||
/* The drafts are a SuffixDecoding proposal (--draft-suffix, suffix.h): a chain of the
|
||||
* sequence's own history, verified with no coupled row (Request::draft_suffix). Implies
|
||||
* `ngram`. */
|
||||
bool suffix = false;
|
||||
/* Device row: the card overwrites its tokens, positions, rollback count and slots from the
|
||||
* StepSlot before the pass runs (advance.h); `ctx_len` is then only an upper bound for the
|
||||
* host-side ceilings. dev_tok/dev_out/dev_aux are advance.h's row descriptor: the verify
|
||||
@@ -135,6 +139,13 @@ public:
|
||||
|
||||
/* The last build's batch for one rank: build()'s result with that rank's slab pointers. */
|
||||
const RadBatch* batch_for(int rank) const;
|
||||
/* Program::plugin_words as declared: the most words one request may carry. Admission checks
|
||||
* it -- the build stage refuses an over-cap sequence, and a refused build restages forever,
|
||||
* so a request admitted past the cap stalls every queue behind it. */
|
||||
int64_t plugin_words_cap() const { return pw_cap_; }
|
||||
/* Whether a checkpoint inside a lone prefill's chunk is handed to the plugin as
|
||||
* RadBatch::ckpt_cut (Scheduler::set_ckpt_inside). Off: ckpt_cut is always 0. */
|
||||
void set_ckpt_cut(bool on) { ckpt_cut_on_ = on; }
|
||||
|
||||
/* The last build's slab and offsets on one rank, for the advance. The caller supplies mode,
|
||||
* round, slot state and inputs (advance.h). */
|
||||
@@ -203,6 +214,7 @@ private:
|
||||
int32_t *h_tok = nullptr, *h_pos = nullptr, *h_cu = nullptr, *h_sid = nullptr;
|
||||
int32_t *h_q = nullptr, *h_ctx = nullptr, *h_acc = nullptr, *h_parent = nullptr;
|
||||
int32_t *h_cktok = nullptr, *h_ckslot = nullptr;
|
||||
int32_t *h_ckcu = nullptr, *d_ckcu = nullptr; /* [3] RadBatch::ckpt_cu */
|
||||
int32_t *h_out = nullptr; /* [n_out] which of this step's tokens want logits */
|
||||
int32_t *h_dout = nullptr; /* [n_draft_out] a history pass's round-1 rows */
|
||||
int32_t *d_tok = nullptr, *d_pos = nullptr, *d_cu = nullptr, *d_sid = nullptr;
|
||||
@@ -255,6 +267,8 @@ private:
|
||||
int ev = -1; /* row of ev_ holding one event per rank */
|
||||
};
|
||||
static constexpr int kFlights = 64;
|
||||
/* Worst-case builds the staging ring holds (see alloc_set). Must stay below kFlights. */
|
||||
static constexpr int kRingBuilds = 16;
|
||||
struct Ring {
|
||||
char* host = nullptr;
|
||||
int64_t bytes = 0;
|
||||
@@ -353,8 +367,13 @@ private:
|
||||
* (`mm_ev_`). */
|
||||
bool mm_on_ = false;
|
||||
bool bidi_on_ = false; /* RadEncoderDecl::bidirectional */
|
||||
bool ckpt_cut_on_ = false; /* set_ckpt_cut */
|
||||
/* The engine serves runtime LoRA adapters (Config::lora): the batch carries each row's slot. */
|
||||
bool lora_on_ = false;
|
||||
/* The trunk's window group (RAD_KV_WINDOW, not a drafter's), -1 for none: a run read both ways
|
||||
* is attended on sliding layers, over this group's block table, so RadBatch::bidi_used counts
|
||||
* from that table's first position (build()). */
|
||||
int32_t bidi_grp_ = -1;
|
||||
/* Program::plugin_words: the words a sequence may carry, 0 for none. */
|
||||
int64_t pw_cap_ = 0;
|
||||
int64_t n_embd_ = 0;
|
||||
|
||||
@@ -128,14 +128,14 @@ double DraftController::yield(const DraftAdapt& s, int d) const {
|
||||
}
|
||||
|
||||
int DraftController::window_of(const DraftAdapt& s) const {
|
||||
if (!adapt_) return p_.max_depth;
|
||||
if (!adapt_) return next_depth();
|
||||
if (s.depth <= 0) return 0;
|
||||
const int D = step_d_ > 0 ? step_d_ : p_.max_depth;
|
||||
return s.depth < D ? s.depth : D;
|
||||
}
|
||||
|
||||
int DraftController::window_for(DraftAdapt& s) const {
|
||||
if (!adapt_) return p_.max_depth;
|
||||
if (!adapt_) return next_depth();
|
||||
if (s.depth <= 0) start(s);
|
||||
return window_of(s);
|
||||
}
|
||||
|
||||
+5
-2
@@ -60,6 +60,9 @@ class DraftController {
|
||||
public:
|
||||
struct Params {
|
||||
int max_depth = 0; /* the deployment's window; 0 disables speculation entirely */
|
||||
/* The head's own rounds when the window is wider than they are (--draft-suffix: a suffix
|
||||
* step verifies more rows than the head drafts); 0 = max_depth. */
|
||||
int head_depth = 0;
|
||||
/* The adaptive policy: `--draft-window adaptive` with a serial drafter, decided by
|
||||
* Scheduler::init. Off, the depth is max_depth. */
|
||||
bool adapt = false;
|
||||
@@ -114,7 +117,7 @@ public:
|
||||
|
||||
/* The draft depth for the next step; 0 means do not speculate. Constant: under the adaptive
|
||||
* policy it is the ceiling, and window_for() is the window. */
|
||||
int next_depth() const { return p_.max_depth; }
|
||||
int next_depth() const { return p_.head_depth > 0 ? p_.head_depth : p_.max_depth; }
|
||||
|
||||
/* ---------------------------------------------------------- the adaptive policy */
|
||||
bool adaptive() const { return adapt_; }
|
||||
@@ -146,7 +149,7 @@ public:
|
||||
/* The deepest window a step at depth D carries: D capped at the deepest stop it was chosen
|
||||
* over; the ceiling before the first choice or with the policy off. Proposals from outside
|
||||
* the head (prompt lookup) are held to it, so they add no deeper pass shape. */
|
||||
int step_window() const { return adapt_ && step_w_ > 0 ? step_w_ : p_.max_depth; }
|
||||
int step_window() const { return adapt_ && step_w_ > 0 ? step_w_ : next_depth(); }
|
||||
|
||||
/* T(R): a drafting decode step of `q_rows` query rows (every sequence's verified token and
|
||||
* its drafts) took `ms` since the end of the previous step, the head's rounds included. Fed
|
||||
|
||||
@@ -0,0 +1,606 @@
|
||||
/* draft_depth.h -- same-step adaptive depth of a coupled serial draft chain (--draft-depth adaptive).
|
||||
*
|
||||
* A fixed chain drafts N tokens every step and its verify pays for N + 1 rows whatever the head
|
||||
* thought of them. Here the chain of a step stops as soon as the head's own laws say the next draft
|
||||
* is unlikely to be accepted: round j (j >= 2) runs only while the chain's confidence stays at or
|
||||
* above the threshold,
|
||||
*
|
||||
* round j runs iff j <= max and ( j <= min or conf(j - 1 - lag) >= stop ),
|
||||
* conf(m) = prod_{i = 1..m} s_i, conf(m <= 0) = 1,
|
||||
*
|
||||
* where s_i is read from round i's coupled state (abi/rad_spechub.h): the largest mass of the law
|
||||
* Q_i the round drew from (`top`), or the mass of the token it drew (`path`, the probability of
|
||||
* the drafted path). The first round that does not run ends the chain; its depth D is the number
|
||||
* of rounds that ran, and the next verify carries D drafts (D + 1 rows).
|
||||
*
|
||||
* `lag` is how many rounds the decision trails the chain: with lag 0 round j is decided by every
|
||||
* round before it, so the card waits for the host between two rounds; with lag 1 round j is decided
|
||||
* when round j - 2 has finished, while round j - 1 runs, so the host's decision (a readback of one
|
||||
* state row, then the next round's or the next verify's issue) hides behind a running round.
|
||||
*
|
||||
* Why this keeps the verify exact. The decision "x_j is drafted" reads Q_1 .. Q_{j-1-lag} and, for
|
||||
* `path`, x_1 .. x_{j-1-lag}: draft-side quantities of the chain's ANCESTORS of x_j only, never a
|
||||
* target output and never x_j itself. For a row-wise verify any such stopping time is exact (each
|
||||
* verified position is exact on its own). For the traversal walk (abi/rad_mtp_traversal.h) the step
|
||||
* of its induction at a node v needs v's number of children to be independent of the tokens drawn
|
||||
* AT v; the shape of a child's subtree may depend on the child's own token, because the induction
|
||||
* hypothesis is applied per child value. Here node v (the prefix x_1 .. x_{j-1}) has a child iff
|
||||
* the rule above holds, a function of v's own path. A rule that read x_j's own mass to admit x_j
|
||||
* would not be exact (tests/mtp_rrs_test.cpp shows the statistic that catches it, and one that
|
||||
* peeks at the target).
|
||||
*
|
||||
* Several sequences in one step: the load-aware rule (DraftDepthCfg::load) and the late choice of
|
||||
* the verify's rows (DraftDepthCfg::late), with the tables they read and the online calibration
|
||||
* that keeps those tables (DraftDepthOnline), further down.
|
||||
*
|
||||
* Plain code, no engine types beyond the wire row: the engine's driver, the scheduler's tests and
|
||||
* the exactness test share it.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "rad_spechub.h"
|
||||
|
||||
namespace rad {
|
||||
|
||||
enum DraftDepthStat : int32_t {
|
||||
DRAFT_DEPTH_TOP = 0, /* s_i = max_x Q_i(x) */
|
||||
DRAFT_DEPTH_PATH = 1, /* s_i = Q_i(x_i), the drawn token's mass */
|
||||
};
|
||||
|
||||
struct DraftDepthCfg {
|
||||
bool on = false;
|
||||
int max = 0; /* the deepest chain: rounds 1 .. max (the head's declared depth caps it) */
|
||||
int min = 1; /* rounds that always run */
|
||||
int lag = 1; /* rounds the decision trails the chain, 0 or more */
|
||||
int stat = DRAFT_DEPTH_TOP;
|
||||
double stop = 0.85; /* the chain goes on while conf >= stop */
|
||||
int lawless = 3; /* the depth of a row with no law (a greedy request, a malformed round) */
|
||||
|
||||
/* ---- The load-aware rule (--draft-depth-load on), for a step that drafts for `load_from` or
|
||||
* more sequences (draft_depth_go_load, draft_depth_select below).
|
||||
*
|
||||
* `stop` was fitted for one sequence, where a draft's price is its verify row plus the head
|
||||
* round that makes it. With n drafting rows the prices part: the round is one pass for every
|
||||
* row, the verify row is each row's own, a row that takes the verify past a kernel's tile
|
||||
* (16, 32, 48 or 64 query rows) pays for the tile, and all of them are a different share of
|
||||
* the tokens the step makes. So the rule weighs expected accepted drafts against time:
|
||||
*
|
||||
* p_i(j) = cal[j](conf_i) the chance that row i's draft j is accepted
|
||||
* cost(R) = row_ms R + sum of jump_ms[k] over the tiles R is past (R > jump_at[k])
|
||||
* round j takes the m rows of largest p that maximise
|
||||
* sum of their p - lam (cost(R + m) - cost(R)) - lam round_ms (m > 0)
|
||||
*
|
||||
* with R the verify rows the step has so far and lam the tokens a millisecond the engine
|
||||
* makes at n sequences: a draft is made when it yields more than the same time does on
|
||||
* average. `cal` is the head's calibration, piecewise linear over the knots `cal_x`.
|
||||
*
|
||||
* Every number here starts from a table measured once (draft_depth_load_defaults) and, with
|
||||
* the online calibration (DraftDepthOnline below), follows the running server: the
|
||||
* acceptance by confidence from the verifies' own accepted counts, the rate and the prices
|
||||
* from the measured step times.
|
||||
*
|
||||
* A step with fewer drafting rows keeps the `stop` rule, so a single stream drafts exactly as
|
||||
* without this. Exactness is the stop rule's (above): whether x_j is drafted reads draft-side
|
||||
* quantities of x_j's ancestors, the same of the step's OTHER sequences (independent of this
|
||||
* sequence's draws) and numbers fixed before the step began -- the tables, which the online
|
||||
* calibration moves only between steps, from verifies and step times that are over. Those
|
||||
* are functions of draws at coordinates the step in hand never reads again (a draft stream is
|
||||
* keyed by the step's base position and its round, an acceptance by its verify position, and
|
||||
* each is consumed once), so given the past the rule is one with constants. Never x_j, never
|
||||
* a target output of the step. (Two requests served with one seed share those coordinates;
|
||||
* the same caveat as --draft-calib online.) */
|
||||
enum { kLoadSeqs = 8, kCalKnots = 8, kCalRounds = 8, kJumps = 4 };
|
||||
bool load = false;
|
||||
int load_from = 5; /* the fewest drafting rows of a load-aware step */
|
||||
int load_min = 2; /* rounds a load-aware step always runs and drafts it never cuts */
|
||||
double load_lam[kLoadSeqs + 1] = {}; /* by drafting rows n, [0] unused; n > kLoadSeqs takes the last */
|
||||
double load_row_ms[kLoadSeqs + 1] = {};
|
||||
double load_round_ms[kLoadSeqs + 1] = {};
|
||||
int load_jump_at[kJumps] = { 16, 32, 48, 64 }; /* a verify of more rows than this ... */
|
||||
double load_jump_ms[kLoadSeqs + 1][kJumps] = {}; /* ... costs this much more, once */
|
||||
double cal_x[kCalKnots] = {}; /* ascending conf knots */
|
||||
/* cal_p[t][j][k]: draft j's acceptance at conf(j - 2 + t) = cal_x[k]: the confidence the rule
|
||||
* reads one round behind (t 0), the last one before the draft (t 1), and the one that
|
||||
* includes the draft's own law (t 2, the late choice). */
|
||||
double cal_p[3][kCalRounds + 1][kCalKnots] = {};
|
||||
|
||||
/* The late choice of the verify's rows (draft_depth_select). A round is one head pass over
|
||||
* the drafting rows, so once a round ran for a row the row holds its draft, and by the time
|
||||
* the next verify is issued the host has read more of the chain's laws than the rule had when
|
||||
* it decided the round: the statistics of every round but the last `late_lag`. `late` chooses
|
||||
* each row's verified prefix again from those, level by level: draft j of the rows still in
|
||||
* at j - 1, by p_i(j) = cal(conf_i(min(j, known))), the best prefix under the same cost model
|
||||
* (no round's price: the rounds have run).
|
||||
*
|
||||
* Exact for the same reason as the rule: draft j is verified by a function of the laws
|
||||
* Q_1 .. Q_j of its own chain -- Q_j is the law AT its parent, a function of the parent's path
|
||||
* and not of x_j -- and of the other sequences' laws up to their round j. Never of a round
|
||||
* past j: Q_{j+1} is conditioned on x_j, and a choice that read it would pick x_j by what
|
||||
* followed it. Only the `top` statistic may be read this way (the drawn token's own mass at
|
||||
* round j is x_j's). */
|
||||
bool late = false;
|
||||
int late_lag = 1; /* rounds the choice does not wait for: 1 = it is made while the last round runs */
|
||||
};
|
||||
|
||||
/* One drafting row's chain while its step is drafted. */
|
||||
struct DraftDepthRow {
|
||||
double conf = 1.0; /* conf(seen) */
|
||||
int seen = 0; /* rounds whose state went into conf */
|
||||
int depth = 1; /* rounds decided to run so far (round 1 always does) */
|
||||
bool done = false; /* a round was refused: depth is final */
|
||||
bool lawless = false; /* no law: the fixed fallback depth */
|
||||
float s[8] = {}; /* each observed round's statistic (RAD_MTP_COUPLE_MAX_ROUNDS) */
|
||||
int rule = 1; /* the round the load-aware rule sent the chain to (the late choice may cut it) */
|
||||
};
|
||||
|
||||
/* Round `round`'s statistic from its state, or a negative number when the state carries no law
|
||||
* (status != 1: a greedy row or a shortlist the proposer could not turn into Q). */
|
||||
inline double draft_depth_stat(const RadMtpCoupleState& s, int round, int stat) {
|
||||
if (s.status != 1 || s.round != round || s.count < 1 || s.count > 8) return -1.0;
|
||||
double top = 0.0, own = -1.0;
|
||||
for (int i = 0; i < s.count; ++i) {
|
||||
const double q = s.q[i];
|
||||
if (!(q > 0.0) || q > 1.0) return -1.0;
|
||||
if (q > top) top = q;
|
||||
if (s.ids[i] == s.x) own = q;
|
||||
}
|
||||
return stat == DRAFT_DEPTH_PATH ? own : top;
|
||||
}
|
||||
|
||||
/* The round whose statistic decides round `j` (>= 2); <= 0 when nothing does (conf = 1). */
|
||||
inline int draft_depth_need(const DraftDepthCfg& c, int j) { return j - 1 - (c.lag > 0 ? c.lag : 0); }
|
||||
|
||||
/* The start of a step's chain for one row. `lawless`: the row draws nothing (a greedy request). */
|
||||
inline void draft_depth_begin(const DraftDepthCfg& c, DraftDepthRow* r, bool lawless) {
|
||||
*r = DraftDepthRow{};
|
||||
r->lawless = lawless;
|
||||
(void)c;
|
||||
}
|
||||
|
||||
/* Feed round `round`'s statistic (rounds in order, each once). A negative one makes the row lawless. */
|
||||
inline void draft_depth_observe(DraftDepthRow* r, int round, double s) {
|
||||
if (round != r->seen + 1) return;
|
||||
r->seen = round;
|
||||
if (s < 0.0) { r->lawless = true; return; }
|
||||
r->conf *= s;
|
||||
if (round >= 1 && round <= 8) r->s[round - 1] = (float)s;
|
||||
}
|
||||
|
||||
/* Whether round `j` (>= 2) runs for this row, given every statistic up to round
|
||||
* draft_depth_need(c, j) was observed. Rounds are asked in order; once one is refused the chain has
|
||||
* ended. Records the answer in r->depth / r->done. */
|
||||
inline bool draft_depth_go(const DraftDepthCfg& c, DraftDepthRow* r, int j) {
|
||||
if (r->done || j != r->depth + 1) return false;
|
||||
bool go;
|
||||
if (j > c.max) go = false;
|
||||
else if (r->lawless) go = j <= (c.lawless > 0 ? c.lawless : 1);
|
||||
else if (j <= c.min) go = true;
|
||||
else {
|
||||
/* conf(need): the row has seen exactly `need` rounds when asked in order with lag >= 0, or
|
||||
* more when the caller observed ahead; recompute is not possible, so the caller observes
|
||||
* no further than draft_depth_need before asking (the driver does). */
|
||||
go = r->conf >= c.stop;
|
||||
}
|
||||
if (go) r->depth = j; else r->done = true;
|
||||
return go;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ the load-aware rule */
|
||||
|
||||
/* conf(m) of a row whose first `m` rounds were observed. */
|
||||
inline double draft_depth_conf(const DraftDepthRow& r, int m) {
|
||||
double c = 1.0;
|
||||
for (int i = 0; i < m && i < 8 && i < r.seen; ++i) c *= (double)r.s[i];
|
||||
return c;
|
||||
}
|
||||
|
||||
/* The knots a calibration table has: cal_x ascends as far as it goes. */
|
||||
inline int draft_depth_knots(const DraftDepthCfg& c) {
|
||||
int K = 1;
|
||||
while (K < DraftDepthCfg::kCalKnots && c.cal_x[K] > c.cal_x[K - 1]) ++K;
|
||||
return K;
|
||||
}
|
||||
|
||||
/* `conf` between two knots: the lower one's index and the upper one's share, for a table's
|
||||
* interpolation and for the online counts alike. */
|
||||
inline void draft_depth_knot_at(const DraftDepthCfg& c, double conf, int* k0, double* w1) {
|
||||
const int K = draft_depth_knots(c);
|
||||
const double* x = c.cal_x;
|
||||
if (!(conf > x[0])) { *k0 = 0; *w1 = 0.0; return; }
|
||||
for (int k = 1; k < K; ++k)
|
||||
if (conf <= x[k]) { *k0 = k - 1; *w1 = (conf - x[k - 1]) / (x[k] - x[k - 1]); return; }
|
||||
*k0 = K - 1; *w1 = 0.0;
|
||||
}
|
||||
|
||||
/* cal[j](conf): the chance that draft j is accepted, from the confidence the decision reads:
|
||||
* table t is by conf(j - 2 + t) (DraftDepthCfg::cal_p). */
|
||||
inline double draft_depth_cal(const DraftDepthCfg& c, int j, double conf, int t = 0) {
|
||||
if (j < 0) j = 0;
|
||||
if (j > DraftDepthCfg::kCalRounds) j = DraftDepthCfg::kCalRounds;
|
||||
if (t < 0) t = 0;
|
||||
if (t > 2) t = 2;
|
||||
int k0; double w1;
|
||||
draft_depth_knot_at(c, conf, &k0, &w1);
|
||||
const double* p = c.cal_p[t][j];
|
||||
return w1 > 0.0 ? p[k0] + (p[k0 + 1] - p[k0]) * w1 : p[k0];
|
||||
}
|
||||
|
||||
inline int draft_depth_seqs(int n) {
|
||||
return n < 1 ? 1 : (n > DraftDepthCfg::kLoadSeqs ? (int)DraftDepthCfg::kLoadSeqs : n);
|
||||
}
|
||||
|
||||
/* What a verify of R query rows costs under the load-aware rule's model, in milliseconds past a
|
||||
* constant. */
|
||||
inline double draft_depth_load_cost(const DraftDepthCfg& c, int n, int R) {
|
||||
const int nn = draft_depth_seqs(n);
|
||||
if (R < 0) R = 0;
|
||||
double ms = c.load_row_ms[nn] * (double)R;
|
||||
for (int k = 0; k < DraftDepthCfg::kJumps; ++k)
|
||||
if (R > c.load_jump_at[k]) ms += c.load_jump_ms[nn][k];
|
||||
return ms;
|
||||
}
|
||||
|
||||
/* Round `j` (>= 2) for the `n` drafting rows of one step under the load-aware rule; every
|
||||
* statistic up to round draft_depth_need(c, j) was observed. `other_rows` are the verify rows the
|
||||
* next step carries beside these rows' (sequences that do not draft). Rows whose chain ended stay
|
||||
* ended. Returns whether the round runs, with each row's answer in depth / done as draft_depth_go
|
||||
* leaves them (and in `rule`, which the late choice does not move). A row with no law, and the
|
||||
* rounds that always run, keep the stop rule's answers and make the round run. */
|
||||
inline bool draft_depth_go_load(const DraftDepthCfg& c, DraftDepthRow* r, int n, int j, int other_rows = 0) {
|
||||
const int nn = draft_depth_seqs(n);
|
||||
const double lam = c.load_lam[nn];
|
||||
const int lmin = c.min > c.load_min ? c.min : c.load_min;
|
||||
enum { kMaxRows = 64 };
|
||||
int cand[kMaxRows], n_cand = 0;
|
||||
double p[kMaxRows];
|
||||
bool want[kMaxRows];
|
||||
int R = other_rows < 0 ? 0 : other_rows, forced = 0;
|
||||
for (int i = 0; i < n && i < kMaxRows; ++i) {
|
||||
want[i] = false;
|
||||
R += 1 + (r[i].depth < 1 ? 1 : r[i].depth);
|
||||
if (r[i].done || j != r[i].depth + 1 || j > c.max) continue;
|
||||
if (r[i].lawless) want[i] = j <= (c.lawless > 0 ? c.lawless : 1);
|
||||
/* A round the rule has read nothing for (round 2, decided one round behind) runs as under
|
||||
* the stop rule: with no law to weigh, the prices alone would turn all drafting on or off
|
||||
* for the whole step, and a calibration that is a little off must not be able to do that. */
|
||||
else if (j <= lmin || draft_depth_need(c, j) <= 0) want[i] = true;
|
||||
else { p[i] = draft_depth_cal(c, j, r[i].conf, c.lag > 0 ? 0 : 1); cand[n_cand++] = i; }
|
||||
forced += want[i];
|
||||
}
|
||||
/* the candidates by falling p (stable: the earlier row first), then the best prefix */
|
||||
for (int a = 1; a < n_cand; ++a) {
|
||||
const int x = cand[a];
|
||||
int b = a;
|
||||
for (; b > 0 && p[cand[b - 1]] < p[x]; --b) cand[b] = cand[b - 1];
|
||||
cand[b] = x;
|
||||
}
|
||||
const double base = draft_depth_load_cost(c, n, R + forced);
|
||||
double sum = 0.0, best = 0.0;
|
||||
int take = 0;
|
||||
for (int m = 1; m <= n_cand; ++m) {
|
||||
sum += p[cand[m - 1]];
|
||||
const double v = sum - lam * (draft_depth_load_cost(c, n, R + forced + m) - base) -
|
||||
(forced ? 0.0 : lam * c.load_round_ms[nn]);
|
||||
if (v > best) { best = v; take = m; }
|
||||
}
|
||||
for (int m = 0; m < take; ++m) want[cand[m]] = true;
|
||||
const bool run = forced > 0 || take > 0;
|
||||
for (int i = 0; i < n && i < kMaxRows; ++i) {
|
||||
if (r[i].done || j != r[i].depth + 1) continue;
|
||||
if (run && want[i]) { r[i].depth = j; r[i].rule = j; } else r[i].done = true;
|
||||
}
|
||||
for (int i = kMaxRows; i < n; ++i) r[i].done = true;
|
||||
return run;
|
||||
}
|
||||
|
||||
/* The late choice (DraftDepthCfg::late): the verified prefix of each of the `n` drafting rows of a
|
||||
* step whose `rounds` rounds were issued, from the statistics observed so far (each row's `seen`;
|
||||
* the driver observes every row up to rounds - late_lag). Level by level: draft j of the rows
|
||||
* still in at j - 1 by the best prefix of their p under the cost model, with no round's price.
|
||||
* A row with no law keeps the depth the rule gave it (at most `rounds`).
|
||||
* Leaves each row's answer in depth / done. */
|
||||
inline void draft_depth_select(const DraftDepthCfg& c, DraftDepthRow* r, int n, int rounds, int other_rows = 0) {
|
||||
const int nn = draft_depth_seqs(n);
|
||||
const double lam = c.load_lam[nn];
|
||||
const int lmin = c.min > c.load_min ? c.min : c.load_min;
|
||||
enum { kMaxRows = 64 };
|
||||
if (n > kMaxRows) n = kMaxRows;
|
||||
int R = other_rows < 0 ? 0 : other_rows;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (r[i].lawless) {
|
||||
if (r[i].depth > rounds) r[i].depth = rounds;
|
||||
if (r[i].depth < 1) r[i].depth = 1;
|
||||
} else {
|
||||
r[i].depth = 1;
|
||||
}
|
||||
r[i].done = r[i].lawless;
|
||||
R += 1 + r[i].depth;
|
||||
}
|
||||
for (int j = 2; j <= rounds && j <= c.max; ++j) {
|
||||
int cand[kMaxRows], n_cand = 0;
|
||||
double p[kMaxRows];
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (r[i].done || r[i].depth != j - 1) continue;
|
||||
/* the confidence read: conf(min(j, seen)), never a round past j */
|
||||
const int m = r[i].seen < j ? r[i].seen : j;
|
||||
p[i] = j <= lmin ? 2.0 : draft_depth_cal(c, j, draft_depth_conf(r[i], m), m - (j - 2));
|
||||
cand[n_cand++] = i;
|
||||
}
|
||||
for (int a = 1; a < n_cand; ++a) {
|
||||
const int x = cand[a];
|
||||
int b = a;
|
||||
for (; b > 0 && p[cand[b - 1]] < p[x]; --b) cand[b] = cand[b - 1];
|
||||
cand[b] = x;
|
||||
}
|
||||
const double base = draft_depth_load_cost(c, n, R);
|
||||
double sum = 0.0, best = 0.0;
|
||||
int take = 0;
|
||||
for (int m = 1; m <= n_cand; ++m) {
|
||||
sum += p[cand[m - 1]];
|
||||
const double v = sum - lam * (draft_depth_load_cost(c, n, R + m) - base);
|
||||
if (v > best || p[cand[m - 1]] > 1.5) { best = v; take = m; } /* > 1.5: a round that always runs */
|
||||
}
|
||||
for (int m = 0; m < n_cand; ++m) {
|
||||
DraftDepthRow& x = r[cand[m]];
|
||||
if (m < take) x.depth = j; else x.done = true;
|
||||
}
|
||||
R += take;
|
||||
if (take == 0) break;
|
||||
}
|
||||
for (int i = 0; i < n; ++i) r[i].done = true;
|
||||
}
|
||||
|
||||
/* The rule's tables as measured once: Qwen3.8-Flash-Next IQR-V4 on two R9700 (tensor parallel),
|
||||
* sampled at temperature 1.0, MTP head with coupling and traversal verify. They are where the
|
||||
* online calibration starts from and what `--draft-depth-load-calib static` serves. By drafting
|
||||
* rows 1 .. 8: the tokens a millisecond, a verify row's and a head round's milliseconds; the
|
||||
* verify's tile jumps past 16 / 32 / 48 / 64 rows; draft j's acceptance by confidence. */
|
||||
inline void draft_depth_load_defaults(DraftDepthCfg* c) {
|
||||
static const double lam[8] = { 0.2325, 0.3558, 0.4341, 0.5125, 0.5494, 0.5863, 0.6232, 0.6602 };
|
||||
static const double row[8] = { 1.159, 0.824, 0.706, 0.587, 0.548, 0.510, 0.471, 0.432 };
|
||||
static const double round[8] = { 0.470, 0.540, 0.570, 0.600, 0.645, 0.690, 0.735, 0.780 };
|
||||
static const double jump[DraftDepthCfg::kJumps] = { 1.30, 1.40, 2.30, 1.00 };
|
||||
static const double x[8] = { 0, 0.3, 0.5, 0.7, 0.85, 0.95, 0.99, 1 };
|
||||
static const double cal[3][4][8] = {
|
||||
{ { 0.575, 0.575, 0.575, 0.575, 0.575, 0.575, 0.575, 0.575 },
|
||||
{ 0.239, 0.239, 0.239, 0.279, 0.337, 0.420, 0.546, 0.809 },
|
||||
{ 0.094, 0.119, 0.172, 0.288, 0.396, 0.526, 0.669, 0.855 },
|
||||
{ 0.055, 0.088, 0.186, 0.322, 0.457, 0.579, 0.710, 0.847 } },
|
||||
{ { 0.318, 0.318, 0.341, 0.403, 0.462, 0.575, 0.723, 0.890 },
|
||||
{ 0.138, 0.185, 0.273, 0.380, 0.503, 0.660, 0.790, 0.931 },
|
||||
{ 0.092, 0.137, 0.241, 0.411, 0.555, 0.711, 0.810, 0.909 },
|
||||
{ 0.056, 0.112, 0.276, 0.414, 0.540, 0.651, 0.823, 0.916 } },
|
||||
{ { 0.251, 0.305, 0.416, 0.532, 0.649, 0.809, 0.919, 0.981 },
|
||||
{ 0.147, 0.220, 0.367, 0.519, 0.661, 0.824, 0.909, 0.971 },
|
||||
{ 0.096, 0.166, 0.346, 0.508, 0.648, 0.783, 0.914, 0.970 },
|
||||
{ 0.063, 0.142, 0.352, 0.478, 0.594, 0.769, 0.899, 0.968 } } };
|
||||
for (int n = 1; n <= DraftDepthCfg::kLoadSeqs; ++n) {
|
||||
c->load_lam[n] = lam[n - 1]; c->load_row_ms[n] = row[n - 1]; c->load_round_ms[n] = round[n - 1];
|
||||
for (int k = 0; k < DraftDepthCfg::kJumps; ++k) c->load_jump_ms[n][k] = jump[k];
|
||||
}
|
||||
c->load_lam[0] = lam[0]; c->load_row_ms[0] = row[0]; c->load_round_ms[0] = round[0];
|
||||
c->load_jump_at[0] = 16; c->load_jump_at[1] = 32; c->load_jump_at[2] = 48; c->load_jump_at[3] = 64;
|
||||
for (int k = 0; k < DraftDepthCfg::kCalKnots; ++k) c->cal_x[k] = x[k];
|
||||
for (int t = 0; t < 3; ++t)
|
||||
for (int j = 0; j <= DraftDepthCfg::kCalRounds; ++j)
|
||||
for (int k = 0; k < DraftDepthCfg::kCalKnots; ++k)
|
||||
c->cal_p[t][j][k] = j < 2 ? 1.0 : cal[t][(j > 5 ? 5 : j) - 2][k];
|
||||
}
|
||||
|
||||
/* "a,b,c" into out[0 .. cap): the count read, or -1 when a word is no number in [lo, hi], or the
|
||||
* list is empty or longer than `cap` (the --draft-depth-load lists). */
|
||||
inline int draft_depth_parse_list(const char* s, double* out, int cap, double lo, double hi) {
|
||||
if (!s || !*s) return -1;
|
||||
int n = 0;
|
||||
for (const char* q = s;;) {
|
||||
char* end = nullptr;
|
||||
const double v = std::strtod(q, &end);
|
||||
if (end == q || !(v >= lo && v <= hi) || n >= cap) return -1;
|
||||
out[n++] = v;
|
||||
if (*end == 0) break;
|
||||
if (*end != ',') return -1;
|
||||
q = end + 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ the online calibration
|
||||
*
|
||||
* The tables above were measured on one model, one pair of cards and one sampling temperature.
|
||||
* A server that runs something else (a lower temperature accepts more at the same confidence;
|
||||
* another card prices a row differently) measures them itself:
|
||||
*
|
||||
* acceptance every verified chain says, for each draft j it carried, whether the verify
|
||||
* accepted it, beside the confidences the decisions read. They are counted at the
|
||||
* knots of the table the decision used (a confidence between two knots goes to
|
||||
* both, by its distance), on top of `prior_w` pseudo-observations of the static
|
||||
* table, and the estimate is made monotone in the confidence. A knot the rule
|
||||
* never drafts at keeps the static value.
|
||||
* rate tokens and milliseconds of the pure decode steps, a moving average by drafting
|
||||
* rows (half-life 64 steps).
|
||||
* prices the same steps' milliseconds regressed on (1, verify rows, rounds, the tiles the
|
||||
* rows are past), by drafting rows, with the static prices as a prior: a
|
||||
* coefficient the steps do not tell apart (a round from the rows that come with
|
||||
* it) stays near the measured table, one they do (a row, a tile) follows them.
|
||||
*
|
||||
* Table 0 (the rule's, read one round behind) counts a chain the rule sent on to round j and the
|
||||
* late choice then cut as "not accepted": what the round yielded is what the rule weighs.
|
||||
*
|
||||
* The driver feeds a chain when its verify is committed and a step when its passes have ended,
|
||||
* and takes the new tables between steps (draft_depth_online_refresh): see the exactness note at
|
||||
* DraftDepthCfg::load. Plain arithmetic; a few hundred flops a step. */
|
||||
struct DraftDepthOnline {
|
||||
enum { kF = 3 + DraftDepthCfg::kJumps, kR = DraftDepthCfg::kCalRounds, kK = DraftDepthCfg::kCalKnots,
|
||||
kN = DraftDepthCfg::kLoadSeqs };
|
||||
double prior_w = 48.0; /* the static table's weight, in verified drafts a knot */
|
||||
double cal_keep = 0.98923; /* a refresh keeps this much of the counts: half in 64 */
|
||||
double cal0[3][kR + 1][kK] = {}; /* the static tables */
|
||||
double cn[3][kR + 1][kK] = {}, ca[3][kR + 1][kK] = {};
|
||||
struct Lam { double tok = 0, ms = 0; int64_t n = 0; } lam[kN + 1];
|
||||
struct Reg { double S[kF][kF] = {}; double b[kF] = {}; double ms_avg = 0; int64_t n = 0; } reg[kN + 1];
|
||||
double theta0[kN + 1][kF] = {}; /* the static prices: (base, row, round, jumps) */
|
||||
double theta[kN + 1][kF] = {}; /* the last fit, for the log */
|
||||
double prec[kF] = { 1e-4, 200.0, 600.0, 20.0, 20.0, 20.0, 20.0 }; /* the prior's weight */
|
||||
double reg_keep = 1.0 - 1.0 / 2048.0; /* a step keeps this much of the sums */
|
||||
int64_t chains = 0, steps = 0, outliers = 0, refreshes = 0;
|
||||
};
|
||||
|
||||
/* Start from the tables `c` holds (the static ones, or the configured). */
|
||||
inline void draft_depth_online_begin(const DraftDepthCfg& c, DraftDepthOnline* o) {
|
||||
*o = DraftDepthOnline{};
|
||||
for (int t = 0; t < 3; ++t)
|
||||
for (int j = 0; j <= DraftDepthOnline::kR; ++j)
|
||||
for (int k = 0; k < DraftDepthOnline::kK; ++k) o->cal0[t][j][k] = c.cal_p[t][j][k];
|
||||
for (int n = 0; n <= DraftDepthOnline::kN; ++n) {
|
||||
o->theta0[n][0] = 0.0;
|
||||
o->theta0[n][1] = c.load_row_ms[n];
|
||||
o->theta0[n][2] = c.load_round_ms[n];
|
||||
for (int k = 0; k < DraftDepthCfg::kJumps; ++k) o->theta0[n][3 + k] = c.load_jump_ms[n][k];
|
||||
for (int f = 0; f < DraftDepthOnline::kF; ++f) o->theta[n][f] = o->theta0[n][f];
|
||||
}
|
||||
}
|
||||
|
||||
/* One verified chain: it carried `depth` drafts of which the verify accepted `accepted`; `s` are
|
||||
* the statistics of its rounds 1 .. n_s (the `top` ones). `rule_depth` is the round the load-aware
|
||||
* rule sent the chain to before the late choice (0: a step the stop rule decided). */
|
||||
inline void draft_depth_online_chain(const DraftDepthCfg& c, DraftDepthOnline* o, int depth, int rule_depth,
|
||||
int accepted, const float* s, int n_s) {
|
||||
if (depth < 1 || n_s < 0) return;
|
||||
++o->chains;
|
||||
const int rule_t = c.lag > 0 ? 0 : 1;
|
||||
const bool rule_cut = rule_depth > 0 && c.late && rule_t == 0; /* table 0 is the rule's alone */
|
||||
const int top = depth > rule_depth ? depth : rule_depth;
|
||||
for (int j = 2; j <= top && j <= DraftDepthOnline::kR; ++j) {
|
||||
const bool verified = j <= depth;
|
||||
const double y = verified && accepted >= j ? 1.0 : 0.0;
|
||||
for (int t = 0; t < 3; ++t) {
|
||||
const int m = j - 2 + t;
|
||||
if (m > n_s || m > 8) continue; /* that round's statistic was not kept */
|
||||
if (t == 0 && rule_cut ? rule_depth < j : !verified) continue;
|
||||
double conf = 1.0;
|
||||
for (int i = 0; i < m; ++i) conf *= (double)s[i];
|
||||
int k0; double w1;
|
||||
draft_depth_knot_at(c, conf, &k0, &w1);
|
||||
o->cn[t][j][k0] += 1.0 - w1; o->ca[t][j][k0] += (1.0 - w1) * y;
|
||||
if (w1 > 0.0) { o->cn[t][j][k0 + 1] += w1; o->ca[t][j][k0 + 1] += w1 * y; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* One pure decode step whose passes have ended, `ms` after the step before it (a pure decode
|
||||
* step of the same `n` drafting rows): its verify's rows R, the rounds D its drafter ran, the
|
||||
* tokens it made. */
|
||||
inline void draft_depth_online_step(const DraftDepthCfg& c, DraftDepthOnline* o, int n, int R, int D,
|
||||
double ms, int tokens) {
|
||||
if (!(ms > 0.0) || ms > 500.0 || n < 1 || R < 1 || tokens < 1) return;
|
||||
const int nn = draft_depth_seqs(n);
|
||||
DraftDepthOnline::Reg& G = o->reg[nn];
|
||||
/* a stall (a client arriving, a page fault) is no price of a row */
|
||||
if (G.n >= 32 && (ms > 2.5 * G.ms_avg || ms < 0.4 * G.ms_avg)) { ++o->outliers; return; }
|
||||
++o->steps;
|
||||
const double wa = 1.0 / (double)(G.n + 1);
|
||||
G.ms_avg += (wa > 1.0 / 64.0 ? wa : 1.0 / 64.0) * (ms - G.ms_avg);
|
||||
++G.n;
|
||||
DraftDepthOnline::Lam& L = o->lam[nn];
|
||||
const double wl = 1.0 / (double)(L.n + 1);
|
||||
const double w = wl > 0.010772 ? wl : 0.010772; /* 1 - 2^(-1/64) */
|
||||
L.tok += w * ((double)tokens - L.tok);
|
||||
L.ms += w * (ms - L.ms);
|
||||
++L.n;
|
||||
double x[DraftDepthOnline::kF];
|
||||
x[0] = 1.0; x[1] = (double)R; x[2] = (double)D;
|
||||
for (int k = 0; k < DraftDepthCfg::kJumps; ++k) x[3 + k] = R > c.load_jump_at[k] ? 1.0 : 0.0;
|
||||
for (int a = 0; a < DraftDepthOnline::kF; ++a) {
|
||||
G.b[a] = G.b[a] * o->reg_keep + x[a] * ms;
|
||||
for (int b = 0; b < DraftDepthOnline::kF; ++b) G.S[a][b] = G.S[a][b] * o->reg_keep + x[a] * x[b];
|
||||
}
|
||||
}
|
||||
|
||||
/* The tables from what was fed so far, into `c`. Between steps only. */
|
||||
inline void draft_depth_online_refresh(DraftDepthCfg* c, DraftDepthOnline* o) {
|
||||
enum { kF = DraftDepthOnline::kF, kK = DraftDepthOnline::kK };
|
||||
++o->refreshes;
|
||||
const int K = draft_depth_knots(*c);
|
||||
for (int t = 0; t < 3; ++t)
|
||||
for (int j = 2; j <= DraftDepthOnline::kR; ++j) {
|
||||
/* each knot's estimate with the static table as pseudo-observations, then pooled
|
||||
* until it does not fall as the confidence rises (pool adjacent violators) */
|
||||
double v[kK], w[kK];
|
||||
int lo[kK], nb = 0;
|
||||
for (int k = 0; k < K; ++k) {
|
||||
const double wk = o->cn[t][j][k] + o->prior_w;
|
||||
const double vk = (o->ca[t][j][k] + o->prior_w * o->cal0[t][j][k]) / wk;
|
||||
v[nb] = vk; w[nb] = wk; lo[nb] = k; ++nb;
|
||||
while (nb > 1 && v[nb - 2] > v[nb - 1]) {
|
||||
v[nb - 2] = (v[nb - 2] * w[nb - 2] + v[nb - 1] * w[nb - 1]) / (w[nb - 2] + w[nb - 1]);
|
||||
w[nb - 2] += w[nb - 1];
|
||||
--nb;
|
||||
}
|
||||
}
|
||||
for (int b = 0; b < nb; ++b) {
|
||||
const int hi = b + 1 < nb ? lo[b + 1] : K;
|
||||
const double p = v[b] < 0.0 ? 0.0 : (v[b] > 1.0 ? 1.0 : v[b]);
|
||||
for (int k = lo[b]; k < hi; ++k) c->cal_p[t][j][k] = p;
|
||||
}
|
||||
for (int k = 0; k < K; ++k) { o->cn[t][j][k] *= o->cal_keep; o->ca[t][j][k] *= o->cal_keep; }
|
||||
}
|
||||
for (int n = 1; n <= DraftDepthOnline::kN; ++n) {
|
||||
const DraftDepthOnline::Lam& L = o->lam[n];
|
||||
if (L.n >= 32 && L.ms > 0.0 && L.tok > 0.0) c->load_lam[n] = L.tok / L.ms;
|
||||
const DraftDepthOnline::Reg& G = o->reg[n];
|
||||
if (G.n < 64) continue;
|
||||
/* (S + P) theta = b + P theta0, by Cholesky: S + P is positive definite */
|
||||
double A[kF][kF], y[kF];
|
||||
for (int a = 0; a < kF; ++a) {
|
||||
y[a] = G.b[a] + o->prec[a] * o->theta0[n][a];
|
||||
for (int b = 0; b < kF; ++b) A[a][b] = G.S[a][b] + (a == b ? o->prec[a] : 0.0);
|
||||
}
|
||||
bool ok = true;
|
||||
for (int a = 0; a < kF && ok; ++a) {
|
||||
for (int b = 0; b <= a; ++b) {
|
||||
double sum = A[a][b];
|
||||
for (int q = 0; q < b; ++q) sum -= A[a][q] * A[b][q];
|
||||
if (a == b) { if (!(sum > 1e-12)) { ok = false; break; } A[a][a] = std::sqrt(sum); }
|
||||
else A[a][b] = sum / A[b][b];
|
||||
}
|
||||
}
|
||||
if (!ok) continue;
|
||||
for (int a = 0; a < kF; ++a) {
|
||||
double sum = y[a];
|
||||
for (int q = 0; q < a; ++q) sum -= A[a][q] * y[q];
|
||||
y[a] = sum / A[a][a];
|
||||
}
|
||||
for (int a = kF - 1; a >= 0; --a) {
|
||||
double sum = y[a];
|
||||
for (int q = a + 1; q < kF; ++q) sum -= A[q][a] * y[q];
|
||||
y[a] = sum / A[a][a];
|
||||
}
|
||||
bool finite = true;
|
||||
for (int a = 0; a < kF; ++a) finite = finite && y[a] == y[a] && y[a] > -1e6 && y[a] < 1e6;
|
||||
if (!finite) continue;
|
||||
auto clamp = [](double v, double lo_, double hi_) { return v < lo_ ? lo_ : (v > hi_ ? hi_ : v); };
|
||||
for (int a = 0; a < kF; ++a) o->theta[n][a] = y[a];
|
||||
c->load_row_ms[n] = clamp(y[1], 0.05, 5.0);
|
||||
c->load_round_ms[n] = clamp(y[2], 0.10, 5.0);
|
||||
for (int k = 0; k < DraftDepthCfg::kJumps; ++k) c->load_jump_ms[n][k] = clamp(y[3 + k], 0.0, 20.0);
|
||||
}
|
||||
}
|
||||
|
||||
/* The whole rule at once, for a chain whose statistics are all known (tests, offline): s[i] is
|
||||
* round i + 1's, n of them (n >= max - 1 - lag is enough). Returns the depth D in [1, max]. */
|
||||
inline int draft_depth_of(const DraftDepthCfg& c, const double* s, int n) {
|
||||
DraftDepthRow r;
|
||||
draft_depth_begin(c, &r, false);
|
||||
for (int j = 2; j <= c.max; ++j) {
|
||||
const int need = draft_depth_need(c, j);
|
||||
while (r.seen < need && r.seen < n) draft_depth_observe(&r, r.seen + 1, s[r.seen]);
|
||||
if (!draft_depth_go(c, &r, j)) break;
|
||||
}
|
||||
return r.depth < 1 ? 1 : r.depth;
|
||||
}
|
||||
|
||||
} /* namespace rad */
|
||||
@@ -164,6 +164,13 @@ struct SchedMetrics {
|
||||
int64_t lookup_held = 0;
|
||||
int64_t lookup_held_drafts = 0;
|
||||
int64_t lookup_held_hits = 0;
|
||||
/* --draft-suffix (suffix.h): verifies that carried a suffix chain, the rows they carried and the
|
||||
* drafts accepted; decode steps not issued ahead because the sequence was in a recurring
|
||||
* pattern (where the lookup could run after the commit instead). */
|
||||
int64_t suffix_steps = 0;
|
||||
int64_t suffix_rows = 0;
|
||||
int64_t suffix_accepted = 0;
|
||||
int64_t suffix_held_ahead = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+290
-33
@@ -215,6 +215,7 @@ int Scheduler::init(Program& prog, const Config& cfg, IKVManager* kv, IPrefixCac
|
||||
|
||||
DraftController::Params dp;
|
||||
dp.max_depth = cfg.n_spec;
|
||||
dp.head_depth = cfg.n_spec_head > 0 && cfg.n_spec_head < cfg.n_spec ? cfg.n_spec_head : 0;
|
||||
/* The adaptive window (draft.h) prices a draft by the measured cost of the step it adds to.
|
||||
* A block drafter proposes its block in one pass, but each verified draft is still a verify
|
||||
* row, which is not free on a MoE that reads each row's routed experts. So it takes the same
|
||||
@@ -388,6 +389,13 @@ int Scheduler::add_locked(std::unique_ptr<Request> r) {
|
||||
/* An embedding input runs in one step or not at all (Request::embed); one longer than a step
|
||||
* could never be admitted. */
|
||||
if (r->embed && (int64_t)r->prompt.size() > cfg_.max_tok) return RAD_E_INVAL;
|
||||
/* The words a request hands the plugin are bounded by the plugin's declaration. The batch
|
||||
* stage refuses a sequence past it, and a refused build restages the step forever -- an
|
||||
* over-cap request admitted here would stall every queue behind it. The server-side route
|
||||
* caps its own words; this is the promise no future route can miss. */
|
||||
if (!r->plugin_words.empty() &&
|
||||
(int64_t)r->plugin_words.size() > builder_.plugin_words_cap())
|
||||
return RAD_E_INVAL;
|
||||
/* Every prompt id, tokenised or client-supplied, names a real vocabulary row: an id past the
|
||||
* embedding table is refused at admission, never staged into a pass. Raw id arrays reach here
|
||||
* straight from the request body, and an op failing mid-step is a device fault (spec §17) --
|
||||
@@ -742,6 +750,7 @@ void Scheduler::close_request(SchedReq& s, ReqState st, const char* reason, bool
|
||||
if (cfg_.prefix_cache && pc_) pc_->release(*s.req);
|
||||
/* Prompt lookup's index is this text's alone. */
|
||||
s.ngram_ix.reset();
|
||||
s.suffix_ix.reset();
|
||||
if (lookup_gate_on_ && s.look.started && s.look.proposed > 0)
|
||||
RAD_DEBUG("prompt lookup: request %llu made %lld proposals, held back %lld (%lld drafts, "
|
||||
"%lld of those scored came true); a %d-draft verify costs %.2f plain steps",
|
||||
@@ -772,6 +781,7 @@ void Scheduler::close_request(SchedReq& s, ReqState st, const char* reason, bool
|
||||
if (s.req->finish_reason.empty() && reason) s.req->finish_reason = reason;
|
||||
queue_erase(running_, s.slot);
|
||||
queue_erase(waiting_, s.slot);
|
||||
if (st == ReqState::Finished && !s.req->embed && !running_.empty()) finished_beside_ = true;
|
||||
s.n_draft = 0;
|
||||
|
||||
/* Terminal. The sink keeps the first finish, so a cancel racing a natural stop yields one
|
||||
@@ -1081,6 +1091,24 @@ int Scheduler::draft_ngram(SchedReq& s, int depth, int* match) const {
|
||||
LookupGate::kLongMatch);
|
||||
}
|
||||
|
||||
/* --draft-suffix: SuffixDecoding's chain for the sequence's committed history (suffix.h). */
|
||||
int Scheduler::suffix_propose(SchedReq& s, int32_t* out, int* match) {
|
||||
if (match) *match = -1;
|
||||
if (!s.req) return 0;
|
||||
const Request& r = *s.req;
|
||||
TokenSeq seq;
|
||||
seq.a = r.prompt.data();
|
||||
seq.na = (int64_t)r.prompt.size();
|
||||
seq.b = r.output.data();
|
||||
seq.nb = (int64_t)r.output.size();
|
||||
const SuffixIndex::Out o =
|
||||
s.suffix_ix.propose(seq, r.id, cfg_.draft_suffix_min_match,
|
||||
std::min(cfg_.draft_suffix_max, (int)RAD_SCHED_MAX_SPEC),
|
||||
cfg_.draft_suffix_min_score, out);
|
||||
if (match && o.n > 0) *match = o.match;
|
||||
return o.n;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ chunking */
|
||||
int64_t Scheduler::chunk_end(const Request& r, int64_t n_target) const {
|
||||
if (rswa_windows_.empty() || !kv_->has_runtime_window(r.id)) return n_target;
|
||||
@@ -1152,9 +1180,13 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
* makes a chunk of its own. Not from a prompt's start: the first interval may be served on
|
||||
* another path (QSA's dense attention below its exactness bound). Not from a tail
|
||||
* checkpoint: the pieces after it would no longer start on the interval. A chunk the
|
||||
* budget cuts short of the span's end steps back to the last boundary it crosses. */
|
||||
* budget cuts short of the span's end steps back to the last boundary it crosses.
|
||||
* --prefill-span-first on spans from the prompt's start too: the first interval's rows
|
||||
* then read QSA's selection, which below the exactness bound holds the same keys as the
|
||||
* dense pass (summed in another order). */
|
||||
int64_t far = next;
|
||||
if (geo_.span > 1 && span_now_ && n_computed >= I && n_computed % I == 0)
|
||||
if (geo_.span > 1 && span_now_ && n_computed % I == 0 &&
|
||||
(n_computed >= I || cfg_.prefill_span_first))
|
||||
far = n_computed + geo_.span * I;
|
||||
if (n_computed + want > far)
|
||||
want = far - n_computed;
|
||||
@@ -1179,8 +1211,24 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
* leaves, so the final chunk splits at the last quantum boundary and the remainder
|
||||
* (under a quantum) runs as the next step's chunk (tail_checkpoint decides when that
|
||||
* is worth it). A window's tail snapshot is taken above, inside its chunk. */
|
||||
const int64_t tail = geo_.window_ckpt ? -1 : tail_checkpoint(n_target);
|
||||
if (tail > n_computed) {
|
||||
/* A prefill alone in its spanned step whose plugin snapshots inside the step
|
||||
* (set_ckpt_inside) takes either snapshot below inside its last chunk, at the same
|
||||
* position, and runs to the prompt's end: the rows past it would otherwise be a step
|
||||
* of their own, which on a routed model reads nearly every expert for a few dozen
|
||||
* rows. Its tail snapshot splits nothing, so it is taken however few rows it lies
|
||||
* past the interval boundary below it (tail_checkpoint's in_step). */
|
||||
const bool inside = ckpt_inside_ && cfg_.prefill_tail_snapshot && geo_.span > 1 &&
|
||||
span_now_ && cfg_.prefill_span > 1 && !geo_.window_ckpt;
|
||||
const int64_t tail = geo_.window_ckpt ? -1 : tail_checkpoint(n_target, inside);
|
||||
if (inside && tail > n_computed) {
|
||||
if (checkpoint_pos) *checkpoint_pos = tail;
|
||||
} else if (inside && n_computed + want > next) {
|
||||
if (checkpoint_pos) *checkpoint_pos = (n_computed + want) / I * I;
|
||||
} else if (!cfg_.prefill_tail_snapshot) {
|
||||
/* --prefill-tail-snapshot off: neither cut below, so the last chunk runs to the
|
||||
* prompt's end; its snapshot is kept where that end is the tail (no cut). */
|
||||
if (tail == n_target && tail > n_computed && checkpoint_pos) *checkpoint_pos = tail;
|
||||
} else if (tail > n_computed) {
|
||||
want = tail - n_computed;
|
||||
if (checkpoint_pos) *checkpoint_pos = tail;
|
||||
} else if (n_computed + want > next) {
|
||||
@@ -1266,8 +1314,9 @@ int64_t Scheduler::bidi_fit(const Request& r, int64_t n_computed, int64_t n_targ
|
||||
* last chunk starts (below). Under nearest, its last quantum boundary, only past the first
|
||||
* interval (a shorter prompt is cheap to redo) and only where it gains at least a quarter
|
||||
* interval over the interval checkpoint below it, which pays for the extra step; a window
|
||||
* snapshot follows its own rule (below). */
|
||||
int64_t Scheduler::tail_checkpoint(int64_t target) const {
|
||||
* snapshot follows its own rule (below). A snapshot taken inside the last chunk (`in_step`)
|
||||
* costs no step, only its copy, and is taken wherever it lies past the interval below it. */
|
||||
int64_t Scheduler::tail_checkpoint(int64_t target, bool in_step) const {
|
||||
const int64_t I = geo_.checkpoint_interval, Q = geo_.quantum;
|
||||
if (I <= 0 || Q <= 0) return -1;
|
||||
if (geo_.exact) {
|
||||
@@ -1294,16 +1343,27 @@ int64_t Scheduler::tail_checkpoint(int64_t target) const {
|
||||
const int64_t t = (target - std::max<int64_t>(Q, 16)) / Q * Q;
|
||||
return t >= std::min<int64_t>(I, kWindowSnapshotMin) ? t : -1;
|
||||
}
|
||||
if (in_step) return tail > I && tail % I != 0 ? tail : -1;
|
||||
return tail > I && tail - tail / I * I >= std::max<int64_t>(Q, I / 4) ? tail : -1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ a prefill sharing a step */
|
||||
void Scheduler::set_span_min(int64_t tokens) {
|
||||
span_min_ = tokens > 0 ? tokens : 0;
|
||||
if (span_min_ > 0 && geo_.span > 1)
|
||||
if (geo_.span <= 1) return;
|
||||
if (cfg_.prefill_span_min >= 0) {
|
||||
/* The deployment's own bound (--prefill-span-min), whatever the experts' placement. */
|
||||
if (span_min_ > 0)
|
||||
RAD_INFO("scheduler: --prefill-span-min %lld: a prefill spans when it is %lld tokens "
|
||||
"or longer", (long long)cfg_.prefill_span_min, (long long)span_min_);
|
||||
else
|
||||
RAD_INFO("scheduler: --prefill-span-min 0: every prefill alone in its step spans from "
|
||||
"its second interval on");
|
||||
} else if (span_min_ > 0) {
|
||||
RAD_INFO("scheduler: --prefill-span: a prefill spans when it is %lld tokens or longer -- "
|
||||
"routed experts are read from host memory, and the arena a spanned step takes is "
|
||||
"room they lose for it", (long long)span_min_);
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::set_stage_rows(int64_t rows) {
|
||||
@@ -1466,6 +1526,8 @@ bool Scheduler::preempt_back() {
|
||||
* blocks to run would be preempted on its first step, a full recompute for nothing. */
|
||||
int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve,
|
||||
int64_t mixed_target_shares) {
|
||||
idle_refuse_ = false;
|
||||
room_wait_ = false;
|
||||
Request& r = *s.req;
|
||||
|
||||
/* A REQUEST THAT WAS PREEMPTED WAITS FOR ROOM FOR THE WHOLE RECOMPUTE, plus one block of
|
||||
@@ -1675,6 +1737,38 @@ int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve,
|
||||
s.hit_attn = h.n_attn_tokens;
|
||||
}
|
||||
|
||||
/* A fresh prefill is admitted only when its WHOLE prompt plus one decode position fits
|
||||
* beside the whole prompt of every runner and their next-token headroom. The generic
|
||||
* admission below only reserves this chunk; without this gate a long prompt can reach 100%
|
||||
* and then be preempted at the first decode step, wasting the entire prefill. */
|
||||
if (cfg_.prefill_room_gate && r.state != ReqState::Preempted && (int64_t)r.n_computed < (int64_t)r.prompt.size()) {
|
||||
int rounds = 0;
|
||||
while (!fresh_prefill_can_fit(s) && rounds < kEvictRounds &&
|
||||
cfg_.prefix_cache && pc_ && pc_->evict(kEvictBlocks) > 0)
|
||||
++rounds;
|
||||
if (!fresh_prefill_can_fit(s)) {
|
||||
/* A prompt the empty pool cannot hold must not starve the queue: it fails below
|
||||
* (spec §17) like the preempted path, rather than waiting forever. */
|
||||
if (!kv_->can_ever_fit(s.seq_len() + 1))
|
||||
; /* fall through: ensure_from() reports the shortfall */
|
||||
else if (running_.empty() && took_.empty()) {
|
||||
/* Nothing is running, so the next step will not free a block or a slot. A hit
|
||||
* kept from the previous bounce (n_computed > 0) can be what can_grow refuses;
|
||||
* drop it once. Still short: refuse, and the step loop fails this request
|
||||
* instead of parking every waiter behind kAdmitWait. */
|
||||
if (r.n_computed > 0) undo_hit(s);
|
||||
(void)kv_->release_idle_states();
|
||||
if (!fresh_prefill_can_fit(s)) {
|
||||
idle_refuse_ = true;
|
||||
return RAD_E_NOMEM;
|
||||
}
|
||||
} else {
|
||||
room_wait_ = true;
|
||||
return kAdmitWait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t target = s.seq_len();
|
||||
int64_t ckpt = -1;
|
||||
int64_t want;
|
||||
@@ -1780,21 +1874,91 @@ void Scheduler::undo_hit(SchedReq& s) {
|
||||
bool Scheduler::preempted_can_prefill(const SchedReq& s) const {
|
||||
const Request& r = *s.req;
|
||||
const int64_t target = s.seq_len();
|
||||
/* What the recompute adopts from the cache (its own prefix, published at the preemption) needs
|
||||
* no new block. */
|
||||
const int64_t hit = (cfg_.prefix_cache && pc_) ? pc_->lookup(r, nullptr, nullptr).n_attn_tokens : 0;
|
||||
/* Whether the pools hold the recompute plus every runner's remaining need, given `hit` tokens
|
||||
* of prefix the recompute adopts without new blocks. */
|
||||
auto enough = [&](int64_t hit) {
|
||||
for (size_t g = 0; g < kvgeom_.g.size(); ++g) {
|
||||
const KVGeom::G& gg = kvgeom_.g[g];
|
||||
/* A group the manager gives no blocks (the sentinel at index 0) asks nothing. Counting
|
||||
* it wanted the whole prompt from a pool of none and kept a preempted request out for
|
||||
* good. */
|
||||
if (!gg.paged || kv_->total_blocks((int32_t)g) <= 0) continue;
|
||||
int64_t need = (target + gg.block_size - 1) / gg.block_size -
|
||||
(int64_t)kv_->block_table(r.id, (int32_t)g).size() - hit / gg.block_size;
|
||||
if (need < 0) need = 0;
|
||||
for (int32_t slot : running_) {
|
||||
const SchedReq& rs = *reqs_[(size_t)slot];
|
||||
if (!rs.req) continue;
|
||||
const Request& rr = *rs.req;
|
||||
int64_t goal = rr.n_computed + 1;
|
||||
if (rr.n_computed < (int64_t)rr.prompt.size())
|
||||
goal = std::max(goal, (int64_t)rr.prompt.size());
|
||||
const int64_t rows = (goal + gg.block_size - 1) / gg.block_size;
|
||||
const int64_t held = (int64_t)kv_->block_table(rr.id, (int32_t)g).size();
|
||||
if (rows > held) need += rows - held;
|
||||
need += 1; /* one block past that, so the next step is not the victim */
|
||||
}
|
||||
if (need > kv_->available_blocks((int32_t)g)) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/* The hash-chain lookup costs the request's length in CPU, and this gate runs per waiting
|
||||
* slot per scheduling round, under mu_. The zero-credit count answers "yes" without it
|
||||
* whenever the pools plainly hold the recompute; the lookup is consulted only when the
|
||||
* credit decides, which is precisely when the gate is about to deny anyway. */
|
||||
if (!enough(0)) {
|
||||
if (!cfg_.prefix_cache || !pc_) return false;
|
||||
/* Credit what the recompute ADOPTS, not the raw attention hit: admit_one clamps the
|
||||
* attention hit to the linear hit under checkpoints -- the linear layers replay from the
|
||||
* checkpoint regardless of how deep the attention matched -- and never adopts the whole
|
||||
* prompt, one token staying for the logits. Crediting deeper than admission adopts
|
||||
* subtracts blocks the recompute will really need: the preempted request is admitted
|
||||
* against a loan it cannot repay, the next ensure preempts it again, and that is the
|
||||
* loop this gate exists to stop. The exact-mode grid floor is folded in as a bound too
|
||||
* -- crediting less than admission adopts only delays a re-admission by one round,
|
||||
* crediting more reopens the loop. */
|
||||
const CacheHit h = pc_->lookup(r, nullptr, nullptr);
|
||||
int64_t hit = h.n_attn_tokens;
|
||||
if (geo_.checkpoints() && h.n_linear_tokens < hit) hit = h.n_linear_tokens;
|
||||
if (geo_.exact && hit > 0) hit = geo_.grid_floor(hit);
|
||||
const int64_t last = target - 1;
|
||||
if (hit > last) hit = last;
|
||||
if (hit < 0) hit = 0;
|
||||
if (!enough(hit)) return false;
|
||||
}
|
||||
|
||||
/* Stateful groups: the recompute needs its state slots back, and every running sequence must
|
||||
* keep the slot it already holds. A sequence the manager does not know is not a refusal:
|
||||
* admit_one adds it, and can_grow on a missing id is false forever. */
|
||||
if (kv_->has_sequence(r.id) && !kv_->can_grow(r.id, target)) return false;
|
||||
for (int32_t slot : running_) {
|
||||
const SchedReq& rs = *reqs_[(size_t)slot];
|
||||
if (rs.req && !kv_->can_grow(rs.req->id, rs.req->n_computed + 1)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Whether a FRESH prefill may start: the whole prompt plus one decode position has to fit in
|
||||
* every FULL paged group, beside the whole prompt (or the next position) of every running
|
||||
* sequence and of every request this step's admission has already taken, with one block past
|
||||
* that for each. Admitting on the first chunk alone lets the pool reach 100% mid-prompt, and
|
||||
* preempt_back() then hands back the whole prefill's KV, so the request starts again at zero.
|
||||
* WINDOW/RING groups recycle; counting the whole prompt against them livelocks a long chat in
|
||||
* Waiting. */
|
||||
bool Scheduler::fresh_prefill_can_fit(const SchedReq& s) const {
|
||||
const Request& r = *s.req;
|
||||
const int64_t target = s.seq_len() + 1; /* prompt + one decode token */
|
||||
|
||||
for (size_t g = 0; g < kvgeom_.g.size(); ++g) {
|
||||
const KVGeom::G& gg = kvgeom_.g[g];
|
||||
/* A group the manager gives no blocks (the sentinel at index 0) asks nothing. Counting it
|
||||
* wanted the whole prompt from a pool of none and kept a preempted request out for good. */
|
||||
if (!gg.paged || kv_->total_blocks((int32_t)g) <= 0) continue;
|
||||
if (gg.kind != RAD_KV_FULL || !gg.paged || kv_->total_blocks((int32_t)g) <= 0) continue;
|
||||
int64_t need = (target + gg.block_size - 1) / gg.block_size -
|
||||
(int64_t)kv_->block_table(r.id, (int32_t)g).size() - hit / gg.block_size;
|
||||
(int64_t)kv_->block_table(r.id, (int32_t)g).size();
|
||||
if (need < 0) need = 0;
|
||||
for (int32_t slot : running_) {
|
||||
auto beside = [&](int32_t slot) {
|
||||
const SchedReq& rs = *reqs_[(size_t)slot];
|
||||
if (!rs.req) continue;
|
||||
if (!rs.req || &rs == &s) return;
|
||||
const Request& rr = *rs.req;
|
||||
int64_t goal = rr.n_computed + 1;
|
||||
if (rr.n_computed < (int64_t)rr.prompt.size())
|
||||
@@ -1802,15 +1966,19 @@ bool Scheduler::preempted_can_prefill(const SchedReq& s) const {
|
||||
const int64_t rows = (goal + gg.block_size - 1) / gg.block_size;
|
||||
const int64_t held = (int64_t)kv_->block_table(rr.id, (int32_t)g).size();
|
||||
if (rows > held) need += rows - held;
|
||||
need += 1; /* one block past that, so the next step is not the victim */
|
||||
}
|
||||
need += 1; /* one block past that for the sequence */
|
||||
};
|
||||
for (int32_t slot : running_) beside(slot);
|
||||
for (size_t i : took_) beside(waiting_[i]);
|
||||
if (need > kv_->available_blocks((int32_t)g)) return false;
|
||||
}
|
||||
|
||||
/* Stateful groups: the recompute needs its state slots back, and every running sequence must
|
||||
* keep the slot it already holds. A sequence the manager does not know is not a refusal:
|
||||
* admit_one adds it, and can_grow on a missing id is false forever. */
|
||||
if (kv_->has_sequence(r.id) && !kv_->can_grow(r.id, target)) return false;
|
||||
/* Stateful groups: the fresh prefill needs a state slot, and every running sequence must keep
|
||||
* the slot it already holds. Asked at the next position, not the prompt's end: the FULL
|
||||
* groups were counted above, and a window or ring group recycles its blocks, so counting the
|
||||
* whole prompt there refuses a prompt longer than its window that the model serves (an idle
|
||||
* engine then fails it). */
|
||||
if (kv_->has_sequence(r.id) && !kv_->can_grow(r.id, (int64_t)r.n_computed + 1)) return false;
|
||||
for (int32_t slot : running_) {
|
||||
const SchedReq& rs = *reqs_[(size_t)slot];
|
||||
if (rs.req && !kv_->can_grow(rs.req->id, rs.req->n_computed + 1)) return false;
|
||||
@@ -1953,13 +2121,21 @@ const RadBatch* Scheduler::step() {
|
||||
|
||||
/* A span is for a prefill alone in its step (ChunkGeometry::span). A spanned step takes as
|
||||
* long as the intervals it carries, so a decode row riding along would wait that long for its
|
||||
* token. The span is taken only when the step can hold nothing but the one prefill (a single
|
||||
* running request with prompt left and no admission possible, or a single request in an empty
|
||||
* engine); every other step is planned at ChunkGeometry::shared_tok as a deployment without a
|
||||
* span plans it, --busy-prefill-chunk included. Both kinds of chunk end on the same interval
|
||||
* token. The span is taken only when the step can hold nothing but one prefill: a single
|
||||
* request in an empty engine, or running requests that all have prompt left with no admission
|
||||
* possible. Of several, the one with the fewest prompt tokens left takes the step alone and the
|
||||
* others wait for it (shortest remaining first): a step of shared_tok split between them runs
|
||||
* well under a spanned step's rate, and the first token of the shortest comes first. Every
|
||||
* other step -- one with a decode row, or a request to admit -- is planned at
|
||||
* ChunkGeometry::shared_tok as a deployment without a span plans it, --busy-prefill-chunk
|
||||
* included. So is the one step after a request finished beside them (finished_beside_): a
|
||||
* follow-up turn its client sends at once arrives while that step runs, and waits for it
|
||||
* rather than for a span several times as long. Both kinds of chunk end on the same interval
|
||||
* grid, so a prompt may switch between them at any step. */
|
||||
span_now_ = true;
|
||||
struct SpanReset { bool& f; ~SpanReset() { f = true; } } span_reset{span_now_};
|
||||
/* The running request a spanned step holds, or -1: every other running request sits it out. */
|
||||
int32_t span_slot = -1;
|
||||
/* Keyed on the flag, not on whether this model has intervals to span: the engine told the
|
||||
* plugin that a step wider than shared_tok is one sequence (RadBuildCtx::max_mixed_tok),
|
||||
* whatever the geometry turned out to be. */
|
||||
@@ -1967,14 +2143,28 @@ const RadBatch* Scheduler::step() {
|
||||
bool lone = false;
|
||||
const bool admit_possible = !waiting_.empty() && !free_cards_.empty() &&
|
||||
(int64_t)running_.size() < cfg_.max_seqs;
|
||||
if (running_.size() == 1 && !admit_possible) {
|
||||
const SchedReq& s0 = *reqs_[(size_t)running_[0]];
|
||||
lone = s0.req->n_computed < (int64_t)s0.req->prompt.size() ||
|
||||
s0.req->n_computed + 1 < s0.seq_len();
|
||||
const bool after_finish = finished_beside_;
|
||||
finished_beside_ = false;
|
||||
if (!running_.empty() && !admit_possible && !after_finish) {
|
||||
int64_t fewest = INT64_MAX;
|
||||
for (int32_t slot : running_) {
|
||||
const SchedReq& sr = *reqs_[(size_t)slot];
|
||||
const Request& rr = *sr.req;
|
||||
const int64_t tg = sr.seq_len();
|
||||
if (rr.n_computed >= (int64_t)rr.prompt.size() && rr.n_computed + 1 >= tg) {
|
||||
span_slot = -1; /* a decode row: a shared step */
|
||||
break;
|
||||
}
|
||||
if (tg - rr.n_computed < fewest) { fewest = tg - rr.n_computed; span_slot = slot; }
|
||||
}
|
||||
lone = span_slot >= 0;
|
||||
/* By the whole prefill, not what is left of it, so a prompt keeps spanning through
|
||||
* its last intervals (set_span_min). */
|
||||
if (lone && span_min_ > 0)
|
||||
if (lone && span_min_ > 0) {
|
||||
const SchedReq& s0 = *reqs_[(size_t)span_slot];
|
||||
lone = std::max<int64_t>((int64_t)s0.req->prompt.size(), s0.seq_len()) >= span_min_;
|
||||
}
|
||||
if (!lone) span_slot = -1;
|
||||
} else if (running_.empty() && waiting_.size() == 1) {
|
||||
const SchedReq& w = *reqs_[(size_t)waiting_[0]];
|
||||
lone = span_min_ == 0 || (w.req && (int64_t)w.req->prompt.size() >= span_min_);
|
||||
@@ -1997,10 +2187,13 @@ const RadBatch* Scheduler::step() {
|
||||
const int64_t Q = std::max<int64_t>(geo_.quantum, 1);
|
||||
/* An eighth of this step's budget, which under a span is shared_tok for a shared step. */
|
||||
const int64_t share_tok = std::max<int64_t>(Q, budget / 8 / Q * Q);
|
||||
const int64_t dec_row_tok = 1 + std::max<int64_t>(depth, draft_.step_window());
|
||||
const int64_t dec_row_tok = 1 + std::max<int64_t>({ (int64_t)depth, (int64_t)draft_.step_window(),
|
||||
cfg_.draft_suffix ? (int64_t)cfg_.draft_suffix_max : 0 });
|
||||
int64_t behind_dec = 0, behind_pf = 0;
|
||||
if (share_step) {
|
||||
for (int32_t slot : running_) {
|
||||
/* Those a spanned step leaves out take no share of it. */
|
||||
if (span_slot >= 0 && slot != span_slot) continue;
|
||||
const Request& rr = *reqs_[(size_t)slot]->req;
|
||||
const int64_t tg = reqs_[(size_t)slot]->seq_len();
|
||||
const bool pf = (rr.n_computed < (int64_t)rr.prompt.size()) || (rr.n_computed + 1 < tg);
|
||||
@@ -2036,6 +2229,9 @@ const RadBatch* Scheduler::step() {
|
||||
* admitted, so new work never preempts work half done. */
|
||||
for (size_t i = 0; i < running_.size(); ) {
|
||||
if ((int64_t)plan_.e.size() >= cfg_.max_seqs || budget <= 0) break;
|
||||
/* A spanned step holds one sequence (RadBuildCtx::max_mixed_tok): the one chosen above. */
|
||||
if (cfg_.prefill_span > 1 && span_now_ && !plan_.e.empty()) break;
|
||||
if (span_slot >= 0 && running_[i] != span_slot) { ++i; continue; }
|
||||
|
||||
int32_t slot = running_[i];
|
||||
SchedReq& s = *reqs_[(size_t)slot];
|
||||
@@ -2086,7 +2282,24 @@ const RadBatch* Scheduler::step() {
|
||||
* drafts this step and no deeper. */
|
||||
const int cap = draft_.adaptive() ? draft_cap(s) : depth;
|
||||
bool ngram = false;
|
||||
if (!r.may_speculate) s.n_draft = 0;
|
||||
bool suffix = false;
|
||||
/* --draft-suffix: a sequence whose own history ends in a recurring pattern verifies that
|
||||
* pattern's earlier continuation in place of the head's draft (the head still drafted
|
||||
* behind the step before, so a miss costs nothing but that draft). A function of the
|
||||
* committed text alone, so the choice never reads a draw; the rows it verifies carry no
|
||||
* coupled state (Request::draft_suffix below), so each is the target's plain draw. */
|
||||
if (cfg_.draft_suffix && r.may_speculate) {
|
||||
int32_t buf[RAD_SCHED_MAX_SPEC];
|
||||
const int np = suffix_propose(s, buf);
|
||||
if (np > 0) {
|
||||
std::copy(buf, buf + np, s.draft);
|
||||
s.n_draft = np;
|
||||
s.draft_tree = false;
|
||||
suffix = true;
|
||||
}
|
||||
}
|
||||
if (suffix) ngram = true;
|
||||
else if (!r.may_speculate) s.n_draft = 0;
|
||||
else if (s.n_draft == 0) {
|
||||
/* As the only drafter under the adaptive window, the lookup is the head: its
|
||||
* proposal is cut to the sequence's own window. */
|
||||
@@ -2114,6 +2327,7 @@ const RadBatch* Scheduler::step() {
|
||||
}
|
||||
if (!ngram && s.n_draft > cap) s.n_draft = cap;
|
||||
s.draft_ngram = ngram;
|
||||
s.draft_suffix = suffix;
|
||||
/* No verified position at or past the context end: nothing past ctx_limit_ - 1 has a
|
||||
* rotary row or block-table column. commit() finishes a sequence before it reaches
|
||||
* the limit, so the one token itself always fits. */
|
||||
@@ -2193,6 +2407,11 @@ const RadBatch* Scheduler::step() {
|
||||
e.n_draft = s.n_draft;
|
||||
e.is_prefill = prefill;
|
||||
e.ngram = !prefill && s.draft_ngram && s.n_draft > 0;
|
||||
e.suffix = e.ngram && s.draft_suffix;
|
||||
/* A suffix chain has no model node: the coupled sampler binds no state to any row of it
|
||||
* (core/sample/sampler.cpp), whatever stale state the head's own draft for these positions
|
||||
* left. */
|
||||
r.draft_suffix = e.suffix;
|
||||
/* A tree drafter's parents, unless prompt lookup replaced its proposal with a chain. */
|
||||
e.draft_parent = (!prefill && s.draft_tree && !e.ngram) ? s.draft_par : nullptr;
|
||||
r.draft_parent = e.n_spec ? e.draft_parent : nullptr;
|
||||
@@ -2264,6 +2483,22 @@ const RadBatch* Scheduler::step() {
|
||||
: 0;
|
||||
const int as = admit_one(s, budget, areserve,
|
||||
std::max<int64_t>(0, mixed_target_shares));
|
||||
/* An idle engine that cannot start this request will not be able to on the next
|
||||
* step either: nothing is running to free a block or a slot. Fail it and ask the
|
||||
* next, instead of returning an empty plan forever (every waiter stays Waiting,
|
||||
* the GPU idles). A refusal that is only a wait for a deferred restore
|
||||
* (admit_next_step_) still waits. */
|
||||
if (idle_refuse_ && as < 0 && running_.empty() && took_.empty() && plan_.e.empty() &&
|
||||
!admit_next_step_ && s.req) {
|
||||
idle_refuse_ = false;
|
||||
RAD_WARN("request %llu failed: its prompt of %zu tokens does not fit the KV "
|
||||
"cache with nothing running (%s); a larger cache (gpu memory, "
|
||||
"kv-cache-dtype) or a shorter prompt serves it",
|
||||
(unsigned long long)s.req->id, s.req->prompt.size(), rad_strerror(as));
|
||||
close_request(s, ReqState::Failed, "idle_admission", false, true, as,
|
||||
"the prompt does not fit the KV cache with nothing running");
|
||||
continue;
|
||||
}
|
||||
/* A preempted request waiting for its whole-recompute gate lets the next one be asked;
|
||||
* an overdue one does not. The room the overdue path made this step is for it, and a
|
||||
* request queued behind it would take that room back: a victim just forced off for it,
|
||||
@@ -2272,6 +2507,10 @@ const RadBatch* Scheduler::step() {
|
||||
* waited. */
|
||||
if (as == kAdmitWait) {
|
||||
if (s.req->state == ReqState::Preempted && preempt_wait_overdue(s)) break;
|
||||
/* A fresh prompt waiting for room holds the queue behind it: shorter requests
|
||||
* admitted past it would keep taking the room it waits for, and nothing ages a
|
||||
* waiting fresh request the way an overdue preempted one is aged. */
|
||||
if (room_wait_) break;
|
||||
++at;
|
||||
continue;
|
||||
}
|
||||
@@ -2642,6 +2881,10 @@ const RadBatch* Scheduler::step_next_locked() {
|
||||
* that cannot rewind decides at commit whether the next step may speculate; one that can,
|
||||
* or no grammar, keeps its answer. */
|
||||
if (!e.produces_token || !r.speculation_fixed) return nullptr;
|
||||
/* --draft-suffix: a sequence whose history ended in a recurring pattern at the last commit
|
||||
* is likely to continue it; its next step is built after the commit, where the lookup can
|
||||
* read the committed end (a step issued ahead is made on the card from the head's drafts). */
|
||||
if (cfg_.draft_suffix && s.suffix_hot) { ++m_.suffix_held_ahead; return nullptr; }
|
||||
/* A SCORED row (Request::token_scores, a /v1/systemone question) that the step in flight
|
||||
* brings to max_tokens gets no step issued ahead: it would run a whole forward pass for a
|
||||
* request that finishes at the commit, and max_tokens=1 pays a decode step after its
|
||||
@@ -2932,6 +3175,11 @@ int Scheduler::commit(StepResult& res) {
|
||||
draft_.yield(s.adapt, now), est);
|
||||
}
|
||||
}
|
||||
if (e.suffix) {
|
||||
++m_.suffix_steps;
|
||||
m_.suffix_rows += e.n_spec;
|
||||
m_.suffix_accepted += a;
|
||||
}
|
||||
m_.draft_tokens += e.n_spec;
|
||||
m_.draft_accepted += a;
|
||||
server::sink_drafts(r.sink, e.n_spec, a);
|
||||
@@ -2939,7 +3187,16 @@ int Scheduler::commit(StepResult& res) {
|
||||
}
|
||||
s.n_draft = 0;
|
||||
r.n_draft = 0;
|
||||
s.draft_suffix = false;
|
||||
r.draft_suffix = false;
|
||||
s.entry = -1;
|
||||
/* --draft-suffix: does the history now end in a pattern that recurred? (step_next_locked) */
|
||||
if (cfg_.draft_suffix && e.produces_token && r.state == ReqState::Running) {
|
||||
int32_t buf[RAD_SCHED_MAX_SPEC];
|
||||
s.suffix_hot = r.may_speculate && suffix_propose(s, buf) > 0;
|
||||
} else {
|
||||
s.suffix_hot = false;
|
||||
}
|
||||
|
||||
/* A request the next step carries finishes now but keeps its blocks, which that step
|
||||
* writes; its commit finds the request not running and returns them. */
|
||||
|
||||
+32
-2
@@ -17,6 +17,7 @@
|
||||
#include "lookup.h"
|
||||
#include "metrics.h"
|
||||
#include "ngram.h"
|
||||
#include "suffix.h"
|
||||
#include "diag/diagnose.h"
|
||||
|
||||
#include <chrono>
|
||||
@@ -82,6 +83,8 @@ struct SchedReq {
|
||||
void drafter_reset() {
|
||||
n_draft = 0;
|
||||
draft_next = 0;
|
||||
draft_suffix = false;
|
||||
suffix_hot = false;
|
||||
conv_cursor = 0;
|
||||
draft_filled = 0;
|
||||
draft_lo = 0;
|
||||
@@ -93,6 +96,13 @@ struct SchedReq {
|
||||
DraftAdapt adapt;
|
||||
/* The proposal the step being planned carries came from prompt lookup (StepEntry::ngram). */
|
||||
bool draft_ngram = false;
|
||||
/* --draft-suffix (suffix.h): the proposal the step being planned carries is a suffix chain
|
||||
* (StepEntry::suffix); and whether the last commit left the sequence's history ending in a
|
||||
* recurring pattern, which keeps the next step from being issued ahead (it is built after the
|
||||
* commit, where the lookup can run). */
|
||||
bool draft_suffix = false;
|
||||
bool suffix_hot = false;
|
||||
SuffixIndex suffix_ix;
|
||||
/* Prompt lookup's index over prompt ++ output (ngram.h), built at the sequence's first lookup
|
||||
* and extended by each later one. It depends on the tokens alone, so preemption keeps it; it
|
||||
* is keyed by request id, so a recycled slot starts over, and a closed request frees it. */
|
||||
@@ -489,8 +499,10 @@ public:
|
||||
SchedMetrics observed_metrics() const;
|
||||
int observed_requests(ReqStat* out, int max) const;
|
||||
|
||||
/* plan_chunk's tail-checkpoint rule for each --prefix-resume mode (see the definition). */
|
||||
int64_t tail_checkpoint(int64_t target) const;
|
||||
/* plan_chunk's tail-checkpoint rule for each --prefix-resume mode (see the definition).
|
||||
* `in_step`: the snapshot is taken inside the last chunk (set_ckpt_inside), which it does not
|
||||
* split, so nearest's quarter-interval floor does not apply. */
|
||||
int64_t tail_checkpoint(int64_t target, bool in_step = false) const;
|
||||
/* The least recompute a snapshot at a shared head (CacheHit::branch_at) must save each later
|
||||
* request for the chunk split that takes it. */
|
||||
static constexpr int64_t kSharedHeadMin = 256;
|
||||
@@ -521,6 +533,10 @@ public:
|
||||
* step takes is room the experts lose for it, which on a short prompt costs more than the span
|
||||
* saves (Engine::serve). */
|
||||
void set_span_min(int64_t tokens);
|
||||
/* Whether a checkpoint may lie inside a chunk (RadBatch::ckpt_cut): the plugin snapshots
|
||||
* inside the step (RadArchProbe::ckpt_snap_ok) and the engine holds a stage for it. Set once
|
||||
* by the engine after init; false keeps every checkpoint at a chunk's end. */
|
||||
void set_ckpt_inside(bool on) { ckpt_inside_ = on; builder_.set_ckpt_cut(on); }
|
||||
/* Whether the step just planned leaves a prompt with at least the stager's smallest pass still
|
||||
* to prefill, so the next step most likely carries a chunk the stager arms for. */
|
||||
bool prefill_continues() const;
|
||||
@@ -562,13 +578,21 @@ private:
|
||||
int64_t stage_rows_ = 0;
|
||||
/* set_span_min: the shortest prefill a span is taken for, 0 for any. */
|
||||
int64_t span_min_ = 0;
|
||||
/* set_ckpt_inside */
|
||||
bool ckpt_inside_ = false;
|
||||
/* Set by admit_one when it held the admitted chunk back: what it would have taken. */
|
||||
int64_t admit_full_ = 0;
|
||||
bool admit_next_step_ = false; /* admit_one's refusal is a wait for the next step */
|
||||
bool idle_refuse_ = false; /* idle engine: this refusal will not clear by waiting */
|
||||
bool room_wait_ = false; /* the refusal is the fresh prefill's room gate */
|
||||
/* Whether this step's prefill may span (ChunkGeometry::span): set by step() for the step it
|
||||
* plans, true only for a prefill alone in its step, and read by plan_chunk. True outside a
|
||||
* step, so plan_chunk called directly answers for a span. */
|
||||
bool span_now_ = true;
|
||||
/* A request finished while others still run: the next step is planned at the shared budget,
|
||||
* not a span (step()), so that the finished conversation's next turn, which a client sends at
|
||||
* once, waits for a shared step rather than a spanned one. Consumed by that step. */
|
||||
bool finished_beside_ = false;
|
||||
IKVManager* kv_ = nullptr;
|
||||
#ifdef RAD_ENABLE_KV_ROLLBACK_TEST_HOOK
|
||||
std::function<void(uint64_t, int, int, int64_t, bool)> kv_rollback_test_hook_;
|
||||
@@ -651,6 +675,9 @@ private:
|
||||
* far the match behind the proposal runs back (NgramIndex::propose), -1 when the proposal did
|
||||
* not come from the index (--debug-draft-oracle). */
|
||||
int draft_ngram(SchedReq& s, int depth, int* match = nullptr) const;
|
||||
/* --draft-suffix: the suffix proposal for `s`'s next step, over its committed history, into
|
||||
* `out` (RAD_SCHED_MAX_SPEC entries). Returns its length, 0 for none. */
|
||||
int suffix_propose(SchedReq& s, int32_t* out, int* match = nullptr);
|
||||
/* Prompt lookup is the deployment's only drafter and --draft-window adaptive is on: its
|
||||
* proposals feed each sequence's estimate and are capped by its window, as a head's are. */
|
||||
bool lookup_adapt_ = false;
|
||||
@@ -903,6 +930,9 @@ private:
|
||||
* preempted request: after --preempt-wait-ms the scheduler reclaims cache blocks and preempts
|
||||
* a decoding runner until one of them can prefill. A runner still prefilling is not a victim. */
|
||||
bool preempted_can_prefill(const SchedReq& s) const;
|
||||
/* A fresh prefill: the whole prompt plus one decode position fits in every FULL paged group,
|
||||
* with one block past that for every running sequence. WINDOW/RING recycle. */
|
||||
bool fresh_prefill_can_fit(const SchedReq& s) const;
|
||||
bool preempt_wait_overdue(const SchedReq& s) const;
|
||||
/* Give blocks back from the prefix cache until the pool has headroom again. */
|
||||
void trim_prefix_cache();
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/* suffix.h -- SuffixDecoding's proposal for a hybrid step selector (--draft-suffix, docs/GUIDE.md).
|
||||
*
|
||||
* SuffixDecoding (Oliaro et al., arXiv 2411.04975) drafts from a suffix tree of earlier text: for
|
||||
* the longest suffix of the current context that occurred before, it expands the tokens that
|
||||
* followed, each node scored by the product of its followers' frequencies (D, the expected number of
|
||||
* accepted tokens along its path). Here the tree is the per-request one (prompt ++ output of this
|
||||
* request; no tree over other requests), reduced to what a chain needs:
|
||||
*
|
||||
* - the earlier occurrence comes from the existing NgramIndex (the --spec-ngram matcher): the
|
||||
* latest earlier occurrence of the longest recurring suffix of `min_match..min_match+3` tokens;
|
||||
* - the frequency rule comes from two count tables over `min_match`-token contexts: how often a
|
||||
* context was followed by anything, and by each token. A proposal token at depth j has
|
||||
* C_j = count(context_j + token_j) / count(context_j) with context_j the last `min_match`
|
||||
* tokens of the sequence extended by the proposal so far, and the chain is cut where its path
|
||||
* score D_j = prod C_i falls under `min_score`.
|
||||
*
|
||||
* It is a heuristic and only that: every proposed token is verified (the sampler's own draw must
|
||||
* equal it), so a collision in the tables, a stale count or a wrong match changes how many tokens a
|
||||
* step lands, never which tokens come out. The tables key on 64-bit hashes and store 32 bits of the
|
||||
* key; a clash merges two contexts' counts.
|
||||
*
|
||||
* The index is incremental: each call indexes the tokens committed since the last one, prompt
|
||||
* included at the first, so a sequence is indexed once over its lifetime. Memory is about 8 bytes a
|
||||
* token per table and per NgramIndex pattern length (4 lengths).
|
||||
*/
|
||||
#pragma once
|
||||
#include "ngram.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace rad {
|
||||
|
||||
class SuffixIndex {
|
||||
public:
|
||||
/* NgramIndex tries pattern lengths min_match .. min_match + kExtra, longest first: the proposal
|
||||
* follows the latest occurrence of the longest recurring suffix in that range. */
|
||||
enum { kExtra = 3, kMaxK = 12 };
|
||||
|
||||
/* Forget the sequence; `owner` is the request id the next lookups are for. */
|
||||
void reset(uint64_t owner = 0) {
|
||||
ix_.reset(owner);
|
||||
followed_.clear();
|
||||
follow_.clear();
|
||||
filled_ = 0;
|
||||
k_ = 0;
|
||||
}
|
||||
uint64_t owner() const { return ix_.owner(); }
|
||||
|
||||
struct Out {
|
||||
int n = 0; /* tokens proposed */
|
||||
int match = 0; /* how far the match behind the proposal runs back (>= min_match) */
|
||||
float score = 0.0f; /* D of the last proposed node: the chance the whole chain is taken */
|
||||
float expect = 0.0f; /* sum of D along the chain: expected accepted tokens */
|
||||
};
|
||||
|
||||
/* The proposal for `seq`: at most `max_rows` tokens into `out` (the index is brought up to the
|
||||
* sequence first). n == 0 when the last `min_match` tokens did not occur before, or the first
|
||||
* token's own score is under `min_score`. 1 <= min_match <= kMaxK. */
|
||||
Out propose(const TokenSeq& seq, uint64_t owner, int min_match, int max_rows, float min_score,
|
||||
int32_t* out) {
|
||||
Out r;
|
||||
if (min_match < 1 || min_match > kMaxK || max_rows < 1 || seq.size() <= min_match) return r;
|
||||
if (ix_.owner() != owner || k_ != min_match) { reset(owner); k_ = min_match; }
|
||||
const int64_t L = seq.size();
|
||||
if (L < filled_) { reset(owner); k_ = min_match; }
|
||||
index_to(seq, L);
|
||||
int match = 0;
|
||||
const int n = ix_.propose(seq, min_match, min_match + kExtra, max_rows, out, &match, 64);
|
||||
if (n <= 0) return r;
|
||||
/* Score the chain: the context moves forward over the proposal's own tokens. */
|
||||
int32_t win[kMaxK];
|
||||
for (int i = 0; i < k_; ++i) win[i] = seq[L - k_ + i];
|
||||
float d = 1.0f, sum = 0.0f;
|
||||
int m = 0;
|
||||
for (; m < n; ++m) {
|
||||
const uint64_t h = hash_ctx(win, k_);
|
||||
const uint32_t a = followed_.get(h);
|
||||
const uint32_t b = follow_.get(mix(h, (uint64_t)(uint32_t)out[m]));
|
||||
if (a == 0 || b == 0) break; /* a path the history never took */
|
||||
const float c = (float)b / (float)a;
|
||||
if (d * c < min_score) break;
|
||||
d *= c;
|
||||
sum += d;
|
||||
for (int i = 0; i + 1 < k_; ++i) win[i] = win[i + 1];
|
||||
win[k_ - 1] = out[m];
|
||||
}
|
||||
r.n = m;
|
||||
r.match = match;
|
||||
r.score = m > 0 ? d : 0.0f;
|
||||
r.expect = sum;
|
||||
return r;
|
||||
}
|
||||
|
||||
int64_t indexed() const { return filled_; }
|
||||
size_t bytes() const { return ix_.bytes() + (followed_.t.capacity() + follow_.t.capacity()) * 8; }
|
||||
|
||||
private:
|
||||
/* Open addressing; an entry is key (the high 32 bits of a 64-bit hash, never 0) << 32 | count.
|
||||
* The probe starts from the stored key, so a rehash needs nothing else. */
|
||||
struct Table {
|
||||
std::vector<uint64_t> t;
|
||||
uint64_t mask = 0;
|
||||
int64_t n = 0;
|
||||
void clear() { t.clear(); t.shrink_to_fit(); mask = 0; n = 0; }
|
||||
static uint32_t key_of(uint64_t h) { return (uint32_t)(h >> 32) | 1u; }
|
||||
static uint64_t start(uint32_t key) { return ((uint64_t)key * 0x9e3779b97f4a7c15ull) >> 29; }
|
||||
uint32_t get(uint64_t h) const {
|
||||
if (t.empty()) return 0;
|
||||
const uint32_t key = key_of(h);
|
||||
for (uint64_t i = start(key) & mask;; i = (i + 1) & mask) {
|
||||
const uint64_t e = t[i];
|
||||
if (e == 0) return 0;
|
||||
if ((uint32_t)(e >> 32) == key) return (uint32_t)e;
|
||||
}
|
||||
}
|
||||
void bump(uint64_t h) {
|
||||
if (t.empty() || (uint64_t)(n + 1) * 2 > mask + 1) grow();
|
||||
const uint32_t key = key_of(h);
|
||||
for (uint64_t i = start(key) & mask;; i = (i + 1) & mask) {
|
||||
uint64_t& e = t[i];
|
||||
if (e == 0) { e = (uint64_t)key << 32 | 1u; ++n; return; }
|
||||
if ((uint32_t)(e >> 32) == key) { if ((uint32_t)e != 0xffffffffu) ++e; return; }
|
||||
}
|
||||
}
|
||||
void grow() {
|
||||
std::vector<uint64_t> old;
|
||||
old.swap(t);
|
||||
const uint64_t cap = old.empty() ? 1024 : (mask + 1) * 2;
|
||||
t.assign(cap, 0);
|
||||
mask = cap - 1;
|
||||
for (uint64_t e : old) {
|
||||
if (!e) continue;
|
||||
for (uint64_t i = start((uint32_t)(e >> 32)) & mask;; i = (i + 1) & mask)
|
||||
if (t[i] == 0) { t[i] = e; break; }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NgramIndex ix_;
|
||||
Table followed_; /* a k-token context -> how many times anything followed it */
|
||||
Table follow_; /* a k-token context and a token -> how many times that token did */
|
||||
int64_t filled_ = 0; /* positions < filled_ are counted */
|
||||
int k_ = 0;
|
||||
|
||||
static uint64_t mix(uint64_t h, uint64_t v) {
|
||||
h ^= v + 0x9e3779b97f4a7c15ull + (h << 6) + (h >> 2);
|
||||
h *= 0xff51afd7ed558ccdull;
|
||||
h ^= h >> 32;
|
||||
return h;
|
||||
}
|
||||
static uint64_t hash_ctx(const int32_t* t, int k) {
|
||||
uint64_t h = 0x84222325cbf29ce4ull;
|
||||
for (int i = 0; i < k; ++i) h = mix(h, (uint64_t)(uint32_t)t[i]);
|
||||
return h;
|
||||
}
|
||||
/* Count, for every position e in [filled_, upto) with k tokens before it, the context
|
||||
* seq[e-k..e-1] followed by seq[e]. */
|
||||
void index_to(const TokenSeq& seq, int64_t upto) {
|
||||
int32_t win[kMaxK];
|
||||
for (int64_t e = filled_ < k_ ? k_ : filled_; e < upto; ++e) {
|
||||
for (int i = 0; i < k_; ++i) win[i] = seq[e - k_ + i];
|
||||
const uint64_t h = hash_ctx(win, k_);
|
||||
followed_.bump(h);
|
||||
follow_.bump(mix(h, (uint64_t)(uint32_t)seq[e]));
|
||||
}
|
||||
filled_ = upto;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace rad */
|
||||
+38
-6
@@ -127,6 +127,8 @@ inline SchedMetrics bridge_metrics(const rad::SchedMetrics& m) {
|
||||
o.draft_refills = m.draft_refills; o.draft_refill_tokens = m.draft_refill_tokens;
|
||||
o.lookup_proposals = m.lookup_proposals; o.lookup_held = m.lookup_held;
|
||||
o.lookup_held_drafts = m.lookup_held_drafts; o.lookup_held_hits = m.lookup_held_hits;
|
||||
o.suffix_steps = m.suffix_steps; o.suffix_rows = m.suffix_rows;
|
||||
o.suffix_accepted = m.suffix_accepted; o.suffix_held_ahead = m.suffix_held_ahead;
|
||||
o.linear_hit_rate = m.linear_hit_rate;
|
||||
o.attn_cached_tokens = m.attn_cached_tokens;
|
||||
o.linear_cached_tokens = m.linear_cached_tokens;
|
||||
@@ -526,12 +528,6 @@ public:
|
||||
* derive it from the template. A declaration the parser cannot run is refused at startup. */
|
||||
int init(const Vocab& v, const RadChatFormat* declared = nullptr,
|
||||
const std::string& plugin = std::string()) {
|
||||
/* The spellings, resolved once. See ReplyOptions::terminators. */
|
||||
terminators_.clear();
|
||||
for (int32_t id : v.eog()) {
|
||||
const std::string s = v.text(id);
|
||||
if (!s.empty()) terminators_.push_back(s);
|
||||
}
|
||||
const int st = t_.load_from_vocab(v);
|
||||
if (st < 0) return st;
|
||||
|
||||
@@ -569,9 +565,45 @@ public:
|
||||
RAD_INFO("chat: reply format %s", chat_format_describe(f).c_str());
|
||||
if (t_.caps().tools && !tool_refusal_.empty())
|
||||
RAD_WARN("chat: tool calls are refused for this model: %s", tool_refusal_.c_str());
|
||||
|
||||
/* The spellings, resolved once. See ReplyOptions::terminators. */
|
||||
terminators_.clear();
|
||||
for (int32_t id : v.eog()) {
|
||||
const std::string s = v.text(id);
|
||||
if (!s.empty()) terminators_.push_back(s);
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* The end-of-generation ids of `v` whose spelling is a marker of the reply format `v` is
|
||||
* served with: `declared` (the architecture plugin's) or the one its template yields. A
|
||||
* checkpoint can list its tool-call close in generation_config.json's eos ids; a turn ending
|
||||
* there cannot write a second call or the text after one, and a reply quoting the tag is cut
|
||||
* at it. The format says what the model writes as a call boundary, so the engine takes these
|
||||
* ids out of the vocabulary's set at bring-up (Vocab::drop_named_eog), before the scheduler,
|
||||
* the cards' step state, the grammar index and this bridge's terminators are built from it.
|
||||
* Empty for a model without tool calls or a format that cannot be read. Logs nothing. */
|
||||
static std::vector<int32_t> eog_call_markers(const Vocab& v, const RadChatFormat* declared) {
|
||||
ChatFormat f;
|
||||
std::string why, refused;
|
||||
if (declared) {
|
||||
if (chat_format_from_abi(declared, &f, &why) < 0 || chat_format_check(f, &why) < 0)
|
||||
return {};
|
||||
} else {
|
||||
const std::string bos = v.bos() >= 0 ? v.text(v.bos()) : std::string();
|
||||
const std::string eos = v.eos() >= 0 ? v.text(v.eos()) : std::string();
|
||||
if (chat_format_from_template(v.chat_template(), bos, eos, &f, &refused, &why) < 0)
|
||||
return {};
|
||||
}
|
||||
std::vector<int32_t> out;
|
||||
if (!f.has_tools()) return out;
|
||||
for (const std::string& m : chat_format_markers(f))
|
||||
for (int32_t id : v.eog())
|
||||
if (v.text(id) == m && std::find(out.begin(), out.end(), id) == out.end())
|
||||
out.push_back(id);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool ready() const { return t_.ready() && fmt_ != nullptr; }
|
||||
bool supports_tools() const override { return t_.caps().tools; }
|
||||
std::string tools_probe_error() const override { return t_.caps().probe_error; }
|
||||
|
||||
+22
-5
@@ -262,7 +262,7 @@ HttpResponse Server::handle_detokenize(const HttpRequest& req) {
|
||||
* Only what this server can fill honestly, under llama-server's names: no GGUF metadata, no
|
||||
* per-slot state. n_ctx is the context one request may use (llama-server's per-slot n_ctx);
|
||||
* omitted when the context length is unknown. */
|
||||
HttpResponse Server::handle_props(const HttpRequest&) {
|
||||
HttpResponse Server::handle_props(const HttpRequest& req) {
|
||||
const SamplingParams& sp = opt_.default_sampling;
|
||||
/* Every field llama-server's `params` carries, so no client finds one missing. Samplers this
|
||||
* server does not run are reported at their off values, which is what it serves. */
|
||||
@@ -333,12 +333,21 @@ HttpResponse Server::handle_props(const HttpRequest&) {
|
||||
o["default_generation_settings"] = std::move(gen);
|
||||
o["total_slots"] = opt_.max_seqs;
|
||||
o["model_alias"] = opt_.model_id;
|
||||
o["model_path"] = opt_.model_path;
|
||||
/* A path on this machine: it travels the way /v1/models' `root` does -- keyless it belongs
|
||||
* to the operator alone, with a key it rides with the key. The compatibility shape keeps
|
||||
* the field; a stranger sees it empty, which is also what a --model stdin read is. */
|
||||
o["model_path"] = (!opt_.api_key.empty() || local_operator(req)) ? opt_.model_path
|
||||
: std::string();
|
||||
o["modalities"] = std::move(modal);
|
||||
o["endpoint_slots"] = false;
|
||||
o["endpoint_props"] = false;
|
||||
o["endpoint_metrics"] = true;
|
||||
o["chat_template"] = deps_.chat ? deps_.chat->source() : std::string();
|
||||
/* The template's source text is the container's own bytes, gated like model_path above;
|
||||
* a keyless stranger has no reader for it anyway. The capability flags stay -- a client
|
||||
* needs them to build a request, and they name no path and quote no source. */
|
||||
o["chat_template"] = (deps_.chat && (!opt_.api_key.empty() || local_operator(req)))
|
||||
? deps_.chat->source()
|
||||
: std::string();
|
||||
o["chat_template_caps"] = json::parse(deps_.chat ? deps_.chat->caps() : std::string("{}"),
|
||||
nullptr, false);
|
||||
std::string bos, eos;
|
||||
@@ -432,7 +441,7 @@ json Server::capabilities() const {
|
||||
* state, plus the engine's, pre-rendered because the server knows nothing about devices,
|
||||
* containers or placement (ServerOptions::engine_info). `endpoints` is the router's own table, so
|
||||
* it cannot go stale. */
|
||||
HttpResponse Server::handle_server_info(const HttpRequest&) {
|
||||
HttpResponse Server::handle_server_info(const HttpRequest& req) {
|
||||
json srv;
|
||||
srv["model"] = opt_.model_id;
|
||||
srv["version"] = opt_.version;
|
||||
@@ -499,8 +508,16 @@ HttpResponse Server::handle_server_info(const HttpRequest&) {
|
||||
json e = json::parse(opt_.engine_info, nullptr, false);
|
||||
if (e.is_discarded() || !e.is_object())
|
||||
RAD_WARN("server: engine_info is not a JSON object; /server_info omits it");
|
||||
else
|
||||
else {
|
||||
/* One member names a file on this machine -- expert_stats.file, the xstats output,
|
||||
* the same path the model card strips for strangers (server.cpp). /server_info
|
||||
* answers keyless by the dashboard-data posture, but a filesystem path is not
|
||||
* dashboard data: a stranger gets the interval, never the path. */
|
||||
if (opt_.api_key.empty() && !local_operator(req) && e.contains("expert_stats") &&
|
||||
e["expert_stats"].is_object())
|
||||
e["expert_stats"].erase("file");
|
||||
o["engine"] = std::move(e);
|
||||
}
|
||||
}
|
||||
metrics_.observe_http(200);
|
||||
return HttpResponse::json_body(200, json_dump(o));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
/* A digest of dashboard/'s sources as of this build of the page. */
|
||||
static const char* const kPageSources = "6e4b952a7acd6ebb56a321f90011faeb0f937f2538dbc76c804a068186a2198e";
|
||||
static const char* const kPageSources = "93afcbaf107a061ecf987dd8a1a4f40c39eb239337673775d5cb61e28b25c1dc";
|
||||
|
||||
/* Every field the page reads of a route's object, as "object.field": the members of the
|
||||
* interfaces in dashboard/src/lib/api.ts, which the page's compiler holds it to. Ends with null. */
|
||||
@@ -128,35 +128,35 @@ R"RADPAGE(tionReference(e.current),Ee.current=e.current)},[g,K,j,M]),_.useEffect
|
||||
R"RADPAGE(ed:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=kl({disabled:i,focusableWhenDisabled:a,native:o});return Ca(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});function Nl(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Nl(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Pl(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Nl(e))&&(r&&(r+=` `),r+=t);return r}var Fl=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Il=Pl,Ll=(e,t)=>n=>{if(t?.variants==null)return Il(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Fl(t)||Fl(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Il(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Rl=Ll(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function zl({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,W.jsx)(Ml,{"data-slot":`button`,className:J(Rl({variant:t,size:n,className:e})),...r})}var Bl=_.createContext(void 0);function Vl(e){let t=_.useContext(Bl);if(!e&&t===void 0)throw Error(mt(27));return t}var Hl=_.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Vl(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Ca(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:jn,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Ul=_.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=Vl(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=kl({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Kn(Qn,e.nativeEvent))}return Ca(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),Wl=_.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Vl(),c=Ec(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Ca(`p`,e,{ref:t,props:[{id:c},o]})}),Gl=_.createContext(void 0);function Kl(){let e=_.useContext(Gl);if(e===void 0)throw Error(mt(26));return e}var ql=`ArrowUp`,Jl=`ArrowDown`,Yl=`ArrowLeft`,Xl=`ArrowRight`,Zl=new Set([ql,Jl,YLine truncated
|
||||
R"RADPAGE(ock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=Or(e),n=t.documentElement,r=t.body,i=Ut(n);if(mu(i,n,r)){let t=new i.MutationObserver(()=>{mu(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Dt||!hu(e);this.restore=a?_u(e):vu(e)}};function bu(e=!0,t=null){Y(()=>{if(e)return yu.acquire(t)},[e,t])}function xu({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=_.useState(0),[d,f]=_.useState(0),p=l===0,m=ao(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=mn(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Z(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return bu(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),Y(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Y(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),Do(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var Su={...Zo,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Cu=class extends Ho{constructor(e,t,n){let r=new ko,i=wu(e,r,t,n);super(i,Tu(r),Su)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled||(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(xo(this.state,e,t.trigger)))}};function wu(e,t,n,r=!1){return{...Go(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function Tu(e){return{popupRef:_.createRef(),backdropRef:_.createRef(),internalBackdropRef:_.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Eu(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,v=m?`alertdialog`:`dialog`,y=Vl(!0),b={modal:h,disablePointerDismissal:g,nested:y!=null,role:v},x=_o((e,t)=>new Cu({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,d),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);Oo(x,S),To(x);let{forceUnmount:T}=Eo(S,x);_.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,Kn(ir))}),[T,x]);let E=S||C||u!=null;return(0,W.jsxs)(Bl.Provider,{value:x,children:[u&&(0,W.jsx)(vo,{handle:u,store:x}),E&&(0,W.jsx)(xu,{store:x,parentContext:y?.context,isDrawer:p}),typeof n==`function`?n({payload:w}):n]})}var Du=st(function(e){return Eu(`dialog`,e)}),Ou=_.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Vl(),c=Ec(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Ca(`h2`,e,{ref:t,props:[{id:c},o]})});function ku(e,t){let n=_.useRef(e),r=Q(t);Y(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Au({...e}){return(0,W.jsx)(Du,{"data-slot":`dialog`,...e})}function ju({...e}){return(0,W.jsx)(lu,{"data-slot":`dialog-portal`,...e})}function Mu({className:e,...t}){return(0,W.jsx)(Hl,{"data-slot":`dialog-overlay`,className:J(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Nu({className:e,children:t,showCloseButton:n=!0,...r}){return(0,W.jsxs)(ju,{children:[(0,W.jsx)(Mu,{}),(0,W.jsxs)(su,{Line truncated
|
||||
R"RADPAGE(,...t}){return(0,W.jsx)(Hl,{"data-slot":`sheet-overlay`,className:J(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,e),...t})}function dd({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,W.jsxs)(ld,{children:[(0,W.jsx)(ud,{}),(0,W.jsxs)(su,{"data-slot":`sheet-content`,"data-side":n,className:J(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,e),...i,children:[t,r&&(0,W.jsxs)(Ul,{"data-slot":`sheet-close`,render:(0,W.jsx)(zl,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,W.jsx)(U,{}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function fd({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sheet-header`,className:J(`flex flex-col gap-0.5 p-4`,e),...t})}function pd({className:e,...t}){return(0,W.jsx)(Ou,{"data-slot":`sheet-title`,className:J(`font-heading text-base font-medium text-foreground`,e),...t})}function md({className:e,...t}){return(0,W.jsx)(Wl,{"data-slot":`sheet-description`,className:J(`text-sm text-muted-foreground`,e),...t})}var hd=`sidebar_state`,gd=604800,_d=`16rem`,vd=`18rem`,yd=`3rem`,bd=`b`,xd=_.createContext(null);function Sd(){let e=_.useContext(xd);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Cd({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=sd(),[c,l]=_.useState(!1),[u,d]=_.useState(e),f=t??u,p=_.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${hd}=${t}; path=/; max-age=${gd}`},[n,f]),m=_.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]);_.useEffect(()=>{let e=e=>{e.key===bd&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let h=f?`expanded`:`collapsed`,g=_.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,W.jsx)(xd.Provider,{value:g,children:(0,W.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":_d,"--sidebar-width-icon":yd,...i},className:J(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function wd({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,dir:a,...o}){let{isMobile:s,state:c,openMobile:l,setOpenMobile:u}=Sd();return n===`none`?(0,W.jsx)(`div`,{"data-slot":`sidebar`,className:J(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...o,children:i}):s?(0,W.jsx)(cd,{open:l,onOpenChange:u,...o,children:(0,W.jsxs)(dd,{dir:a,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":vd},side:e,children:[(0,W.jsxs)(fd,{className:`sr-only`,children:[(0,W.jsx)(pd,{children:`Sidebar`}),(0,W.jsx)(md,{children:`Displays the mobile sidebar.`})]}),(0,W.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,W.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":c,"data-collapsible":c===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,W.jsx)(`div`,{"data-slot":`sidebar-gap`,className:J(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,W.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":e,className:J(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[leLine truncated
|
||||
R"RADPAGE(ate:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var Kd=_.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=Ec(u||void 0),h=Bd(),g=h?.value??[],v=(i||h?.disabled)??!1,[y,b]=Rd({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:x,buttonRef:S}=kl({disabled:v,native:d}),C={disabled:v,pressed:y},w=[S,t],T=[{"aria-pressed":y,onClick(e){let t=!y,n=Kn(qn,e.nativeEvent);o?.(t,n),n.isCanceled||(m&&h?.setGroupValue?.(m,t,n),n.isCanceled||b(t))}},p,x],E=Ca(`button`,e,{enabled:!h,state:C,ref:w,props:T}),D=_.useMemo(()=>({disabled:v,focusableWhenDisabled:!1}),[v]);return h?(0,W.jsx)(Gd,{tag:`button`,render:c,className:n,style:f,metadata:D,state:C,refs:w,props:T}):E});function qd(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=_.useState(0),s=nt(Yd).current,c=nt(Jd).current,l=_.useRef(0),u=_.useRef(!0),d=_.useRef(null),f=_.useRef(null),p=Q(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Q((e,t)=>{c.set(e,t),p()}),h=Q(e=>{c.delete(e),p()}),g=Q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function v(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Qd(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&$d(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Zd(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=Q(()=>{let[e,t]=Xd(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});v(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&y()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=Q(e=>(s.add(e),()=>{s.delete(e)})),x=_.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,W.jsx)(Vd.Provider,{value:x,children:t})}function Jd(){return new Map}function Yd(){return new Set}function Xd(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>$d(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Zd(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Qd(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function $d(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ef(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var tf=`data-composite-item-active`;function nf(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=dt}=e,[p,m]=_.useState(0),h=r!=null,g=_.useRef(null),v=dr(g,c),y=_.useRef([]),b=_.useRef(!1),x=_.useRef(null),S=o??p,C=Q((e,t=!1)=>{if(x.current=y.current[e]??null,(s??m)(e),t){let t=y.current[e];tu(g.current,t,a,n)}}),w=Q(e=>{if(e.size===0)return;if(b.current){let e=y.current,t=e.indexOf(x.current);if(t===-1){let t=e[S];!t||ui(e,S,d)?C(rf(e,d)):x.current=t}else t!==S&&C(t);return}b.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(ui(t,S,d)){let e=li(t,{disabledIndices:d});oi(t,e)||C(e)}tu(g.current,r,a,n)});Y(()=>{if(d==null||o!=null||!b.current)return;let e=y.current;if(ui(e,S,d)){let t=li(e,{disabledIndices:d});oi(e,t)||C(t)}},[d,o,S,y,C]);let T=Q((e,t,n)=>i?i(e,t,n,y):n),E=Q(e=>{let o=e.key===`Home`||e.key===`End`;if(!Zl.has(e.key)||!l&&o||af(e,f)||!g.current)return;let s=a===`rtl`,c=s?Yl:Xl,p=s?Xl:Yl,m=n===`vertical`?Jl:c,_=n===`vertical`?ql:p,v=mn(e.nativeEvent);if(v!=null&&eu(v)&&!ef(v)){let t=v.selectionStart,n=v.selectionEnd,r=v.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=si(y,d),w=ci(y,d);r!=null&&(b=r({disabledIndices:d,elementsRef:y,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:T,orientation:n,rtl:s}));let Line truncated
|
||||
R"RADPAGE(clearInterval(o)}},[e,t]),{data:e?Cf.get(e)??null:null,error:r}}var Tf=e=>typeof e==`number`&&Number.isFinite(e);function Ef(e){if(!Tf(e))return`–`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=Math.abs(e);for(;r>=1024&&n<t.length-1;)r/=1024,++n;let i=r>=100||n===0?r.toFixed(0):r>=10?r.toFixed(1):r.toFixed(2);return(e<0?`-`:``)+i+` `+t[n]}function Df(e){let t=Ef(e);if(t===`–`)return[`–`,``];let n=t.lastIndexOf(` `);return[t.slice(0,n),t.slice(n+1)]}var Of=e=>Tf(e)?Ef(e)+`/s`:`–`;function $(e,t=0){return Tf(e)?e.toLocaleString(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}):`–`}function kf(e){if(!Tf(e))return`–`;let t=Math.abs(e);return t>=100?$(e,0):t>=10?$(e,1):$(e,2)}var Af=(e,t=1)=>Tf(e)?(e*100).toFixed(t):`–`;function jf(e){return Tf(e)?e<1?Math.round(e*1e3)+` ms`:e<60?(e<10?e.toFixed(1):e.toFixed(0))+` s`:e<3600?Math.floor(e/60)+` m `+String(Math.floor(e%60)).padStart(2,`0`)+` s`:e<86400?Math.floor(e/3600)+` h `+String(Math.floor(e%3600/60)).padStart(2,`0`)+` m`:Math.floor(e/86400)+` d `+Math.floor(e%86400/3600)+` h`:`–`}function Mf(e,t=!1){let n=new Date(e*1e3),r=e=>String(e).padStart(2,`0`);return r(n.getHours())+`:`+r(n.getMinutes())+(t?`:`+r(n.getSeconds()):``)}function Nf(e,t){return jf(Math.max(0,(t-e)/1e3))+` ago`}var Pf=3600,Ff=200,If=class{t=[];c=new Map;append(e,t){let n=0;for(;n<e.length&&e[n]<=this.end;)++n;if(n===e.length)return;let r=this.t.length;for(let t=n;t<e.length;++t)this.t.push(e[t]);let i=this.t.length;for(let[e,i]of Object.entries(t)){let t=this.c.get(e);t||(t=Array(r).fill(null),this.c.set(e,t));for(let e=n;e<i.length;++e)t.push(i[e])}for(let e of this.c.values())for(;e.length<i;)e.push(null);let a=this.firstAfter(this.t[i-1]-Pf);if(a>64){this.t.splice(0,a);for(let e of this.c.values())e.splice(0,a)}}firstAfter(e){let t=0,n=this.t.length;for(;t<n;){let r=t+n>>1;this.t[r]<=e?t=r+1:n=r}return t}col(e){return this.c.get(e)}has(e){let t=this.c.get(e);return!!t&&t.some(e=>e!==null)}last(e,t=300){let n=this.c.get(e);if(n){for(let e=n.length-1;e>=0&&e>=n.length-t;--e)if(n[e]!==null)return n[e]}return null}get end(){return this.t.length?this.t[this.t.length-1]:0}},Lf=class{series=new If;live=null;finished=[];loaded=!1;error=null;refused=!1;version=0;path;subs=new Set;timer;busy=!1;users=0;constructor(e){this.path=e}subscribe=e=>(this.subs.add(e),++this.users===1&&this.start(),()=>{this.subs.delete(e),--this.users===0&&this.stop()});getVersion=()=>this.version;start(){this.poll(),this.timer=window.setInterval(()=>{document.hidden||this.poll()},Ff),document.addEventListener(`visibilitychange`,this.onVisible)}stop(){window.clearInterval(this.timer),document.removeEventListener(`visibilitychange`,this.onVisible)}onVisible=()=>{document.hidden||this.poll()};async poll(){if(!(this.busy||this.refused)){this.busy=!0;try{let e=this.series.end,t=this.path.includes(`?`)?`&`:`?`,n=await xf(this.path+(e?t+`since=`+e:``));if(this.series.append(n.t,n.c),n.requests?.length){let e=new Set(this.finished.slice(-64).map(e=>e.id+`:`+e.at));for(let t of n.requests)e.has(t.id+`:`+t.at)||this.finished.push(t);this.finished.length>500&&this.finished.splice(0,this.finished.length-500)}this.live=n.live,this.loaded=!0,this.error=null}catch(e){this.error=e instanceof Error?e.message:String(e),e instanceof bf&&e.status===403&&(this.refused=!0)}finally{this.busy=!1,++this.version,this.subs.forEach(e=>e())}}}},Rf=new Lf(`history`),zf=new Map;function Bf(e){let t=zf.get(e);return t||(t=new Lf(Sf(`history`,e)),zf.set(e,t)),t}function Vf(e){return(0,_.useSyncExternalStore)(e.subscribe,e.getVersion),e}function Hf(e){let t=e,n=new Set;return{get:()=>t,set(e){e!==t&&(t=e,n.forEach(e=>e()))},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}var Uf=e=>{try{return localStorage.getItem(e)}catch{return null}},Wf=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},Gf=Hf(document.documentElement.classList.contains(`dark`)?`dark`:`light`);function Kf(e){document.documentElement.classList.toggle(`dark`,e===`dark`),Wf(`radiance.theme`,e),Gf.set(e)}var qf=()=>(0,_.useSyncExternalStore)(Gf.subscribe,Gf.get),Jf=[[60,`1m`],[300,`5m`],[900,`15m`],[3600,`1h`]],Yf=Number(Uf(`radiance.range`)),Xf=Hf(Jf.some(([e])=>e===Yf)?Yf:300);function Zf(e){Wf(`radiance.range`,String(e)),Xf.set(e)}var Qf=()=>(0,_.useSyncExternalStore)(Xf.subscribe,Xf.get),$f=[`performance`,`requests`,`sessions`,`details`];function ep(){let e=/^#\/m\/([^/]+)(?:\/([a-z]+))?/.exec(location.hash);if(!e)return{model:null,tab:`performance`};let t=$f.includes(e[2])?e[2]:`performance`;return{model:decodeURIComponent(e[1]),tab:t}}var tp=ep(),np=new Set;window.addEventListener(`hashchange`,()=>{tp=ep(),np.forEach(e=>e())});var rp=()=>(0,_.useSyncExternalStore)(e=>(np.add(e),()=>{np.delete(e)}),()=>tp),ip=(e,t=`performance`)=>e===null?`#/`:`#/m/`+encodeURIComponent(e)+`/`+t,ap=_.createContext(void 0);function op(){let e=_.useContext(ap);if(e===void 0)throw Error(mt(64));return e}var sp=`data-activation-direction`,cp={tabActivationDirection:e=>({[sp]:e})Line truncated
|
||||
R"RADPAGE( [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function bp({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,W.jsx)(`table`,{"data-slot":`table`,className:J(`w-full caption-bottom text-sm`,e),...t})})}function xp({className:e,...t}){return(0,W.jsx)(`thead`,{"data-slot":`table-header`,className:J(`[&_tr]:border-b`,e),...t})}function Sp({className:e,...t}){return(0,W.jsx)(`tbody`,{"data-slot":`table-body`,className:J(`[&_tr:last-child]:border-0`,e),...t})}function Cp({className:e,...t}){return(0,W.jsx)(`tr`,{"data-slot":`table-row`,className:J(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function wp({className:e,...t}){return(0,W.jsx)(`th`,{"data-slot":`table-head`,className:J(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function Tp({className:e,...t}){return(0,W.jsx)(`td`,{"data-slot":`table-cell`,className:J(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}var Ep=_.createContext(void 0);function Dp(){let e=_.useContext(Ep);if(e===void 0)throw Error(mt(63));return e}var Op=`data-checked`,kp=`data-unchecked`,Ap={...Hu,checked(e){return e?{[Op]:``}:{[kp]:``}}},jp=_.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:v,style:y,...b}=e,{clearErrors:x}=qu(),{state:S,setTouched:C,setDirty:w,validityData:T,setFilled:E,validationMode:D,disabled:O,name:k,validation:A}=Gu(),{labelId:j}=Yu(),M=O||m,N=k??l,P=_.useRef(null),F=dr(P,c,A.inputRef),I=_.useRef(null),L=ed(M,I),R=Ec(),z=$u({id:s}),B=u?void 0:z,[V,ee]=Rd({controlled:n,default:!!i,name:`Switch`,state:`checked`});td(I,R,V,void 0,!M,l),Y(()=>{E(V)},[V,E]),ku(V,()=>{x(N),w(V!==T.initialValue),A.change(V)});let{getButtonProps:H,buttonRef:te}=kl({disabled:M,native:u}),ne=Xu(a,j,P,!u,B,b[`aria-label`]),U={id:u?z:R,role:`switch`,"aria-checked":V,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":ne,onFocus(){L(!0)},onBlur(){let e=P.current;e&&!M&&(C(!0),L(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){if(f||M)return;e.preventDefault();let t=P.current;t&&Ol(t,e)}},re={...A.getValidationProps(M),checked:V,disabled:M,form:o,id:B,name:N,required:p,style:N?jr:Ar,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Kn(qn,e.nativeEvent);d?.(t,n),n.isCanceled||ee(t)},onClick(e){e.stopPropagation()},onFocus(){I.current?.focus()},...v===void 0?ft:{value:v}},ie=_.useMemo(()=>({...S,checked:V,disabled:M,readOnly:f,required:p}),[S,V,M,f,p]),ae=Ca(`span`,e,{state:ie,ref:[t,I,te],props:[U,b,H,e=>A.getValidationProps(M,e)],stateAttributesMapping:Ap});return(0,W.jsxs)(Ep.Provider,{value:ie,children:[ae,!V&&N&&g!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,form:o,name:N,value:g,disabled:M}),(0,W.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),Mp=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Ca(`span`,e,{state:Dp(),ref:t,stateAttributesMapping:Ap,props:a})});function Np({className:e,size:t=`default`,...n}){return(0,W.jsx)(jp,{"data-slot":`switch`,"data-size":t,className:J(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-dLine truncated
|
||||
R"RADPAGE(assName:`num text-right`,children:$(e.kernels)}),(0,W.jsx)(Tp,{className:`pr-4 text-muted-foreground`,children:e.build_target??`–`})]},e.name))})]})}),(n.notes?.length??0)>0&&(0,W.jsx)(hl,{title:`Notes`,description:`Messages from the model plugin during setup`,children:(0,W.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:n.notes.map((e,t)=>(0,W.jsx)(`li`,{className:`border-l-2 pl-3 leading-snug`,children:e},t))})})]}),(0,W.jsx)(cd,{open:!!s,onOpenChange:e=>{e||c(null)},children:(0,W.jsx)(dd,{className:`w-full gap-0 overflow-y-auto sm:max-w-xl`,children:s&&(0,W.jsx)(Rp,{op:s})})})]})}function Lp({model:e}){let[t,n]=(0,_.useState)(null),r=()=>{xf(Sf(`admin/control-vector`,e)).then(n).catch(()=>n(null))};return(0,_.useEffect)(r,[e]),t?(0,W.jsxs)(`label`,{className:`flex items-center gap-3 rounded-xl border bg-card px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Control vector`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted-foreground`,children:t.name??``}),(0,W.jsx)(Np,{checked:!!t.default,onCheckedChange:i=>{n({...t,default:i}),xf(Sf(`admin/control-vector`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:i})}).catch(()=>void 0).finally(r)}})]}):null}function Rp({op:e}){let t=Pp(e),n=[[`Geometry`,e.geometry],[`Launches per pass`,$(e.count??1)],[`Range`,e.ranged?`${e.ranged} from ${e.range_lo} to ${e.range_hi}`:void 0],[`Kernel`,t?.kernel],[`Library`,t?.plugin],[`Computes`,t?.computes],[`Shapes`,t?.shape],[`Types`,t?.dtypes],[`Requires`,t?.constraints?.length?t.constraints.join(`; `):void 0]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(fd,{children:[(0,W.jsx)(pd,{children:e.op}),(0,W.jsx)(md,{children:e.schema?.doc??`Op `+e.index})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-6`,children:[(0,W.jsx)(`dl`,{className:`grid grid-cols-[8rem_1fr] gap-x-3 gap-y-2 text-sm`,children:n.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`contents`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`min-w-0 break-words font-mono text-xs leading-5`,children:t})]},e))}),(e.weights?.length??0)>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`Weights`}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:e.weights.slice(0,24).map(e=>(0,W.jsxs)(`div`,{className:`flex items-baseline gap-3 border-b px-3 py-1.5 text-xs last:border-b-0`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.dtype,` · `,e.shape]}),(0,W.jsx)(`span`,{className:`num w-20 text-right`,children:Ef(e.bytes)})]},e.name))})]}),(e.bands?.length??0)>1&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`By size`}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:e.bands.map(e=>(0,W.jsxs)(`div`,{className:`flex items-baseline gap-3 border-b px-3 py-1.5 text-xs last:border-b-0`,children:[(0,W.jsx)(`span`,{className:`num w-28 text-muted-foreground`,children:e.span}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:(e.device??e.host)?.kernel??`–`})]},e.span))})]})]})]})}var zp=!0,Bp=`uplot`,Vp=`u-hz`,Hp=`u-vt`,Up=`u-title`,Wp=`u-wrap`,Gp=`u-under`,Kp=`u-over`,qp=`u-axis`,Jp=`u-off`,Yp=`u-select`,Xp=`u-cursor-x`,Zp=`u-cursor-y`,Qp=`u-cursor-pt`,$p=`u-legend`,em=`u-live`,tm=`u-inline`,nm=`u-series`,rm=`u-marker`,im=`u-label`,am=`u-value`,om=`width`,sm=`height`,cm=`top`,lm=`bottom`,um=`left`,dm=`right`,fm=`#000`,pm=`#0000`,mm=`mousemove`,hm=`mousedown`,gm=`mouseup`,_m=`mouseenter`,vm=`mouseleave`,ym=`dblclick`,bm=`resize`,xm=`scroll`,Sm=`change`,Cm=`dppxchange`,wm=`--`,Tm=typeof window<`u`,Em=Tm?document:null,Dm=Tm?window:null,Om=Tm?navigator:null,km,Am;function jm(){let e=devicePixelRatio;km!=e&&(km=e,Am&&Km(Sm,Am,jm),Am=matchMedia(`(min-resolution: ${km-.001}dppx) and (max-resolution: ${km+.001}dppx)`),Gm(Sm,Am,jm),Dm.dispatchEvent(new CustomEvent(Cm)))}function Mm(e,t){if(t!=null){let n=e.classList;!n.contains(t)&&n.add(t)}}function Nm(e,t){let n=e.classList;n.contains(t)&&n.remove(t)}function Pm(e,t,n){e.style[t]=n+`px`}function Fm(e,t,n,r){let i=Em.createElement(e);return t!=null&&Mm(i,t),n?.insertBefore(i,r),i}function Im(e,t){return Fm(`div`,e,t)}var Lm=new WeakMap;function Rm(e,t,n,r,i){let a=`translate(`+t+`px,`+n+`px)`;a!=Lm.get(e)&&(e.style.transform=a,Lm.set(e,a),t<0||n<0||t>r||n>i?Mm(e,Jp):Nm(e,Jp))}var zm=new WeakMap;function Bm(e,t,n){let r=t+n;r!=zm.get(e)&&(zm.set(e,r),e.style.background=t,e.style.borderColor=n)}var Vm=new WeakMap;function Hm(e,t,n,r){let i=t+``+n;i!=Vm.get(e)&&(Vm.set(e,i),e.style.height=n+`px`,e.style.width=t+`px`,e.style.marginLeft=r?-t/2+`px`:0,e.style.marginTop=r?-n/2+`px`:0)}var Um={passive:!0},Wm={...Um,cLine truncated
|
||||
`,Mg=`{YYYY}`,Ng=jg+Mg,Pg=`{M}/{D}`,Fg=jg+Pg,Ig=Fg+`/{YY}`,Lg=`{aa}`,Rg=`{h}:{mm}`+Lg,zg=jg+Rg,Bg=`:{ss}`,Vg=null;functi)RADPAGE"
|
||||
R"RADPAGE(on Hg(e){let t=e*1e3,n=t*60,r=n*60,i=r*24,a=i*30,o=i*365,s=(e==1?Gh(10,0,3,Eg).filter(Tg):Gh(10,-3,0,Eg)).concat([t,t*5,t*10,t*15,t*30,n,n*5,n*10,n*15,n*30,r,r*2,r*3,r*4,r*6,r*8,r*12,i,i*2,i*3,i*4,i*5,i*6,i*7,i*8,i*9,i*10,i*15,a,a*2,a*3,a*4,a*6,o,o*2,o*5,o*10,o*25,o*50,o*100]),c=[[o,Mg,Vg,Vg,Vg,Vg,Vg,Vg,1],[i*28,`{MMM}`,Ng,Vg,Vg,Vg,Vg,Vg,1],[i,Pg,Ng,Vg,Vg,Vg,Vg,Vg,1],[r,`{h}`+Lg,Ig,Vg,Fg,Vg,Vg,Vg,1],[n,Rg,Ig,Vg,Fg,Vg,Vg,Vg,1],[t,Bg,Ig+` `+Rg,Vg,Fg+` `+Rg,Vg,zg,Vg,1],[e,Bg+`.{fff}`,Ig+` `+Rg,Vg,Fg+` `+Rg,Vg,zg,Vg,1]];function l(t){return(s,c,l,u,d,f)=>{let p=[],m=d>=o,h=d>=a&&d<o,g=t(l),_=Hh(g*e,3),v=Qg(g.getFullYear(),m?0:g.getMonth(),h||m?1:g.getDate()),y=Hh(v*e,3);if(h||m){let n=h?d/a:0,r=m?d/o:0,i=_==y?_:Hh(Qg(v.getFullYear()+r,v.getMonth()+n,1)*e,3),s=new Date(gh(i/e)),c=s.getFullYear(),l=s.getMonth();for(let a=0;i<=u;a++){let o=Qg(c+r*a,l+n*a,1),s=o-t(Hh(o*e,3));i=Hh((+o+s)*e,3),i<=u&&p.push(i)}}else{let a=d>=i?i:d,o=y+(hh(l)-hh(_))+Bh(_-y,a);p.push(o);let m=t(o),h=m.getHours()+m.getMinutes()/n+m.getSeconds()/r,g=d/r,v=f/s.axes[c]._space;for(;o=Hh(o+d,e==1?0:3),!(o>u);)if(g>1){let e=hh(Hh(h+g,6))%24,n=t(o).getHours()-e;n>1&&(n=-1),o-=n*r,h=(h+g)%24;let i=p[p.length-1];Hh((o-i)/d,3)*v>=.7&&p.push(o)}else p.push(o)}return p}}return[s,c,l]}var[Ug,Wg,Gg]=Hg(1),[Kg,qg,Jg]=Hg(.001);Gh(2,-53,53,[1]);function Yg(e,t){return e.map(e=>e.map((n,r)=>r==0||r==8||n==null?n:t(r==1||e[8]==0?n:e[1]+n)))}function Xg(e,t){return(n,r,i,a,o)=>{let s=t.find(e=>o>=e[0])||t[t.length-1],c,l,u,d,f,p;return r.map(t=>{let n=e(t),r=n.getFullYear(),i=n.getMonth(),a=n.getDate(),o=n.getHours(),m=n.getMinutes(),h=n.getSeconds(),g=r!=c&&s[2]||i!=l&&s[3]||a!=u&&s[4]||o!=d&&s[5]||m!=f&&s[6]||h!=p&&s[7]||s[1];return c=r,l=i,u=a,d=o,f=m,p=h,g(n)})}}function Zg(e,t){let n=Sg(t);return(t,r,i,a,o)=>r.map(t=>n(e(t)))}function Qg(e,t,n){return new Date(e,t,n)}function $g(e,t){return t(e)}var e_=`{YYYY}-{MM}-{DD} {h}:{mm}{aa}`;function t_(e,t){return(n,r,i,a)=>a==null?wm:t(e(r))}function n_(e,t){let n=e.series[t];return n.width?n.stroke(e,t):n.points.width?n.points.stroke(e,t):null}function r_(e,t){return e.series[t].fill(e,t)}var i_={show:!0,live:!0,isolate:!1,mount:jh,markers:{show:!0,width:2,stroke:n_,fill:r_,dash:`solid`},idx:null,idxs:null,values:[]};function a_(e,t){let n=e.cursor.points,r=Im(),i=n.size(e,t);Pm(r,om,i),Pm(r,sm,i);let a=i/-2;Pm(r,`marginLeft`,a),Pm(r,`marginTop`,a);let o=n.width(e,t,i);return o&&Pm(r,`borderWidth`,o),r}function o_(e,t){let n=e.series[t].points;return n._fill||n._stroke}function s_(e,t){let n=e.series[t].points;return n._stroke||n._fill}function c_(e,t){return e.series[t].points.size}var l_=[0,0];function u_(e,t,n){return l_[0]=t,l_[1]=n,l_}function d_(e,t,n,r=!0){return e=>{e.button!=0||r&&e.target!=t||n(e)}}function f_(e,t,n,r=!0){return e=>{r&&e.target!=t||n(e)}}var p_={show:!0,x:!0,y:!0,lock:!1,move:u_,points:{one:!1,show:a_,size:c_,width:0,stroke:s_,fill:o_},bind:{mousedown:d_,mouseup:d_,click:d_,dblclick:d_,mousemove:f_,mouseleave:f_,mouseenter:f_},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,n,r,i)=>r-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},m_={show:!0,stroke:`rgba(0,0,0,0.07)`,width:2},h_=ig({},m_,{filter:Nh}),g_=ig({},h_,{size:10}),__=ig({},m_,{show:!1}),v_=`12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`,y_=`bold `+v_,b_=1.5,x_={show:!0,scale:`x`,stroke:fm,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:y_,side:2,grid:h_,ticks:g_,border:__,font:v_,lineGap:b_,rotate:0},S_=`Value`,C_=`Time`,w_={show:!0,scale:`x`,auto:!1,sorted:1,min:Eh,max:-1/0,idxs:[]};function T_(e,t,n,r,i){return t.map(e=>e==null?``:dh(e))}function E_(e,t,n,r,i,a,o){let s=[],c=Uh.get(i)||0;n=o?n:Hh(Bh(n,i),c);for(let e=n;e<=r;e=Hh(e+i,c))s.push(Object.is(e,-0)?0:e);return s}function D_(e,t,n,r,i,a,o){let s=[],c=e.scales[e.axes[t].scale].log;i=bh(c,hh((c==10?Sh:Ch)(n))),c==10&&(i=Ag[qm(i,Ag)]);let l=n,u=i*c;c==10&&(u=Ag[qm(u,Ag)]);do s.push(l),l+=i,c==10&&!Uh.has(l)&&(l=Hh(l,Uh.get(i))),l>=u&&(i=l,u=i*c,c==10&&(u=Ag[qm(u,Ag)]));while(l<=r);return s}function O_(e,t,n,r,i,a,o){let s=e.scales[e.axes[t].scale].asinh,c=r>s?D_(e,t,yh(s,n),r,i):[s],l=r>=0&&n<=0?[0]:[];return(n<-s?D_(e,t,yh(s,-r),-n,i):[s]).reverse().map(e=>-e).concat(l,c)}var k_=/./,A_=/[12357]/,j_=/[125]/,M_=/1/,N_=(e,t,n,r)=>e.map((e,i)=>t==4&&e==0||i%r==0&&n.test(e.toExponential()[+(e<0)])?e:null);function P_(e,t,n,r,i){let a=e.axes[n],o=a.scale,s=e.scales[o],c=e.valToPos,l=a._space,u=c(10,o),d=c(9,o)-u>=l?k_:c(7,o)-u>=l?A_:c(5,o)-u>=l?j_:M_;if(d==M_){let e=mh(c(1,o)-u);if(e<l)return N_(t.slice().reverse(),s.distr,d,_h(l/e)).reverse()}return N_(t,s.distr,d,1)}function F_(e,t,n,r,i){let a=e.axes[n],o=a.scale,s=a._space,c=e.valToPos,l=mh(c(1,o)-Line truncated
|
||||
R"RADPAGE(r,o,a)},F=sh(e.bands,qh).find(e=>e.series[0]==t),I=F==null?0:F.dir,L=m.fillTo(e,t,m.min,m.max,I),R=T(b(L,v,w,S)),z,B,V,ee=C,H=T(m.width*km),te=!1,ne=null,U=null,re=null,W=null;d!=null&&(H==0||f!=null)&&(te=!0,ne=d.values(e,t,i,p),U=new Map,new Set(ne).forEach(e=>{e!=null&&U.set(e,new Path2D)}),H>0&&(re=f.values(e,t,i,p),W=new Map,new Set(re).forEach(e=>{e!=null&&W.set(e,new Path2D)})));let{x0:ie,size:ae}=l;if(ie!=null&&ae!=null){E=1,h=ie.values(e,t,i,p),ie.unit==2&&(h=h.map(t=>e.posToVal(x+t*C,_.key,!0)));let n=ae.values(e,t,i,p);B=ae.unit==2?n[0]*C:y(n[0],_,C,x)-y(0,_,C,x),ee=Sv(h,g,y,_,C,x,ee),V=ee-B+D}else ee=Sv(h,g,y,_,C,x,ee),V=ee*o+D,B=ee-V;V<1&&(V=0),H>=B/2&&(H=0),V<5&&(T=Mh);let G=V>0,oe=ee-V-(G?H:0);B=T(Oh(oe,k,O)),z=(E==0?B/2:E==M?0:B)-E*M*((E==0?D/2:0)+(G?H/2:0));let se={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},ce=te?null:new Path2D,le=null;if(F!=null)le=e.data[F.series[1]];else{let{y0:n,y1:r}=l;n!=null&&r!=null&&(g=r.values(e,t,i,p),le=n.values(e,t,i,p))}let ue=A*B,de=j*B;for(let n=M==1?i:p;n>=i&&n<=p;n+=M){let r=g[n];if(r==null)continue;if(le!=null){let e=le[n]??0;if(r-e==0)continue;R=b(e,v,w,S)}let i=y(_.distr!=2||l!=null?h[n]:n,_,C,x),a=b(sh(r,L),v,w,S),o=T(i-z),s=T(yh(a,R)),c=T(vh(a,R)),u=s-c;if(r!=null){let i=r<0?de:ue,a=r<0?ue:de;te?(H>0&&re[n]!=null&&N(W.get(re[n]),o,c+hh(H/2),B,yh(0,u-H),i,a),ne[n]!=null&&N(U.get(ne[n]),o,c+hh(H/2),B,yh(0,u-H),i,a)):N(ce,o,c+hh(H/2),B,yh(0,u-H),i,a),P(e,t,n,o-H/2,c,B+H,u)}}return H>0?se.stroke=te?W:ce:te||(se._fill=m.width==0?m._fill:m._stroke??m._fill,se.width=0),se.fill=te?U:ce,se})}function wv(e,t){let n=sh(t?.alignGaps,0);return(t,r,i,a)=>Z_(t,r,(o,s,c,l,u,d,f,p,m,h,g)=>{[i,a]=Zm(c,i,a);let _=o.pxRound,v=e=>_(d(e,l,h,p)),y=e=>_(f(e,u,g,m)),b,x,S;l.ori==0?(b=ov,S=cv,x=mv):(b=sv,S=lv,x=hv);let C=l.dir*(l.ori==0?1:-1),w=v(s[C==1?i:a]),T=w,E=[],D=[];for(let e=C==1?i:a;e>=i&&e<=a;e+=C)if(c[e]!=null){let t=s[e],n=v(t);E.push(T=n),D.push(y(c[e]))}let O={stroke:e(E,D,b,S,x,_),fill:null,clip:null,band:null,gaps:null,flags:Y_},k=O.stroke,[A,j]=Q_(t,r);if(o.fill!=null||A!=0){let e=O.fill=new Path2D(k),n=y(o.fillTo(t,r,o.min,o.max,A));S(e,T,n),S(e,w,n)}if(!o.spanGaps){let e=[];e.push(...rv(s,c,i,a,C,v,n)),O.gaps=e=o.gaps(t,r,i,a,e),O.clip=tv(e,l.ori,p,m,h,g)}return j!=0&&(O.band=j==2?[ev(t,r,i,a,k,-1),ev(t,r,i,a,k,1)]:ev(t,r,i,a,k,j)),O})}function Tv(e){return wv(Ev,e)}function Ev(e,t,n,r,i,a){let o=e.length;if(o<2)return null;let s=new Path2D;if(n(s,e[0],t[0]),o==2)r(s,e[1],t[1]);else{let n=Array(o),r=Array(o-1),a=Array(o-1),c=Array(o-1);for(let n=0;n<o-1;n++)a[n]=t[n+1]-t[n],c[n]=e[n+1]-e[n],r[n]=a[n]/c[n];n[0]=r[0];for(let e=1;e<o-1;e++)r[e]===0||r[e-1]===0||r[e-1]>0!=r[e]>0?n[e]=0:(n[e]=3*(c[e-1]+c[e])/((2*c[e]+c[e-1])/r[e-1]+(c[e]+2*c[e-1])/r[e]),isFinite(n[e])||(n[e]=0));n[o-1]=r[o-2];for(let r=0;r<o-1;r++)i(s,e[r]+c[r]/3,t[r]+n[r]*c[r]/3,e[r+1]-c[r]/3,t[r+1]-n[r+1]*c[r]/3,e[r+1],t[r+1])}return s}var Dv=new Set;function Ov(){for(let e of Dv)e.syncRect(!0)}Tm&&(Gm(bm,Dm,Ov),Gm(xm,Dm,Ov,!0),Gm(Cm,Dm,()=>{Wv.pxRatio=km}));var kv=bv(),Av=gv();function jv(e,t,n,r){return(r?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,r)=>Nv(e,r,t,n))}function Mv(e,t){return e.map((e,n)=>n==0?{}:ig({},t,e))}function Nv(e,t,n,r){return ig({},t==0?n:r,e)}function Pv(e,t,n){return t==null?Jh:[t,n]}var Fv=Pv;function Iv(e,t,n){return t==null?Jh:oh(t,n,nh,!0)}function Lv(e,t,n,r){return t==null?Jh:eh(t,n,e.scales[r].log,!1)}var Rv=Lv;function zv(e,t,n,r){return t==null?Jh:th(t,n,e.scales[r].log,!1)}var Bv=zv;function Vv(e,t,n,r,i){let a=yh(Dh(e),Dh(t)),o=t-e,s=qm(i/r*o,n);do{let e=n[s],t=r*e/o;if(t>=i&&a+(e<5?Uh.get(e):0)<=17)return[e,t]}while(++s<n.length);return[0,0]}function Hv(e){let t,n;return e=e.replace(/(\d+)px/,(e,r)=>(t=gh((n=+r)*km))+`px`),[e,t,n]}function Uv(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Hh(e[2]*km,1);e[0]=e[0].replace(/[0-9.]+px/,t+`px`),e[1]=t})}function Wv(e,t,n){let r={mode:sh(e.mode,1)},i=r.mode;function a(e,t,n,r){let i=t.valToPct(e);return r+n*(t.dir==-1?1-i:i)}function o(e,t,n,r){let i=t.valToPct(e);return r+n*(t.dir==-1?i:1-i)}function s(e,t,n,r){return t.ori==0?a(e,t,n,r):o(e,t,n,r)}r.valToPosH=a,r.valToPosV=o;let c=!1;r.status=0;let l=r.root=Im(Bp);if(e.id!=null&&(l.id=e.id),Mm(l,e.class),e.title){let t=Im(Up,l);t.textContent=e.title}let u=Fm(`canvas`),d=r.ctx=u.getContext(`2d`),f=Im(Wp,l);Gm(`click`,f,e=>{e.target===m&&(Zt!=qt||Qt!=Jt)&&en.click(r,e)},!0);let p=r.under=Im(Gp,f);f.appendChild(u);let m=r.over=Im(Kp,f);e=rg(e);let h=+sh(e.pxAlign,1),g=iv(h);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(r,e)||e)});let _=e.ms||.001,v=r.series=i==1?jv(e.series||[],w_,U_,!1):Mv(e.series||[null],H_),y=r.axes=jv(e.axes||[],x_,L_,!0),b=r.scales={},x=r.bands=e.bands||[];x.forEach(e=>{e.fill=Ah(e.fill||null),e.dir=sh(e.dir,-1)});let S=i==2?v[1].facets[0].scale:v[0].scale,C={axes:Mt,series:xt},w=(e.drawOrder||[`axes`,`series`]).map(e=>C[e]);function T(e){let t=e.distr==3?t=>Sh(t>0?t:e.clamp(r,t,e.min,e.Line truncated
|
||||
R"RADPAGE(urn c==0&&(s||a)&&(l=t==0&&!i||t==2&&!o?gh(x_.size/3):0),c==1&&(i||o)&&(l=t==1&&!a||t==3&&!s?gh(L_.size/2):0),l}let Xe=r.padding=(e.padding||[Ye,Ye,Ye,Ye]).map(e=>Ah(sh(e,Ye))),Ze=r._padding=Xe.map((e,t)=>e(r,t,Je,0)),Qe,$e=null,et=null,tt=i==1?v[0].idxs:null,nt=null,rt=!1;function it(e,n){if(t=e??[],r.data=r._data=t,i==2){Qe=0;for(let e=1;e<v.length;e++)Qe+=t[e][0].length}else{t.length==0&&(r.data=r._data=t=[[]]),nt=t[0],Qe=nt.length;let e=t;if(O==2){e=t.slice();let n=e[0]=Array(Qe);for(let e=0;e<Qe;e++)n[e]=e}r._data=t=e}if(Nt(!0),Gn(`setData`),O==2&&(Ee=!0),n!==!1){let e=D;e.auto(r,rt)?at():cn(S,e.min,e.max),De||=z.left>=0,ke=!0,Rt()}}r.setData=it;function at(){rt=!0;let e,n;i==1&&(Qe>0?($e=tt[0]=0,et=tt[1]=Qe-1,e=t[0][$e],n=t[0][et],O==2?(e=$e,n=et):e==n&&(O==3?[e,n]=eh(e,e,D.log,!1):O==4?[e,n]=th(e,e,D.log,!1):D.time?n=e+gh(86400/_):[e,n]=oh(e,n,nh,!0))):($e=tt[0]=e=null,et=tt[1]=n=null)),cn(S,e,n)}let ot,st,ct,lt,ut,dt,ft,Y,pt,mt;function ht(e,t,n,r,i,a){e??=pm,n??=qh,r??=`butt`,i??=pm,a??=`round`,e!=ot&&(d.strokeStyle=ot=e),i!=st&&(d.fillStyle=st=i),t!=ct&&(d.lineWidth=ct=t),a!=ut&&(d.lineJoin=ut=a),r!=dt&&(d.lineCap=dt=r),n!=lt&&d.setLineDash(lt=n)}function gt(e,t,n,r){t!=st&&(d.fillStyle=st=t),e!=ft&&(d.font=ft=e),n!=Y&&(d.textAlign=Y=n),r!=pt&&(d.textBaseline=pt=r)}function _t(e,t,n,i,a=0){if(i.length>0&&e.auto(r,rt)&&(t==null||t.min==null)){let t=sh($e,0),r=sh(et,i.length-1),o=n.min==null?$m(i,t,r,a,e.distr==3):[n.min,n.max];e.min=vh(e.min,n.min=o[0]),e.max=yh(e.max,n.max=o[1])}}let vt={min:null,max:null};function yt(){for(let e in b){let t=b[e];j[e]==null&&(t.min==null||j[S]!=null&&t.auto(r,rt))&&(j[e]=vt)}for(let e in b){let t=b[e];j[e]==null&&t.from!=null&&j[t.from]!=null&&(j[e]=vt)}j[S]!=null&&Nt(!0);let e={};for(let t in j){let n=j[t];if(n!=null){let a=e[t]=rg(b[t],eg);if(n.min!=null)ig(a,n);else if(t!=S||i==2){if(Qe==0&&a.from==null){let e=a.range(r,null,null,t);a.min=e[0],a.max=e[1]}else a.min=Eh,a.max=-1/0}}}if(Qe>0){v.forEach((n,a)=>{if(i==1){let i=n.scale,o=j[i];if(o==null)return;let s=e[i];if(a==0){let e=s.range(r,s.min,s.max,i);s.min=e[0],s.max=e[1],$e=qm(s.min,t[0]),et=qm(s.max,t[0]),et-$e>1&&(t[0][$e]<s.min&&$e++,t[0][et]>s.max&&et--),n.min=nt[$e],n.max=nt[et]}else n.show&&n.auto&&_t(s,o,n,t[a],n.sorted);n.idxs[0]=$e,n.idxs[1]=et}else if(a>0&&n.show&&n.auto){let[r,i]=n.facets,o=r.scale,s=i.scale,[c,l]=t[a],u=e[o],d=e[s];u!=null&&_t(u,j[o],r,c,r.sorted),d!=null&&_t(d,j[s],i,l,i.sorted),n.min=i.min,n.max=i.max}});for(let t in e){let n=e[t],i=j[t];if(n.from==null&&(i==null||i.min==null)){let e=n.range(r,n.min==Eh?null:n.min,n.max==-1/0?null:n.max,t);n.min=e[0],n.max=e[1]}}}for(let t in e){let n=e[t];if(n.from!=null){let i=e[n.from];if(i.min==null)n.min=n.max=null;else{let e=n.range(r,i.min,i.max,t);n.min=e[0],n.max=e[1]}}}let n={},a=!1;for(let t in e){let r=e[t],i=b[t];if(i.min!=r.min||i.max!=r.max){i.min=r.min,i.max=r.max;let e=i.distr;i._min=e==3?Sh(i.min):e==4?Th(i.min,i.asinh):e==100?i.fwd(i.min):i.min,i._max=e==3?Sh(i.max):e==4?Th(i.max,i.asinh):e==100?i.fwd(i.max):i.max,n[t]=a=!0}}if(a){v.forEach((e,t)=>{i==2?t>0&&n.y&&(e._paths=null):n[e.scale]&&(e._paths=null)});for(let e in n)Ee=!0,Gn(`setScale`,e);V&&z.left>=0&&(De=ke=!0)}for(let e in j)j[e]=null}function bt(e){let t=Oh($e-1,0,Qe-1),n=Oh(et+1,0,Qe-1);for(;e[t]==null&&t>0;)t--;for(;e[n]==null&&n<Qe-1;)n++;return[t,n]}function xt(){if(Qe>0){let e=v.some(e=>e._focus)&&mt!=Re.alpha;e&&(d.globalAlpha=mt=Re.alpha),v.forEach((e,n)=>{if(n>0&&e.show&&(St(n,!1),St(n,!0),e._paths==null)){let a=mt;mt!=e.alpha&&(d.globalAlpha=mt=e.alpha);let o=i==2?[0,t[n][0].length-1]:bt(t[n]);e._paths=e.paths(r,n,o[0],o[1]),mt!=a&&(d.globalAlpha=mt=a)}}),v.forEach((e,t)=>{if(t>0&&e.show){let n=mt;mt!=e.alpha&&(d.globalAlpha=mt=e.alpha),e._paths!=null&&Ct(t,!1);{let n=e._paths==null?null:e._paths.gaps,i=e.points.show(r,t,$e,et,n),a=e.points.filter(r,t,i,n);(i||a)&&(e.points._paths=e.points.paths(r,t,$e,et,a),Ct(t,!0))}mt!=n&&(d.globalAlpha=mt=n),Gn(`drawSeries`,t)}}),e&&(d.globalAlpha=mt=1)}}function St(e,t){let n=t?v[e].points:v[e];n._stroke=n.stroke(r,e),n._fill=n.fill(r,e)}function Ct(e,t){let n=t?v[e].points:v[e],{stroke:r,fill:i,clip:a,flags:o,_stroke:s=n._stroke,_fill:c=n._fill,_width:l=n.width}=n._paths;l=Hh(l*km,3);let u=null,f=l%2/2;t&&c==null&&(c=l>0?`#fff`:s);let p=n.pxAlign==1&&f>0;if(p&&d.translate(f,f),!t){let e=be-l/2,t=xe-l/2,n=Se+l,r=Ce+l;u=new Path2D,u.rect(e,t,n,r)}t?Tt(s,l,n.dash,n.cap,c,r,i,o,a):wt(e,s,l,n.dash,n.cap,c,r,i,o,u,a),p&&d.translate(-f,-f)}function wt(e,n,i,a,o,s,c,l,u,d,f){let p=!1;u!=0&&x.forEach((m,h)=>{if(m.series[0]==e){let e=v[m.series[1]],g=t[m.series[1]],_=(e._paths||Kh).band;Yh(_)&&(_=m.dir==1?_[0]:_[1]);let y,b=null;e.show&&_&&ch(g,$e,et)?(b=m.fill(r,h)||s,y=e._paths.clip):_=null,Tt(n,i,a,o,b,c,l,u,d,f,y,_),p=!0}}),p||Tt(n,i,a,o,s,c,l,u,d,f)}function Tt(e,t,n,r,i,a,o,s,c,l,u,f){ht(e,t,n,r,i),(c||l||f)&&(d.save(),c&&d.clip(c),l&&d.clip(l)),f?(s&3)==3?(d.clip(f),u&&d.clip(u),Dt(i,o),Et(e,a,t)):s&X_?(Dt(Line truncated
|
||||
`)==-1?[t]:t.split(/\n/gm);for(let e=0;e<n.length;e++){let t=n[e];D?(d.save(),d.translate(a,o+e*j),d.rotate(D),d.fillText(t,0,0),d.restore()):d.fillText(t,a,o+e*j)}}}S.show&&kt(M,S.filter(r,v,e,f,x),i,n,O,T,Hh(S.width*km,3),S.stroke(r,e),S.dash,S.cap);let P=t.grid;P.show&&kt(M,P.filter(r,v,e,f,x),i,i==0?2:1,i==0?xe:be,i==0?Ce:Se,Hh(P.width*km,3),P.stroke(r,e),P.dash,P.cap),C.show&&kt([O],[1],+(i==0),i==0?1:2,i==1?xe:be,i==1?Ce:Se,Hh(C.width*km,3),C.stroke(r,e),C.dash,C.cap)}Gn(`drawAxes`)}function Nt(e){v.forEach((t,n)=>{n>0&&(t._paths=null,e&&(i==1?(t.min=null,t.max=null):t.facets.forEach(e=>{e.min=null,e.max=null})))})}let Pt=!1,Ft=!1,It=[];function Lt(){Ft=!1;for(let e=0;e<It.length;e++)Gn(...It[e]);It.length=0}function Rt(){Pt||=(ug(Bt),!0)}function zt(e,t=!1){Pt=!0,Ft=t,e(r),Bt(),t&&It.length>0&&queueMicrotask(Lt)}r.batch=zt;function Bt(){if(we&&=(yt(),!1),Ee&&=(Me(),!1),Te){if(Pm(p,um,me),Pm(p,cm,he),Pm(p,om,K),Pm(p,sm,q),Pm(m,um,me),Pm(m,cm,he),Pm(m,om,K),Pm(m,sm,q),Pm(f,om,fe),Pm(f,sm,pe),u.width=gh(fe*km),u.height=gh(pe*km),y.forEach(({_el:e,_show:t,_size:n,_pos:r,side:i})=>{if(e!=null){if(t){let t=i===3||i===0?n:0,a=i%2==1;Pm(e,a?`left`:`top`,r-t),Pm(e,a?`width`:`height`,n),Pm(e,a?`top`:`left`,a?he:me),Pm(e,a?`height`:`width`,a?q:K),Nm(e,Jp)}else Mm(e,Jp)}}),ot=st=ct=ut=dt=ft=Y=pt=lt=null,mt=1,kn(!0),me!=ge||he!=_e||K!=ve||q!=ye){Nt(!1);let e=K/ve,t=q/ye;if(V&&!De&&z.left>=0){z.left*=e,z.top*=t,Wt&&Rm(Wt,gh(z.left),0,K,q),Gt&&Rm(Gt,0,gh(z.top),K,q);for(let n=0;n<Ve.length;n++){let r=Ve[n];r!=null&&(He[n]*=e,Ue[n]*=t,Rm(r,_h(He[n]),_h(Ue[n]),K,q))}}if(rn.show&&!Oe&&rn.left>=0&&rn.width>0){rn.left*=e,rn.width*=e,rn.top*=t,rn.height*=t;for(let e in Mn)Pm(an,e,rn[e])}ge=me,_e=he,ve=K,ye=q}Gn(`setSize`),Te=!1}fe>0&&pe>0&&(d.clearRect(0,0,u.width,u.height),Gn(`drawClear`),w.forEach(e=>e()),Gn(`draw`)),rn.show&&Oe&&(on(rn),Oe=!1),V&&De&&(Dn(null,!0,!1),De=!1),R.show&&R.live&&ke&&(Tn(),ke=!1),c||(c=!0,r.status=1,Gn(`ready`)),rt=!1,Pt=!1}r.redraw=(e,t)=>{Ee=t||!1,e===!1?Rt():cn(S,D.min,D.max)};function Vt(e,n){let i=b[e];if(i.from==null){if(Qe==0){let t=i.range(r,n.min,n.max,e);n.min=t[0],n.max=t[1]}if(n.min>n.max){let e=n.min;n.min=n.max,n.max=e}if(Qe>1&&n.min!=null&&n.max!=null&&n.max-n.min<1e-16)return;e==S&&i.distr==2&&Qe>0&&(n.min=qm(n.min,t[0]),n.max=qm(n.max,t[0]),n.min==n.max&&n.max++),j[e]=n,we=!0,Rt()}}r.setScale=Vt;let Ht,Ut,Wt,Gt,X,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t=!1,en=z.drag,tn=en.x,nn=en.y;V&&(z.x&&(Ht=Im(Xp,m)),z.y&&(Ut=Im(Zp,m)),D.ori==0?(Wt=Ht,Gt=Ut):(Wt=Ut,Gt=Ht),Zt=z.left,Qt=z.top);let rn=r.select=ig({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),an=rn.show?Im(Yp,rn.over?m:p):null;function on(e,t){if(rn.show){for(let t in e)rn[t]=e[t],t in Mn&&Pm(an,t,e[t]);t!==!1&&Gn(`setSelect`)}}r.setSelect=on;function sn(e){if(v[e].show)B&&Nm(U[e],Jp);else if(B&&Mm(U[e],Jp),V){let t=Be?Ve[0]:Ve[e];t!=null&&Rm(t,-10,-10,K,q)}}function cn(e,t,n){Vt(e,{min:t,max:n})}function ln(e,t,n,a){t.focus!=null&&_n(e),t.show!=null&&v.forEach((n,r)=>{r>0&&(e==r||e==null)&&(n.show=t.show,sn(r),i==2?(cn(n.facets[0].scale,null,null),cn(n.facets[1].scale,null,null)):cn(n.scale,null,null),Rt())}),n!==!1&&Gn(`setSeries`,e,t),a&&Xn(`setSeries`,r,e,t)}r.setSeries=ln;function un(e,t){ig(x[e],t)}function dn(e,t){e.fill=Ah(e.fill||null),e.dir=sh(e.dir,-1),t??=x.length,x.splice(t,0,e)}function fn(e){e==null?x.length=0:x.splice(e,1)}r.addBand=dn,r.setBand=un,r.delBand=fn;function Z(e,t){v[e].alpha=t,V&&Ve[e]!=null&&(Ve[e].style.opacity=t),B&&U[e]&&(U[e].style.opacity=t)}let pn,mn,hn,gn={focus:!0};function _n(e){if(e!=hn){let t=e==null,n=Re.alpha!=1;v.forEach((r,a)=>{if(i==1||a>0){let i=t||a==0||a==e;r._focus=t?null:i,n&&Z(a,i?1:Re.alpha)}}),hn=e,n&&Rt()}}B&&ze&&ue(vm,H,e=>{z._lock||(Ie(e),hn!=null&&ln(null,gn,!0,qn.setSeries))});function vn(e,t,n){let r=b[t];n&&(e=e/km-(r.ori==1?he:me));let i=K;r.ori==1&&(i=q,e=i-e),r.dir==-1&&(e=i-e);let a=r._min,o=r._max,s=e/i,c=a+(o-a)*s,l=r.distr;return l==3?bh(10,c):l==4?wh(c,r.asinh):l==100?r.bwd(c):c}function yn(e,n){return qm(vn(e,S,n),t[0],$e,et)}r.valToIdx=e=>qm(e,t[0]),r.posToIdx=yn,r.posToVal=vn,r.valToPos=(e,t,n)=>b[t].ori==0?a(e,b[t],n?Se:K,n?be:0):o(e,b[t],n?Ce:q,n?xe:0),r.setCursor=(e,t,n)=>{Zt=e.left,Qt=e.top,Dn(null,t,n)};function bn(e,t){Pm(an,um,rn.left=e),Pm(an,om,rn.width=t)}function xn(e,t){Pm(an,cm,rn.top=e),Pm(an,sm,rn.height=t)}let Sn=D.ori==0?bn:xn,Cn=D.ori==1?bn:xn;function wn(){if(B&&R.live)for(let e=+(i==2);e<v.length;e++){if(e==0&&ie)continue;let t=R.values[e],n=0;for(let r in t)re[e][n++].firstChild.nodeValue=t[r]}}function Tn(e,t){if(e!=null&&(e.idxs?e.idxs.fo)RADPAGE"
|
||||
R"RADPAGE(rEach((e,t)=>{L[t]=e}):Zh(e.idx)||L.fill(e.idx),R.idx=L[0]),B&&R.live){for(let e=0;e<v.length;e++)(e>0||i==1&&!ie)&&En(e,L[e]);wn()}ke=!1,t!==!1&&Gn(`setLegend`)}r.setLegend=Tn;function En(e,n){let i=v[e],a=e==0&&O==2?nt:t[e],o;ie?o=i.values(r,e,n)??ae:(o=i.value(r,n==null?null:a[n],e,n),o=o==null?ae:{_:o}),R.values[e]=o}function Dn(e,n,a){Yt=Zt,Xt=Qt,[Zt,Qt]=z.move(r,Zt,Qt),z.left=Zt,z.top=Qt,V&&(Wt&&Rm(Wt,gh(Zt),0,K,q),Gt&&Rm(Gt,0,gh(Qt),K,q));let o,s=$e>et;pn=Eh,mn=null;let c=D.ori==0?K:q,l=D.ori==1?K:q;if(Zt<0||Qe==0||s){o=z.idx=null;for(let e=0;e<v.length;e++){let t=Ve[e];t!=null&&Rm(t,-10,-10,K,q)}ze&&ln(null,gn,!0,e==null&&qn.setSeries),R.live&&(L.fill(o),ke=!0)}else{let e,n,a;i==1&&(e=D.ori==0?Zt:Qt,n=vn(e,S),o=z.idx=qm(n,t[0],$e,et),a=k(t[0][o],D,c,0));let s=-10,u=-10,d=0,f=0,p=!0,m=``,h=``;for(let e=+(i==2);e<v.length;e++){let g=v[e],_=L[e],y=_==null?null:i==1?t[e][_]:t[e][1][_],x=z.dataIdx(r,e,o,n),S=x==null?null:i==1?t[e][x]:t[e][1][x];if(ke=ke||S!=y||x!=_,L[e]=x,e>0&&g.show){let n=x==null?-10:x==o?a:k(i==1?t[0][x]:t[e][0][x],D,c,0),_=S==null?-10:A(S,i==1?b[g.scale]:b[g.facets[1].scale],l,0);if(ze&&S!=null){let t=D.ori==1?Zt:Qt,n=mh(Re.dist(r,e,x,_,t));if(n<pn){let r=Re.bias;if(r!=0){let i=vn(t,g.scale),a=S>=0?1:-1,o=i>=0?1:-1;o==a&&(o==1?r==1?S>=i:S<=i:r==1?S<=i:S>=i)&&(pn=n,mn=e)}else pn=n,mn=e}}if(ke||Be){let t,i;D.ori==0?(t=n,i=_):(t=_,i=n);let a,o,c,l,g,v,y=!0,b=Le.bbox;if(b!=null){y=!1;let t=b(r,e);c=t.left,l=t.top,a=t.width,o=t.height}else c=t,l=i,a=o=Le.size(r,e);if(v=Le.fill(r,e),g=Le.stroke(r,e),Be)e==mn&&pn<=Re.prox&&(s=c,u=l,d=a,f=o,p=y,m=v,h=g);else{let t=Ve[e];t!=null&&(He[e]=c,Ue[e]=l,Hm(t,a,o,y),Bm(t,v,g),Rm(t,_h(c),_h(l),K,q))}}}}if(Be){let e=Re.prox;if(ke||(hn==null?pn<=e:pn>e||mn!=hn)){let e=Ve[0];e!=null&&(He[0]=s,Ue[0]=u,Hm(e,d,f,p),Bm(e,m,h),Rm(e,_h(s),_h(u),K,q))}}}if(rn.show&&$t){if(e!=null){let[t,n]=qn.scales,[r,i]=qn.match,[a,o]=e.cursor.sync.scales,s=e.cursor.drag;if(tn=s._x,nn=s._y,tn||nn){let{left:s,top:u,width:d,height:f}=e.select,p=e.scales[a].ori,m=e.posToVal,h,g,_,v,y,x=t!=null&&r(t,a),S=n!=null&&i(n,o);x&&tn?(p==0?(h=s,g=d):(h=u,g=f),_=b[t],v=k(m(h,a),_,c,0),y=k(m(h+g,a),_,c,0),Sn(vh(v,y),mh(y-v))):Sn(0,c),S&&nn?(p==1?(h=s,g=d):(h=u,g=f),_=b[n],v=A(m(h,o),_,l,0),y=A(m(h+g,o),_,l,0),Cn(vh(v,y),mh(y-v))):Cn(0,l)}else Nn()}else{let e=mh(Yt-X),t=mh(Xt-Kt);if(D.ori==1){let n=e;e=t,t=n}tn=en.x&&e>=en.dist,nn=en.y&&t>=en.dist;let n=en.uni;n==null?en.x&&en.y&&(tn||nn)&&(tn=nn=!0):tn&&nn&&(tn=e>=n,nn=t>=n,!tn&&!nn&&(t>e?nn=!0:tn=!0));let r,i;tn&&(D.ori==0?(r=qt,i=Zt):(r=Jt,i=Qt),Sn(vh(r,i),mh(i-r)),nn||Cn(0,l)),nn&&(D.ori==1?(r=qt,i=Zt):(r=Jt,i=Qt),Cn(vh(r,i),mh(i-r)),tn||Sn(0,c)),!tn&&!nn&&(Sn(0,0),Cn(0,0))}}if(en._x=tn,en._y=nn,e==null){if(a){if(Jn!=null){let[e,t]=qn.scales;qn.values[0]=e==null?null:vn(D.ori==0?Zt:Qt,e),qn.values[1]=t==null?null:vn(D.ori==1?Zt:Qt,t)}Xn(mm,r,Zt,Qt,K,q,o)}if(ze){let e=a&&qn.setSeries,t=Re.prox;hn==null?pn<=t&&ln(mn,gn,!0,e):pn>t?ln(null,gn,!0,e):mn!=hn&&ln(mn,gn,!0,e)}}ke&&(R.idx=o,Tn()),n!==!1&&Gn(`setCursor`)}let On=null;Object.defineProperty(r,"rect",{get(){return On??kn(!1),On}});function kn(e=!1){e?On=null:(On=m.getBoundingClientRect(),Gn(`syncRect`,On))}function An(e,t,n,r,i,a,o){z._lock||$t&&e!=null&&e.movementX==0&&e.movementY==0||(jn(e,t,n,r,i,a,o,!1,e!=null),e==null?Dn(t,!0,!1):Dn(null,!0,!0))}function jn(e,t,n,i,a,o,c,l,u){if(On??kn(!1),Ie(e),e!=null)n=e.clientX-On.left,i=e.clientY-On.top;else{if(n<0||i<0){Zt=-10,Qt=-10;return}let[e,r]=qn.scales,c=t.cursor.sync,[l,u]=c.values,[d,f]=c.scales,[p,m]=qn.match,h=t.axes[0].side%2==1,g=D.ori==0?K:q,_=D.ori==1?K:q,v=h?o:a,y=h?a:o,x=h?i:n,S=h?n:i;if(n=d==null?x/v*g:p(e,d)?s(l,b[e],g,0):-10,i=f==null?S/y*_:m(r,f)?s(u,b[r],_,0):-10,D.ori==1){let e=n;n=i,i=e}}u&&(t==null||t.cursor.event.type==mm)&&((n<=1||n>=K-1)&&(n=zh(n,K)),(i<=1||i>=q-1)&&(i=zh(i,q))),l?(X=n,Kt=i,[qt,Jt]=z.move(r,n,i)):(Zt=n,Qt=i)}let Mn={width:0,height:0,left:0,top:0};function Nn(){on(Mn,!1)}let Pn,Fn,In,Ln;function Rn(e,t,n,i,a,o,s){$t=!0,tn=nn=en._x=en._y=!1,jn(e,t,n,i,a,o,s,!0,!1),e!=null&&(ue(gm,Em,zn,!1),Xn(hm,r,qt,Jt,K,q,null));let{left:c,top:l,width:u,height:d}=rn;Pn=c,Fn=l,In=u,Ln=d}function zn(e,t,n,i,a,o,s){$t=en._x=en._y=!1,jn(e,t,n,i,a,o,s,!1,!0);let{left:c,top:l,width:u,height:d}=rn,f=u>0||d>0,p=Pn!=c||Fn!=l||In!=u||Ln!=d;if(f&&p&&on(rn),en.setScale&&f&&p){let e=c,t=u,n=l,r=d;if(D.ori==1&&(e=l,t=d,n=c,r=u),tn&&cn(S,vn(e,S),vn(e+t,S)),nn)for(let e in b){let t=b[e];e!=S&&t.from==null&&t.min!=Eh&&cn(e,vn(n+r,e),vn(n,e))}Nn()}else z.lock&&(z._lock=!z._lock,Dn(t,!0,e!=null));e!=null&&(de(gm,Em),Xn(gm,r,Zt,Qt,K,q,null))}function Bn(e,t,n,r,i,a,o){if(z._lock)return;Ie(e);let s=$t;if($t){let e=!0,t=!0,n,r;D.ori==0?(n=tn,r=nn):(n=nn,r=tn),n&&r&&(e=Zt<=10||Zt>=K-10,t=Qt<=10||Qt>=q-10),n&&e&&(Zt=Zt<qt?0:K),r&&t&&(Qt=Qt<Jt?0:q),Dn(null,!0,!0),$t=!1}Zt=-10,Qt=-10,L.fill(null),Dn(null,!0,!0),s&&($t=s)}function Vn(e,t,n,i,a,o,s){z._lock||(Ie(e),at(),Nn(),e!=null&&Xn(ym,r,Zt,Qt,K,q,null))}function Hn(){y.forEaLine truncated
|
||||
R"RADPAGE(t`,label:`Decode`,unit:`tok/s`,show:e=>[Tf(e.decode_tps)?ny(e.decode_tps):`–`],lines:ry(`decode`,`tokens a second`),fmt:ny},{id:`step`,kinds:`chat`,label:`Step`,unit:`ms`,show:(e,t)=>{let n=t.last(`step`);return[Tf(n)?n>=100?n.toFixed(0):n.toFixed(2):`–`,(e.step_ns_decode_best??0)>0?`best `+ey(e.step_ns_decode_best/1e6):``]},lines:[{key:`step`,label:`step`,color:1},{key:`stepBest`,label:`best`,dash:!0}],fmt:ey,tight:!0},{id:`prefill`,kinds:`chat`,label:`Prefill`,unit:`tok/s`,show:(e,t)=>{let n=t.last(`prefillRate`);return[Tf(n)?ny(n):`–`]},lines:ry(`prefillRate`,`tokens a second`),fmt:ny,join:!0},{id:`reqs`,kinds:`chat`,always:!0,label:`Requests`,show:(e,t,n)=>[String(e.running??0),(n?`of `+n+` slots`:``)+(e.waiting?` · `+e.waiting+` waiting`:``)],lines:[{key:`running`,label:`running`,color:1},{key:`waiting`,label:`waiting`,color:5},{key:`preempted`,label:`preempted`,color:2}],fmt:e=>$(e),stack:!0,integer:!0},{id:`kv`,kinds:`chat`,label:`KV cache`,show:e=>{let[t,n]=Df(e.kv_bytes_used);return[t,`of `+Ef(e.kv_bytes_total),n]},lines:[{key:`kvRead`,label:`in use`,color:1},{key:`kvKept`,label:`cached for the next turn`,color:4}],fmt:Ef,stack:!0,bytes:!0},{id:`hit`,kinds:`chat`,label:`Prefix cache hits`,unit:`%`,show:e=>[Tf(e.prefix_hit_rate)?Af(e.prefix_hit_rate):`–`],lines:ry(`hit`,`of prompt tokens`),fmt:ty,max:1},{id:`accept`,kinds:`chat`,label:`Acceptance`,unit:`%`,draft:!0,show:(e,t)=>[Af(t.last(`accept`))],lines:ry(`accept`,`of drafted tokens`),fmt:ty,max:1},{id:`tok`,kinds:`chat`,label:`Tokens per step`,draft:!0,show:(e,t)=>{let n=t.last(`tokStep`);return[Tf(n)?n.toFixed(2):`–`]},lines:ry(`tokStep`,`tokens`),fmt:e=>e.toFixed(2),tight:!0},{id:`ethru`,kinds:`embed`,always:!0,label:`Throughput`,unit:`tok/s`,show:e=>[Tf(e.prefill_tps)?ny(e.prefill_tps):`–`],lines:ry(`prefill`,`tokens a second`),fmt:ny},{id:`erate`,kinds:`embed`,always:!0,label:`Inputs`,unit:`/s`,show:(e,t)=>{let n=t.last(`reqRate`);return[Tf(n)?ny(n):`–`]},lines:ry(`reqRate`,`inputs a second`),fmt:ny},{id:`estep`,kinds:`embed`,always:!0,label:`Step`,unit:`ms`,show:(e,t)=>{let n=t.last(`stepAny`);return[Tf(n)?n.toFixed(2):`–`]},lines:ry(`stepAny`,`step`),fmt:ey,tight:!0},{id:`eflight`,kinds:`embed`,always:!0,label:`Active requests`,show:e=>[String(e.in_flight??0)],lines:ry(`flight`,`in flight`),fmt:e=>$(e),integer:!0},{id:`jrun`,kinds:`gen`,always:!0,label:`Running`,show:e=>[String(e.jobs?.running??0)],lines:ry(`jobRun`,`running`),fmt:e=>$(e),integer:!0},{id:`jdone`,kinds:`gen`,always:!0,label:`Completed`,show:e=>[$(e.jobs?.done),e.jobs?.failed?e.jobs.failed+` failed`:``],lines:ry(`jobDone`,`made`),fmt:e=>$(e),integer:!0},{id:`jlast`,kinds:`gen`,always:!0,label:`Last duration`,show:e=>[e.jobs?.done?jf(e.jobs.last_ms/1e3):`–`],lines:ry(`jobTime`,`took`),fmt:e=>jf(e),join:!0},{id:`jmean`,kinds:`gen`,always:!0,label:`Mean`,show:e=>[e.jobs?.done?jf(e.jobs.total_ms/e.jobs.done/1e3):`–`],lines:ry(`jobTime`,`took`),fmt:e=>jf(e),join:!0}],ay=[[`lkAr`,`between accelerators`],[`lkUp`,`host to accelerator`],[`lkDn`,`accelerator to host`],[`lkSsd`,`drive`],[`lkStream`,`streaming`]].map(([e,t],n)=>({key:e,label:t,color:n+1}));function oy({scope:e,kind:t,slots:n,noun:r}){let i=Qf(),[a,o]=(0,_.useState)(null),s=e.live,c=e.series,l=(s?.draft_positions?.length??0)>0,u=e=>e.always||e.lines.some(e=>!e.dash&&(c.col(e.key)??[]).some(e=>(e??0)>0)),d=iy.filter(e=>e.kinds===t&&(!e.draft||l||c.has(e.lines[0].key))&&(s?u(e):!e.draft)),f=d.find(e=>e.id===a)??d[0];if(!f)return(0,W.jsx)(wl,{children:`No data for this model yet`});let p=ay.filter(e=>(c.col(e.key)??[]).some(e=>(e??0)>0)),m=s?.experts;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-xl border bg-card`,children:[(0,W.jsx)(`div`,{role:`tablist`,className:`grid grid-cols-2 border-b sm:grid-cols-4 xl:grid-flow-col xl:auto-cols-fr xl:grid-cols-none`,children:d.map(e=>{let[t,i,a]=s?e.show(s,c,n,r):[`–`],l=e===f;return(0,W.jsxs)(`button`,{role:`tab`,"aria-selected":l,onClick:()=>o(e.id),className:J(`relative -mb-px flex min-w-0 flex-col gap-1 border-r border-b px-4 py-3 text-left transition-colors outline-none last:border-r-0 hover:bg-accent/50 focus-visible:bg-accent/60`,l&&`bg-accent/40`),children:[(0,W.jsx)(`span`,{className:`truncate text-xs font-medium text-muted-foreground`,children:e.id===`jdone`&&r?r:e.label}),(0,W.jsxs)(`span`,{className:`num flex items-baseline gap-1 text-xl leading-none font-semibold tracking-tight`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:t}),(a??e.unit)&&(0,W.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:a??e.unit})]}),(0,W.jsx)(`span`,{className:`min-h-4 truncate text-xs text-muted-foreground`,children:i}),l&&(0,W.jsx)(`span`,{className:`absolute inset-x-0 bottom-0 h-0.5 bg-primary`})]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[f.lines.length>1&&(0,W.jsx)($v,{lines:f.lines}),(0,W.jsx)(Qv,{data:c,version:eLine truncated
|
||||
R"RADPAGE(ldren:u.slice(0,r).map(e=>(0,W.jsxs)(Cp,{children:[(0,W.jsx)(Tp,{className:`num pl-4 font-medium`,children:e.id}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.prompt)}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.out)}),(0,W.jsx)(Tp,{className:`num text-right text-muted-foreground`,children:$(e.ctx)}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.ttft)?jf(e.ttft):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.pf)?kf(e.pf)+` tok/s`:`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.tps)&&e.tps>0?kf(e.tps)+` tok/s`:`–`}),(0,W.jsx)(Tp,{className:`num pr-4 text-right text-muted-foreground`,children:Nf(e.at,a)})]},e.id+`:`+e.at))})]}),u.length>r&&(0,W.jsx)(`div`,{className:`border-t p-2 text-center`,children:(0,W.jsxs)(zl,{variant:`ghost`,size:`sm`,onClick:()=>i(r+100),children:[`Show `,Math.min(100,u.length-r),` more`]})})]})})]})}var fy=e=>e>=1e3?kf(e/1e3)+`k`:kf(e);function py({pts:e}){if(e.length<2)return(0,W.jsx)(wl,{children:`Available after two finished requests`});let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.max(...t),a=Math.max(...n)*1.08,o=e=>i>r?(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r)):.5;return(0,W.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-2 gap-y-1`,children:[(0,W.jsxs)(`div`,{className:`num flex flex-col justify-between text-right text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:kf(a)}),(0,W.jsx)(`span`,{children:kf(a/2)}),(0,W.jsx)(`span`,{children:`0`})]}),(0,W.jsxs)(`div`,{className:`relative h-44 rounded-md border bg-background/40`,children:[(0,W.jsx)(`div`,{className:`absolute inset-x-0 top-1/2 border-t border-dashed border-grid`}),e.map((e,t)=>(0,W.jsxs)(dl,{children:[(0,W.jsx)(fl,{render:(0,W.jsx)(`i`,{className:`absolute size-2 -translate-x-1/2 translate-y-1/2 rounded-full bg-primary/70 ring-1 ring-background hover:bg-primary`,style:{left:2+96*o(e.x)+`%`,bottom:96*e.y/a+`%`}})}),(0,W.jsxs)(pl,{children:[e.r.id,` · `,$(e.x),` tokens of context · `,kf(e.y),` tok/s`]})]},t))]}),(0,W.jsx)(`div`,{}),(0,W.jsxs)(`div`,{className:`num flex justify-between text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:fy(r)}),(0,W.jsx)(`span`,{children:`tokens of context`}),(0,W.jsx)(`span`,{children:fy(i)})]})]})}function my({values:e}){if(e.length<2)return(0,W.jsx)(wl,{children:`Available after two finished requests`});let t=[0,.1,.2,.5,1,2,5,10,30,1/0],n=t.findIndex(t=>t>Math.max(...e)),r=t.slice(0,Math.max(6,n+1)),i=r.slice(0,-1).map((t,n)=>e.filter(e=>e>=t&&e<r[n+1]).length),a=Math.max(...i,1),o=e=>r[e+1]===1/0?`over `+jf(r[e]):`under `+jf(r[e+1]);return(0,W.jsxs)(`div`,{className:`flex h-[12.25rem] flex-col justify-end gap-1.5`,children:[(0,W.jsx)(`div`,{className:`flex flex-1 items-end justify-center gap-1.5`,children:i.map((e,t)=>(0,W.jsxs)(dl,{children:[(0,W.jsx)(fl,{render:(0,W.jsxs)(`div`,{className:`flex h-full max-w-24 flex-1 flex-col justify-end`,children:[(0,W.jsx)(`span`,{className:`num mb-1 text-center text-[11px] text-muted-foreground`,children:e||``}),(0,W.jsx)(`div`,{className:`rounded-sm bg-primary/80`,style:{height:Math.max(e?3:0,82*e/a)+`%`}})]})}),(0,W.jsxs)(pl,{children:[e,` `,e===1?`request`:`requests`,` `,o(t)]})]},t))}),(0,W.jsx)(`div`,{className:`num flex justify-center gap-1.5 border-t pt-1 text-[11px] text-muted-foreground`,children:i.map((e,t)=>(0,W.jsx)(`span`,{className:`max-w-24 flex-1 truncate text-center`,children:r[t+1]===1/0?`> `+jf(r[t]):`< `+jf(r[t+1])},t))})]})}function hy({model:e}){let{data:t,error:n}=wf(Sf(`sessions`,e),5e3);if(!t)return(0,W.jsx)(wl,{children:n??`Loading`});let r=(t.sessions??[]).slice().sort((e,t)=>e.idle_s-t.idle_s),i=(t.linear?.checkpoints_written??0)>0||r.some(e=>e.snapshots>0),a=r.filter(e=>!i||e.resume_tokens>0||e.snapshots>0),o=r.filter(e=>!a.includes(e)),s=e=>i?Math.min(e.resume_tokens||0,e.tokens):e.tokens,[c,l]=Df(t.pool?.bytes_used),[u,d]=Df(t.occupancy?.host_bytes);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,W.jsx)(ml,{label:`Resumable`,value:$(a.length),detail:o.length?`${o.length} will restart`:`cached conversations`}),(0,W.jsx)(ml,{label:`Tokens cached`,value:$(t.pool?.tokens_used),detail:t.pool?`of ${$(t.pool.tokens_total)}`:``}),(0,W.jsx)(ml,{label:`VRAM in use`,value:c,unit:l,detail:t.pool?`of ${Ef(t.pool.bytes_total)}`:``}),t.enabled?(0,W.jsx)(ml,{label:`Host memory in use`,value:u,unit:d,detail:t.occupancy?.host_cap_bytes?`of ${Ef(t.occupancy.host_cap_bytes)}`:``}):(0,W.jsx)(ml,{label:`Prefix cache hits`,value:t.prefix_hit_rate==null?`–`:(t.prefix_hit_rate*100).toFixed(1),unit:`%`,detail:`of prompt tokens reused`})]}),(0,W.jsx)(hl,{title:`Will resume`,description:a.length?`Conversations whose next turn can reuse cached tokens, most recent first`:void 0,flush:a.length>0,children:a.length?(0,W.jsx)(gy,{rows:a,reuse:s}):(0,W.jsx)(wl,{children:`No cached conversations`})}),o.lengLine truncated
|
||||
R"RADPAGE(0,W.jsx)(Ty,{fleet:n,card:i.card,hueOf:r,data:e.series,version:e.version,range:t},i.card))}),(0,W.jsx)(hl,{title:`State over time`,description:`Each model's state across the time range`,children:(0,W.jsx)(Dy,{models:n.models,data:e.series,version:e.version,range:t})}),(0,W.jsx)(hl,{title:`Models`,flush:!0,children:(0,W.jsxs)(bp,{children:[(0,W.jsx)(xp,{children:(0,W.jsxs)(Cp,{className:`hover:bg-transparent`,children:[(0,W.jsx)(wp,{className:`pl-4`,children:`Model`}),(0,W.jsx)(wp,{children:`State`}),(0,W.jsx)(wp,{className:`text-right`,children:`Priority`}),(0,W.jsx)(wp,{children:`Accelerators`}),(0,W.jsx)(wp,{className:`text-right`,children:`VRAM`}),(0,W.jsx)(wp,{className:`text-right`,children:`Host`}),(0,W.jsx)(wp,{className:`text-right`,children:`Active`}),(0,W.jsx)(wp,{className:`text-right`,children:`Loads`}),(0,W.jsx)(wp,{className:`text-right`,children:`Parks`}),(0,W.jsx)(wp,{className:`pr-4 text-right`,children:`Last load`})]})}),(0,W.jsx)(Sp,{children:n.models.map(e=>(0,W.jsxs)(Cp,{className:`cursor-pointer`,onClick:()=>{location.hash=ip(e.id)},children:[(0,W.jsxs)(Tp,{className:`pl-4`,children:[(0,W.jsxs)(`a`,{href:ip(e.id),className:`flex items-center gap-2 font-medium`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`i`,{className:`size-2 rounded-full`,style:{background:r.get(e.id)}}),e.id]}),(0,W.jsx)(`div`,{className:`mt-0.5 max-w-72 truncate pl-4 text-xs text-muted-foreground`,children:e.error??e.file})]}),(0,W.jsx)(Tp,{children:(0,W.jsx)(bl,{state:e.state,doing:e.doing})}),(0,W.jsxs)(Tp,{className:`num text-right`,children:[$(e.priority),e.pinned?` · pinned`:``]}),(0,W.jsx)(Tp,{className:`num text-muted-foreground`,children:e.cards?.length?e.cards.join(`, `):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Cy(e)>0?Ef(Cy(e)):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:(e.host_bytes??0)+(e.host_pinned_bytes??0)>0?Ef((e.host_bytes??0)+(e.host_pinned_bytes??0)):`–`}),(0,W.jsxs)(Tp,{className:`num text-right`,children:[e.in_flight?$(e.in_flight):`–`,e.waiting?` +${e.waiting}`:``]}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.loads)}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.parks)}),(0,W.jsx)(Tp,{className:`num pr-4 text-right`,children:Tf(e.load_seconds)?jf(e.load_seconds):`–`})]},e.id))})]})})]})}function Ty({fleet:e,card:t,hueOf:n,data:r,version:i,range:a}){let o=e.cards.find(e=>e.card===t),s=e.models.map(e=>({key:e.id,label:e.id,value:Sy(e,t),color:n.get(e.id),text:Ef(Sy(e,t))})),c=(o.vram_bytes??0)-(o.free_bytes??0),l=s.reduce((e,t)=>e+t.value,0),u=Math.max(Math.min(o.queue_bytes??0,c-l),0),d=c-l-u;u>0&&s.push({key:`~queues`,label:`Queues (${o.queues??0} open)`,value:u,color:`var(--idle)`,text:Ef(u)}),d>64<<20&&s.push({key:`~other`,label:`Model buffers and driver`,value:d,color:`var(--muted-foreground)`,text:Ef(d)});let f=e.models.map((e,n)=>({key:`c${t}:${e.id}`,label:e.id,color:n+1}));return(0,W.jsx)(hl,{title:(0,W.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[`Accelerator `,t,(0,W.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:o.name})]}),action:(0,W.jsxs)(`span`,{className:`num text-xs text-muted-foreground`,children:[Ef(o.free_bytes),` free of `,Ef(o.vram_bytes)]}),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(xl,{parts:s,total:o.vram_bytes,className:`h-3`}),(0,W.jsx)(Sl,{parts:s,className:`content-start xl:min-h-10`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,W.jsx)(Ey,{label:`Busy`,value:Tf(o.busy)?Math.round(o.busy*100)+`%`:`–`,data:r,k:`busy${t}`,max:1}),(0,W.jsx)(Ey,{label:`Power`,value:Tf(o.power_w)?Math.round(o.power_w)+` W`:`–`,data:r,k:`power${t}`}),(0,W.jsx)(Ey,{label:`Temperature`,value:Tf(o.temp_c)?Math.round(o.temp_c)+` °C`:`–`,data:r,k:`temp${t}`})]}),(0,W.jsx)(Qv,{data:r,version:i,lines:f,range:a,fmt:Ef,stack:!0,bytes:!0,height:170,max:o.vram_bytes})]})})}function Ey({label:e,value:t,data:n,k:r,max:i}){let a=n.col(r)??[],o=n.firstAfter(n.end-300),s=a.slice(o),c=s.filter(e=>e!==null),l=i??Math.max(1,...c)*1.05,u=i===void 0?Math.min(...c,l)*.9:0,d=s.length,f=``,p=!1;return s.forEach((e,t)=>{e===null?p=!1:(f+=(p?`L`:`M`)+(100*t/Math.max(1,d-1)).toFixed(2)+` `+(27-24*(Math.min(e,l)-u)/Math.max(1e-9,l-u)).toFixed(2),p=!0)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-background/40 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`num text-base font-semibold whitespace-nowrap`,children:t})]}),(0,W.jsx)(`svg`,{viewBox:`0 0 100 30`,preserveAspectRatio:`none`,className:`h-8 min-w-0 flex-1 text-primary`,children:(0,W.jsx)(`path`,{d:f,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})})]})}function Dy({models:e,data:t,version:n,range:r}){let i=(0,_.useMemo)(()=>{let n=t.end-r,i=t.firstAfter(n);rLine truncated
|
||||
R"RADPAGE(ate:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var Kd=_.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=Ec(u||void 0),h=Bd(),g=h?.value??[],v=(i||h?.disabled)??!1,[y,b]=Rd({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:x,buttonRef:S}=kl({disabled:v,native:d}),C={disabled:v,pressed:y},w=[S,t],T=[{"aria-pressed":y,onClick(e){let t=!y,n=Kn(qn,e.nativeEvent);o?.(t,n),n.isCanceled||(m&&h?.setGroupValue?.(m,t,n),n.isCanceled||b(t))}},p,x],E=Ca(`button`,e,{enabled:!h,state:C,ref:w,props:T}),D=_.useMemo(()=>({disabled:v,focusableWhenDisabled:!1}),[v]);return h?(0,W.jsx)(Gd,{tag:`button`,render:c,className:n,style:f,metadata:D,state:C,refs:w,props:T}):E});function qd(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Q(i),[,o]=_.useState(0),s=nt(Yd).current,c=nt(Jd).current,l=_.useRef(0),u=_.useRef(!0),d=_.useRef(null),f=_.useRef(null),p=Q(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Q((e,t)=>{c.set(e,t),p()}),h=Q(e=>{c.delete(e),p()}),g=Q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function v(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Qd(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&$d(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Zd(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=Q(()=>{let[e,t]=Xd(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});v(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&y()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let b=Q(e=>(s.add(e),()=>{s.delete(e)})),x=_.useMemo(()=>({register:m,unregister:h,subscribeMapChange:b,nextIndexRef:l}),[m,h,b,l]);return(0,W.jsx)(Vd.Provider,{value:x,children:t})}function Jd(){return new Map}function Yd(){return new Set}function Xd(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>$d(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Zd(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Qd(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function $d(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ef(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var tf=`data-composite-item-active`;function nf(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=dt}=e,[p,m]=_.useState(0),h=r!=null,g=_.useRef(null),v=dr(g,c),y=_.useRef([]),b=_.useRef(!1),x=_.useRef(null),S=o??p,C=Q((e,t=!1)=>{if(x.current=y.current[e]??null,(s??m)(e),t){let t=y.current[e];tu(g.current,t,a,n)}}),w=Q(e=>{if(e.size===0)return;if(b.current){let e=y.current,t=e.indexOf(x.current);if(t===-1){let t=e[S];!t||ui(e,S,d)?C(rf(e,d)):x.current=t}else t!==S&&C(t);return}b.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(ui(t,S,d)){let e=li(t,{disabledIndices:d});oi(t,e)||C(e)}tu(g.current,r,a,n)});Y(()=>{if(d==null||o!=null||!b.current)return;let e=y.current;if(ui(e,S,d)){let t=li(e,{disabledIndices:d});oi(e,t)||C(t)}},[d,o,S,y,C]);let T=Q((e,t,n)=>i?i(e,t,n,y):n),E=Q(e=>{let o=e.key===`Home`||e.key===`End`;if(!Zl.has(e.key)||!l&&o||af(e,f)||!g.current)return;let s=a===`rtl`,c=s?Yl:Xl,p=s?Xl:Yl,m=n===`vertical`?Jl:c,_=n===`vertical`?ql:p,v=mn(e.nativeEvent);if(v!=null&&eu(v)&&!ef(v)){let t=v.selectionStart,n=v.selectionEnd,r=v.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=si(y,d),w=ci(y,d);r!=null&&(b=r({disabledIndices:d,elementsRef:y,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:T,orientation:n,rtl:s}));let Line truncated
|
||||
R"RADPAGE(eturn()=>{r=!1,window.clearInterval(o)}},[e,t]),{data:e?Cf.get(e)??null:null,error:r}}var Tf=e=>typeof e==`number`&&Number.isFinite(e);function Ef(e){if(!Tf(e))return`–`;let t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`],n=0,r=Math.abs(e);for(;r>=1024&&n<t.length-1;)r/=1024,++n;let i=r>=100||n===0?r.toFixed(0):r>=10?r.toFixed(1):r.toFixed(2);return(e<0?`-`:``)+i+` `+t[n]}function Df(e){let t=Ef(e);if(t===`–`)return[`–`,``];let n=t.lastIndexOf(` `);return[t.slice(0,n),t.slice(n+1)]}var Of=e=>Tf(e)?Ef(e)+`/s`:`–`;function $(e,t=0){return Tf(e)?e.toLocaleString(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}):`–`}function kf(e){if(!Tf(e))return`–`;let t=Math.abs(e);return t>=100?$(e,0):t>=10?$(e,1):$(e,2)}var Af=(e,t=1)=>Tf(e)?(e*100).toFixed(t):`–`;function jf(e){return Tf(e)?e<1?Math.round(e*1e3)+` ms`:e<60?(e<10?e.toFixed(1):e.toFixed(0))+` s`:e<3600?Math.floor(e/60)+` m `+String(Math.floor(e%60)).padStart(2,`0`)+` s`:e<86400?Math.floor(e/3600)+` h `+String(Math.floor(e%3600/60)).padStart(2,`0`)+` m`:Math.floor(e/86400)+` d `+Math.floor(e%86400/3600)+` h`:`–`}function Mf(e,t=!1){let n=new Date(e*1e3),r=e=>String(e).padStart(2,`0`);return r(n.getHours())+`:`+r(n.getMinutes())+(t?`:`+r(n.getSeconds()):``)}function Nf(e,t){return jf(Math.max(0,(t-e)/1e3))+` ago`}var Pf=3600,Ff=200,If=class{t=[];c=new Map;append(e,t){let n=0;for(;n<e.length&&e[n]<=this.end;)++n;if(n===e.length)return;let r=this.t.length;for(let t=n;t<e.length;++t)this.t.push(e[t]);let i=this.t.length;for(let[e,i]of Object.entries(t)){let t=this.c.get(e);t||(t=Array(r).fill(null),this.c.set(e,t));for(let e=n;e<i.length;++e)t.push(i[e])}for(let e of this.c.values())for(;e.length<i;)e.push(null);let a=this.firstAfter(this.t[i-1]-Pf);if(a>64){this.t.splice(0,a);for(let e of this.c.values())e.splice(0,a)}}firstAfter(e){let t=0,n=this.t.length;for(;t<n;){let r=t+n>>1;this.t[r]<=e?t=r+1:n=r}return t}col(e){return this.c.get(e)}has(e){let t=this.c.get(e);return!!t&&t.some(e=>e!==null)}last(e,t=300){let n=this.c.get(e);if(n){for(let e=n.length-1;e>=0&&e>=n.length-t;--e)if(n[e]!==null)return n[e]}return null}get end(){return this.t.length?this.t[this.t.length-1]:0}},Lf=class{series=new If;live=null;finished=[];loaded=!1;error=null;refused=!1;version=0;path;subs=new Set;timer;busy=!1;users=0;constructor(e){this.path=e}subscribe=e=>(this.subs.add(e),++this.users===1&&this.start(),()=>{this.subs.delete(e),--this.users===0&&this.stop()});getVersion=()=>this.version;start(){this.poll(),this.timer=window.setInterval(()=>{document.hidden||this.poll()},Ff),document.addEventListener(`visibilitychange`,this.onVisible)}stop(){window.clearInterval(this.timer),document.removeEventListener(`visibilitychange`,this.onVisible)}onVisible=()=>{document.hidden||this.poll()};async poll(){if(!(this.busy||this.refused)){this.busy=!0;try{let e=this.series.end,t=this.path.includes(`?`)?`&`:`?`,n=await xf(this.path+(e?t+`since=`+e:``));if(this.series.append(n.t,n.c),n.requests?.length){let e=new Set(this.finished.slice(-64).map(e=>e.id+`:`+e.at));for(let t of n.requests)e.has(t.id+`:`+t.at)||this.finished.push(t);this.finished.length>500&&this.finished.splice(0,this.finished.length-500)}this.live=n.live,this.loaded=!0,this.error=null}catch(e){this.error=e instanceof Error?e.message:String(e),e instanceof bf&&e.status===403&&(this.refused=!0)}finally{this.busy=!1,++this.version,this.subs.forEach(e=>e())}}}},Rf=new Lf(`history`),zf=new Map;function Bf(e){let t=zf.get(e);return t||(t=new Lf(Sf(`history`,e)),zf.set(e,t)),t}function Vf(e){return(0,_.useSyncExternalStore)(e.subscribe,e.getVersion),e}function Hf(e){let t=e,n=new Set;return{get:()=>t,set(e){e!==t&&(t=e,n.forEach(e=>e()))},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}var Uf=e=>{try{return localStorage.getItem(e)}catch{return null}},Wf=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},Gf=Hf(document.documentElement.classList.contains(`dark`)?`dark`:`light`);function Kf(e){document.documentElement.classList.toggle(`dark`,e===`dark`),Wf(`radiance.theme`,e),Gf.set(e)}var qf=()=>(0,_.useSyncExternalStore)(Gf.subscribe,Gf.get),Jf=[[60,`1m`],[300,`5m`],[900,`15m`],[3600,`1h`]],Yf=Number(Uf(`radiance.range`)),Xf=Hf(Jf.some(([e])=>e===Yf)?Yf:300);function Zf(e){Wf(`radiance.range`,String(e)),Xf.set(e)}var Qf=()=>(0,_.useSyncExternalStore)(Xf.subscribe,Xf.get),$f=[`performance`,`requests`,`sessions`,`details`];function ep(){let e=/^#\/m\/([^/]+)(?:\/([a-z]+))?/.exec(location.hash);if(!e)return{model:null,tab:`performance`};let t=$f.includes(e[2])?e[2]:`performance`;return{model:decodeURIComponent(e[1]),tab:t}}var tp=ep(),np=new Set;window.addEventListener(`hashchange`,()=>{tp=ep(),np.forEach(e=>e())});var rp=()=>(0,_.useSyncExternalStore)(e=>(np.add(e),()=>{np.delete(e)}),()=>tp),ip=(e,t=`performance`)=>e===null?`#/`:`#/m/`+encodeURIComponent(e)+`/`+t,ap=_.createContext(void 0);function op(){let e=_.useContext(ap);if(e===void 0)throw Error(mt(64));return e}var sp=`data-activation-direction`,cp={tabActivationDLine truncated
|
||||
R"RADPAGE(-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function bp({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,W.jsx)(`table`,{"data-slot":`table`,className:J(`w-full caption-bottom text-sm`,e),...t})})}function xp({className:e,...t}){return(0,W.jsx)(`thead`,{"data-slot":`table-header`,className:J(`[&_tr]:border-b`,e),...t})}function Sp({className:e,...t}){return(0,W.jsx)(`tbody`,{"data-slot":`table-body`,className:J(`[&_tr:last-child]:border-0`,e),...t})}function Cp({className:e,...t}){return(0,W.jsx)(`tr`,{"data-slot":`table-row`,className:J(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function wp({className:e,...t}){return(0,W.jsx)(`th`,{"data-slot":`table-head`,className:J(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function Tp({className:e,...t}){return(0,W.jsx)(`td`,{"data-slot":`table-cell`,className:J(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}var Ep=_.createContext(void 0);function Dp(){let e=_.useContext(Ep);if(e===void 0)throw Error(mt(63));return e}var Op=`data-checked`,kp=`data-unchecked`,Ap={...Hu,checked(e){return e?{[Op]:``}:{[kp]:``}}},jp=_.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:v,style:y,...b}=e,{clearErrors:x}=qu(),{state:S,setTouched:C,setDirty:w,validityData:T,setFilled:E,validationMode:D,disabled:O,name:k,validation:A}=Gu(),{labelId:j}=Yu(),M=O||m,N=k??l,P=_.useRef(null),F=dr(P,c,A.inputRef),I=_.useRef(null),L=ed(M,I),R=Ec(),z=$u({id:s}),B=u?void 0:z,[V,ee]=Rd({controlled:n,default:!!i,name:`Switch`,state:`checked`});td(I,R,V,void 0,!M,l),Y(()=>{E(V)},[V,E]),ku(V,()=>{x(N),w(V!==T.initialValue),A.change(V)});let{getButtonProps:H,buttonRef:te}=kl({disabled:M,native:u}),ne=Xu(a,j,P,!u,B,b[`aria-label`]),U={id:u?z:R,role:`switch`,"aria-checked":V,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":ne,onFocus(){L(!0)},onBlur(){let e=P.current;e&&!M&&(C(!0),L(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){if(f||M)return;e.preventDefault();let t=P.current;t&&Ol(t,e)}},re={...A.getValidationProps(M),checked:V,disabled:M,form:o,id:B,name:N,required:p,style:N?jr:Ar,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Kn(qn,e.nativeEvent);d?.(t,n),n.isCanceled||ee(t)},onClick(e){e.stopPropagation()},onFocus(){I.current?.focus()},...v===void 0?ft:{value:v}},ie=_.useMemo(()=>({...S,checked:V,disabled:M,readOnly:f,required:p}),[S,V,M,f,p]),ae=Ca(`span`,e,{state:ie,ref:[t,I,te],props:[U,b,H,e=>A.getValidationProps(M,e)],stateAttributesMapping:Ap});return(0,W.jsxs)(Ep.Provider,{value:ie,children:[ae,!V&&N&&g!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,form:o,name:N,value:g,disabled:M}),(0,W.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),Mp=_.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Ca(`span`,e,{state:Dp(),ref:t,stateAttributesMapping:Ap,props:a})});function Np({className:e,size:t=`default`,...n}){return(0,W.jsx)(jp,{"data-slot":`switch`,"data-size":t,className:J(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:curLine truncated
|
||||
R"RADPAGE(`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.kernels)}),(0,W.jsx)(Tp,{className:`pr-4 text-muted-foreground`,children:e.build_target??`–`})]},e.name))})]})}),(n.notes?.length??0)>0&&(0,W.jsx)(hl,{title:`Notes`,description:`Messages from the model plugin during setup`,children:(0,W.jsx)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:n.notes.map((e,t)=>(0,W.jsx)(`li`,{className:`border-l-2 pl-3 leading-snug`,children:e},t))})})]}),(0,W.jsx)(cd,{open:!!s,onOpenChange:e=>{e||c(null)},children:(0,W.jsx)(dd,{className:`w-full gap-0 overflow-y-auto sm:max-w-xl`,children:s&&(0,W.jsx)(Rp,{op:s})})})]})}function Lp({model:e}){let[t,n]=(0,_.useState)(null),r=()=>{xf(Sf(`admin/control-vector`,e)).then(n).catch(()=>n(null))};return(0,_.useEffect)(r,[e]),t?(0,W.jsxs)(`label`,{className:`flex items-center gap-3 rounded-xl border bg-card px-4 py-3`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Control vector`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted-foreground`,children:t.name??``}),(0,W.jsx)(Np,{checked:!!t.default,onCheckedChange:i=>{n({...t,default:i}),xf(Sf(`admin/control-vector`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:i})}).catch(()=>void 0).finally(r)}})]}):null}function Rp({op:e}){let t=Pp(e),n=[[`Geometry`,e.geometry],[`Launches per pass`,$(e.count??1)],[`Range`,e.ranged?`${e.ranged} from ${e.range_lo} to ${e.range_hi}`:void 0],[`Kernel`,t?.kernel],[`Library`,t?.plugin],[`Computes`,t?.computes],[`Shapes`,t?.shape],[`Types`,t?.dtypes],[`Requires`,t?.constraints?.length?t.constraints.join(`; `):void 0]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(fd,{children:[(0,W.jsx)(pd,{children:e.op}),(0,W.jsx)(md,{children:e.schema?.doc??`Op `+e.index})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-6`,children:[(0,W.jsx)(`dl`,{className:`grid grid-cols-[8rem_1fr] gap-x-3 gap-y-2 text-sm`,children:n.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`contents`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`min-w-0 break-words font-mono text-xs leading-5`,children:t})]},e))}),(e.weights?.length??0)>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`Weights`}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:e.weights.slice(0,24).map(e=>(0,W.jsxs)(`div`,{className:`flex items-baseline gap-3 border-b px-3 py-1.5 text-xs last:border-b-0`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.dtype,` · `,e.shape]}),(0,W.jsx)(`span`,{className:`num w-20 text-right`,children:Ef(e.bytes)})]},e.name))})]}),(e.bands?.length??0)>1&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`By size`}),(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:e.bands.map(e=>(0,W.jsxs)(`div`,{className:`flex items-baseline gap-3 border-b px-3 py-1.5 text-xs last:border-b-0`,children:[(0,W.jsx)(`span`,{className:`num w-28 text-muted-foreground`,children:e.span}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:(e.device??e.host)?.kernel??`–`})]},e.span))})]})]})]})}var zp=!0,Bp=`uplot`,Vp=`u-hz`,Hp=`u-vt`,Up=`u-title`,Wp=`u-wrap`,Gp=`u-under`,Kp=`u-over`,qp=`u-axis`,Jp=`u-off`,Yp=`u-select`,Xp=`u-cursor-x`,Zp=`u-cursor-y`,Qp=`u-cursor-pt`,$p=`u-legend`,em=`u-live`,tm=`u-inline`,nm=`u-series`,rm=`u-marker`,im=`u-label`,am=`u-value`,om=`width`,sm=`height`,cm=`top`,lm=`bottom`,um=`left`,dm=`right`,fm=`#000`,pm=`#0000`,mm=`mousemove`,hm=`mousedown`,gm=`mouseup`,_m=`mouseenter`,vm=`mouseleave`,ym=`dblclick`,bm=`resize`,xm=`scroll`,Sm=`change`,Cm=`dppxchange`,wm=`--`,Tm=typeof window<`u`,Em=Tm?document:null,Dm=Tm?window:null,Om=Tm?navigator:null,km,Am;function jm(){let e=devicePixelRatio;km!=e&&(km=e,Am&&Km(Sm,Am,jm),Am=matchMedia(`(min-resolution: ${km-.001}dppx) and (max-resolution: ${km+.001}dppx)`),Gm(Sm,Am,jm),Dm.dispatchEvent(new CustomEvent(Cm)))}function Mm(e,t){if(t!=null){let n=e.classList;!n.contains(t)&&n.add(t)}}function Nm(e,t){let n=e.classList;n.contains(t)&&n.remove(t)}function Pm(e,t,n){e.style[t]=n+`px`}function Fm(e,t,n,r){let i=Em.createElement(e);return t!=null&&Mm(i,t),n?.insertBefore(i,r),i}function Im(e,t){return Fm(`div`,e,t)}var Lm=new WeakMap;function Rm(e,t,n,r,i){let a=`translate(`+t+`px,`+n+`px)`;a!=Lm.get(e)&&(e.style.transform=a,Lm.set(e,a),t<0||n<0||t>r||n>i?Mm(e,Jp):Nm(e,Jp))}var zm=new WeakMap;function Bm(e,t,n){let r=t+n;r!=zm.get(e)&&(zm.set(e,r),e.style.background=t,e.style.borderColor=n)}var Vm=new WeakMap;function Hm(e,t,n,r){let i=t+``+n;i!=Vm.get(e)&&(Vm.set(e,i),e.style.height=n+`px`,e.style.width=t+`px`,e.style.marginLeft=r?-t/2+`px`:0,e.style.marginTop=r?-n/2+`px`:0)}var Um=Line truncated
|
||||
`,Mg=`{YYYY}`,Ng=jg+Mg,Pg=`{M}/{D}`,Fg=jg+Pg,Ig=Fg+`/{YY}`,Lg=`{aa}`,Rg=`{h}:{mm}`+Lg,zg=jg+Rg,Bg=)RADPAGE"
|
||||
R"RADPAGE(`:{ss}`,Vg=null;function Hg(e){let t=e*1e3,n=t*60,r=n*60,i=r*24,a=i*30,o=i*365,s=(e==1?Gh(10,0,3,Eg).filter(Tg):Gh(10,-3,0,Eg)).concat([t,t*5,t*10,t*15,t*30,n,n*5,n*10,n*15,n*30,r,r*2,r*3,r*4,r*6,r*8,r*12,i,i*2,i*3,i*4,i*5,i*6,i*7,i*8,i*9,i*10,i*15,a,a*2,a*3,a*4,a*6,o,o*2,o*5,o*10,o*25,o*50,o*100]),c=[[o,Mg,Vg,Vg,Vg,Vg,Vg,Vg,1],[i*28,`{MMM}`,Ng,Vg,Vg,Vg,Vg,Vg,1],[i,Pg,Ng,Vg,Vg,Vg,Vg,Vg,1],[r,`{h}`+Lg,Ig,Vg,Fg,Vg,Vg,Vg,1],[n,Rg,Ig,Vg,Fg,Vg,Vg,Vg,1],[t,Bg,Ig+` `+Rg,Vg,Fg+` `+Rg,Vg,zg,Vg,1],[e,Bg+`.{fff}`,Ig+` `+Rg,Vg,Fg+` `+Rg,Vg,zg,Vg,1]];function l(t){return(s,c,l,u,d,f)=>{let p=[],m=d>=o,h=d>=a&&d<o,g=t(l),_=Hh(g*e,3),v=Qg(g.getFullYear(),m?0:g.getMonth(),h||m?1:g.getDate()),y=Hh(v*e,3);if(h||m){let n=h?d/a:0,r=m?d/o:0,i=_==y?_:Hh(Qg(v.getFullYear()+r,v.getMonth()+n,1)*e,3),s=new Date(gh(i/e)),c=s.getFullYear(),l=s.getMonth();for(let a=0;i<=u;a++){let o=Qg(c+r*a,l+n*a,1),s=o-t(Hh(o*e,3));i=Hh((+o+s)*e,3),i<=u&&p.push(i)}}else{let a=d>=i?i:d,o=y+(hh(l)-hh(_))+Bh(_-y,a);p.push(o);let m=t(o),h=m.getHours()+m.getMinutes()/n+m.getSeconds()/r,g=d/r,v=f/s.axes[c]._space;for(;o=Hh(o+d,e==1?0:3),!(o>u);)if(g>1){let e=hh(Hh(h+g,6))%24,n=t(o).getHours()-e;n>1&&(n=-1),o-=n*r,h=(h+g)%24;let i=p[p.length-1];Hh((o-i)/d,3)*v>=.7&&p.push(o)}else p.push(o)}return p}}return[s,c,l]}var[Ug,Wg,Gg]=Hg(1),[Kg,qg,Jg]=Hg(.001);Gh(2,-53,53,[1]);function Yg(e,t){return e.map(e=>e.map((n,r)=>r==0||r==8||n==null?n:t(r==1||e[8]==0?n:e[1]+n)))}function Xg(e,t){return(n,r,i,a,o)=>{let s=t.find(e=>o>=e[0])||t[t.length-1],c,l,u,d,f,p;return r.map(t=>{let n=e(t),r=n.getFullYear(),i=n.getMonth(),a=n.getDate(),o=n.getHours(),m=n.getMinutes(),h=n.getSeconds(),g=r!=c&&s[2]||i!=l&&s[3]||a!=u&&s[4]||o!=d&&s[5]||m!=f&&s[6]||h!=p&&s[7]||s[1];return c=r,l=i,u=a,d=o,f=m,p=h,g(n)})}}function Zg(e,t){let n=Sg(t);return(t,r,i,a,o)=>r.map(t=>n(e(t)))}function Qg(e,t,n){return new Date(e,t,n)}function $g(e,t){return t(e)}var e_=`{YYYY}-{MM}-{DD} {h}:{mm}{aa}`;function t_(e,t){return(n,r,i,a)=>a==null?wm:t(e(r))}function n_(e,t){let n=e.series[t];return n.width?n.stroke(e,t):n.points.width?n.points.stroke(e,t):null}function r_(e,t){return e.series[t].fill(e,t)}var i_={show:!0,live:!0,isolate:!1,mount:jh,markers:{show:!0,width:2,stroke:n_,fill:r_,dash:`solid`},idx:null,idxs:null,values:[]};function a_(e,t){let n=e.cursor.points,r=Im(),i=n.size(e,t);Pm(r,om,i),Pm(r,sm,i);let a=i/-2;Pm(r,`marginLeft`,a),Pm(r,`marginTop`,a);let o=n.width(e,t,i);return o&&Pm(r,`borderWidth`,o),r}function o_(e,t){let n=e.series[t].points;return n._fill||n._stroke}function s_(e,t){let n=e.series[t].points;return n._stroke||n._fill}function c_(e,t){return e.series[t].points.size}var l_=[0,0];function u_(e,t,n){return l_[0]=t,l_[1]=n,l_}function d_(e,t,n,r=!0){return e=>{e.button!=0||r&&e.target!=t||n(e)}}function f_(e,t,n,r=!0){return e=>{r&&e.target!=t||n(e)}}var p_={show:!0,x:!0,y:!0,lock:!1,move:u_,points:{one:!1,show:a_,size:c_,width:0,stroke:s_,fill:o_},bind:{mousedown:d_,mouseup:d_,click:d_,dblclick:d_,mousemove:f_,mouseleave:f_,mouseenter:f_},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,t)=>{t.stopPropagation(),t.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,t,n,r,i)=>r-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},m_={show:!0,stroke:`rgba(0,0,0,0.07)`,width:2},h_=ig({},m_,{filter:Nh}),g_=ig({},h_,{size:10}),__=ig({},m_,{show:!1}),v_=`12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`,y_=`bold `+v_,b_=1.5,x_={show:!0,scale:`x`,stroke:fm,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:y_,side:2,grid:h_,ticks:g_,border:__,font:v_,lineGap:b_,rotate:0},S_=`Value`,C_=`Time`,w_={show:!0,scale:`x`,auto:!1,sorted:1,min:Eh,max:-1/0,idxs:[]};function T_(e,t,n,r,i){return t.map(e=>e==null?``:dh(e))}function E_(e,t,n,r,i,a,o){let s=[],c=Uh.get(i)||0;n=o?n:Hh(Bh(n,i),c);for(let e=n;e<=r;e=Hh(e+i,c))s.push(Object.is(e,-0)?0:e);return s}function D_(e,t,n,r,i,a,o){let s=[],c=e.scales[e.axes[t].scale].log;i=bh(c,hh((c==10?Sh:Ch)(n))),c==10&&(i=Ag[qm(i,Ag)]);let l=n,u=i*c;c==10&&(u=Ag[qm(u,Ag)]);do s.push(l),l+=i,c==10&&!Uh.has(l)&&(l=Hh(l,Uh.get(i))),l>=u&&(i=l,u=i*c,c==10&&(u=Ag[qm(u,Ag)]));while(l<=r);return s}function O_(e,t,n,r,i,a,o){let s=e.scales[e.axes[t].scale].asinh,c=r>s?D_(e,t,yh(s,n),r,i):[s],l=r>=0&&n<=0?[0]:[];return(n<-s?D_(e,t,yh(s,-r),-n,i):[s]).reverse().map(e=>-e).concat(l,c)}var k_=/./,A_=/[12357]/,j_=/[125]/,M_=/1/,N_=(e,t,n,r)=>e.map((e,i)=>t==4&&e==0||i%r==0&&n.test(e.toExponential()[+(e<0)])?e:null);function P_(e,t,n,r,i){let a=e.axes[n],o=a.scale,s=e.scales[o],c=e.valToPos,l=a._space,u=c(10,o),d=c(9,o)-u>=l?k_:c(7,o)-u>=l?A_:c(5,o)-u>=l?j_:M_;if(d==M_){let e=mh(c(1,o)-u);if(e<l)return N_(t.slice().reverse(),s.distr,d,_h(l/e)).reverse()}return N_(t,s.distr,d,1)}function F_(e,t,n,r,i){let a=e.axes[n],o=a.scale,s=a._space,c=eLine truncated
|
||||
R"RADPAGE(,r,i,a,o)=>{u(e,t,n,i,r,o,a)},F=sh(e.bands,qh).find(e=>e.series[0]==t),I=F==null?0:F.dir,L=m.fillTo(e,t,m.min,m.max,I),R=T(b(L,v,w,S)),z,B,V,ee=C,H=T(m.width*km),te=!1,ne=null,U=null,re=null,W=null;d!=null&&(H==0||f!=null)&&(te=!0,ne=d.values(e,t,i,p),U=new Map,new Set(ne).forEach(e=>{e!=null&&U.set(e,new Path2D)}),H>0&&(re=f.values(e,t,i,p),W=new Map,new Set(re).forEach(e=>{e!=null&&W.set(e,new Path2D)})));let{x0:ie,size:ae}=l;if(ie!=null&&ae!=null){E=1,h=ie.values(e,t,i,p),ie.unit==2&&(h=h.map(t=>e.posToVal(x+t*C,_.key,!0)));let n=ae.values(e,t,i,p);B=ae.unit==2?n[0]*C:y(n[0],_,C,x)-y(0,_,C,x),ee=Sv(h,g,y,_,C,x,ee),V=ee-B+D}else ee=Sv(h,g,y,_,C,x,ee),V=ee*o+D,B=ee-V;V<1&&(V=0),H>=B/2&&(H=0),V<5&&(T=Mh);let G=V>0,oe=ee-V-(G?H:0);B=T(Oh(oe,k,O)),z=(E==0?B/2:E==M?0:B)-E*M*((E==0?D/2:0)+(G?H/2:0));let se={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},ce=te?null:new Path2D,le=null;if(F!=null)le=e.data[F.series[1]];else{let{y0:n,y1:r}=l;n!=null&&r!=null&&(g=r.values(e,t,i,p),le=n.values(e,t,i,p))}let ue=A*B,de=j*B;for(let n=M==1?i:p;n>=i&&n<=p;n+=M){let r=g[n];if(r==null)continue;if(le!=null){let e=le[n]??0;if(r-e==0)continue;R=b(e,v,w,S)}let i=y(_.distr!=2||l!=null?h[n]:n,_,C,x),a=b(sh(r,L),v,w,S),o=T(i-z),s=T(yh(a,R)),c=T(vh(a,R)),u=s-c;if(r!=null){let i=r<0?de:ue,a=r<0?ue:de;te?(H>0&&re[n]!=null&&N(W.get(re[n]),o,c+hh(H/2),B,yh(0,u-H),i,a),ne[n]!=null&&N(U.get(ne[n]),o,c+hh(H/2),B,yh(0,u-H),i,a)):N(ce,o,c+hh(H/2),B,yh(0,u-H),i,a),P(e,t,n,o-H/2,c,B+H,u)}}return H>0?se.stroke=te?W:ce:te||(se._fill=m.width==0?m._fill:m._stroke??m._fill,se.width=0),se.fill=te?U:ce,se})}function wv(e,t){let n=sh(t?.alignGaps,0);return(t,r,i,a)=>Z_(t,r,(o,s,c,l,u,d,f,p,m,h,g)=>{[i,a]=Zm(c,i,a);let _=o.pxRound,v=e=>_(d(e,l,h,p)),y=e=>_(f(e,u,g,m)),b,x,S;l.ori==0?(b=ov,S=cv,x=mv):(b=sv,S=lv,x=hv);let C=l.dir*(l.ori==0?1:-1),w=v(s[C==1?i:a]),T=w,E=[],D=[];for(let e=C==1?i:a;e>=i&&e<=a;e+=C)if(c[e]!=null){let t=s[e],n=v(t);E.push(T=n),D.push(y(c[e]))}let O={stroke:e(E,D,b,S,x,_),fill:null,clip:null,band:null,gaps:null,flags:Y_},k=O.stroke,[A,j]=Q_(t,r);if(o.fill!=null||A!=0){let e=O.fill=new Path2D(k),n=y(o.fillTo(t,r,o.min,o.max,A));S(e,T,n),S(e,w,n)}if(!o.spanGaps){let e=[];e.push(...rv(s,c,i,a,C,v,n)),O.gaps=e=o.gaps(t,r,i,a,e),O.clip=tv(e,l.ori,p,m,h,g)}return j!=0&&(O.band=j==2?[ev(t,r,i,a,k,-1),ev(t,r,i,a,k,1)]:ev(t,r,i,a,k,j)),O})}function Tv(e){return wv(Ev,e)}function Ev(e,t,n,r,i,a){let o=e.length;if(o<2)return null;let s=new Path2D;if(n(s,e[0],t[0]),o==2)r(s,e[1],t[1]);else{let n=Array(o),r=Array(o-1),a=Array(o-1),c=Array(o-1);for(let n=0;n<o-1;n++)a[n]=t[n+1]-t[n],c[n]=e[n+1]-e[n],r[n]=a[n]/c[n];n[0]=r[0];for(let e=1;e<o-1;e++)r[e]===0||r[e-1]===0||r[e-1]>0!=r[e]>0?n[e]=0:(n[e]=3*(c[e-1]+c[e])/((2*c[e]+c[e-1])/r[e-1]+(c[e]+2*c[e-1])/r[e]),isFinite(n[e])||(n[e]=0));n[o-1]=r[o-2];for(let r=0;r<o-1;r++)i(s,e[r]+c[r]/3,t[r]+n[r]*c[r]/3,e[r+1]-c[r]/3,t[r+1]-n[r+1]*c[r]/3,e[r+1],t[r+1])}return s}var Dv=new Set;function Ov(){for(let e of Dv)e.syncRect(!0)}Tm&&(Gm(bm,Dm,Ov),Gm(xm,Dm,Ov,!0),Gm(Cm,Dm,()=>{Wv.pxRatio=km}));var kv=bv(),Av=gv();function jv(e,t,n,r){return(r?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map((e,r)=>Nv(e,r,t,n))}function Mv(e,t){return e.map((e,n)=>n==0?{}:ig({},t,e))}function Nv(e,t,n,r){return ig({},t==0?n:r,e)}function Pv(e,t,n){return t==null?Jh:[t,n]}var Fv=Pv;function Iv(e,t,n){return t==null?Jh:oh(t,n,nh,!0)}function Lv(e,t,n,r){return t==null?Jh:eh(t,n,e.scales[r].log,!1)}var Rv=Lv;function zv(e,t,n,r){return t==null?Jh:th(t,n,e.scales[r].log,!1)}var Bv=zv;function Vv(e,t,n,r,i){let a=yh(Dh(e),Dh(t)),o=t-e,s=qm(i/r*o,n);do{let e=n[s],t=r*e/o;if(t>=i&&a+(e<5?Uh.get(e):0)<=17)return[e,t]}while(++s<n.length);return[0,0]}function Hv(e){let t,n;return e=e.replace(/(\d+)px/,(e,r)=>(t=gh((n=+r)*km))+`px`),[e,t,n]}function Uv(e){e.show&&[e.font,e.labelFont].forEach(e=>{let t=Hh(e[2]*km,1);e[0]=e[0].replace(/[0-9.]+px/,t+`px`),e[1]=t})}function Wv(e,t,n){let r={mode:sh(e.mode,1)},i=r.mode;function a(e,t,n,r){let i=t.valToPct(e);return r+n*(t.dir==-1?1-i:i)}function o(e,t,n,r){let i=t.valToPct(e);return r+n*(t.dir==-1?i:1-i)}function s(e,t,n,r){return t.ori==0?a(e,t,n,r):o(e,t,n,r)}r.valToPosH=a,r.valToPosV=o;let c=!1;r.status=0;let l=r.root=Im(Bp);if(e.id!=null&&(l.id=e.id),Mm(l,e.class),e.title){let t=Im(Up,l);t.textContent=e.title}let u=Fm(`canvas`),d=r.ctx=u.getContext(`2d`),f=Im(Wp,l);Gm(`click`,f,e=>{e.target===m&&(Zt!=qt||Qt!=Jt)&&en.click(r,e)},!0);let p=r.under=Im(Gp,f);f.appendChild(u);let m=r.over=Im(Kp,f);e=rg(e);let h=+sh(e.pxAlign,1),g=iv(h);(e.plugins||[]).forEach(t=>{t.opts&&(e=t.opts(r,e)||e)});let _=e.ms||.001,v=r.series=i==1?jv(e.series||[],w_,U_,!1):Mv(e.series||[null],H_),y=r.axes=jv(e.axes||[],x_,L_,!0),b=r.scales={},x=r.bands=e.bands||[];x.forEach(e=>{e.fill=Ah(e.fill||null),e.dir=sh(e.dir,-1)});let S=i==2?v[1].facets[0].scale:v[0].scale,C={axes:Mt,series:xt},w=(e.drawOrder||[`axes`,`series`]).map(e=>C[e]);function T(e){let t=e.distr==3?t=>Sh(t>0?Line truncated
|
||||
R"RADPAGE(a,o,s]=n,c=t%2,l=0;return c==0&&(s||a)&&(l=t==0&&!i||t==2&&!o?gh(x_.size/3):0),c==1&&(i||o)&&(l=t==1&&!a||t==3&&!s?gh(L_.size/2):0),l}let Xe=r.padding=(e.padding||[Ye,Ye,Ye,Ye]).map(e=>Ah(sh(e,Ye))),Ze=r._padding=Xe.map((e,t)=>e(r,t,Je,0)),Qe,$e=null,et=null,tt=i==1?v[0].idxs:null,nt=null,rt=!1;function it(e,n){if(t=e??[],r.data=r._data=t,i==2){Qe=0;for(let e=1;e<v.length;e++)Qe+=t[e][0].length}else{t.length==0&&(r.data=r._data=t=[[]]),nt=t[0],Qe=nt.length;let e=t;if(O==2){e=t.slice();let n=e[0]=Array(Qe);for(let e=0;e<Qe;e++)n[e]=e}r._data=t=e}if(Nt(!0),Gn(`setData`),O==2&&(Ee=!0),n!==!1){let e=D;e.auto(r,rt)?at():cn(S,e.min,e.max),De||=z.left>=0,ke=!0,Rt()}}r.setData=it;function at(){rt=!0;let e,n;i==1&&(Qe>0?($e=tt[0]=0,et=tt[1]=Qe-1,e=t[0][$e],n=t[0][et],O==2?(e=$e,n=et):e==n&&(O==3?[e,n]=eh(e,e,D.log,!1):O==4?[e,n]=th(e,e,D.log,!1):D.time?n=e+gh(86400/_):[e,n]=oh(e,n,nh,!0))):($e=tt[0]=e=null,et=tt[1]=n=null)),cn(S,e,n)}let ot,st,ct,lt,ut,dt,ft,Y,pt,mt;function ht(e,t,n,r,i,a){e??=pm,n??=qh,r??=`butt`,i??=pm,a??=`round`,e!=ot&&(d.strokeStyle=ot=e),i!=st&&(d.fillStyle=st=i),t!=ct&&(d.lineWidth=ct=t),a!=ut&&(d.lineJoin=ut=a),r!=dt&&(d.lineCap=dt=r),n!=lt&&d.setLineDash(lt=n)}function gt(e,t,n,r){t!=st&&(d.fillStyle=st=t),e!=ft&&(d.font=ft=e),n!=Y&&(d.textAlign=Y=n),r!=pt&&(d.textBaseline=pt=r)}function _t(e,t,n,i,a=0){if(i.length>0&&e.auto(r,rt)&&(t==null||t.min==null)){let t=sh($e,0),r=sh(et,i.length-1),o=n.min==null?$m(i,t,r,a,e.distr==3):[n.min,n.max];e.min=vh(e.min,n.min=o[0]),e.max=yh(e.max,n.max=o[1])}}let vt={min:null,max:null};function yt(){for(let e in b){let t=b[e];j[e]==null&&(t.min==null||j[S]!=null&&t.auto(r,rt))&&(j[e]=vt)}for(let e in b){let t=b[e];j[e]==null&&t.from!=null&&j[t.from]!=null&&(j[e]=vt)}j[S]!=null&&Nt(!0);let e={};for(let t in j){let n=j[t];if(n!=null){let a=e[t]=rg(b[t],eg);if(n.min!=null)ig(a,n);else if(t!=S||i==2){if(Qe==0&&a.from==null){let e=a.range(r,null,null,t);a.min=e[0],a.max=e[1]}else a.min=Eh,a.max=-1/0}}}if(Qe>0){v.forEach((n,a)=>{if(i==1){let i=n.scale,o=j[i];if(o==null)return;let s=e[i];if(a==0){let e=s.range(r,s.min,s.max,i);s.min=e[0],s.max=e[1],$e=qm(s.min,t[0]),et=qm(s.max,t[0]),et-$e>1&&(t[0][$e]<s.min&&$e++,t[0][et]>s.max&&et--),n.min=nt[$e],n.max=nt[et]}else n.show&&n.auto&&_t(s,o,n,t[a],n.sorted);n.idxs[0]=$e,n.idxs[1]=et}else if(a>0&&n.show&&n.auto){let[r,i]=n.facets,o=r.scale,s=i.scale,[c,l]=t[a],u=e[o],d=e[s];u!=null&&_t(u,j[o],r,c,r.sorted),d!=null&&_t(d,j[s],i,l,i.sorted),n.min=i.min,n.max=i.max}});for(let t in e){let n=e[t],i=j[t];if(n.from==null&&(i==null||i.min==null)){let e=n.range(r,n.min==Eh?null:n.min,n.max==-1/0?null:n.max,t);n.min=e[0],n.max=e[1]}}}for(let t in e){let n=e[t];if(n.from!=null){let i=e[n.from];if(i.min==null)n.min=n.max=null;else{let e=n.range(r,i.min,i.max,t);n.min=e[0],n.max=e[1]}}}let n={},a=!1;for(let t in e){let r=e[t],i=b[t];if(i.min!=r.min||i.max!=r.max){i.min=r.min,i.max=r.max;let e=i.distr;i._min=e==3?Sh(i.min):e==4?Th(i.min,i.asinh):e==100?i.fwd(i.min):i.min,i._max=e==3?Sh(i.max):e==4?Th(i.max,i.asinh):e==100?i.fwd(i.max):i.max,n[t]=a=!0}}if(a){v.forEach((e,t)=>{i==2?t>0&&n.y&&(e._paths=null):n[e.scale]&&(e._paths=null)});for(let e in n)Ee=!0,Gn(`setScale`,e);V&&z.left>=0&&(De=ke=!0)}for(let e in j)j[e]=null}function bt(e){let t=Oh($e-1,0,Qe-1),n=Oh(et+1,0,Qe-1);for(;e[t]==null&&t>0;)t--;for(;e[n]==null&&n<Qe-1;)n++;return[t,n]}function xt(){if(Qe>0){let e=v.some(e=>e._focus)&&mt!=Re.alpha;e&&(d.globalAlpha=mt=Re.alpha),v.forEach((e,n)=>{if(n>0&&e.show&&(St(n,!1),St(n,!0),e._paths==null)){let a=mt;mt!=e.alpha&&(d.globalAlpha=mt=e.alpha);let o=i==2?[0,t[n][0].length-1]:bt(t[n]);e._paths=e.paths(r,n,o[0],o[1]),mt!=a&&(d.globalAlpha=mt=a)}}),v.forEach((e,t)=>{if(t>0&&e.show){let n=mt;mt!=e.alpha&&(d.globalAlpha=mt=e.alpha),e._paths!=null&&Ct(t,!1);{let n=e._paths==null?null:e._paths.gaps,i=e.points.show(r,t,$e,et,n),a=e.points.filter(r,t,i,n);(i||a)&&(e.points._paths=e.points.paths(r,t,$e,et,a),Ct(t,!0))}mt!=n&&(d.globalAlpha=mt=n),Gn(`drawSeries`,t)}}),e&&(d.globalAlpha=mt=1)}}function St(e,t){let n=t?v[e].points:v[e];n._stroke=n.stroke(r,e),n._fill=n.fill(r,e)}function Ct(e,t){let n=t?v[e].points:v[e],{stroke:r,fill:i,clip:a,flags:o,_stroke:s=n._stroke,_fill:c=n._fill,_width:l=n.width}=n._paths;l=Hh(l*km,3);let u=null,f=l%2/2;t&&c==null&&(c=l>0?`#fff`:s);let p=n.pxAlign==1&&f>0;if(p&&d.translate(f,f),!t){let e=be-l/2,t=xe-l/2,n=Se+l,r=Ce+l;u=new Path2D,u.rect(e,t,n,r)}t?Tt(s,l,n.dash,n.cap,c,r,i,o,a):wt(e,s,l,n.dash,n.cap,c,r,i,o,u,a),p&&d.translate(-f,-f)}function wt(e,n,i,a,o,s,c,l,u,d,f){let p=!1;u!=0&&x.forEach((m,h)=>{if(m.series[0]==e){let e=v[m.series[1]],g=t[m.series[1]],_=(e._paths||Kh).band;Yh(_)&&(_=m.dir==1?_[0]:_[1]);let y,b=null;e.show&&_&&ch(g,$e,et)?(b=m.fill(r,h)||s,y=e._paths.clip):_=null,Tt(n,i,a,o,b,c,l,u,d,f,y,_),p=!0}}),p||Tt(n,i,a,o,s,c,l,u,d,f)}function Tt(e,t,n,r,i,a,o,s,c,l,u,f){ht(e,t,n,r,i),(c||l||f)&&(d.save(),c&&d.clip(c),l&&d.clip(l)),f?(s&3)==3?(d.clip(f),u&&d.clip(u),Dt(i,oLine truncated
|
||||
`)==-1?[t]:t.split(/\n/gm);for(let e=0;e<n.length;e++){let t=n[e];D?(d.save(),d.translate(a,o+e*j),d.rotate(D),d.fillText(t,0,0),d.restore()):d.fillText(t,a,o+e*j)}}}S.show&&kt(M,S.filter(r,v,e,f,x),i,n,O,T,Hh(S.width*km,3),S.stroke(r,e),S.dash,S.cap);let P=t.grid;P.show&&kt(M,P.filter(r,v,e,f,x),i,i==0?2:1,i==0?xe:be,i==0?Ce:Se,Hh(P.width*km,3),P.stroke(r,e),P.dash,P.cap),C.show&&kt([O],[1],+(i==0),i==0?1:2,i==1?xe:be,i==1?Ce:Se,Hh(C.width*km,3),C.stroke(r,e),C.dash,C.cap)}Gn(`drawAxes`)}function Nt(e){v.forEach((t,n)=>{n>0&&(t._paths=null,e&&(i==1?(t.min=null,t.max=null):t.facets.forEach(e=>{e.min=null,e.max=null})))})}let Pt=!1,Ft=!1,It=[];function Lt(){Ft=!1;for(let e=0;e<It.length;e++)Gn(...It[e]);It.length=0}function Rt(){Pt||=(ug(Bt),!0)}function zt(e,t=!1){Pt=!0,Ft=t,e(r),Bt(),t&&It.length>0&&queueMicrotask(Lt)}r.batch=zt;function Bt(){if(we&&=(yt(),!1),Ee&&=(Me(),!1),Te){if(Pm(p,um,me),Pm(p,cm,he),Pm(p,om,K),Pm(p,sm,q),Pm(m,um,me),Pm(m,cm,he),Pm(m,om,K),Pm(m,sm,q),Pm(f,om,fe),Pm(f,sm,pe),u.width=gh(fe*km),u.height=gh(pe*km),y.forEach(({_el:e,_show:t,_size:n,_pos:r,side:i})=>{if(e!=null){if(t){let t=i===3||i===0?n:0,a=i%2==1;Pm(e,a?`left`:`top`,r-t),Pm(e,a?`width`:`height`,n),Pm(e,a?`top`:`left`,a?he:me),Pm(e,a?`height`:`width`,a?q:K),Nm(e,Jp)}else Mm(e,Jp)}}),ot=st=ct=ut=dt=ft=Y=pt=lt=null,mt=1,kn(!0),me!=ge||he!=_e||K!=ve||q!=ye){Nt(!1);let e=K/ve,t=q/ye;if(V&&!De&&z.left>=0){z.left*=e,z.top*=t,Wt&&Rm(Wt,gh(z.left),0,K,q),Gt&&Rm(Gt,0,gh(z.top),K,q);for(let n=0;n<Ve.length;n++){let r=Ve[n];r!=null&&(He[n]*=e,Ue[n]*=t,Rm(r,_h(He[n]),_h(Ue[n]),K,q))}}if(rn.show&&!Oe&&rn.left>=0&&rn.width>0){rn.left*=e,rn.width*=e,rn.top*=t,rn.height*=t;for(let e in Mn)Pm(an,e,rn[e])}ge=me,_e=he,ve=K,ye=q}Gn(`setSize`),Te=!1}fe>0&&pe>0&&(d.clearRect(0,0,u.width,u.height),Gn(`drawClear`),w.forEach(e=>e()),Gn(`draw`)),rn.show&&Oe&&(on(rn),Oe=!1),V&&De&&(Dn(null,!0,!1),De=!1),R.show&&R.live&&ke&&(Tn(),ke=!1),c||(c=!0,r.status=1,Gn(`ready`)),rt=!1,Pt=!1}r.redraw=(e,t)=>{Ee=t||!1,e===!1?Rt():cn(S,D.min,D.max)};function Vt(e,n){let i=b[e];if(i.from==null){if(Qe==0){let t=i.range(r,n.min,n.max,e);n.min=t[0],n.max=t[1]}if(n.min>n.max){let e=n.min;n.min=n.max,n.max=e}if(Qe>1&&n.min!=null&&n.max!=null&&n.max-n.min<1e-16)return;e==S&&i.distr==2&&Qe>0&&(n.min=qm(n.min,t[0]),n.max=qm(n.max,t[0]),n.min==n.max&&n.max++),j[e]=n,we=!0,Rt()}}r.setScale=Vt;let Ht,Ut,Wt,Gt,X,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t=!1,en=z.drag,tn=en.x,nn=en.y;V&&(z.x&&(Ht=Im(Xp,m)),z.y&&(Ut=Im(Zp,m)),D.ori==0?(Wt=Ht,Gt=Ut):(Wt=Ut,Gt=Ht),Zt=z.left,Qt=z.top);let rn=r.select=ig({show:!0,over:!0,left:0,width:0,top:0,height:0},e.select),an=rn.show?Im(Yp,rn.over?m:p):null;function on(e,t){if(rn.show){for(let t in e)rn[t]=e[t],t in Mn&&Pm(an,t,e[t]);t!==!1&&Gn(`setSelect`)}}r.setSelect=on;function sn(e){if(v[e].show)B&&Nm(U[e],Jp);else if(B&&Mm(U[e],Jp),V){let t=Be?Ve[0]:Ve[e];t!=null&&Rm(t,-10,-10,K,q)}}function cn(e,t,n){Vt(e,{min:t,max:n})}function ln(e,t,n,a){t.focus!=null&&_n(e),t.show!=null&&v.forEach((n,r)=>{r>0&&(e==r||e==null)&&(n.show=t.show,sn(r),i==2?(cn(n.facets[0].scale,null,null),cn(n.facets[1].scale,null,null)):cn(n.scale,null,null),Rt())}),n!==!1&&Gn(`setSeries`,e,t),a&&Xn(`setSeries`,r,e,t)}r.setSeries=ln;function un(e,t){ig(x[e],t)}function dn(e,t){e.fill=Ah(e.fill||null),e.dir=sh(e.dir,-1),t??=x.length,x.splice(t,0,e)}function fn(e){e==null?x.length=0:x.splice(e,1)}r.addBand=dn,r.setBand=un,r.delBand=fn;function Z(e,t){v[e].alpha=t,V&&Ve[e]!=null&&(Ve[e].style.opacity=t),B&&U[e]&&(U[e].style.opacity=t)}let pn,mn,hn,gn={focus:!0};function _n(e){if(e!=hn){let t=e==null,n=Re.alpha!=1;v.forEach((r,a)=>{if(i==1||a>0){let i=t||a==0||a==e;r._focus=t?null:i,n&&Z(a,i?1:Re.alpha)}}),hn=e,n&&Rt()}}B&&ze&&ue(vm,H,e=>{z._lock||(Ie(e),hn!=null&&ln(null,gn,!0,qn.setSeries))});function vn(e,t,n){let r=b[t];n&&(e=e/km-(r.ori==1?he:me));let i=K;r.ori==1&&(i=q,e=i-e),r.dir==-1&&(e=i-e);let a=r._min,o=r._max,s=e/i,c=a+(o-a)*s,l=r.distr;return l==3?bh(10,c):l==4?wh(c,r.asinh):l==100?r.bwd(c):c}function yn(e,n){return qm(vn(e,S,n),t[0],$e,et)}r.valToIdx=e=>qm(e,t[0]),r.posToIdx=yn,r.posToVal=vn,r.valToPos=(e,t,n)=>b[t].ori==0?a(e,b[t],n?Se:K,n?be:0):o(e,b[t],n?Ce:q,n?xe:0),r.setCursor=(e,t,n)=>{Zt=e.left,Qt=e.top,Dn(null,t,n)};function bn(e,t){Pm(an,um,rn.left=e),Pm(an,om,rn.width=t)}function xn(e,t){Pm(an,cm,rn.top=e),Pm(an,sm,rn.height=t)}let Sn=D.ori==0?bn:xn,Cn=D.ori==1?bn:xn;function wn(){if(B&&R.live)for(let e=+(i==2);e<v.length;e++){if(e==0&&ie)continue;let t=R.values[e],n=0;for(let r in t)re[e][n++].firstChild.nodeValue=t[r]}}function Tn(e,t){if(e!=n)RADPAGE"
|
||||
R"RADPAGE(ull&&(e.idxs?e.idxs.forEach((e,t)=>{L[t]=e}):Zh(e.idx)||L.fill(e.idx),R.idx=L[0]),B&&R.live){for(let e=0;e<v.length;e++)(e>0||i==1&&!ie)&&En(e,L[e]);wn()}ke=!1,t!==!1&&Gn(`setLegend`)}r.setLegend=Tn;function En(e,n){let i=v[e],a=e==0&&O==2?nt:t[e],o;ie?o=i.values(r,e,n)??ae:(o=i.value(r,n==null?null:a[n],e,n),o=o==null?ae:{_:o}),R.values[e]=o}function Dn(e,n,a){Yt=Zt,Xt=Qt,[Zt,Qt]=z.move(r,Zt,Qt),z.left=Zt,z.top=Qt,V&&(Wt&&Rm(Wt,gh(Zt),0,K,q),Gt&&Rm(Gt,0,gh(Qt),K,q));let o,s=$e>et;pn=Eh,mn=null;let c=D.ori==0?K:q,l=D.ori==1?K:q;if(Zt<0||Qe==0||s){o=z.idx=null;for(let e=0;e<v.length;e++){let t=Ve[e];t!=null&&Rm(t,-10,-10,K,q)}ze&&ln(null,gn,!0,e==null&&qn.setSeries),R.live&&(L.fill(o),ke=!0)}else{let e,n,a;i==1&&(e=D.ori==0?Zt:Qt,n=vn(e,S),o=z.idx=qm(n,t[0],$e,et),a=k(t[0][o],D,c,0));let s=-10,u=-10,d=0,f=0,p=!0,m=``,h=``;for(let e=+(i==2);e<v.length;e++){let g=v[e],_=L[e],y=_==null?null:i==1?t[e][_]:t[e][1][_],x=z.dataIdx(r,e,o,n),S=x==null?null:i==1?t[e][x]:t[e][1][x];if(ke=ke||S!=y||x!=_,L[e]=x,e>0&&g.show){let n=x==null?-10:x==o?a:k(i==1?t[0][x]:t[e][0][x],D,c,0),_=S==null?-10:A(S,i==1?b[g.scale]:b[g.facets[1].scale],l,0);if(ze&&S!=null){let t=D.ori==1?Zt:Qt,n=mh(Re.dist(r,e,x,_,t));if(n<pn){let r=Re.bias;if(r!=0){let i=vn(t,g.scale),a=S>=0?1:-1,o=i>=0?1:-1;o==a&&(o==1?r==1?S>=i:S<=i:r==1?S<=i:S>=i)&&(pn=n,mn=e)}else pn=n,mn=e}}if(ke||Be){let t,i;D.ori==0?(t=n,i=_):(t=_,i=n);let a,o,c,l,g,v,y=!0,b=Le.bbox;if(b!=null){y=!1;let t=b(r,e);c=t.left,l=t.top,a=t.width,o=t.height}else c=t,l=i,a=o=Le.size(r,e);if(v=Le.fill(r,e),g=Le.stroke(r,e),Be)e==mn&&pn<=Re.prox&&(s=c,u=l,d=a,f=o,p=y,m=v,h=g);else{let t=Ve[e];t!=null&&(He[e]=c,Ue[e]=l,Hm(t,a,o,y),Bm(t,v,g),Rm(t,_h(c),_h(l),K,q))}}}}if(Be){let e=Re.prox;if(ke||(hn==null?pn<=e:pn>e||mn!=hn)){let e=Ve[0];e!=null&&(He[0]=s,Ue[0]=u,Hm(e,d,f,p),Bm(e,m,h),Rm(e,_h(s),_h(u),K,q))}}}if(rn.show&&$t){if(e!=null){let[t,n]=qn.scales,[r,i]=qn.match,[a,o]=e.cursor.sync.scales,s=e.cursor.drag;if(tn=s._x,nn=s._y,tn||nn){let{left:s,top:u,width:d,height:f}=e.select,p=e.scales[a].ori,m=e.posToVal,h,g,_,v,y,x=t!=null&&r(t,a),S=n!=null&&i(n,o);x&&tn?(p==0?(h=s,g=d):(h=u,g=f),_=b[t],v=k(m(h,a),_,c,0),y=k(m(h+g,a),_,c,0),Sn(vh(v,y),mh(y-v))):Sn(0,c),S&&nn?(p==1?(h=s,g=d):(h=u,g=f),_=b[n],v=A(m(h,o),_,l,0),y=A(m(h+g,o),_,l,0),Cn(vh(v,y),mh(y-v))):Cn(0,l)}else Nn()}else{let e=mh(Yt-X),t=mh(Xt-Kt);if(D.ori==1){let n=e;e=t,t=n}tn=en.x&&e>=en.dist,nn=en.y&&t>=en.dist;let n=en.uni;n==null?en.x&&en.y&&(tn||nn)&&(tn=nn=!0):tn&&nn&&(tn=e>=n,nn=t>=n,!tn&&!nn&&(t>e?nn=!0:tn=!0));let r,i;tn&&(D.ori==0?(r=qt,i=Zt):(r=Jt,i=Qt),Sn(vh(r,i),mh(i-r)),nn||Cn(0,l)),nn&&(D.ori==1?(r=qt,i=Zt):(r=Jt,i=Qt),Cn(vh(r,i),mh(i-r)),tn||Sn(0,c)),!tn&&!nn&&(Sn(0,0),Cn(0,0))}}if(en._x=tn,en._y=nn,e==null){if(a){if(Jn!=null){let[e,t]=qn.scales;qn.values[0]=e==null?null:vn(D.ori==0?Zt:Qt,e),qn.values[1]=t==null?null:vn(D.ori==1?Zt:Qt,t)}Xn(mm,r,Zt,Qt,K,q,o)}if(ze){let e=a&&qn.setSeries,t=Re.prox;hn==null?pn<=t&&ln(mn,gn,!0,e):pn>t?ln(null,gn,!0,e):mn!=hn&&ln(mn,gn,!0,e)}}ke&&(R.idx=o,Tn()),n!==!1&&Gn(`setCursor`)}let On=null;Object.defineProperty(r,"rect",{get(){return On??kn(!1),On}});function kn(e=!1){e?On=null:(On=m.getBoundingClientRect(),Gn(`syncRect`,On))}function An(e,t,n,r,i,a,o){z._lock||$t&&e!=null&&e.movementX==0&&e.movementY==0||(jn(e,t,n,r,i,a,o,!1,e!=null),e==null?Dn(t,!0,!1):Dn(null,!0,!0))}function jn(e,t,n,i,a,o,c,l,u){if(On??kn(!1),Ie(e),e!=null)n=e.clientX-On.left,i=e.clientY-On.top;else{if(n<0||i<0){Zt=-10,Qt=-10;return}let[e,r]=qn.scales,c=t.cursor.sync,[l,u]=c.values,[d,f]=c.scales,[p,m]=qn.match,h=t.axes[0].side%2==1,g=D.ori==0?K:q,_=D.ori==1?K:q,v=h?o:a,y=h?a:o,x=h?i:n,S=h?n:i;if(n=d==null?x/v*g:p(e,d)?s(l,b[e],g,0):-10,i=f==null?S/y*_:m(r,f)?s(u,b[r],_,0):-10,D.ori==1){let e=n;n=i,i=e}}u&&(t==null||t.cursor.event.type==mm)&&((n<=1||n>=K-1)&&(n=zh(n,K)),(i<=1||i>=q-1)&&(i=zh(i,q))),l?(X=n,Kt=i,[qt,Jt]=z.move(r,n,i)):(Zt=n,Qt=i)}let Mn={width:0,height:0,left:0,top:0};function Nn(){on(Mn,!1)}let Pn,Fn,In,Ln;function Rn(e,t,n,i,a,o,s){$t=!0,tn=nn=en._x=en._y=!1,jn(e,t,n,i,a,o,s,!0,!1),e!=null&&(ue(gm,Em,zn,!1),Xn(hm,r,qt,Jt,K,q,null));let{left:c,top:l,width:u,height:d}=rn;Pn=c,Fn=l,In=u,Ln=d}function zn(e,t,n,i,a,o,s){$t=en._x=en._y=!1,jn(e,t,n,i,a,o,s,!1,!0);let{left:c,top:l,width:u,height:d}=rn,f=u>0||d>0,p=Pn!=c||Fn!=l||In!=u||Ln!=d;if(f&&p&&on(rn),en.setScale&&f&&p){let e=c,t=u,n=l,r=d;if(D.ori==1&&(e=l,t=d,n=c,r=u),tn&&cn(S,vn(e,S),vn(e+t,S)),nn)for(let e in b){let t=b[e];e!=S&&t.from==null&&t.min!=Eh&&cn(e,vn(n+r,e),vn(n,e))}Nn()}else z.lock&&(z._lock=!z._lock,Dn(t,!0,e!=null));e!=null&&(de(gm,Em),Xn(gm,r,Zt,Qt,K,q,null))}function Bn(e,t,n,r,i,a,o){if(z._lock)return;Ie(e);let s=$t;if($t){let e=!0,t=!0,n,r;D.ori==0?(n=tn,r=nn):(n=nn,r=tn),n&&r&&(e=Zt<=10||Zt>=K-10,t=Qt<=10||Qt>=q-10),n&&e&&(Zt=Zt<qt?0:K),r&&t&&(Qt=Qt<Jt?0:q),Dn(null,!0,!0),$t=!1}Zt=-10,Qt=-10,L.fill(null),Dn(null,!0,!0),s&&($t=s)}function Vn(e,t,n,i,a,o,s){z._lock||(Ie(e),at(),Nn(),e!=null&&Xn(ym,r,Zt,Qt,K,q,null))Line truncated
|
||||
R"RADPAGE(id:`decode`,kinds:`chat`,label:`Decode`,unit:`tok/s`,show:e=>[Tf(e.decode_tps)?ny(e.decode_tps):`–`],lines:ry(`decode`,`tokens a second`),fmt:ny},{id:`step`,kinds:`chat`,label:`Step`,unit:`ms`,show:(e,t)=>{let n=t.last(`step`);return[Tf(n)?n>=100?n.toFixed(0):n.toFixed(2):`–`,(e.step_ns_decode_best??0)>0?`best `+ey(e.step_ns_decode_best/1e6):``]},lines:[{key:`step`,label:`step`,color:1},{key:`stepBest`,label:`best`,dash:!0}],fmt:ey,tight:!0},{id:`prefill`,kinds:`chat`,label:`Prefill`,unit:`tok/s`,show:(e,t)=>{let n=t.last(`prefillRate`);return[Tf(n)?ny(n):`–`]},lines:ry(`prefillRate`,`tokens a second`),fmt:ny,join:!0},{id:`reqs`,kinds:`chat`,always:!0,label:`Requests`,show:(e,t,n)=>[String(e.running??0),(n?`of `+n+` slots`:``)+(e.waiting?` · `+e.waiting+` waiting`:``)],lines:[{key:`running`,label:`running`,color:1},{key:`waiting`,label:`waiting`,color:5},{key:`preempted`,label:`preempted`,color:2}],fmt:e=>$(e),stack:!0,integer:!0},{id:`kv`,kinds:`chat`,label:`KV cache`,show:e=>{let[t,n]=Df(e.kv_bytes_used);return[t,`of `+Ef(e.kv_bytes_total),n]},lines:[{key:`kvRead`,label:`in use`,color:1},{key:`kvKept`,label:`cached for the next turn`,color:4}],fmt:Ef,stack:!0,bytes:!0},{id:`hit`,kinds:`chat`,label:`Prefix cache hits`,unit:`%`,show:e=>[Tf(e.prefix_hit_rate)?Af(e.prefix_hit_rate):`–`],lines:ry(`hit`,`of prompt tokens`),fmt:ty,max:1},{id:`accept`,kinds:`chat`,label:`Acceptance`,unit:`%`,draft:!0,show:(e,t)=>[Af(t.last(`accept`))],lines:ry(`accept`,`of drafted tokens`),fmt:ty,max:1},{id:`tok`,kinds:`chat`,label:`Tokens per step`,draft:!0,show:(e,t)=>{let n=t.last(`tokStep`);return[Tf(n)?n.toFixed(2):`–`]},lines:ry(`tokStep`,`tokens`),fmt:e=>e.toFixed(2),tight:!0},{id:`ethru`,kinds:`embed`,always:!0,label:`Throughput`,unit:`tok/s`,show:e=>[Tf(e.prefill_tps)?ny(e.prefill_tps):`–`],lines:ry(`prefill`,`tokens a second`),fmt:ny},{id:`erate`,kinds:`embed`,always:!0,label:`Inputs`,unit:`/s`,show:(e,t)=>{let n=t.last(`reqRate`);return[Tf(n)?ny(n):`–`]},lines:ry(`reqRate`,`inputs a second`),fmt:ny},{id:`estep`,kinds:`embed`,always:!0,label:`Step`,unit:`ms`,show:(e,t)=>{let n=t.last(`stepAny`);return[Tf(n)?n.toFixed(2):`–`]},lines:ry(`stepAny`,`step`),fmt:ey,tight:!0},{id:`eflight`,kinds:`embed`,always:!0,label:`Active requests`,show:e=>[String(e.in_flight??0)],lines:ry(`flight`,`in flight`),fmt:e=>$(e),integer:!0},{id:`jrun`,kinds:`gen`,always:!0,label:`Running`,show:e=>[String(e.jobs?.running??0)],lines:ry(`jobRun`,`running`),fmt:e=>$(e),integer:!0},{id:`jdone`,kinds:`gen`,always:!0,label:`Completed`,show:e=>[$(e.jobs?.done),e.jobs?.failed?e.jobs.failed+` failed`:``],lines:ry(`jobDone`,`made`),fmt:e=>$(e),integer:!0},{id:`jlast`,kinds:`gen`,always:!0,label:`Last duration`,show:e=>[e.jobs?.done?jf(e.jobs.last_ms/1e3):`–`],lines:ry(`jobTime`,`took`),fmt:e=>jf(e),join:!0},{id:`jmean`,kinds:`gen`,always:!0,label:`Mean`,show:e=>[e.jobs?.done?jf(e.jobs.total_ms/e.jobs.done/1e3):`–`],lines:ry(`jobTime`,`took`),fmt:e=>jf(e),join:!0}],ay=[[`lkAr`,`between accelerators`],[`lkUp`,`host to accelerator`],[`lkDn`,`accelerator to host`],[`lkSsd`,`drive`],[`lkStream`,`streaming`]].map(([e,t],n)=>({key:e,label:t,color:n+1}));function oy({scope:e,kind:t,slots:n,noun:r}){let i=Qf(),[a,o]=(0,_.useState)(null),s=e.live,c=e.series,l=(s?.draft_positions?.length??0)>0,u=e=>e.always||e.lines.some(e=>!e.dash&&(c.col(e.key)??[]).some(e=>(e??0)>0)),d=iy.filter(e=>e.kinds===t&&(!e.draft||l||c.has(e.lines[0].key))&&(s?u(e):!e.draft)),f=d.find(e=>e.id===a)??d[0];if(!f)return(0,W.jsx)(wl,{children:`No data for this model yet`});let p=ay.filter(e=>(c.col(e.key)??[]).some(e=>(e??0)>0)),m=s?.experts;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`overflow-hidden rounded-xl border bg-card`,children:[(0,W.jsx)(`div`,{role:`tablist`,className:`grid grid-cols-2 border-b sm:grid-cols-4 xl:grid-flow-col xl:auto-cols-fr xl:grid-cols-none`,children:d.map(e=>{let[t,i,a]=s?e.show(s,c,n,r):[`–`],l=e===f;return(0,W.jsxs)(`button`,{role:`tab`,"aria-selected":l,onClick:()=>o(e.id),className:J(`relative -mb-px flex min-w-0 flex-col gap-1 border-r border-b px-4 py-3 text-left transition-colors outline-none last:border-r-0 hover:bg-accent/50 focus-visible:bg-accent/60`,l&&`bg-accent/40`),children:[(0,W.jsx)(`span`,{className:`truncate text-xs font-medium text-muted-foreground`,children:e.id===`jdone`&&r?r:e.label}),(0,W.jsxs)(`span`,{className:`num flex items-baseline gap-1 text-xl leading-none font-semibold tracking-tight`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:t}),(a??e.unit)&&(0,W.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:a??e.unit})]}),(0,W.jsx)(`span`,{className:`min-h-4 truncate text-xs text-muted-foreground`,children:i}),l&&(0,W.jsx)(`span`,{className:`absolute inset-x-0 bottom-0 h-0.5 bg-primary`})]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[f.lines.length>1&&(0,W.jsx)($v,{lines:f.lines}),(0,W.jsxLine truncated
|
||||
R"RADPAGE(})}),(0,W.jsx)(Sp,{children:u.slice(0,r).map(e=>(0,W.jsxs)(Cp,{children:[(0,W.jsx)(Tp,{className:`num pl-4 font-medium`,children:e.id}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.prompt)}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.out)}),(0,W.jsx)(Tp,{className:`num text-right text-muted-foreground`,children:$(e.ctx)}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.ttft)?jf(e.ttft):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.pf)?kf(e.pf)+` tok/s`:`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Tf(e.tps)&&e.tps>0?kf(e.tps)+` tok/s`:`–`}),(0,W.jsx)(Tp,{className:`num pr-4 text-right text-muted-foreground`,children:Nf(e.at,a)})]},e.id+`:`+e.at))})]}),u.length>r&&(0,W.jsx)(`div`,{className:`border-t p-2 text-center`,children:(0,W.jsxs)(zl,{variant:`ghost`,size:`sm`,onClick:()=>i(r+100),children:[`Show `,Math.min(100,u.length-r),` more`]})})]})})]})}var fy=e=>e>=1e3?kf(e/1e3)+`k`:kf(e);function py({pts:e}){if(e.length<2)return(0,W.jsx)(wl,{children:`Available after two finished requests`});let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.max(...t),a=Math.max(...n)*1.08,o=e=>i>r?(Math.log(e)-Math.log(r))/(Math.log(i)-Math.log(r)):.5;return(0,W.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-2 gap-y-1`,children:[(0,W.jsxs)(`div`,{className:`num flex flex-col justify-between text-right text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:kf(a)}),(0,W.jsx)(`span`,{children:kf(a/2)}),(0,W.jsx)(`span`,{children:`0`})]}),(0,W.jsxs)(`div`,{className:`relative h-44 rounded-md border bg-background/40`,children:[(0,W.jsx)(`div`,{className:`absolute inset-x-0 top-1/2 border-t border-dashed border-grid`}),e.map((e,t)=>(0,W.jsxs)(dl,{children:[(0,W.jsx)(fl,{render:(0,W.jsx)(`i`,{className:`absolute size-2 -translate-x-1/2 translate-y-1/2 rounded-full bg-primary/70 ring-1 ring-background hover:bg-primary`,style:{left:2+96*o(e.x)+`%`,bottom:96*e.y/a+`%`}})}),(0,W.jsxs)(pl,{children:[e.r.id,` · `,$(e.x),` tokens of context · `,kf(e.y),` tok/s`]})]},t))]}),(0,W.jsx)(`div`,{}),(0,W.jsxs)(`div`,{className:`num flex justify-between text-[11px] text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:fy(r)}),(0,W.jsx)(`span`,{children:`tokens of context`}),(0,W.jsx)(`span`,{children:fy(i)})]})]})}function my({values:e}){if(e.length<2)return(0,W.jsx)(wl,{children:`Available after two finished requests`});let t=[0,.1,.2,.5,1,2,5,10,30,1/0],n=t.findIndex(t=>t>Math.max(...e)),r=t.slice(0,Math.max(6,n+1)),i=r.slice(0,-1).map((t,n)=>e.filter(e=>e>=t&&e<r[n+1]).length),a=Math.max(...i,1),o=e=>r[e+1]===1/0?`over `+jf(r[e]):`under `+jf(r[e+1]);return(0,W.jsxs)(`div`,{className:`flex h-[12.25rem] flex-col justify-end gap-1.5`,children:[(0,W.jsx)(`div`,{className:`flex flex-1 items-end justify-center gap-1.5`,children:i.map((e,t)=>(0,W.jsxs)(dl,{children:[(0,W.jsx)(fl,{render:(0,W.jsxs)(`div`,{className:`flex h-full max-w-24 flex-1 flex-col justify-end`,children:[(0,W.jsx)(`span`,{className:`num mb-1 text-center text-[11px] text-muted-foreground`,children:e||``}),(0,W.jsx)(`div`,{className:`rounded-sm bg-primary/80`,style:{height:Math.max(e?3:0,82*e/a)+`%`}})]})}),(0,W.jsxs)(pl,{children:[e,` `,e===1?`request`:`requests`,` `,o(t)]})]},t))}),(0,W.jsx)(`div`,{className:`num flex justify-center gap-1.5 border-t pt-1 text-[11px] text-muted-foreground`,children:i.map((e,t)=>(0,W.jsx)(`span`,{className:`max-w-24 flex-1 truncate text-center`,children:r[t+1]===1/0?`> `+jf(r[t]):`< `+jf(r[t+1])},t))})]})}function hy({model:e}){let{data:t,error:n}=wf(Sf(`sessions`,e),5e3);if(!t)return(0,W.jsx)(wl,{children:n??`Loading`});let r=(t.sessions??[]).slice().sort((e,t)=>e.idle_s-t.idle_s),i=(t.linear?.checkpoints_written??0)>0||r.some(e=>e.snapshots>0),a=r.filter(e=>!i||e.resume_tokens>0||e.snapshots>0),o=r.filter(e=>!a.includes(e)),s=e=>i?Math.min(e.resume_tokens||0,e.tokens):e.tokens,[c,l]=Df(t.pool?.bytes_used),[u,d]=Df(t.occupancy?.host_bytes);return(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,W.jsx)(ml,{label:`Resumable`,value:$(a.length),detail:o.length?`${o.length} will restart`:`cached conversations`}),(0,W.jsx)(ml,{label:`Tokens cached`,value:$(t.pool?.tokens_used),detail:t.pool?`of ${$(t.pool.tokens_total)}`:``}),(0,W.jsx)(ml,{label:`VRAM in use`,value:c,unit:l,detail:t.pool?`of ${Ef(t.pool.bytes_total)}`:``}),t.enabled?(0,W.jsx)(ml,{label:`Host memory in use`,value:u,unit:d,detail:t.occupancy?.host_cap_bytes?`of ${Ef(t.occupancy.host_cap_bytes)}`:``}):(0,W.jsx)(ml,{label:`Prefix cache hits`,value:t.prefix_hit_rate==null?`–`:(t.prefix_hit_rate*100).toFixed(1),unit:`%`,detail:`of prompt tokens reused`})]}),(0,W.jsx)(hl,{title:`Will resume`,description:a.length?`Conversations whose next turn can reuse cached tokens, most recent first`:void 0,flush:a.length>0,children:a.length?(0,W.jsx)(gy,{rows:a,reuse:s}):(0,W.jsx)(wl,{children:`No cached conLine truncated
|
||||
R"RADPAGE(x)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:r.cards.map(n=>(0,W.jsx)(Ty,{fleet:r,card:n.card,hueOf:i,data:e.series,version:e.version,range:t},n.card))}),(0,W.jsx)(hl,{title:`State over time`,description:`Each model's state across the time range`,children:(0,W.jsx)(Dy,{models:r.models,data:e.series,version:e.version,range:t})}),(0,W.jsx)(hl,{title:`Models`,flush:!0,children:(0,W.jsxs)(bp,{children:[(0,W.jsx)(xp,{children:(0,W.jsxs)(Cp,{className:`hover:bg-transparent`,children:[(0,W.jsx)(wp,{className:`pl-4`,children:`Model`}),(0,W.jsx)(wp,{children:`State`}),(0,W.jsx)(wp,{className:`text-right`,children:`Priority`}),(0,W.jsx)(wp,{children:`Accelerators`}),(0,W.jsx)(wp,{className:`text-right`,children:`VRAM`}),(0,W.jsx)(wp,{className:`text-right`,children:`Host`}),(0,W.jsx)(wp,{className:`text-right`,children:`Active`}),(0,W.jsx)(wp,{className:`text-right`,children:`Loads`}),(0,W.jsx)(wp,{className:`text-right`,children:`Parks`}),(0,W.jsx)(wp,{className:`pr-4 text-right`,children:`Last load`})]})}),(0,W.jsx)(Sp,{children:r.models.map(e=>(0,W.jsxs)(Cp,{className:`cursor-pointer`,onClick:()=>{location.hash=ip(e.id)},children:[(0,W.jsxs)(Tp,{className:`pl-4`,children:[(0,W.jsxs)(`a`,{href:ip(e.id),className:`flex items-center gap-2 font-medium`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`i`,{className:`size-2 rounded-full`,style:{background:i.get(e.id)}}),e.id]}),(0,W.jsx)(`div`,{className:`mt-0.5 max-w-72 truncate pl-4 text-xs text-muted-foreground`,children:e.error??e.file})]}),(0,W.jsx)(Tp,{children:(0,W.jsx)(bl,{state:e.state,doing:e.doing})}),(0,W.jsxs)(Tp,{className:`num text-right`,children:[$(e.priority),e.pinned?` · pinned`:``]}),(0,W.jsx)(Tp,{className:`num text-muted-foreground`,children:e.cards?.length?e.cards.join(`, `):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:Cy(e)>0?Ef(Cy(e)):`–`}),(0,W.jsx)(Tp,{className:`num text-right`,children:(e.host_bytes??0)+(e.host_pinned_bytes??0)>0?Ef((e.host_bytes??0)+(e.host_pinned_bytes??0)):`–`}),(0,W.jsxs)(Tp,{className:`num text-right`,children:[e.in_flight?$(e.in_flight):`–`,e.waiting?` +${e.waiting}`:``]}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.loads)}),(0,W.jsx)(Tp,{className:`num text-right`,children:$(e.parks)}),(0,W.jsx)(Tp,{className:`num pr-4 text-right`,children:Tf(e.load_seconds)?jf(e.load_seconds):`–`})]},e.id))})]})})]})}function Ty({fleet:e,card:t,hueOf:n,data:r,version:i,range:a}){let o=e.cards.find(e=>e.card===t),s=e.models.map(e=>({key:e.id,label:e.id,value:Sy(e,t),color:n.get(e.id),text:Ef(Sy(e,t))})),c=(o.vram_bytes??0)-(o.free_bytes??0),l=s.reduce((e,t)=>e+t.value,0),u=Math.max(Math.min(o.queue_bytes??0,c-l),0),d=c-l-u;u>0&&s.push({key:`~queues`,label:`Queues (${o.queues??0} open)`,value:u,color:`var(--idle)`,text:Ef(u)}),d>64<<20&&s.push({key:`~other`,label:`Model buffers and driver`,value:d,color:`var(--muted-foreground)`,text:Ef(d)});let f=e.models.map((e,n)=>({key:`c${t}:${e.id}`,label:e.id,color:n+1}));return(0,W.jsx)(hl,{title:(0,W.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[`Accelerator `,t,(0,W.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:o.name})]}),action:(0,W.jsxs)(`span`,{className:`num text-xs text-muted-foreground`,children:[Ef(o.free_bytes),` free of `,Ef(o.vram_bytes)]}),children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(xl,{parts:s,total:o.vram_bytes,className:`h-3`}),(0,W.jsx)(Sl,{parts:s,className:`content-start xl:min-h-10`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,W.jsx)(Ey,{label:`Busy`,value:Tf(o.busy)?Math.round(o.busy*100)+`%`:`–`,data:r,k:`busy${t}`,max:1}),(0,W.jsx)(Ey,{label:`Power`,value:Tf(o.power_w)?Math.round(o.power_w)+` W`:`–`,data:r,k:`power${t}`}),(0,W.jsx)(Ey,{label:`Temperature`,value:Tf(o.temp_c)?Math.round(o.temp_c)+` °C`:`–`,data:r,k:`temp${t}`})]}),(0,W.jsx)(Qv,{data:r,version:i,lines:f,range:a,fmt:Ef,stack:!0,bytes:!0,height:170,max:o.vram_bytes})]})})}function Ey({label:e,value:t,data:n,k:r,max:i}){let a=n.col(r)??[],o=n.firstAfter(n.end-300),s=a.slice(o),c=s.filter(e=>e!==null),l=i??Math.max(1,...c)*1.05,u=i===void 0?Math.min(...c,l)*.9:0,d=s.length,f=``,p=!1;return s.forEach((e,t)=>{e===null?p=!1:(f+=(p?`L`:`M`)+(100*t/Math.max(1,d-1)).toFixed(2)+` `+(27-24*(Math.min(e,l)-u)/Math.max(1e-9,l-u)).toFixed(2),p=!0)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-background/40 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,W.jsx)(`div`,{className:`num text-base font-semibold whitespace-nowrap`,children:t})]}),(0,W.jsx)(`svg`,{viewBox:`0 0 100 30`,preserveAspectRatio:`none`,className:`h-8 min-w-0 flex-1 text-primary`,children:(0,W.jsx)(`path`,{d:f,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})})]})}function Dy({models:e,data:t,versiLine truncated
|
||||
<style rel="stylesheet" crossorigin>/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-backdrop-blur:initial;--tw-backd)RADPAGE"
|
||||
R"RADPAGE(rop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0px;--scroll-fade-b:0px;--scroll-fade-s:0px;--scroll-fade-e:0px;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0px;--scroll-fade-b:0px;--scroll-fade-s:0px;--scroll-fade-e:0px;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@layer theme{:root,:host{--font-sans:"Geist Variable", ui-sans-serif, system-ui, sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-xl:36rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--leading-snug:1.375;--radius-md:calc(var(--radius) * .8);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Geist Variable", ui-sans-serif, system-ui, sans-serif;--default-mono-font-family:"Geist Mono Variable", ui-monospace, "SF Mono", Menlo, monospace}}@layer base{*,:after,:before{box-sizing:border-box;border:0 solid;margin:0;padding:0}::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--defLine truncated
|
||||
R"RADPAGE(n-width\){max-width:var(--skeleton-width)}.max-w-14{max-width:calc(var(--spacing) * 14)}.max-w-24{max-width:calc(var(--spacing) * 24)}.max-w-72{max-width:calc(var(--spacing) * 72)}.max-w-80{max-width:calc(var(--spacing) * 80)}.max-w-\[28rem\]{max-width:28rem}.max-w-\[50vw\]{max-width:50vw}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-prose{max-width:65ch}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-8{min-width:calc(var(--spacing) * 8)}.min-w-9{min-width:calc(var(--spacing) * 9)}.min-w-12{min-width:calc(var(--spacing) * 12)}.min-w-36{min-width:calc(var(--spacing) * 36)}.min-w-\[3px\]{min-width:3px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.caption-bottom{caption-side:bottom}.origin-\(--transform-origin\){transform-origin:var(--transform-origin)}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-px{--tw-translate-x:-1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-px{--tw-translate-x:1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-1\/2{--tw-translate-y:calc(1 / 2 * 100%);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[calc\(-50\%-2px\)\]{--tw-translate-y:calc(-50% - 2px);translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-45{rotate:45deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.cursor-pointer{cursor:pointer}.auto-rows-min{grid-auto-rows:min-content}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[8rem_1fr\]{grid-template-columns:8rem 1fr}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.grid-cols-\[auto_1fr_auto\]{grid-template-columns:auto 1fr auto}.grid-cols-\[minmax\(6rem\,10rem\)_1fr\]{grid-template-columns:minmax(6rem,10rem) 1fr}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.content-start{align-content:flex-start}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-\(--card-spacing\){gap:var(--card-spacing)}.gap-0{gap:0}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-\[--spacing\(var\(--gap\)\)\]{gap:calc(var(--spacing) * var(--gap))}.gap-\[3px\]{gap:3px}.gap-px{gap:1px}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.self-start{align-self:flex-start}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[1px\]{border-radius:1px}.rounded-\[2px\]{border-radius:2px}.rounded-\[min\(var\(--radius-md\)\,10px\)\]{border-radius:min(var(--radius-md), 10px)}.rounded-\[min\(var\(--radius-md\)\,12px\)\]{border-radius:min(var(--radius-md), 12px)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) * .8)}.rounded-sm{border-radius:calc(var(--radius) * .6)}.rounded-xl{border-radius:calc(var(--radius) * 1.4)}.rounded-t-xl{border-top-left-radius:calc(var(--radius) * 1.4);border-top-right-radius:calc(var(--radius) * 1.4)}.rounded-b-xl{border-bottom-right-radius:calc(var(--radius) * 1.4);border-bottom-left-radius:calc(var(--radius) * 1.4)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-background\/60{border-color:var(--background)}@supports (color:color-mix(in lab, red, red)){.boLine truncated
|
||||
R"RADPAGE(00001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-none{--tw-shadow:0 0 #0000;box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-background{--tw-ring-color:var(--background)}.ring-foreground\/10{--tw-ring-color:var(--foreground)}@supports (color:color-mix(in lab, red, red)){.ring-foreground\/10{--tw-ring-color:color-mix(in oklab, var(--foreground) 10%, transparent)}}.ring-sidebar-ring{--tw-ring-color:var(--sidebar-ring)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[height\]{transition-property:height;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[left\,right\,width\]{transition-property:left,right,width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[margin\,opacity\]{transition-property:margin,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\,height\,padding\]{transition-property:width,height,padding;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:Line truncated
|
||||
R"RADPAGE(:0}.file\:bg-transparent::file-selector-button{background-color:#0000}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-foreground::file-selector-button{color:var(--foreground)}.placeholder\:text-muted-foreground::placeholder{color:var(--muted-foreground)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:-inset-2:after{content:var(--tw-content);inset:calc(var(--spacing) * -2)}.after\:-inset-x-3:after{content:var(--tw-content);inset-inline:calc(var(--spacing) * -3)}.after\:-inset-y-2:after{content:var(--tw-content);inset-block:calc(var(--spacing) * -2)}.after\:inset-y-0:after{content:var(--tw-content);inset-block:0}.after\:start-1\/2:after{content:var(--tw-content);inset-inline-start:50%}.after\:w-\[2px\]:after{content:var(--tw-content);width:2px}.after\:bg-foreground:after{content:var(--tw-content);background-color:var(--foreground)}.after\:opacity-0:after{content:var(--tw-content);opacity:0}.after\:transition-opacity:after{content:var(--tw-content);transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}:is(:where(.group)[data-collapsible=offcanvas] .group-data-\[collapsible\=offcanvas\]\:after\:left-full):after{content:var(--tw-content);left:100%}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:inset-x-0):after{content:var(--tw-content);inset-inline:0}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:bottom-\[-5px\]):after{content:var(--tw-content);bottom:-5px}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:h-0\.5):after{content:var(--tw-content);height:calc(var(--spacing) * .5)}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:inset-y-0):after{content:var(--tw-content);inset-block:0}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:-right-1):after{content:var(--tw-content);right:calc(var(--spacing) * -1)}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:w-0\.5):after{content:var(--tw-content);width:calc(var(--spacing) * .5)}.last\:border-r-0:last-child{border-right-style:var(--tw-border-style);border-right-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:bg-\[color-mix\(in_oklch\,var\(--secondary\)\,var\(--foreground\)_5\%\)\]:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-\[color-mix\(in_oklch\,var\(--secondary\)\,var\(--foreground\)_5\%\)\]:hover{background-color:color-mix(in oklch,var(--secondary),var(--foreground) 5%)}}.hover\:bg-accent\/50:hover{background-color:var(--accent)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/50:hover{background-color:color-mix(in oklab, var(--accent) 50%, transparent)}}.hover\:bg-destructive\/20:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-destructive\/20:hover{background-color:color-mix(in oklab, var(--destructive) 20%, transparent)}}.hover\:bg-muted:hover,.hover\:bg-muted\/50:hover{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab, var(--muted) 50%, transparent)}}.hover\:bg-primary:hover,.hover\:bg-primary\/80:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary\/80:hover{background-color:color-mix(in oklab, var(--primary) 80%, transparent)}}.hover\:bg-sidebar-accent:hover{background-color:var(--sidebar-accent)}.hover\:bg-transparent:hover{background-color:#0000}.hover\:text-foreground:hover{color:var(--foreground)}.hover\:text-sidebar-accent-foreground:hover{color:var(--sidebar-accent-foreground)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-\[0_0_0_1px_var\(--sidebar-accent\)\]:hover{--tw-shadow:0 0 0 1px var(--tw-shadow-color,var(--sidebar-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.hover\:outline:hover{outline-style:var(--tw-outline-style);outline-width:1px}.hover\:outline-foreground:hover{outline-color:var(--foreground)}:is(:where(.group)[data-collapsible=offcanvas] .hover\:group-data-\[collapsible\=offcanvas\]\:bg-sidebar:hover){background-color:var(--sidebar)}.hover\:after\:bg-sidebar-border:hover:after{content:var(--tw-content);background-color:var(--sidebar-border)}}.focus\:z-10:focus,.focus-visible\:z-10:focus-visible{z-iLine truncated
|
||||
R"RADPAGE(a-side=inline-end]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=inline-end\]\:slide-in-from-left-2[data-side=inline-end]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}.data-\[side\=inline-start\]\:top-1\/2\![data-side=inline-start]{top:50%!important}.data-\[side\=inline-start\]\:-right-1[data-side=inline-start]{right:calc(var(--spacing) * -1)}.data-\[side\=inline-start\]\:-translate-y-1\/2[data-side=inline-start]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=inline-start\]\:slide-in-from-right-2[data-side=inline-start]{--tw-enter-translate-x:calc(2*var(--spacing))}.data-\[side\=left\]\:inset-y-0[data-side=left]{inset-block:0}.data-\[side\=left\]\:top-1\/2\![data-side=left]{top:50%!important}.data-\[side\=left\]\:-right-1[data-side=left]{right:calc(var(--spacing) * -1)}.data-\[side\=left\]\:left-0[data-side=left]{left:0}.data-\[side\=left\]\:h-full[data-side=left]{height:100%}.data-\[side\=left\]\:w-3\/4[data-side=left]{width:75%}.data-\[side\=left\]\:-translate-y-1\/2[data-side=left]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=left\]\:border-r[data-side=left]{border-right-style:var(--tw-border-style);border-right-width:1px}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:calc(2*var(--spacing))}:is(:where(.group)[data-collapsible=offcanvas] .data-\[side\=left\]\:group-data-\[collapsible\=offcanvas\]\:left-\[calc\(var\(--sidebar-width\)\*-1\)\][data-side=left]){left:calc(var(--sidebar-width) * -1)}.data-\[side\=left\]\:data-ending-style\:translate-x-\[-2\.5rem\][data-side=left][data-ending-style],.data-\[side\=left\]\:data-starting-style\:translate-x-\[-2\.5rem\][data-side=left][data-starting-style]{--tw-translate-x:-2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:inset-y-0[data-side=right]{inset-block:0}.data-\[side\=right\]\:top-1\/2\![data-side=right]{top:50%!important}.data-\[side\=right\]\:right-0[data-side=right]{right:0}.data-\[side\=right\]\:-left-1[data-side=right]{left:calc(var(--spacing) * -1)}.data-\[side\=right\]\:h-full[data-side=right]{height:100%}.data-\[side\=right\]\:w-3\/4[data-side=right]{width:75%}.data-\[side\=right\]\:-translate-y-1\/2[data-side=right]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:border-l[data-side=right]{border-left-style:var(--tw-border-style);border-left-width:1px}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}:is(:where(.group)[data-collapsible=offcanvas] .data-\[side\=right\]\:group-data-\[collapsible\=offcanvas\]\:right-\[calc\(var\(--sidebar-width\)\*-1\)\][data-side=right]){right:calc(var(--sidebar-width) * -1)}.data-\[side\=right\]\:data-ending-style\:translate-x-\[2\.5rem\][data-side=right][data-ending-style],.data-\[side\=right\]\:data-starting-style\:translate-x-\[2\.5rem\][data-side=right][data-starting-style]{--tw-translate-x:2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=top\]\:inset-x-0[data-side=top]{inset-inline:0}.data-\[side\=top\]\:top-0[data-side=top]{top:0}.data-\[side\=top\]\:-bottom-2\.5[data-side=top]{bottom:calc(var(--spacing) * -2.5)}.data-\[side\=top\]\:h-auto[data-side=top]{height:auto}.data-\[side\=top\]\:border-b[data-side=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:calc(2*var(--spacing))}.data-\[side\=top\]\:data-ending-style\:translate-y-\[-2\.5rem\][data-side=top][data-ending-style],.data-\[side\=top\]\:data-starting-style\:translate-y-\[-2\.5rem\][data-side=top][data-starting-style]{--tw-translate-y:-2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[size\=default\]\:h-\[18\.4px\][data-size=default]{height:18.4px}.data-\[size\=default\]\:w-\[32px\][data-size=default]{width:32px}.data-\[size\=md\]\:text-sm[data-size=md]{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.data-\[size\=sm\]\:h-\[14px\][data-size=sm]{height:14px}.data-\[size\=sm\]\:w-\[24px\][data-size=sm]{width:24px}.data-\[size\=sm\]\:rounded-\[min\(var\(--radius-md\)\,10px\)\][data-size=sm]{border-radius:min(var(--radius-md), 10px)}.data-\[size\=sm\]\:text-xs[data-size=sm]{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.data-\[size\=sm\]\:\[--card-spacing\:--spacing\(3\)\][data-size=sm]{--card-spacing:calc(var(--spacing) * 3)}.data-\[size\=sm\]\:has-data-\[slot\=card-footer\]\:pb-0[data-size=sm]:has([data-slot=card-footer]){padding-bottom:0}:is(.\*\*\:data-\[slot\=kbd\]\:relative *)[data-slot=kbd]{position:relative}:is(.\*\*\:data-\[slot\=kbd\]\:isolate *)[data-slot=kbd]{isolation:isolate}:is(.\*\*\:data-\[slot\=kbd\]\:z-Line truncated
|
||||
R"RADPAGE(arent)}}.dark\:bg-input\/30:is(.dark *){background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:bg-input\/30:is(.dark *){background-color:color-mix(in oklab, var(--input) 30%, transparent)}}.dark\:text-muted-foreground:is(.dark *){color:var(--muted-foreground)}@media (hover:hover){.dark\:hover\:bg-destructive\/30:is(.dark *):hover{background-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-destructive\/30:is(.dark *):hover{background-color:color-mix(in oklab, var(--destructive) 30%, transparent)}}.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:color-mix(in oklab, var(--input) 50%, transparent)}}.dark\:hover\:bg-muted\/50:is(.dark *):hover{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-muted\/50:is(.dark *):hover{background-color:color-mix(in oklab, var(--muted) 50%, transparent)}}.dark\:hover\:text-foreground:is(.dark *):hover{color:var(--foreground)}}.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:color-mix(in oklab, var(--destructive) 40%, transparent)}}.dark\:disabled\:bg-input\/80:is(.dark *):disabled{background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:disabled\:bg-input\/80:is(.dark *):disabled{background-color:color-mix(in oklab, var(--input) 80%, transparent)}}.dark\:aria-invalid\:border-destructive\/50:is(.dark *)[aria-invalid=true]{border-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:aria-invalid\:border-destructive\/50:is(.dark *)[aria-invalid=true]{border-color:color-mix(in oklab, var(--destructive) 50%, transparent)}}.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, var(--destructive) 40%, transparent)}}.data-open\:animate-in:where([data-state=open]),.data-open\:animate-in:where([data-open]:not([data-open=false])){animation:enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none)}.data-open\:fade-in-0:where([data-state=open]),.data-open\:fade-in-0:where([data-open]:not([data-open=false])){--tw-enter-opacity:0}.data-open\:zoom-in-95:where([data-state=open]),.data-open\:zoom-in-95:where([data-open]:not([data-open=false])){--tw-enter-scale:.95}@media (hover:hover){:is(.data-open\:hover\:bg-sidebar-accent:where([data-state=open]),.data-open\:hover\:bg-sidebar-accent:where([data-open]:not([data-open=false]))):hover{background-color:var(--sidebar-accent)}:is(.data-open\:hover\:text-sidebar-accent-foreground:where([data-state=open]),.data-open\:hover\:text-sidebar-accent-foreground:where([data-open]:not([data-open=false]))):hover{color:var(--sidebar-accent-foreground)}}.data-closed\:animate-out:where([data-state=closed]),.data-closed\:animate-out:where([data-closed]:not([data-closed=false])){animation:exit var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none)}.data-closed\:fade-out-0:where([data-state=closed]),.data-closed\:fade-out-0:where([data-closed]:not([data-closed=false])){--tw-exit-opacity:0}.data-closed\:zoom-out-95:where([data-state=closed]),.data-closed\:zoom-out-95:where([data-closed]:not([data-closed=false])){--tw-exit-scale:.95}.data-checked\:bg-primary:where([data-state=checked]),.data-checked\:bg-primary:where([data-checked]:not([data-checked=false])){background-color:var(--primary)}:is(:where(.group\/switch)[data-size=default] .group-data-\[size\=default\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-state=checked]),:is(:where(.group\/switch)[data-size=default] .group-data-\[size\=default\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-checked]:not([data-checked=false])),:is(:where(.group\/switch)[data-size=sm] .group-data-\[size\=sm\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-state=checked]),:is(:where(.group\/switch)[data-size=sm] .group-data-\[size\=sm\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-checked]:not([data-checked=false])){--tw-translate-x:calc(100% - 2px);translate:var(--tw-translate-x) var(--tw-translate-y)}.dark\:data-checked\:bg-primary-foreground:is(.dark *):where([data-state=checked]),.dark\:data-checked\:bg-primary-foreground:is(.dark *):where([data-checkLine truncated
|
||||
R"RADPAGE(height:calc(var(--spacing) * 3)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-3\.5 svg:not([class*=size-]){width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\.border-b\]\:pb-\(--card-spacing\).border-b{padding-bottom:var(--card-spacing)}:is(.\*\:\[a\]\:underline>*):is(a){text-decoration-line:underline}:is(.\*\:\[a\]\:underline-offset-3>*):is(a){text-underline-offset:3px}@media (hover:hover){:is(.\*\:\[a\]\:hover\:text-foreground>*):is(a):hover{color:var(--foreground)}}:is(.\*\:\[img\:first-child\]\:rounded-t-xl>*):is(img:first-child){border-top-left-radius:calc(var(--radius) * 1.4);border-top-right-radius:calc(var(--radius) * 1.4)}:is(.\*\:\[img\:last-child\]\:rounded-b-xl>*):is(img:last-child){border-bottom-right-radius:calc(var(--radius) * 1.4);border-bottom-left-radius:calc(var(--radius) * 1.4)}.\[\&\>button\]\:hidden>button{display:none}.\[\&\>span\:last-child\]\:truncate>span:last-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\[\&\>svg\]\:size-4>svg{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&\>svg\]\:shrink-0>svg{flex-shrink:0}.\[\&\>svg\]\:text-sidebar-accent-foreground>svg{color:var(--sidebar-accent-foreground)}.\[\&\>tr\]\:last\:border-b-0>tr:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}[data-side=left][data-collapsible=offcanvas] .\[\[data-side\=left\]\[data-collapsible\=offcanvas\]_\&\]\:-right-2{right:calc(var(--spacing) * -2)}[data-side=left][data-state=collapsed] .\[\[data-side\=left\]\[data-state\=collapsed\]_\&\]\:cursor-e-resize{cursor:e-resize}[data-side=right][data-collapsible=offcanvas] .\[\[data-side\=right\]\[data-collapsible\=offcanvas\]_\&\]\:-left-2{left:calc(var(--spacing) * -2)}[data-side=right][data-state=collapsed] .\[\[data-side\=right\]\[data-state\=collapsed\]_\&\]\:cursor-w-resize{cursor:w-resize}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}@property --scroll-fade-t{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-b{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-s{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-e{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-mask{syntax:"*";inherits:false}@property --shimmer-angle{syntax:"<angle>";inherits:true;initial-value:20deg}@property --shimmer-image{syntax:"*";inherits:false}@property --shimmer-text-fill{syntax:"*";inherits:false}@media (prefers-reduced-motion:reduce){.shimmer{-webkit-text-fill-color:currentColor;background-image:none;animation:none}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(data:font/woff2;base64,d09GMgABAAAAAHLYABQAAAABAQgAAHJiAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGoYFG4GfHhyHTD9IVkFSh1s/TVZBUjwGYD9TVEFUgTgAhRAvfhEICvZo3iMLhEIAMIGoaAE2AiQDiQAEIAWIGgeLSQwHGyLxFWxXY6CewOalNZfPMyrYrmbcDkTU+r1qNsKGjQMg3hwT/X9SUhlDE9iTFqA63e4PtWQjlBo5goYcMo0ZqbViQ0jvqjjmPNf7mgM3sj6o9UXp+5FQOzPJbOE3Jx5hd/ytpmpjm0pYR9BzruG68ZnXxBVYEMSHMTAwnWpYTZ0wG3f74drkjkO9/6wik1904hQkUpdYDWmJLZFY0pNBEcb7IndF19PSj1kEuE38iIQcX4SK1qgisnr6gFERPc4+OgJHpJCEZJaAxtzpl8/CAc8Rzfk/exe9hCSEEEII4fAAIZilNJgFLUVSVAJFvJRHwV/VaP29R8UpddoiNaXiVOXz+nnW8vzTuOd/7TP3wUxgI76kJCdlOHSryZ2cIZquptBglVCzlLbxtmnUViK7SXY3ySbepI23Th21In7G/T/8PXD3nBn2TjlRgXtD5X9y8/sLj1BKDapUxtT7bcyW//zF1njpmb9ZiFmfWWVarEkKASLEBdHC8/y9O39WtzLine truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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)format("woff2-variations")}:root{--background:#f9fafb;--foreground:#111419;--card:#fff;--card-foreground:#111419;--popover:#fff;--popover-foreground:#111419;--primary:#2e62c9;--primary-foreground:#f9fafb;--secondary:#eef0f3;--secondary-foreground:#1e2228;--muted:#eef0f3;--muted-foreground:#5e646c;--accent:#e9edf2;--accent-foreground:#171b20;--destructive:#df2225;--border:#dfe1e5;--input:#dfe1e5;--ring:#5684da;--radius:.625rem;--sidebar:#f4f6f8;--sidebar-foreground:#111419;--sidebar-primary:#2e62c9;--sidebar-primary-foreground:#f9fafb;--sidebar-accent:#e6eaef;--sidebar-accent-foreground:#171b20;--sidebar-border:#dfe1e5;--sidebar-ring:#5684da;--series-1:#396ed6;--series-2:#d95737;--series-3:#00967c;--series-4:#915dc5;--series-5:#b88a00;--series-6:#c3518d;--series-7:#0094bd;--series-8:#419547;--ok:#25984d;--warn:#d38e00;--bad:#de3b3d;--idle:#7f8793;--grid:#e2e5e8}@supports (color:lab(0% 0 0)){:root{--background:lab(98.2562% -.166595 -.736153);--foreground:lab(6.15419% -.356875 -4.10882);--card:lab(100% 0 0);--card-foreground:lab(6.15419% -.356875 -4.10882);--popover:lab(100% 0 0);--popover-foreground:lab(6.15419% -.356875 -4.10882);--primary:lab(42.6189% 11.5611 -59.7505);--primary-foreground:lab(98.2562% -.166595 -.736153);--secondary:lab(94.7703% -.411719 -1.83765);--secondary-foreground:lab(12.9538% -.484258 -4.41422);--muted:lab(94.7703% -.411719 -1.83765);--muted-foreground:lab(41.9469% -.688925 -5.55613);--accent:lab(93.604% -.651121 -2.93589);--accent-foreground:lab(9.47247% -.459656 -4.40383);--destructive:lab(49.0747% 69.3434 49.6251);--border:lab(89.5482% -.491649 -2.20379);--input:lab(89.5482% -.491649 -2.20379);--ring:lab(54.8356% 4.35138 -49.6759);--sidebar:lab(96.7463% -.248939 -1.10371);--sidebar-foreground:lab(6.15419% -.356875 -4.10882);--sidebar-primary:lab(42.6189% 11.5611 -59.7505);--sidebar-primary-foreground:lab(98.2562% -.166595 -.736153);--sidebar-accent:lab(92.444% -.650853 -2.93578);--sidebar-accent-foreground:lab(9.47247% -.459656 -4.40383);--sidebar-border:lab(89.5482% -.491649 -2.20379);--sidebar-ring:lab(54.8356% 4.35138 -49.6759);--series-1:lab(47.3516% 10.0889 -59.8436);--series-2:lab(54.4452% 50.6614 45.0348);--series-3:lab(55.1513% -42.4221 3.65769);--series-4:lab(48.837% 37.1132 -46.9834);--series-5:lab(60.6937% 11.3242 68.7955);--series-6:lab(51.444% 51.1158 -9.89943);--series-7:lab(56.3446% -25.1481 -33.3622);--series-8:lab(55.2905% -39.2931 32.7248);--ok:lab(55.4741% -45.4549 30.1606);--waLine truncated
|
||||
R"RADPAGE(ox!important}.u-inline.u-live th:after{content:":";vertical-align:middle}.u-inline:not(.u-live) .u-value{display:none}.u-series>*{padding:4px}.u-series th{cursor:pointer}.u-legend .u-off>*{opacity:.3}.u-select{pointer-events:none;background:#00000012;position:absolute}.u-cursor-x,.u-cursor-y{pointer-events:none;will-change:transform;position:absolute;top:0;left:0}.u-hz .u-cursor-x,.u-vt .u-cursor-y{border-right:1px dashed #607d8b;height:100%}.u-hz .u-cursor-y,.u-vt .u-cursor-x{border-bottom:1px dashed #607d8b;width:100%}.u-cursor-pt{pointer-events:none;will-change:transform;border:0 solid;border-radius:50%;position:absolute;top:0;left:0;background-clip:padding-box!important}.u-axis.u-off,.u-select.u-off,.u-cursor-x.u-off,.u-cursor-y.u-off,.u-cursor-pt.u-off{display:none}
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow)RADPAGE"
|
||||
R"RADPAGE(:0 0 #0000;--tw-outline-style:solid;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0px;--scroll-fade-b:0px;--scroll-fade-s:0px;--scroll-fade-e:0px;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0px;--scroll-fade-b:0px;--scroll-fade-s:0px;--scroll-fade-e:0px;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@layer theme{:root,:host{--font-sans:"Geist Variable", ui-sans-serif, system-ui, sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-xl:36rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--leading-snug:1.375;--radius-md:calc(var(--radius) * .8);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Geist Variable", ui-sans-serif, system-ui, sans-serif;--default-mono-font-family:"Geist Mono Variable", ui-monospace, "SF Mono", Menlo, monospace}}@layer base{*,:after,:before{box-sizing:border-box;border:0 solid;margin:0;padding:0}::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--defLine truncated
|
||||
R"RADPAGE(:-moz-fit-content;width:fit-content}.w-full{width:100%}.max-w-\(--skeleton-width\){max-width:var(--skeleton-width)}.max-w-14{max-width:calc(var(--spacing) * 14)}.max-w-24{max-width:calc(var(--spacing) * 24)}.max-w-72{max-width:calc(var(--spacing) * 72)}.max-w-80{max-width:calc(var(--spacing) * 80)}.max-w-\[28rem\]{max-width:28rem}.max-w-\[50vw\]{max-width:50vw}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-prose{max-width:65ch}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-8{min-width:calc(var(--spacing) * 8)}.min-w-9{min-width:calc(var(--spacing) * 9)}.min-w-12{min-width:calc(var(--spacing) * 12)}.min-w-36{min-width:calc(var(--spacing) * 36)}.min-w-\[3px\]{min-width:3px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.caption-bottom{caption-side:bottom}.origin-\(--transform-origin\){transform-origin:var(--transform-origin)}.-translate-x-1\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-x-px{--tw-translate-x:-1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-px{--tw-translate-x:1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-1\/2{--tw-translate-y:calc(1 / 2 * 100%);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[calc\(-50\%-2px\)\]{--tw-translate-y:calc(-50% - 2px);translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-45{rotate:45deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.cursor-pointer{cursor:pointer}.auto-rows-min{grid-auto-rows:min-content}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[8rem_1fr\]{grid-template-columns:8rem 1fr}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.grid-cols-\[auto_1fr_auto\]{grid-template-columns:auto 1fr auto}.grid-cols-\[minmax\(6rem\,10rem\)_1fr\]{grid-template-columns:minmax(6rem,10rem) 1fr}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.content-start{align-content:flex-start}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-\(--card-spacing\){gap:var(--card-spacing)}.gap-0{gap:0}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-\[--spacing\(var\(--gap\)\)\]{gap:calc(var(--spacing) * var(--gap))}.gap-\[3px\]{gap:3px}.gap-px{gap:1px}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.self-start{align-self:flex-start}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[1px\]{border-radius:1px}.rounded-\[2px\]{border-radius:2px}.rounded-\[min\(var\(--radius-md\)\,10px\)\]{border-radius:min(var(--radius-md), 10px)}.rounded-\[min\(var\(--radius-md\)\,12px\)\]{border-radius:min(var(--radius-md), 12px)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) * .8)}.rounded-sm{border-radius:calc(var(--radius) * .6)}.rounded-xl{border-radius:calc(var(--radius) * 1.4)}.rounded-t-xl{border-top-left-radius:calc(var(--radius) * 1.4);border-top-right-radius:calc(var(--radius) * 1.4)}.rounded-b-xl{border-bottom-right-radius:calc(var(--radius) * 1.4);border-bottom-left-radius:calc(var(--radius) * 1.4)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-background\/60{border-Line truncated
|
||||
R"RADPAGE(shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-none{--tw-shadow:0 0 #0000;box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-background{--tw-ring-color:var(--background)}.ring-foreground\/10{--tw-ring-color:var(--foreground)}@supports (color:color-mix(in lab, red, red)){.ring-foreground\/10{--tw-ring-color:color-mix(in oklab, var(--foreground) 10%, transparent)}}.ring-sidebar-ring{--tw-ring-color:var(--sidebar-ring)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media (forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[height\]{transition-property:height;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[left\,right\,width\]{transition-property:left,right,width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[margin\,opacity\]{transition-property:margin,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\,height\,padding\]{transition-property:width,height,padding;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[width\]{transition-property:width;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;tranLine truncated
|
||||
R"RADPAGE(-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-transparent::file-selector-button{background-color:#0000}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-foreground::file-selector-button{color:var(--foreground)}.placeholder\:text-muted-foreground::placeholder{color:var(--muted-foreground)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:-inset-2:after{content:var(--tw-content);inset:calc(var(--spacing) * -2)}.after\:-inset-x-3:after{content:var(--tw-content);inset-inline:calc(var(--spacing) * -3)}.after\:-inset-y-2:after{content:var(--tw-content);inset-block:calc(var(--spacing) * -2)}.after\:inset-y-0:after{content:var(--tw-content);inset-block:0}.after\:start-1\/2:after{content:var(--tw-content);inset-inline-start:50%}.after\:w-\[2px\]:after{content:var(--tw-content);width:2px}.after\:bg-foreground:after{content:var(--tw-content);background-color:var(--foreground)}.after\:opacity-0:after{content:var(--tw-content);opacity:0}.after\:transition-opacity:after{content:var(--tw-content);transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}:is(:where(.group)[data-collapsible=offcanvas] .group-data-\[collapsible\=offcanvas\]\:after\:left-full):after{content:var(--tw-content);left:100%}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:inset-x-0):after{content:var(--tw-content);inset-inline:0}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:bottom-\[-5px\]):after{content:var(--tw-content);bottom:-5px}:is(:where(.group\/tabs):where([data-orientation=horizontal]) .group-data-horizontal\/tabs\:after\:h-0\.5):after{content:var(--tw-content);height:calc(var(--spacing) * .5)}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:inset-y-0):after{content:var(--tw-content);inset-block:0}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:-right-1):after{content:var(--tw-content);right:calc(var(--spacing) * -1)}:is(:where(.group\/tabs):where([data-orientation=vertical]) .group-data-vertical\/tabs\:after\:w-0\.5):after{content:var(--tw-content);width:calc(var(--spacing) * .5)}.last\:border-r-0:last-child{border-right-style:var(--tw-border-style);border-right-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:bg-\[color-mix\(in_oklch\,var\(--secondary\)\,var\(--foreground\)_5\%\)\]:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-\[color-mix\(in_oklch\,var\(--secondary\)\,var\(--foreground\)_5\%\)\]:hover{background-color:color-mix(in oklch,var(--secondary),var(--foreground) 5%)}}.hover\:bg-accent\/50:hover{background-color:var(--accent)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-accent\/50:hover{background-color:color-mix(in oklab, var(--accent) 50%, transparent)}}.hover\:bg-destructive\/20:hover{background-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-destructive\/20:hover{background-color:color-mix(in oklab, var(--destructive) 20%, transparent)}}.hover\:bg-muted:hover,.hover\:bg-muted\/50:hover{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab, var(--muted) 50%, transparent)}}.hover\:bg-primary:hover,.hover\:bg-primary\/80:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-primary\/80:hover{background-color:color-mix(in oklab, var(--primary) 80%, transparent)}}.hover\:bg-sidebar-accent:hover{background-color:var(--sidebar-accent)}.hover\:bg-transparent:hover{background-color:#0000}.hover\:text-foreground:hover{color:var(--foreground)}.hover\:text-sidebar-accent-foreground:hover{color:var(--sidebar-accent-foreground)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-\[0_0_0_1px_var\(--sidebar-accent\)\]:hover{--tw-shadow:0 0 0 1px var(--tw-shadow-color,var(--sidebar-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.hover\:outline:hover{outline-style:var(--tw-outline-style);outline-width:1px}.hover\:outline-foreground:hover{outline-color:var(--foreground)}:is(:where(.group)[data-collapsible=offcanvas] .hover\:group-data-\[collapsible\=offcanvas\]\:bg-sidebar:hover){background-color:var(--sidebar)}.hover\:after\:bg-sidebar-border:hover:after{content:var(--tw-content);background-color:var(--sLine truncated
|
||||
R"RADPAGE(lc(var(--spacing) * -1)}.data-\[side\=inline-end\]\:-translate-y-1\/2[data-side=inline-end]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=inline-end\]\:slide-in-from-left-2[data-side=inline-end]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}.data-\[side\=inline-start\]\:top-1\/2\![data-side=inline-start]{top:50%!important}.data-\[side\=inline-start\]\:-right-1[data-side=inline-start]{right:calc(var(--spacing) * -1)}.data-\[side\=inline-start\]\:-translate-y-1\/2[data-side=inline-start]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=inline-start\]\:slide-in-from-right-2[data-side=inline-start]{--tw-enter-translate-x:calc(2*var(--spacing))}.data-\[side\=left\]\:inset-y-0[data-side=left]{inset-block:0}.data-\[side\=left\]\:top-1\/2\![data-side=left]{top:50%!important}.data-\[side\=left\]\:-right-1[data-side=left]{right:calc(var(--spacing) * -1)}.data-\[side\=left\]\:left-0[data-side=left]{left:0}.data-\[side\=left\]\:h-full[data-side=left]{height:100%}.data-\[side\=left\]\:w-3\/4[data-side=left]{width:75%}.data-\[side\=left\]\:-translate-y-1\/2[data-side=left]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=left\]\:border-r[data-side=left]{border-right-style:var(--tw-border-style);border-right-width:1px}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:calc(2*var(--spacing))}:is(:where(.group)[data-collapsible=offcanvas] .data-\[side\=left\]\:group-data-\[collapsible\=offcanvas\]\:left-\[calc\(var\(--sidebar-width\)\*-1\)\][data-side=left]){left:calc(var(--sidebar-width) * -1)}.data-\[side\=left\]\:data-ending-style\:translate-x-\[-2\.5rem\][data-side=left][data-ending-style],.data-\[side\=left\]\:data-starting-style\:translate-x-\[-2\.5rem\][data-side=left][data-starting-style]{--tw-translate-x:-2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:inset-y-0[data-side=right]{inset-block:0}.data-\[side\=right\]\:top-1\/2\![data-side=right]{top:50%!important}.data-\[side\=right\]\:right-0[data-side=right]{right:0}.data-\[side\=right\]\:-left-1[data-side=right]{left:calc(var(--spacing) * -1)}.data-\[side\=right\]\:h-full[data-side=right]{height:100%}.data-\[side\=right\]\:w-3\/4[data-side=right]{width:75%}.data-\[side\=right\]\:-translate-y-1\/2[data-side=right]{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:border-l[data-side=right]{border-left-style:var(--tw-border-style);border-left-width:1px}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}:is(:where(.group)[data-collapsible=offcanvas] .data-\[side\=right\]\:group-data-\[collapsible\=offcanvas\]\:right-\[calc\(var\(--sidebar-width\)\*-1\)\][data-side=right]){right:calc(var(--sidebar-width) * -1)}.data-\[side\=right\]\:data-ending-style\:translate-x-\[2\.5rem\][data-side=right][data-ending-style],.data-\[side\=right\]\:data-starting-style\:translate-x-\[2\.5rem\][data-side=right][data-starting-style]{--tw-translate-x:2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=top\]\:inset-x-0[data-side=top]{inset-inline:0}.data-\[side\=top\]\:top-0[data-side=top]{top:0}.data-\[side\=top\]\:-bottom-2\.5[data-side=top]{bottom:calc(var(--spacing) * -2.5)}.data-\[side\=top\]\:h-auto[data-side=top]{height:auto}.data-\[side\=top\]\:border-b[data-side=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:calc(2*var(--spacing))}.data-\[side\=top\]\:data-ending-style\:translate-y-\[-2\.5rem\][data-side=top][data-ending-style],.data-\[side\=top\]\:data-starting-style\:translate-y-\[-2\.5rem\][data-side=top][data-starting-style]{--tw-translate-y:-2.5rem;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[size\=default\]\:h-\[18\.4px\][data-size=default]{height:18.4px}.data-\[size\=default\]\:w-\[32px\][data-size=default]{width:32px}.data-\[size\=md\]\:text-sm[data-size=md]{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.data-\[size\=sm\]\:h-\[14px\][data-size=sm]{height:14px}.data-\[size\=sm\]\:w-\[24px\][data-size=sm]{width:24px}.data-\[size\=sm\]\:rounded-\[min\(var\(--radius-md\)\,10px\)\][data-size=sm]{border-radius:min(var(--radius-md), 10px)}.data-\[size\=sm\]\:text-xs[data-size=sm]{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.data-\[size\=sm\]\:\[--card-spacing\:--spacing\(3\)\][data-size=sm]{--card-spacing:calc(var(--spacing) * 3)}.data-\[size\=sm\]\:has-data-\[slot\=card-footer\]\:pb-0[data-size=sm]:has([data-slot=card-footer]){padding-bottom:0}:is(.\*\*\:data-\[slot\=kbd\]\:relative *)[data-slot=kbd]{position:relative}:is(.\*\*\:data-\[slot\=kbd\]\:isolLine truncated
|
||||
R"RADPAGE(rk *){background-color:color-mix(in oklab, var(--destructive) 20%, transparent)}}.dark\:bg-input\/30:is(.dark *){background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:bg-input\/30:is(.dark *){background-color:color-mix(in oklab, var(--input) 30%, transparent)}}.dark\:text-muted-foreground:is(.dark *){color:var(--muted-foreground)}@media (hover:hover){.dark\:hover\:bg-destructive\/30:is(.dark *):hover{background-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-destructive\/30:is(.dark *):hover{background-color:color-mix(in oklab, var(--destructive) 30%, transparent)}}.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:color-mix(in oklab, var(--input) 50%, transparent)}}.dark\:hover\:bg-muted\/50:is(.dark *):hover{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-muted\/50:is(.dark *):hover{background-color:color-mix(in oklab, var(--muted) 50%, transparent)}}.dark\:hover\:text-foreground:is(.dark *):hover{color:var(--foreground)}}.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:color-mix(in oklab, var(--destructive) 40%, transparent)}}.dark\:disabled\:bg-input\/80:is(.dark *):disabled{background-color:var(--input)}@supports (color:color-mix(in lab, red, red)){.dark\:disabled\:bg-input\/80:is(.dark *):disabled{background-color:color-mix(in oklab, var(--input) 80%, transparent)}}.dark\:aria-invalid\:border-destructive\/50:is(.dark *)[aria-invalid=true]{border-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:aria-invalid\:border-destructive\/50:is(.dark *)[aria-invalid=true]{border-color:color-mix(in oklab, var(--destructive) 50%, transparent)}}.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, var(--destructive) 40%, transparent)}}.data-open\:animate-in:where([data-state=open]),.data-open\:animate-in:where([data-open]:not([data-open=false])){animation:enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none)}.data-open\:fade-in-0:where([data-state=open]),.data-open\:fade-in-0:where([data-open]:not([data-open=false])){--tw-enter-opacity:0}.data-open\:zoom-in-95:where([data-state=open]),.data-open\:zoom-in-95:where([data-open]:not([data-open=false])){--tw-enter-scale:.95}@media (hover:hover){:is(.data-open\:hover\:bg-sidebar-accent:where([data-state=open]),.data-open\:hover\:bg-sidebar-accent:where([data-open]:not([data-open=false]))):hover{background-color:var(--sidebar-accent)}:is(.data-open\:hover\:text-sidebar-accent-foreground:where([data-state=open]),.data-open\:hover\:text-sidebar-accent-foreground:where([data-open]:not([data-open=false]))):hover{color:var(--sidebar-accent-foreground)}}.data-closed\:animate-out:where([data-state=closed]),.data-closed\:animate-out:where([data-closed]:not([data-closed=false])){animation:exit var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,none)}.data-closed\:fade-out-0:where([data-state=closed]),.data-closed\:fade-out-0:where([data-closed]:not([data-closed=false])){--tw-exit-opacity:0}.data-closed\:zoom-out-95:where([data-state=closed]),.data-closed\:zoom-out-95:where([data-closed]:not([data-closed=false])){--tw-exit-scale:.95}.data-checked\:bg-primary:where([data-state=checked]),.data-checked\:bg-primary:where([data-checked]:not([data-checked=false])){background-color:var(--primary)}:is(:where(.group\/switch)[data-size=default] .group-data-\[size\=default\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-state=checked]),:is(:where(.group\/switch)[data-size=default] .group-data-\[size\=default\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-checked]:not([data-checked=false])),:is(:where(.group\/switch)[data-size=sm] .group-data-\[size\=sm\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-state=checked]),:is(:where(.group\/switch)[data-size=sm] .group-data-\[size\=sm\]\/switch\:data-checked\:translate-x-\[calc\(100\%-2px\)\]):where([data-checked]:not([data-checked=false])){--tw-translate-x:calc(100% - 2px);translate:var(--tw-translate-x) var(--tw-translate-y)}.dark\:data-checked\:bg-primary-foreground:is(.dark *):where([data-state=checked])Line truncated
|
||||
R"RADPAGE(-\'\]\)\]\:size-3 svg:not([class*=size-]){width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-3\.5 svg:not([class*=size-]){width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\.border-b\]\:pb-\(--card-spacing\).border-b{padding-bottom:var(--card-spacing)}:is(.\*\:\[a\]\:underline>*):is(a){text-decoration-line:underline}:is(.\*\:\[a\]\:underline-offset-3>*):is(a){text-underline-offset:3px}@media (hover:hover){:is(.\*\:\[a\]\:hover\:text-foreground>*):is(a):hover{color:var(--foreground)}}:is(.\*\:\[img\:first-child\]\:rounded-t-xl>*):is(img:first-child){border-top-left-radius:calc(var(--radius) * 1.4);border-top-right-radius:calc(var(--radius) * 1.4)}:is(.\*\:\[img\:last-child\]\:rounded-b-xl>*):is(img:last-child){border-bottom-right-radius:calc(var(--radius) * 1.4);border-bottom-left-radius:calc(var(--radius) * 1.4)}.\[\&\>button\]\:hidden>button{display:none}.\[\&\>span\:last-child\]\:truncate>span:last-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\[\&\>svg\]\:size-4>svg{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&\>svg\]\:shrink-0>svg{flex-shrink:0}.\[\&\>svg\]\:text-sidebar-accent-foreground>svg{color:var(--sidebar-accent-foreground)}.\[\&\>tr\]\:last\:border-b-0>tr:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}[data-side=left][data-collapsible=offcanvas] .\[\[data-side\=left\]\[data-collapsible\=offcanvas\]_\&\]\:-right-2{right:calc(var(--spacing) * -2)}[data-side=left][data-state=collapsed] .\[\[data-side\=left\]\[data-state\=collapsed\]_\&\]\:cursor-e-resize{cursor:e-resize}[data-side=right][data-collapsible=offcanvas] .\[\[data-side\=right\]\[data-collapsible\=offcanvas\]_\&\]\:-left-2{left:calc(var(--spacing) * -2)}[data-side=right][data-state=collapsed] .\[\[data-side\=right\]\[data-state\=collapsed\]_\&\]\:cursor-w-resize{cursor:w-resize}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:none}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-blur{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}@property --scroll-fade-t{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-b{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-s{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-e{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --scroll-fade-mask{syntax:"*";inherits:false}@property --shimmer-angle{syntax:"<angle>";inherits:true;initial-value:20deg}@property --shimmer-image{syntax:"*";inherits:false}@property --shimmer-text-fill{syntax:"*";inherits:false}@media (prefers-reduced-motion:reduce){.shimmer{-webkit-text-fill-color:currentColor;background-image:none;animation:none}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(data:font/woff2;base64,d09GMgABAAAAAHLYABQAAAABAQgAAHJiAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGoYFG4GfHhyHTD9IVkFSh1s/TVZBUjwGYD9TVEFUgTgAhRAvfhEICvZo3iMLhEIAMIGoaAE2AiQDiQAEIAWIGgeLSQwHGyLxFWxXY6CewOalNZfPMyrYrmbcDkTU+r1qNsKGjQMg3hwT/X9SUhlDE9iTFqA63e4PtWQjlBo5goYcMo0ZqbViQ0jvqjjmPNf7mgM3sj6o9UXp+5FQOzPJbOE3Jx5hd/ytpmpjm0pYR9BzruG68ZnXxBVYEMSHMTAwnWpYTZ0wG3f74drkjkO9/6wik1904hQkUpdYDWmJLZFY0pNBEcb7IndF19PSj1kEuE38iIQcX4SK1qgisnr6gFERPc4+OgJHpJCEZJaAxtzpl8/CAc8Rzfk/exe9hCSEEEII4fAAIZilNJgFLUVSVAJFvJRHwV/VaP29R8UpddoiNaXiVOXz+nnW8vzTuOd/7TP3wUxgI76kJCdlOHSryZ2cIZquptBglVCzlLbxtmnUViK7SXY3ySbepI23Th21In7G/T/8PXD3nBn2TLine truncated
|
||||
R"RADPAGE(cBjj0kMnIGBDnz6CkBGMhDEmKSkOEyaESGYw5mzgbNmis2NHSq6Jq/XoXs3EwY3BM39UIfuqGhgFzcWgiIURoBZFeqj4chNBGAQYMVzgZqSpYeYUNRExJ2HGnRsHCi6c2ZPQJy59J2QVuwW66Sr6WSYsWJajQ5YT0C+Z3CUTGskUyZQ1W3Jm32NBFAIBS3PJc/Lpl9ef1lEzNlu2/L0WFYokQviYCFw8uvj02FJwpJaqWKMz/yt2CeP+UBwe8G3MHzcCOfa/aWi7j8AoRr5AV2r7wdG8jJQ/PuqGiMnbywX1UYPgJESoMOEiRIoSLUOmLNly5MqTr0jJiNnMpo0jbiPiXQS3gXADAAAAALCycXuyAAd6084t/bMQBdCVSxPImfy/+o4SBP9vxzGOjcLxeRKpZEnKfBr3fkMeS/8/l8Y0DXNwOEUNMSJapbeBuTaGBPvrfNX8F/m+w1GFvvWGIBJStvslHC1we9zllP1+KZcOiQycKY7yI9pRcRHLf6/vxOz7aOjZYUzyxtTjlJECmJOzVi7+nTjz5tJyqDtLW1YKFcci5VUouKgwPxP64zCWgGYh8bWYS6pLKyD8sm4GgVfhwNc7/zJwMdFR4NGt2lyWTh6iMovRt+dXRuxpjsC77nnGZvultSrlL+Sdh4YNsELBgMBNtjVL0gbwh1CQRHgIz2EuewHfJJhXcdUPL1H05KtwQhwMx2B+OMrTkTABqjZ3vV44gRBzjGZD1xKrcaOqJVZN68fPBOw8dSsi+/O0zsEgv1oOaPj+FBogrBBwCB+ikLgLYZdX2AA4SMr57kZ/wGv7q1UPqILzwveeEYIiKUx/x4jt6PcjxlJnCpqQiWgsTIUsJxFTBPEEyWyiTBQXP9UCPVNCNLSKMxybrSMwzkVMKgsDOWlIUzsovbwHFWZRikzTE8Tq5GLULQhPoKWgAdlYSdbwVsywW5tA4xPbGkBJEg0zyR/jT7Ma5DyAHHdhufErrwpJI+75thxcNMb8EJP13tJLMDsiqPyhPPlzLg9y87iYwE1PZ6np8IfxCBscGsbK8uYIMWttiGj5xywAlwsgJqV/Bh/uAsqj0xYh1PJge9nCWUvEhjwm+Kz+mTLDQHREQzjY0pMolZMqFTQyaClUKlc/+DvPJDdbmSSFEqQplkC9Pld0GILjaqKa9yLZMGAeBhgFSH4ICTc3RSBQQh8SKWoABtzAWmUTDEEOtvrCQkxwvJKnUVmqGdoaAihyNL/nDGJBJwhMML9ZhFI0SeegVh1d8eI+S+drmUqJDXiG7oqaruSr/a6YppEp4ssQAp4LDrgWsA2w/A/+nvHNzLvAae7Nh+14xMJHDT+h62lHn9f/Dux8D65+CCOflfHncPSr/0v3ZxwBzwEC8JZdHTXRbe56zHt44Aj+9Phx51/df6NOD4/YRnVj2NjQueyFJVfMV/uvtV+zXgtcZ35QdUN6S3/LeAu/rRznjgvHpeO6O+DTsLtVd/l3hXc9d4P3Ku/p7ssfFH8FP3Q+an4UfeJ90v+08Dv2s2vPGp9xn41NMH+onmiccE5MPi/8uexl9UvpS/lL02vpa/1rw2vza+i1+3XP69E38AjOD8/GtHu1N3670fjWf+bNW82Hzc/++7D9uHO/89KF8Yv5/YmLN14Sq6XqyctTV45due7KXVfFg56DE9eI9DUNf6PUmLpx1e2+drk9pCf0Qf3+e+GPBh4ClpNRDgwGoG+e5T/32vxv8/0Xf6/S/ohuJ+vGjqN1sAsAPHxeftXaYA0wfwErM6g4HW5h0EcCpYLcBRXk7iQBXB5fvafgHF/G5GlwuyPu8jG75oiASBhCLuTjH///ArQtziGBlwFkYkYBNiOgtfZ8gOUIwHbYtbcXVCEA9I9mMeK+rwIkOU+hEmQoUacNAuBkckC6YirnNkxX/hzbEcsiIM9yG2Y76VbMTdJ150tWLCyydXG13XFBsFgDPaRCerlXYyulmr7STiFRSDjw0mynn+bIyficymhqoSqCU3Ambr5ZQIpJKWlGWpEupDcZSO5cNTNdvLp0wP/pwGaOvG20uzgSdxLgDWecokeKSMmFO5NeXVcY/yGc9InA/2fSkHn+j3kA/33fMQDfP97lnlRZsoGzbz6pYkeZc4AoAdd5agqADzFo9V4eCO92AbcmfeO0Z875MxR4Y8J1N4z5ywmXHXfeSaf85D8/nPUaQmDRwSWgT8iAhJQJkilzduwpOHDkxJ0HT1583HbBeI7BtWRQChQkRBi1aDFiJUmlMUuaDAWKFCuhVaZKtRq1Gtz01a1EYNAZ//N/k6Z88y5LvDfXo0ThQ67iUwA+tS+G/OKtkVzNHi0e22mHXYbRYCgYqOiY2PTw6OIzImJIjMOMNQuWbFj5h4wbZy5ceZMrpTKNL3/T+QkQLEq4CJFmipdghlDpcmTKkifbv3JVKjdbhTqF6tnKz1zE44GH7rjnvrsQYDEMIsBEdCEJctSXvvbyzWFnMeESO0WhCuw0RepFnzMUi492lhL6V8A5SrXOvnaeZBfCLtBM7RzYRVqoF4tdsgl1Z9F5cL65Rf1nDyw8F1h+JMCwEqhXAaDB+riX8HIz6UgSoaq86q6GxqUyATQaHhsLoGk6alKN1cjE1a2cukzw42JQ02px9aXmOnHy0evjUSUjqj52pav6VMUaFpIWr0O5HGXSUTP19KTUNW/is9SXsU6qkSSboV1kcHkiAgqi61MbEUY1JmNiyPPNsbG2WeXOTZJ/xo2goIleZCB0BVqtjrvZqsCl82v22TVlGu9yyCPII0vMYgfcrH337LZTKVImpwPRer2U+1XgI1dSmJ1CczXN4jivNxEhQj/2I54yfroPzYnNxm5na40dwxAw3iAFXs8ZwnJprelWCtPQH9M+s7lPcs+qalZJcnZRLgbpjEUSGbc52qXdlkmUabPZA21JpapONB7sksg+KnQf32eV4R8VX/veHaFDawevYZvzSQWExSavMyAAH/PAgGYvpdnPmRkS/KZOq0ZmSeXzLuggInw4JuKiv7nl34tZKZZR5MJv5OY/t6yWJH8XoBIuxX46dLNzeqZ9VRdUE37Kv96EhodUx6sFxi/MPqXYR96p1+K54zvWVzrrNPSy5zDWs1IcT5ApACPWgGUu32461R+iAl9qzbAOrfWVm4IpqzJ2KXTKr0YvMxObqPnzrFXNNYI83vp2aOQZQx4EEn72bVDlB6J8kISMZsrOiuW3XD2DseyYTg8vIyWpwlfxrO6yBI56hU5ymu8vH2UhDCD51v2TTyX7CVsDnTi4Vd1seWMtj4ppLvhAGu+/K8SWyXkWB/PIDLJ385M9jOsCaEDaAOlSe67WDiL3k6XofjdwGGeGsxq5zU3s+MYnrUTx+jH3JNjm33j9Fwa7YnBd4Z4qF59A/bK50uObRo3iz19umCA/Q5PkVojOdMyfnqL0sIRTDXrL4liNfLmhyD5S9dKM3yrsUbGRQUetYlsHnPApFwUtTEwYzbJ/DZjBzOmBNtGA7Mfk6GvPl10Q64EYgRCS5tiuyyZQ5HKnt/e5l3Pylkq1Pitwzbn4UD78IX0/VuSR8t3XwdE2MyRPHt9U5rPM4/cGw2z8Y8ivlHTmIWruSJL0rT/hVPb9mdPZo+VQkM1lJLKsbxhosyluIO+fiMKJfUd20ByUB62e+68hC5fr1Ur2Wq3vLG90nI/zstRLoJxJ2eJy8LGb5QHJ/zD2XPECErA3XxiZ3+0NIwkbltlZM/k7XcsQjecnUb2VVjLKR9gx5bnACGRoSRdoG5bVT2qIwJGSKXcfTdnmuPogxlR7seLDLPfV7z/fGh5kdVFlFtavaJz8ymNW5h37lVsDbAuZqNJZe2tnTa9yK70SNGt6eQleF9lPNFvbhOzjcZT+9O1WtX/ycSmhSJJikFmKyq3qfK9cftx7hayCwGO+w8AAptjDQBA1vNJxSkh56V8whCwDAsFOV96PglHmO/oX/nzRTwO1jMs/7IKLqd85J11Hd/14sitY0F1Hm1iG6irDu6Pu+5sS0XuVYt2qvxejAdSYnmX5Z3FfOfMv2cPUfe+LFYlu2Eq3k322+6BosLemdZwWvFryufuM0iMtFB89InssR301eXGVe6VuNeUua55CfXP6TJhQ7oEFy73dnDn/Uo3tO4MMrdZyjq26zCua4wup6/PGROa0kFAzPB+jGK1Mr+NcuIptUK2PxIWyQonKxTvvmT3nslPvm3pcaRGrVhGU6rtc7S3P8OmEBjyH3/A0YD++MkCn5Davzx1HZdpUrX9vrTMuc5rmT4L7IJ5KciK+78vYmwc31duK7WFkkJowROhC9BeRGzaXJfarVXNy+Zoz9goYSJ+Lix+NRRxMqHkSlkXfJ9yPoCGpTftLf01+lCIfhgX3u6vgQphBNhBq93bToX9astcbjc57axnt2anlUi8VDCSXKLY5FNWGCCuYU8p9vDtCe1mjAR+kLRKNTX/RWbPzzEnSt+yKR30TGyE6yUPCTHsLOVRi+AvQl8bAnRnclobOwT8LyhmPdxMTKYGa9I8fMLjV9WSSCDVnIB9LNPRsM/uLU+WaWCZ3nBipfZ2RJJnYWqsmDMJScpBNbcOA6i7JFMf3tMP2oLAX9+2T9O6dhGTMds87JpK4Dza8N6qRNv85fzmdL9p3yH414qIEzrYQqc5eYbLK/D+Vkq+ZR6tVjyssr01uaqqz1OAVymIYImnaJ+2ja7DCvdx6NDYp0+V8g+EtU+32dZPPKcE14+7qQspnPNt+8sNdmACFuaq6k6J5jvw04cER/59B9TLmC4XqTb9KiTQVDiTCRhWOPJk9/2gLks52cP0e17n4Szu3u8ur03ixnMZa5YSyyltT2+lASYoAuY00pm0m55HFwYCXPd0KI08NQ8a2rJZadc0f1nlamoVszs0snxGUl1/aHNJh0jixwlQfpD6pT3W+iFV6ZUStlqZC+OWONOdmKiCN1bO6OUf/HlGMoiE+8ozfxlfLdCLkQs6qTKtgJLine truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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 truncated
|
||||
R"RADPAGE(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)format("woff2-variations")}:root{--background:#f9fafb;--foreground:#111419;--card:#fff;--card-foreground:#111419;--popover:#fff;--popover-foreground:#111419;--primary:#2e62c9;--primary-foreground:#f9fafb;--secondary:#eef0f3;--secondary-foreground:#1e2228;--muted:#eef0f3;--muted-foreground:#5e646c;--accent:#e9edf2;--accent-foreground:#171b20;--destructive:#df2225;--border:#dfe1e5;--input:#dfe1e5;--ring:#5684da;--radius:.625rem;--sidebar:#f4f6f8;--sidebar-foreground:#111419;--sidebar-primary:#2e62c9;--sidebar-primary-foreground:#f9fafb;--sidebar-accent:#e6eaef;--sidebar-accent-foreground:#171b20;--sidebar-border:#dfe1e5;--sidebar-ring:#5684da;--series-1:#396ed6;--series-2:#d95737;--series-3:#00967c;--series-4:#915dc5;--series-5:#b88a00;--series-6:#c3518d;--series-7:#0094bd;--series-8:#419547;--ok:#25984d;--warn:#d38e00;--bad:#de3b3d;--idle:#7f8793;--grid:#e2e5e8}@supports (color:lab(0% 0 0)){:root{--background:lab(98.2562% -.166595 -.736153);--foreground:lab(6.15419% -.356875 -4.10882);--card:lab(100% 0 0);--card-foreground:lab(6.15419% -.356875 -4.10882);--popover:lab(100% 0 0);--popover-foreground:lab(6.15419% -.356875 -4.10882);--primary:lab(42.6189% 11.5611 -59.7505);--primary-foreground:lab(98.2562% -.166595 -.736153);--secondary:lab(94.7703% -.411719 -1.83765);--secondary-foreground:lab(12.9538% -.484258 -4.41422);--muted:lab(94.7703% -.411719 -1.83765);--muted-foreground:lab(41.9469% -.688925 -5.55613);--accent:lab(93.604% -.651121 -2.93589);--accent-foreground:lab(9.47247% -.459656 -4.40383);--destructive:lab(49.0747% 69.3434 49.6251);--border:lab(89.5482% -.491649 -2.20379);--input:lab(89.5482% -.491649 -2.20379);--ring:lab(54.8356% 4.35138 -49.6759);--sidebar:lab(96.7463% -.248939 -1.10371);--sidebar-foreground:lab(6.15419% -.356875 -4.10882);--sidebar-primary:lab(42.6189% 11.5611 -59.7505);--sidebar-primary-foreground:lab(98.2562% -.166595 -.736153);--sidebar-accent:lab(92.444% -.650853 -2.93578);--sidebar-accent-foreground:lab(9.47247% -.459656 -4.40383);--sidebar-border:lab(89.5482% -.491649 -2.20379);--sidebar-ring:lab(54.8356% 4.35138 -49.6759);--series-1:lab(47.3516% 10.0889 -59.8436);--series-2:lab(54.4452% 50.6614 45.0348);--series-3:lab(55.1513% -42.4221 3.65769);--series-4:lab(48.837% 37.1132 -46.9834);--series-5:lab(60.6937% 11.3242 68.7955);--series-6:lab(51.444% 51.1158 -9.89943);--series-7:lab(56.3446% -25.1481 -33.3622);--series-Line truncated
|
||||
R"RADPAGE(.u-marker{width:1em;height:1em;margin-right:4px;background-clip:padding-box!important}.u-inline.u-live th:after{content:":";vertical-align:middle}.u-inline:not(.u-live) .u-value{display:none}.u-series>*{padding:4px}.u-series th{cursor:pointer}.u-legend .u-off>*{opacity:.3}.u-select{pointer-events:none;background:#00000012;position:absolute}.u-cursor-x,.u-cursor-y{pointer-events:none;will-change:transform;position:absolute;top:0;left:0}.u-hz .u-cursor-x,.u-vt .u-cursor-y{border-right:1px dashed #607d8b;height:100%}.u-hz .u-cursor-y,.u-vt .u-cursor-x{border-bottom:1px dashed #607d8b;width:100%}.u-cursor-pt{pointer-events:none;will-change:transform;border:0 solid;border-radius:50%;position:absolute;top:0;left:0;background-clip:padding-box!important}.u-axis.u-off,.u-select.u-off,.u-cursor-x.u-off,.u-cursor-y.u-off,.u-cursor-pt.u-off{display:none}
|
||||
/*$vite$:1*/</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+85
-28
@@ -16,8 +16,7 @@ namespace server {
|
||||
|
||||
namespace {
|
||||
|
||||
/* Requests that name a job by its id in the path. Without a model they are asked of every model,
|
||||
* and the one that knows the id answers; the others say 404. */
|
||||
/* Requests that name a job by its id in the path. Without a model, ask the resident servers. */
|
||||
bool id_route(const std::string& path) {
|
||||
return path.rfind("/v1/videos/", 0) == 0 || path.rfind("/status/", 0) == 0;
|
||||
}
|
||||
@@ -226,7 +225,10 @@ void Front::install_routes(const Router& model_router) {
|
||||
bool fleet = method == "GET" && (path == "/" || path == "/dashboard");
|
||||
for (const auto& [p, fn] : own) fleet |= method == "GET" && path == p;
|
||||
if (fleet) continue;
|
||||
router_.add(method, path, [this](const HttpRequest& q) { return forward(q); });
|
||||
/* Copy the guarded mark with the route: the front's wake-guard then reads the same fact
|
||||
* the engine's registration set, through the same matcher. */
|
||||
router_.add(method, path, [this](const HttpRequest& q) { return forward(q); },
|
||||
model_router.guarded(method, path));
|
||||
}
|
||||
for (const auto& [p, fn] : own)
|
||||
router_.get(p, [this, fn = fn](const HttpRequest& q) { return (this->*fn)(q); });
|
||||
@@ -447,7 +449,7 @@ Front::Entry* Front::resolve(const std::string& model) {
|
||||
|
||||
Front::Got Front::lease(const std::string& model, const std::string& path, int64_t wait_ms,
|
||||
uint64_t* until_ns, Entry** out, std::shared_ptr<void>* held,
|
||||
HttpResponse* refusal) {
|
||||
HttpResponse* refusal, bool operator_ok) {
|
||||
std::unique_lock<std::mutex> lk(mu_);
|
||||
*out = nullptr;
|
||||
Entry* e = resolve(model);
|
||||
@@ -490,8 +492,11 @@ Front::Got Front::lease(const std::string& model, const std::string& path, int64
|
||||
return Got::Refused;
|
||||
}
|
||||
if (e->state == State::Failed) {
|
||||
/* The failure prose quotes fetch errors and filesystem paths: operator-facing. A
|
||||
* stranger learns the model failed -- that is public anyway -- never why. */
|
||||
*refusal = refuse(path, 503, "service_unavailable",
|
||||
"model '" + e->name + "' could not be loaded: " + e->why);
|
||||
"model '" + e->name + "' could not be loaded" +
|
||||
(operator_ok ? ": " + e->why : std::string()));
|
||||
const uint64_t t = rad_mono_ns();
|
||||
refusal->set_header("Retry-After",
|
||||
std::to_string(e->retry_ns > t ? (e->retry_ns - t) / 1000000000ull + 1 : 1));
|
||||
@@ -542,18 +547,42 @@ static bool wants_stream(const HttpRequest& q) {
|
||||
q.body.compare(b, e - b, "true") == 0;
|
||||
}
|
||||
|
||||
std::vector<std::pair<Front::Entry*, std::shared_ptr<void>>> Front::hold_open() {
|
||||
std::vector<std::pair<Front::Entry*, std::shared_ptr<void>>> Front::hold_open(bool include_draining_jobs) {
|
||||
std::vector<std::pair<Entry*, std::shared_ptr<void>>> held;
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
for (auto& p : entries_)
|
||||
if (!p->removed && p->state == State::Open) held.emplace_back(p.get(), lease_entry(p.get()));
|
||||
if (!p->removed && p->server &&
|
||||
(p->state == State::Open || (include_draining_jobs && p->state == State::Closing)))
|
||||
held.emplace_back(p.get(), include_draining_jobs ? lease_quiet(p.get()) : lease_entry(p.get()));
|
||||
return held;
|
||||
}
|
||||
|
||||
/* The path Router::match actually dispatches on: split_path (http.cpp) drops empty segments,
|
||||
* so "//stats" and "/stats/" ARE the route "/stats". Every guard that compares path text must
|
||||
* read the canonical form, or a slash turns any exact match into a bypass. */
|
||||
static std::string path_canonical(const std::string& p) {
|
||||
std::string out;
|
||||
out.reserve(p.size());
|
||||
for (const char c : p)
|
||||
if (c != '/' || out.empty() || out.back() != '/') out += c;
|
||||
if (out.size() > 1 && out.back() == '/') out.pop_back();
|
||||
return out;
|
||||
}
|
||||
|
||||
bool Front::dashboard_read(const HttpRequest& q) {
|
||||
if (q.method != "GET") return false;
|
||||
return q.path == "/stats" || q.path == "/sessions" || q.path == "/graph" ||
|
||||
q.path == "/server_info" || q.path == "/admin/control-vector";
|
||||
const std::string p = path_canonical(q.path);
|
||||
return p == "/stats" || p == "/sessions" || p == "/graph" ||
|
||||
p == "/server_info" || p == "/admin/control-vector";
|
||||
}
|
||||
|
||||
/* The routes Server::register_routes marks guarded are the ones whose handlers answer the local
|
||||
* operator only keyless. The front reads that mark back off its own copied routes (each guarded
|
||||
* at registration in server.cpp) rather than re-listing it: one source, and the match is the
|
||||
* router's -- so slash forms and the DELETE /sessions/:label shape decide exactly as the handler
|
||||
* is reached, and a route cannot be guarded in one place and not the other. */
|
||||
bool Front::guarded_route(const HttpRequest& q) const {
|
||||
return router_.guarded(q.method, q.path);
|
||||
}
|
||||
|
||||
void Front::keep_job(const std::string& id, int64_t expires_at, int64_t max_kept, Handler answer) {
|
||||
@@ -567,6 +596,16 @@ void Front::keep_job(const std::string& id, int64_t expires_at, int64_t max_kept
|
||||
if (jobs_.size() > cap) jobs_.erase(jobs_.begin(), jobs_.end() - (std::ptrdiff_t)cap);
|
||||
}
|
||||
|
||||
std::shared_ptr<void> Front::hold_active_job(const Server* server) {
|
||||
if (!server) return {};
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
for (auto& p : entries_)
|
||||
if (!p->removed && p->server == server &&
|
||||
(p->state == State::Open || p->state == State::Closing))
|
||||
return lease_quiet(p.get());
|
||||
return {};
|
||||
}
|
||||
|
||||
Handler Front::kept_job(const HttpRequest& q) {
|
||||
if (!id_route(q.path)) return nullptr;
|
||||
const std::string id = route_id(q.path);
|
||||
@@ -586,8 +625,23 @@ Handler Front::kept_job(const HttpRequest& q) {
|
||||
}
|
||||
|
||||
HttpResponse Front::forward(HttpRequest q) {
|
||||
std::string canonical = path_canonical(q.path);
|
||||
const bool names_job = id_route(canonical);
|
||||
if (names_job) q.path = std::move(canonical);
|
||||
if (Handler kept = kept_job(q)) return kept(q);
|
||||
const std::string model = requested_model(q);
|
||||
if (model.empty() && names_job) {
|
||||
/* The default model is irrelevant to a job id. Polling must never start a cold model. */
|
||||
for (auto& [entry, hold] : hold_open(/*include_draining_jobs=*/true)) {
|
||||
HttpResponse response = entry->server->router().dispatch(q);
|
||||
if (response.status == 404 || response.status == 501) continue;
|
||||
hold_until_close(response, hold);
|
||||
return response;
|
||||
}
|
||||
/* The worker may have finished and its model closed after the first lookup. */
|
||||
if (Handler kept = kept_job(q)) return kept(q);
|
||||
return refuse(q.path, 404, "not_found_error", "no model holds " + q.path);
|
||||
}
|
||||
/* A dashboard read is not a use of the model: it does not bring one back, and it does not
|
||||
* keep one that nobody asks anything of from going idle. */
|
||||
if (dashboard_read(q)) {
|
||||
@@ -631,6 +685,19 @@ HttpResponse Front::forward(HttpRequest q) {
|
||||
Entry* e = nullptr;
|
||||
std::shared_ptr<void> l;
|
||||
HttpResponse refusal;
|
||||
/* A guarded route asked by someone the handler will refuse brings its model back for a
|
||||
* 403 alone: the wake fetched, evicted, and charged for nothing. Answer the not-open
|
||||
* state here and the stranger's request never touches the scheduler. An open model still
|
||||
* dispatches -- its handler is the guard that answers -- and so does everything once the
|
||||
* operator asks, rule or no rule. */
|
||||
if (guarded_route(q) && operator_rule_ && !operator_rule_(q)) {
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
Entry* r = resolve(model);
|
||||
if (r && r->state != State::Open)
|
||||
return refuse(q.path, 409, "model_not_open", "model '" + r->name + "' is " +
|
||||
state_name(r->state) +
|
||||
"; this request does not bring it back");
|
||||
}
|
||||
/* A streaming request for a model that is not open gets its event stream at once. */
|
||||
if (keepalive_ms_ > 0 && wants_stream(q)) {
|
||||
bool open = false;
|
||||
@@ -641,21 +708,8 @@ HttpResponse Front::forward(HttpRequest q) {
|
||||
}
|
||||
if (!open) return forward_waiting(std::move(q), model);
|
||||
}
|
||||
const Got g = lease(model, q.path, -1, nullptr, &e, &l, &refusal);
|
||||
if (g != Got::Leased) {
|
||||
if (model.empty() && id_route(q.path) && refusal.status == 400) {
|
||||
/* Every loaded model that might hold the job, in turn; the first that knows it
|
||||
* answers. */
|
||||
for (auto& [ent, hold] : hold_open()) {
|
||||
HttpResponse r = ent->server->router().dispatch(q);
|
||||
if (r.status == 404) continue;
|
||||
hold_until_close(r, hold);
|
||||
return r;
|
||||
}
|
||||
return refuse(q.path, 404, "not_found_error", "no model holds " + q.path);
|
||||
}
|
||||
return refusal;
|
||||
}
|
||||
const Got g = lease(model, q.path, -1, nullptr, &e, &l, &refusal, caller_is_operator(q));
|
||||
if (g != Got::Leased) return refusal;
|
||||
strip_base(&q, model);
|
||||
HttpResponse r = e->server->router().dispatch(std::move(q));
|
||||
hold_until_close(r, l);
|
||||
@@ -690,7 +744,8 @@ HttpResponse Front::forward_waiting(HttpRequest q, const std::string& model) {
|
||||
}
|
||||
Entry* e = nullptr;
|
||||
HttpResponse refusal;
|
||||
const Got g = lease(w->model, w->q.path, keepalive_ms_, &w->until, &e, &w->lease, &refusal);
|
||||
const Got g = lease(w->model, w->q.path, keepalive_ms_, &w->until, &e, &w->lease, &refusal,
|
||||
caller_is_operator(w->q));
|
||||
if (g == Got::Waiting) {
|
||||
chunk = ": loading model " + w->model + "\n\n";
|
||||
return true;
|
||||
@@ -724,7 +779,7 @@ void Front::forward_socket(const HttpRequest& q, WsConn& c) {
|
||||
Entry* e = nullptr;
|
||||
std::shared_ptr<void> l;
|
||||
HttpResponse refusal;
|
||||
if (lease(model, q.path, -1, nullptr, &e, &l, &refusal) != Got::Leased) {
|
||||
if (lease(model, q.path, -1, nullptr, &e, &l, &refusal, caller_is_operator(q)) != Got::Leased) {
|
||||
c.close(1008, model.empty() ? "name a model with ?model=" : "model '" + model + "' is not served here");
|
||||
return;
|
||||
}
|
||||
@@ -734,6 +789,8 @@ void Front::forward_socket(const HttpRequest& q, WsConn& c) {
|
||||
}
|
||||
|
||||
HttpResponse Front::models(const HttpRequest& q) {
|
||||
/* Discovery holds the server alive without marking it used: polling cards must not
|
||||
* restart the idle TTL or keep a warm-up model resident. */
|
||||
/* One model's card: asked of the model it names, under its own id. A model not loaded is
|
||||
* described without loading it. */
|
||||
if (q.path.rfind("/v1/models/", 0) == 0 && q.path.size() > 11) {
|
||||
@@ -751,7 +808,7 @@ HttpResponse Front::models(const HttpRequest& q) {
|
||||
return HttpResponse::json_body(200, card.dump());
|
||||
}
|
||||
e = r;
|
||||
l = lease_entry(r);
|
||||
l = lease_quiet(r);
|
||||
}
|
||||
HttpRequest one = q;
|
||||
const size_t colon = id.find(':');
|
||||
@@ -765,7 +822,7 @@ HttpResponse Front::models(const HttpRequest& q) {
|
||||
for (auto& p : entries_) {
|
||||
if (p->removed) continue;
|
||||
Row r{p.get(), nullptr, p->name, p->aliases, p->state};
|
||||
if (p->state == State::Open) r.hold = lease_entry(p.get());
|
||||
if (p->state == State::Open) r.hold = lease_quiet(p.get());
|
||||
rows.push_back(std::move(r));
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 363 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user