Archived
4be0a347919518047f9e956d966f233ede4969cd
20
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4be0a34791 |
kv tiers: a restore makes room the way pressure does, and a chain the pool cannot hold stops at a snapshot
A restore reserved only from the free list. The reserve's trim leaves a quarter of the pool free
after every publish, so a returning conversation larger than that came back as far as the free
list reached, and the lookup stopped at the first block still on the host. On GLM-5.3-Flash at
eight ranks, two conversations of 314K tokens in a 446,832-token pool: the second turn of the
first brought back exactly the 27,930 free blocks, hit 111,772 tokens, and on its hybrid state
resumed at the snapshot at 1,024, since geometric backoff keeps nothing between 1,024 and 131,072.
Its prefill took 84 s instead of under one.
PCBinding::restore_plan now makes room before the engine plans the restore, the same way
PCBinding::evict does for an admission: PrefixCache::trim_for drops entries whose host copy has
landed, the engine lands pending copies (flush_fn), and it drops again. It never erases one,
spares the restoring chain itself and every chain a waiting request holds, and like trim never
touches one a running sequence reads. The free quarter may go; the reserve's trim after the next
publish frees it again. One block table serves every rank, so the room rank 0's cache makes is
room on every rank, as with evict.
When the pool still cannot hold the chain, PrefixCache::restorable_from cuts it at the deepest
valid snapshot the shorter prefix reaches, so no block comes back past the point the hit resumes
from; without recurrent state it cuts where the room ends. TierExec::issue_restore keeps its own
cut as the backstop.
Both cuts are counted: radiance:prefix_restore_cuts_total for restores the pool could not hold
whole (/sessions moved.restore_cuts), and radiance:prefix_hit_cuts_total{reason="resumed_below"}
for admissions that resumed more than one checkpoint interval below their attention hit, which
hit_cut_tokens alone did not tell apart from many small tails (/stats and /sessions hit_cuts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
7d392b0400 |
mem_test: a conversation restored from the host tier comes back no further than the free list
A restore reserves only from the free list, so after the reserve's trim has left a quarter of the pool free, a session larger than that comes back partly, and the lookup stops at the first block still on the host. On a hybrid model the hit then resumes at the deepest snapshot below that point, which the retention ladder can put far down the chain. These tests drive the engine's restore against the real cache, tiers and manager: two conversations of 0.6 of the pool, the second admitted by pressure and published, then the first restored. Red on this tree: the first comes back as far as the free list reaches, the hybrid one resumes below its tip, and a restore the pool cannot hold is cut where the reservation ended, not at a snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1ad675e10c |
glm5next: the DSA indexer scores and selects by query rows over the ranks -- the prefill op that grows with context runs a run of rows a rank, bit for bit
Every rank scored every query row of a step against every complete block of its sequence and selected its 512 blocks, the same work eight times: 58 ms of a 1029 ms step at a 4096-row chunk and 20k of context, about 185 ms at 64k, the largest op that grows with the context. From GlmTp::kSplitRows each rank now scores one run of the step's rows with dsa_score's row_part, selects for the rows of its run under the bounds the scorer rebased (cu_part), and two all_gathers lay the page tables and lengths end to end (8 MiB a layer at 4096 rows). The key side stays replicated. The run's queries are all a rank needs, so the query projection, its quantiser and the head gates run on the run's rows too, and the gates lose their column split and gather; the bf16 projection stays on the step's rows where a run would be 64 rows or fewer, the skinny band whose split count a tuned configuration may set. Each row's selection is the same kernels' answer to the same operands, so the joined table is bit-identical to the replicated one and MLA reads it unchanged. The rule for a run is GlmTp's, stated once: ceil(T / world) rows rounded up to whole 16-byte words of the gathered row, because an all_gather moves whole words; the indexer gathers one i32 length a row, so its runs are multiples of four (DsaCache::part_rows). A rank whose run lies wholly past a small step takes the first run and computes dead rows, so every plane it gathers is written (GlmTp::run_of). The selection planes hold world runs, which can reach past the step, and the score plane shrinks to one run, 256 MiB to 32 MiB at 64k of context and a 4096-row chunk. A decode step splits too once rows x live blocks reach 2^18 from 16 rows (GlmTp::kSplitWork): eight sequences verifying five drafts from about 22k of context, where scoring 48 rows over 8000 blocks (250 us on one R9700) outweighs the two eight-rank gathers (about 50 us); a single sequence's six rows never pay. The replicated issue passes cu_part absent as its tenth operand, because the engine counts operands against the schema and refused the nine-operand issue at a served engine's first long prompt. On eight R9700s (TP8, two ranks on Gen4 x8 that day) a 19887-token prompt prefills 3927 tok/s against 3748 on 1.9.0, 7881 tokens 3990 against 3655, 2k 3849 against 3663; greedy text with the adaptive draft window is identical. r4d_emu splits decode rows beside a prefill chunk at 2, 4 and 8 ranks and joins the runs as the gather does, byte for byte against the unsplit scorer; glm5next_test declares the split at 2 and 8 ranks with the lint, holds the row rule to the formula it replaced at every world, and pins the graph and steps (world 1 0xed3fc26c486ea1b5 / 0x33e5f136f0dbba15, world 8 0x712f01858dbe1047 / 0xf9e357b1333c638f). dsa_score_fp8's selftest passes 62 of 62 on eight cards, and --perfdsa times the indexer whole and as one rank's run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
66812280bb |
r4d_selftest: --perfdsa -- GLM's DSA indexer timed at a context length, whole and as one rank's run
dsa_score scores every complete block of each row's sequence and qsa_select ranks them, so both grow with the context in decode as in prefill. --perfdsa CTX [M] [iters] times them at M rows in the packed-cache form glm5next issues, and as one rank's run of a step split over 2, 4 and 8 ranks by rows (dsa_score's row_part), printing what the split saves before its two all_gathers. On one R9700, 48 rows (eight sequences verifying five drafts) take 273 + 155 us at 60k of context and a run of 8 rows 53 + 21 us; six rows save 9 us. qsa_select at 4000 blocks takes 89 us for any row count up to 32: its split path needs two chunks of 4096, so a list of 3500 to 4096 blocks falls to the single-workgroup kernel past its key cache. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
afe5318259 |
dsa_score: row_part -- score one run of a step's query rows, and rebase cu for the selection after it
With `row_part` p, `score` holds R rows and row i is query row p * R + i; `q`, `q_scale` and `gate` stay the whole step's, so a run is the unsplit op's rows bit for bit. A row past the last sequence scores -inf, so every rank's run can be the same length whatever the step's. The optional output `cu_part` receives cu - p * R, under which qsa_select runs over the run's own rows (pos offset by p * R) and finds each row's sequence unchanged; qsa_select itself is untouched. This is what an indexer split over tensor-parallel ranks by query rows needs from the op: the scoring is the only per-row work in GLM-5.3's indexer that grows with the context. libr4d offsets the query operands and compares row0 + r against cu; libref and libavx index the same way. Without `row_part` nothing changes. Tests: the selftest scores each case's rows in equal runs and holds every run to the unsplit rows' bytes and cu_part to the rebased bounds; ref_test checks a run, a run past the step and a short query plane; r4d_emu_dsa (r4d_dsa.hip now runs on the emulator) splits decode rows beside a prefill chunk at 2, 4 and 8 ranks, selects with the rebased bounds and joins the runs as the all_gather does, byte for byte against the unsplit scorer and selection, ties and signed gates included. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
fa4a7a75a4 |
glm5next: the plugin over its blocks, one a file, and rad_glm_tp.h for the shards and the split threshold -- the same graph, read in order
The plugin carried the draft head's buffers, weights and ops in its declare and its draft pass
in its step, with the three ops that join the head to its layer declared inside the layer
function; each GLM block carried its core in a header of its own (rad_block_mla_latent.h,
rad_block_kda_state.h, rad_block_dsa_cache.h), the split threshold sat in rad_tp_split.h beside
the router's column split, and 64 / world, 8192 / world, 2048 / world were spelled across the
plugin and the blocks. tests/arch_test.cpp held the recording builder, the run-phase fakes, the
step lint, the batch kits and the fingerprints beside every architecture's cases, 9.5k lines in
one translation unit, GLM-5.3's among them.
Now one block a file in arch/common: rad_block_glm_{mhc,kda,mla,indexer,router,mtp}.h, the
cores joined to their blocks, and GlmMtp the draft head in three parts (inputs, join, head),
declared and stepped around the plugin's layer 45. rad_glm_tp.h (GlmTp) holds the widths a
rank's shard divides, the one threshold kSplitRows and the replicated all_reduce declared once;
SplitF32Proj moves over unchanged. The plugin reads as the stream's buffers, then each block's,
the KV groups, the layers, the head and the draft head.
tests/arch_fakes.h holds the fakes and the helpers every architecture test needs, included by
one translation unit a binary (neither binary links rad_core, as before); GLM-5.3's cases are
tests/glm5next_test.cpp, which includes only its plugin, with two cases new: every op the plugin
issues carries the operand count its schema declares (the kernel libraries' schemas under
$RADIANCE_HOME/kernels, counted as core/runtime/issue.cpp counts), and every declared weight
reads an entry the served container holds, at the dtype its stored encoding calls for (the
container's names and encodings as rad-info -v lists them).
Every declared name, declaration order and issue order is as it was: the pinned graph and step
hashes at one and eight ranks are the values arch_test pinned before the move (world 1
0xed3fc26c486ea1b5 / 0x98ba2952bb37b075, world 8 0x8204e073efdeee0c / 0x1279aecfe4e32d9a), and
arch_test's pins of the other architectures are unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
||
|
|
d2a165d56d |
jinja: the caps probe hands the template an empty tools array, not [null] -- GLM-5.3's template iterated it and lost string content
json{nullptr} is the one-element array [null], not an empty one. The string-content probe
passed it as `tools`; GLM-5.3's template iterates `tools` under `{% if tools %}`, so the probe's
render threw on the null element, the throw was taken for "cannot render string content", and
with typed content unsupported as well every request logged `render_message_to_json: Neither
string content nor typed content is supported`. llama.cpp master passes json::array() (PR
#27130); so does this probe now. The GLM-shaped template in chat_test asserts string content.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
||
|
|
778cbf315e |
docs, compose: GLM-5.3-Flash
The glm5next section of ARCHITECTURES.md (geometry, traps, KV groups, linears, tensor parallelism, the MoE decode fusions, measurements), the conversion and the four RADIANCE_GLM_* variables in GUIDE.md, the README's models table. deploy/compose/glm53-flash.yaml serves the container on eight R9700s with the expert plane resident and the native MTP layer drafting, with the flags of the measured run. Co-Authored-By: John McDonough <18016200+JohnCMcDonough@users.noreply.github.com> |
||
|
|
78c58841bf |
libr4d: GLM-5.3's kernels -- mHC, KDA, the DSA indexer, MLA, f32-scaled FP8, MXFP4 experts
The device rows for GLM-5.3-Flash's ops, at its geometry and at TP4 and TP8 slices: - mhc_pre / mhc_post / mhc_contract, and mhc_pre_partial / mhc_pre_finish, which run mhc_pre's own projection and finishing kernels with its chunk-sum order, so the pair is byte-identical to mhc_pre at n 4096, hc 4, chunk 2048. - kda_update_k128_v128_bf16, one, two or four value rows a wave, both state forms. - dsa_pool_fp8, dsa_query_fp8 and dsa_score_fp8 (fp8 WMMA, 32 heads of 128). - mla_attn: a matrix row whose WMMA tile holds a query's heads, or pairs eight heads of two neighbouring queries over the union of their page tables, above the wave row; mla_project with up to eight rows a thread or wave. - gemm_nt_f32 and router_sigmoid_topk in tiled and one-wave-a-row forms; gemm_fp8a8_f32scale and moe_gemm_fp8a8_f32scale read f32 block scales in place; moe_gemm_mxfp4a8 decodes e2m1 into exact E4M3 bytes for fp8 WMMA, with an expert-major decode form and a wide prefill form. - swiglu_clamped, and the device-only fusions of GLM's MoE block: swiglu_clamped_quant_fp8, router_sigmoid_topk_scatter, and moe_scatter_inv / moe_gather_inv, which pass the gather's slot table from the sort instead of rebuilding it. moe_gather takes f32 routing weights in its column-per-thread kernel. The sort and the gather kernels move from r4d_moe.hip into r4d_moe_sort.h and r4d_moe_gather.h, so the fused router and gather instantiate the same code. Every form that replaces another gives its bytes: tests/r4d_emu runs the kernels on the host (test_f32, test_fp8f32, test_kda, test_mhc, test_mla, test_moefuse, test_moemx), r4d_selftest compares them on a card against libref and against each other, and plugin_test pins the mla_attn band. docs/OPS.md states what libr4d serves. Co-Authored-By: John McDonough <18016200+JohnCMcDonough@users.noreply.github.com> |
||
|
|
e60810116c |
chat: tagged calls whose name the opener opens -- GLM-5's <tool_call>NAME<arg_key>
GLM-5 writes <tool_call>NAME<arg_key>K</arg_key><arg_value>V</arg_value>...</tool_call>: no prefix of the name's own and no suffix, the name ends at the first argument or at the call's close. The tagged family now takes an empty name_suffix when name_prefix opens the call (no call_open): the derivation from the template makes the per-call opener the prefix and its closer call_end, the grammar takes eps() for the suffix, and the streaming parser finds the name's end byte by byte (name_stop, name_plausible) and reads the closing tag as the first item of the body. arg_name_suffix and arg_value_prefix may both be set and are read back to back, so chat_format_markers keeps both tags. value_newlines comes from a probe render of the template rather than a constant (GLM and MiniCPM false, Qwen true). The ABI struct is unchanged; its comments say what an empty name_suffix means now. chatparse_test: GLM's template serves tools; the derived format equals the one a plugin would declare; every rendered reply in the corpus reads back as the message it rendered, split at every byte; and replies that stray from the grammar. Each fails without this change. The Gemma refusal names call_end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
5ac0bc9690 |
tests/data/chat: GLM-5.3's template as a fifth reference render
The template as GLM-5.3-Flash ships it, in cases.json beside the other four, with its goldens from
mkchatgolden.py (jinja2 3.1.6); bos is empty, eos <|endoftext|>, and no media, since no
architecture here reads its pictures. It needs the dotted index (vendor/patches/0021).
Two cases leave it out: an assistant turn with tool calls and content null. The template prints
that content bare ({{- content }} in visible_text), so jinja2 writes "None" into the turn, and the
engine, as llama.cpp's runtime does, writes nothing. The golden would hold the engine to a
template bug; the reply-side tests for this format read those turns instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
a14fab2317 |
jinja: a dotted integer is an index, as in jinja2 -- llama.cpp's #28817
jinja2 reads `obj.0` as `obj[0]`; the engine threw "Static member property must be an identifier". GLM-5's template tests a tool result with `m.content.0.type`, and the capability probe swallows the throw, so the template came back as tools=0 tool_calls=0 and every request with `tools` was refused. The fix is llama.cpp's ae9afff8, which landed after the lifted commit, taken as it is so the next refresh drops it. vendor/patches/0021, vendor/UPSTREAM; chat_test (a_dotted_integer_is_an_index_as_in_jinja2) fails without it on both counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
da1ffff9a8 |
docker: the test stage can leave entries out (TEST_EXCLUDE, build.sh -E)
Without perf_event_open in the build sandbox, tokenizer_perf_test bounds the encoder's linearity by CPU time. Its 500 KB single word reads a ratio of 10 to 12 against the threshold of 9 on a Zen 2 VM with 512 KiB of L2, every run, with the tokenizer unchanged. A ctest -E regex lets such a host build the image without the threshold moving for everyone. Empty by default. docs/DOCKER.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
748f63637e |
docker: the test stage's parallelism and CPU budgets apart from the compile (build.sh -J, -B)
The per-binary CPU budgets are set on a fast machine. A VM on an EPYC 7302 spends 4.6x the quoted CPU time on tokenizer_test's reference pass, so the image's test stage failed there on a correct tree, and -j sized for the compile also sized the tests: twelve at once on a 24-thread host put tests on busy SMT siblings, which costs CPU seconds too. RAD_TEST_CPU_BUDGET_SCALE multiplies the budget where rad_test.h reads it, at run time, so a direct ctest takes it as well and the build layer is untouched by it. The stage takes it as TEST_CPU_BUDGET_SCALE (build.sh -B) and its parallelism as TEST_JOBS (build.sh -J), each empty by default, which is the stage as before. harness_test checks the factor and keeps it out of its fixture's environment; docs/DOCKER.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6fb31c0577 |
docs/GUIDE: eight cards on unequal links -- weighted shards, pieces and their environment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2c0dd8535e |
sample: at eight ranks a rank keeps the candidates the merge can hold
Over a split vocabulary every rank's candidates are gathered and merged in one workgroup (sample_merge_topk), and libr4d's row holds world_size * n_cand <= 4096 pairs in LDS. The engine declared the default 1024 a rank, 8192 pairs at eight ranks, and the first step stopped on a shape the merge does not serve. Declare now narrows the width to 4096 / world_size, 512 at eight ranks, and says so in one line; a request whose top_k is wider is refused at admission, as a top_k over the width already was. Two and four ranks keep 1024. sample_test: at two, four and eight ranks declare succeeds, top_k at the width is admitted and one more is refused, naming the width. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
279214f520 |
libr4d: the eight-rank two-shot's shard weights from the PCIe links by default
Weights from a variable describe one board on one day. Unset or "auto", RADIANCE_AR8_SHARD_WEIGHTS now reads them from the links: each rank takes its card's bus id from the runtime (hipDeviceGetPCIBusId), walks /sys/bus/pci/devices from the root port down to the card as core/diag/sysinfo.cpp's read_card does, and keeps the slowest hop's current speed x width x line code (8b/10b under 8 GT/s, 128b/130b from there) / 8. The R9700 sits behind an on-card switch whose endpoint reports Gen5 x16 in any slot, so a degraded slot shows only at the root port. The weight is round(4 x (rate / fastest)^2): x16 4, half the rate 1, a quarter 0. On the board of the previous commits that is the measured best, 4,1,0,4,0,1,4,4, and after both Gen4 links retrained at Gen5 x8 it is 4,1,1,4,1,1,4,4, where the 16 MiB two-shot takes 1360 us. "off" keeps the shards even and eight integers set them, as before. The ranks publish their links in the rendezvous (ar8_settle) and, after one barrier, derive the same table from the same eight entries before anything is sized; settings that differ between ranks fail init on every rank. Equal weights run the unweighted kernel, and a rank whose path says nothing (no /sys/bus/pci in a container) leaves the shards even, with a warning naming it. Startup logs one line, "[r4d] eight-rank two-shot shard weights from the slowest PCIe hop of each card: r0 32.0 GT/s x16 63.0 GB/s w4, r1 32.0 GT/s x8 31.5 GB/s w1, ...". The links are read once, at init: a link that falls back while the server runs changes the weights at the next start. r4d_ar_links_test builds that board's sysfs under a temporary root (root port, on-card switch, endpoint) and checks the bottleneck hop, the weights before and after the repair, equal links, the line code and a path that says nothing; it needs only libr4d's include path. r4d_selftest runs auto and off at the default floors, for bits only since what auto derives depends on the box, and --perfar8 derives the weights the same way and names each rank's link. 206 of 206 on the cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
adc7f37a70 |
libr4d: the eight-rank two-shot in pieces, both hops on the link at once, by message size
Each block splits its words (in shard space) into K runs. Step j pushes run j+1's first hop and reduces and pushes run j's second, then handshakes, so a rank with a short shard sends and receives at once instead of one direction a hop. A launch takes K+1 handshakes instead of two. The flag a (block, source) publishes is a monotone counter, so one handshake vouches for every earlier one, and r4d_ar_seq_take reserves the K steps at once (`steps`, 1 for every other kernel): one-shots and gathers on the same instance stay in the family's flag space. The regions stay at 0 and the longest shard, so the scratch is as before; every word is touched by the same thread in the same three steps, so the fold, the bits and the in-place form are unchanged. The launcher clamps K to the words a block holds, and K 1 is its own instantiation without the loop. 16 MiB, bf16, warm K 1 K 2 K 4 K 8 even 2841 us 2806 2667 2470 4,1,0,4,0,1,4,4 2730 2126 1798 1636 4,2,1,4,1,2,4,4 2495 2121 1940 1922 4,1,0,4,0,1,4,4 in 8 pieces is 42% under the even split. Fitting measured = f x computed + h x (K+1) at K 4 and 8 gives f = 1.21 and h about 5 us a handshake: what separates 1636 us from the 1.17 ms the Gen4 links need is their efficiency, not the handshakes. A decode-sized message loses with either: numel even K 1 4,1,0,4,0,1,4,4: K 1 / K 2 / K 4 / K 8 196608 73 us 85 / 76 / 81 / 113 524288 214 207 / 166 / 169 / 198 2097152 699 711 / 581 / 531 / 527 8388608 2841 2730 / 2126 / 1798 / 1636 so below RADIANCE_AR8_SHARD_WEIGHTS_MIN_ELEMS and RADIANCE_AR8_PIECES_MIN_ELEMS (262144 elements each) the message runs even and in one piece, on the kernel as it was. Above them, without RADIANCE_AR8_PIECES, K follows the size (r4d_ar8_auto_pieces): 2 under 1048576 elements, 4 under 4194304, 8 above, where the crossings above lie. RADIANCE_AR8_PIECES (1 to 16) fixes K over the floor, and a launch's `pieces` parameter (the selftest's) overrides that. Weights and K are a function of the message size and the instance (ar8_weights_for, ar8_pieces_for), so a replay of the same size decides the same; the slot is sized for weights only when the largest message is over the weight floor. Every rank compares both variables and both floors at init. r4d_selftest, with both floors at 0: the weighted and even sets at K 1, 2 and 4 (1- and 9-word messages cross the launcher's clamp), and one instance whose K changes from launch to launch (1, 4, 2, 8, 16, 3, 1), which a wrong flag reservation hangs or races. At the default floors: the size rule over 131072 to 4194304 elements, K 4 on both sides of the piece floor, a 131073-word message over the weight floor (served only weighted) and a 9-word one under it (refused, and served at a floor of 64). 192 of 192 on the cards. --perfar8 names the floors and times the two-shot as the server runs it and at K 1, 2, 4 and 8. GLM-5.3-Flash at TP8 (an out-of-tree plugin) on these eight cards with 4,1,0,4,0,1,4,4, against the same build without in the same hour: a 20K-token prefill 3450 tok/s against 2945, 8K 3372 against 2920; eight agent streams 457 tok/s against 458, one 141 against 139. K 8 at every size instead gave the same prefill (3461) and 436 at eight streams, 113 at one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4777be8654 |
libr4d: the eight-rank two-shot's shards weighted per rank (RADIANCE_AR8_SHARD_WEIGHTS)
In the two-shot rank r reduces shard r: in the first hop it sends N - len_r and receives (ws-1)*len_r, in the second the reverse. With even shards every rank moves 1.75 N each way at eight ranks, so on a board whose links differ the slowest link sets the time. On eight R9700 (four links at Gen5 x16, two at Gen5 x8 and two that trained at Gen4 x8, 14.3 GB/s one way by TransferBench) the 16 MiB two-shot, a 2048-token chunk at 4096 wide, takes 2.45 to 3.05 ms over a day, where the Gen4 links alone need 2.05 ms for their 28 MiB. RADIANCE_AR8_SHARD_WEIGHTS=w0,...,w7 sizes rank r's shard in proportion to w_r (the floor, then the few remaining words one each to the weighted ranks in ascending order); a rank of weight 0 owns no shard and only pushes, gathers and handshakes. The shard bounds become a table the kernel takes by value (r4d_ar_shards.h, host-only, shared by the launcher, the shim and the selftest), so a recorded launch keeps its table. Equal weights give the even split word for word, and unset the split is the even one as before; three and four ranks stay unweighted. Which rank reduces a word changes the link it crosses, not its fold, so every table gives the same bits. Every rank must cut the message at the same words: init reads the variable on each rank and fails on all of them if the ranks disagree. A weight over half the sum makes the longest shard's two regions outgrow a message, and only then does init grow the slot. Weighted shards need not divide the words evenly, so the even rule (words % 8, else RAD_E_SHAPE) applies without weights only. Measured with --perfar8 (16 MiB, bf16, warm): even 2.78 to 3.05 ms that day, 4,1,0,4,0,1,4,4 (no shard on the Gen4 ranks) 2.71, 4,2,1,4,1,2,4,4 2.50, 2,1,1,2,1,1,2,2 2.58. Only 10 to 17%: with the hops separated by a handshake a rank sends in one and receives in the other, and the larger of N - len and 7 len a hop is least at len = N/8. The weights pay once the hops overlap. r4d_selftest: ar_wide_weighted runs 0,3,1,0,5,1,2,4, 1,0,0,0,0,0,0,0 and 4,1,0,4,0,1,4,4 over uneven and empty shards, a single owner (the slot grows) and messages of 1 and 9 words, which the even split refuses; the refusal check runs without weights whatever the environment. 55 of 55 on the cards, every one bit for bit with the fold. --perfar8 prints the weights, every size's shard lengths and each rank's time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0eb3d96ce1 |
libr4d: at eight ranks the exact one-shot ends at 8192 elements, the two-shot at 8 blocks
The exact all-reduce at eight ranks shared the three- and four-rank band: one-shot up to 524288 elements. The one-shot sends (ws-1)*N bytes a rank, seven times the message at eight ranks, where the two-shot sends 2*(ws-1)/ws*N, and on eight R9700 (PCIe P2P, bf16, warm) the two-shot is the faster from 16384 elements on. A decode step of eight streams with a draft window of six on GLM-5.3-Flash (4096 wide, an out-of-tree plugin) reduces 48 x 4096 = 196608 elements: 232 us one-shot, 68 us two-shot, where all_reduce was 20.7% of the step's device time. R4D_AR_8RANK_ONESHOT_MAX_ELEMS is 8192, a multiple of 64, the eight-rank two-shot's DIV; cArTsExact8 starts one element above it. The two-shot's block rule stops at 8 blocks at eight ranks: every block handshakes with seven peers, and past eight blocks the extra flag rounds cost more than the reduce bandwidth they add (4 blocks up to 393216 elements, 5 at 524288, 8 instead of 16 from 2097152). Both rows fold in fp32 in ascending rank order, so neither change moves a bit. numel before after 4096 one-shot 22.5 us one-shot nb 4 12.8 us 16384 one-shot 39.7 two-shot nb 4 21.5 131072 one-shot 176.3 two-shot nb 4 52.3 196608 one-shot nb 16 233.2 two-shot nb 4 68.7 524288 one-shot 573.7 two-shot nb 5 177.4 2097152 two-shot nb 16 615.8 two-shot nb 8 610.5 8388608 two-shot nb 16 2460 two-shot nb 8 2489 16777216 two-shot nb 16 4999 two-shot nb 8 4824 At 4096 the rule already chose 4 blocks; the 22.5 us was the microbenchmark's, ten launches after the host-side check, which now warms up with as many launches as it times. Band edges are the union over every candidate row (core/plugin/bands.cpp), so the edge at 8192 splits the two-, three- and four-rank bands too. Both halves resolve the same row, kernel and bits, at the cost of one more instance per (width, dtype) whose slot holds 8192 elements. Keeping the edge to eight ranks would need the band builder to skip rows whose fixed constraints the geometry rules out (world_size 8 here), a change to every op's bands for one row; plugin_test states the new edges instead. r4d_selftest runs the eight-rank rows (ar_oneshot_8rank_exact, ar_twoshot_8rank_exact, ar_gather_8rank) through the width-parametrised cases of the three- and four-rank ones instead of skipping them: the pattern's band edge is at 8192 and 8256 there, and a 9-word message must be refused. --perfar8 numel [iters] [dtype] times both rows, one thread a card, at the block rule and at 4 to 64 blocks, each checked bit for bit against the fold on every rank. On the cards: ar_oneshot_8rank_exact 20 ok, ar_twoshot_8rank_exact 16 ok, ar_gather_8rank 5 ok. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |