Repository navigation
Conversation
…n's (IN-PROCESS-LEARNING)
One owner per context, llama-lived-routing.{h,cpp} (was llama-pinned-experts):
- the table: per sequence, [position][layer][n_used] u8 expert ids plus a lived flag per position and
layer (models with up to 256 experts; the last layer runs only a ubatch's outputs, so its other rows
are never lived). A later serving decode at a position overwrites it; a rewind keeps it.
- capture (llama_set_routing_capture): a serving graph copies each MoE layer's choice into its slice of
one context-owned device buffer (in the step's own command stream, as the K/V cache is written); one
async read per ubatch, written to the table at synchronize, so the GPU never waits.
- replay: llama_opt_learn_begin pins its own sequence over the reply and the served tail it restores;
with capture on, a span she never served is refused by name. Every learn end clears the pin.
- llama_set_pinned_experts imports a span and pins it; llama_get_lived_routing reads one (what a
sequence paged out carries); llama_lived_routing_bytes and _host_us price it.
Measured on the M5, Qwen3.6-35B-A3B Q4_K_M (test-walk-exact WALK_PINNED WALK_PINNED_CHECKS_ONLY):
CPU and Metal: capture 0 of 32 rows x 40 layers differ from what the graph selected (the last
layer its output only); pinned per sequence 0 of 128; graph reuse, pin before / between 0 of 64.
Capture host time: 405 us per decode with a read per layer (Metal's async read is a command buffer
and a blit each), 33 us with one buffer and one read. Decode tok/s on/off (WALK_ROUTING_BENCH, 8
alternated rounds) median 0.956, inside the bench's own +/-5% noise while 4 residents load the node:
the GPU-side price is to be measured on a quiet node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…refused: the live gate passes - llama_set_routing_capture answers a typed status (recording, a dense base, too many experts, no room) - llama_opt_learn_begin refuses a lesson on a mixture-of-experts base while capture is off: it never trains a function she did not serve - llama_set_pinned_experts imports -1 as never routed (as llama_get_lived_routing reads it), so a sequence's routing carries between contexts whole - test-walk-exact WALK_LIVE_PINNED: the control serves her prefix and reply with capture on; the reference step replays that routing; the live context imports the reply's routing (as a paged-in sequence would) and learns through llama_opt_learn_begin Measured on the M5, Metal, Qwen3.6-35B-A3B Q4_K_M, a stream per slot, f16 cache, flash attention, WALK_LIVE_ONLY WALK_LIVE_STREAMS_ONLY WALK_LIVE_TILES (64-row tiles), WALK_LIVE_PINNED: her reply learned in place vs the walk's exact step: cosine 1.0000, norm ratio 1.0001 her cache byte-identical to a stable decode of the reply; the neighbour byte-identical Without WALK_LIVE_PINNED the same run is refused at llama_opt_learn_begin (no routing recorded). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
5090 review of fork head 987da3d: routing_capture_bench always runs off first, then on, in a single advancing context. Each on block therefore sees 64 more tokens of history and different input positions than its paired off block. That confounds the GPU capture overhead estimate. For a paired comparison, replay the same prefix and continuation with capture off and on, counterbalance execution order, and report paired elapsed times after synchronization. The current metric is whole-decode throughput; the host timer alone cannot isolate device time. CUDA build is in progress. |
|
At 987da3d, set_pinned_experts skips an imported all-minus-one row without clearing its old lived flag. routing_settle also skips a non-output last-layer row. When the same sequence and position are reused, a lesson can replay expert IDs from the previous turn. Please test replacing a covered span with a missing last-layer row and verify readback returns -1 and that row routes afresh. A mixed row with a valid first ID and a later -1 also passes validation and narrows -1 to 255. Please validate all IDs before writing. Source review only; CUDA replay awaits a quiet GPU. |
|
5090 CUDA, fork #168 head 987da3d, Release SM120 built 00:37:48Z, exe SHA256 E346C2C7FEEA44638B30194847ADF7CFA61D85D4C5275220ED6EA4A8D9BCA20B. 35B Q4_K_M, 41/41 layers on GPU. Capture, sequence isolation, both graph reuse checks: zero mismatches, exit 0. Eight 64-token pairs: median 193.71 tok/s off, 170.12 on (0.878); on slower in all eight. Always-on-second context bias remains. Host timer 5016.6 us/decode is not isolated GPU time. Existing checks do not cover same-position replacement. Core 2135 restored; 27B serving ready, zero residents. No durable learning claim. |
|
Pristine fork #168 head 987da3d, same 5090 35B CUDA artifact as capture checks: live pinned learning exits 0xc0000409 in ggml_cuda_out_prod at out-prod.cu:246, cuBLAS SGEMM rejects a parameter before a comparison exists. Core 2135 restored and serving ready. Rebuilding the candidate with only the previously validated singleton-stride change for an otherwise identical replay. |
|
5090 live-sequence replay, fork #168 head 987da3d plus singleton-stride kernel e91e9764, built 04:07:08Z SHA256 08E80DFCE88445DA6A9696A311387D95511A8084048246AFE5567C6F439ED132. Same 35B fixture that aborted on pristine head now exits 0. Live update vs exact reference: cosine 1.0000, norm ratio 1.0005; learner cache matches stable decode and neighbour cache is byte-identical. This validates the live-sequence fixture; it does not measure resident persistence or prove a 64-row tile was exercised. Core 2135 restored. |
|
5090 explicit tiled live replay FAILED. Same #168 source 987da3d plus stride fix e91e9764, exe SHA256 08E80DFCE88445DA6A9696A311387D95511A8084048246AFE5567C6F439ED132, built 04:07:08Z. WALK_LIVE_TILES=1 WALK_LIVE_TILE_ROWS=64: 8 units / 440 decoded rows, max 64. Update cosine 0.6383 (gate 0.997), norm ratio 0.6351, tiled loss 3.277057 vs reference 3.277724. Both caches byte-identical, exit 1. Same executable untiled 1.0000/1.0005. Earlier passing live result cannot qualify tiling. Control 2135 restored. Testing neighbour interleaving separately. |
|
Same 5090 build and 64-row replay with neighbour decodes disabled: 8 units, 440 rows; cosine 0.6379, norm ratio 0.6348, tiled loss 3.277057, exit 1. Both caches byte-identical. With neighbour turns the cosine was 0.6383. Interleaving is unnecessary for this failure. Testing one 220-row tile through the tiled API. |
|
35B on 5090, one 220-row tile via same tiled API and idle neighbour: two units, 440 rows, loss 3.277724 equals reference, update cosine 1.0000, norm ratio 1.0007, both caches byte-identical, exit 0. Same candidate and lesson at 64 rows failed (0.6379). This isolates a split-dependent difference; the first divergent operation is still unknown. Testing a 219+1 split. |
|
5090 35B split isolation: with only the final row in a second tile (219+1), update cosine fell from 1.0000 to 0.5502, norm ratio 0.6397, loss 3.276368 vs reference 3.277724. Both cache comparisons passed, neighbour decodes disabled. Same exact executable 08E80DFC…39ED132 on fork #168 + singleton stride. This reproduces the failure at one boundary and supplies a minimal tail to trace. Core 2135 restored. No claim about which backward op causes it. |
One owner per context, llama-lived-routing.{h,cpp} (was llama-pinned-experts):
layer (models with up to 256 experts; the last layer runs only a ubatch's outputs, so its other rows
are never lived). A later serving decode at a position overwrites it; a rewind keeps it.
one context-owned device buffer (in the step's own command stream, as the K/V cache is written); one
async read per ubatch, written to the table at synchronize, so the GPU never waits.
with capture on, a span she never served is refused by name. Every learn end clears the pin.
sequence paged out carries); llama_lived_routing_bytes and _host_us price it.
Measured on the M5, Qwen3.6-35B-A3B Q4_K_M (test-walk-exact WALK_PINNED WALK_PINNED_CHECKS_ONLY):
CPU and Metal: capture 0 of 32 rows x 40 layers differ from what the graph selected (the last
layer its output only); pinned per sequence 0 of 128; graph reuse, pin before / between 0 of 64.
Capture host time: 405 us per decode with a read per layer (Metal's async read is a command buffer
and a blit each), 33 us with one buffer and one read. Decode tok/s on/off (WALK_ROUTING_BENCH, 8
alternated rounds) median 0.956, inside the bench's own +/-5% noise while 4 residents load the node:
the GPU-side price is to be measured on a quiet node.
Stacked on #167 (merged). Upstream is touched by one-line hooks only: the call in build_moe_ffn,
t_routingon the graph result and its reset, the cparams pointer,routing_queueafter a serving ubatch computes,routing_settlein synchronize, the pin inopt_learn_begin, andclear_pinat each learn end. Everything else is in llama-lived-routing.{h,cpp}.Not yet wired: continuum's Learner turns capture on (the Rust binding is next), and a sequence's table isn't carried by
seq_cp(a lesson on a copied prefix is refused by name).🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo