Repository navigation
Mac port train 2: Metal kernels, the qwen35moe session, bloomery-serve-metal and KV checkpoints (#593) - #726
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the move of the head tie rule left the 6 · band · rms formula in two places.
Must fix
1. head_cap and flip_cap both own 6 · band · rms(row) (kind B, duplication)
crates/refset/src/flip.rs:113 computes 6.0 * band * rms(ik_row). crates/gpu-gates/src/flip.rs:153 computes the same value. In the base, head_cap called flip_cap, so there was one owner. This diff moved head_cap to refset and copied the body. A later change to the factor 6 in one file passes the other file's gates unchanged. The card gates and the Metal gates would then read different caps for the same band.
Cost: the fix removes an import and a body, and the existing bit-equality test (flip.rs:280-311) still covers flip_cap.
Fix, in crates/gpu-gates/src/flip.rs: delete the line use refset::flip::rms; and replace the function:
pub fn flip_cap(band: f64, row: &[f32]) -> f64 {
head_cap(band, row)
}Non-blocking
⚠ A failed restore leaves the session half-installed: crates/metal/src/arch/qwen3moe/session.rs:820. install_stores writes lane and ring layer by layer. If write_at or write fails at layer k, layers 0..k hold the checkpoint's ring, pos stays, and the session is not poisoned. The next step then runs on mixed state and returns plausible ids. Only a device write error reaches this, so it is not a must-fix. Direction: on an install_stores error, call self.reset() (or poison the session) so the caller sees a refusal, not wrong tokens.
Optimization headroom
- D. More at once: crates/metal/src/arch/qwen3moe/target.rs:94 runs the prompt as one host-fed step per id. Turn 1 is 9.67 s for about 546 ids, about 17.7 ms an id [derived from the PR body, M4 Pro, loaded machine]. A prompt pass reads each expert weight once per id; a batched pass would read it once per chunk.
- E. Less work: session.rs:789 and session.rs:813. A take allocates a 73,728,000-byte host
Vecand copies twice (shared pages toVec,Vecto slot). A cut allocates and zero-fills the same size. A direct shared-pages to shared-pages copy removes one allocation and one copy per take (one per 256 prompt positions, and one per chat message start).
Checked
- Duplicates: about 30 new items checked.
PlanDims::q35overlapsgpudimsonly in the head-count lookup;gpualso checks uniformity and has more fields, so no copy.VocabDecoder,TemplateFile,ChatSurfaceandsampler_factoryare moves frombind.rs; the old copies are gone. Therefusehelper repeats insession.rs,arena.rsandtarget.rs(dryer 1.00); three 5-line copies cost less than an owner, so no finding. Other dryer pairs read: themainstubs of the bins and the gatemutants.rspair, both shared shape only. The one real duplicate is finding 1. - Complexity: the crapper list is gate bins (
a_free51,k_keep46,main48) and kernel host binders (bind_flash45,Arena::open44), all new functions. Gate bodies are linear clause lists, andbind_flashis a checked argument bind. No split asked. - Silent failure: 7 sites followed.
generate_metal.rs:211(a documented default; a non-count is an unknown flag at:149).server.rs:116,127(theu32::MAXclamp keeps at mostpos).session.rs:516,528,586(let _only after an earlier error that is returned).seg.rs:154andarena.rs:723(an empty segment list gives 0 and the window check refuses). ACut::StayorCut::Emptyreachinginstall_storeswith zeros: not reachable,Session::cutreturns first forn == posandn == 0. - Tests: the Metal gates run only on a Mac and were not run here, so no mutation result from me. I read the
checkpoint.rstake, cut and restore rules and theserver.rstests: thelogits a rowandlogits bufferrefusals and the splits test each fail on a dropped check. - Gates: pins moved:
unsafe-ratchet.txtmetal 22 7 11andrecipes.pypure-crate list, both dated with reasons. The ratchet PIN text says impls 11 -> 12 but the line keeps 11;tools/check-unsafe.shdecides which is right. Removedhead_*tests ingpu-gates/src/flip.rsreappear inrefset/src/flip.rs:184,223. - Escape catalog: no shell changes beyond the
justfilerecipe; its&&chain ends in|| { …; exit 1; }groups, and no C1 to C4 pattern matched.
Notes
- The PR body says box gates for the moved CUDA host code (rope table,
layer_plans, flip rules) follow in a comment. None is in the PR text yet. Nonvidia-smiline, commit hashes orjust gate-*output for the touched CUDA crates (gpu,gpu-gates,chain) is in the PR text. The Mac evidence has the model file, timings and recipe names but no command output. - The speed table is on a loaded machine (load 4.3 to 5.1), as the PR says. It is a development number and I did not use it as a gate.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bind.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
There was a problem hiding this comment.
Since the last review:
- Earlier duplication item: withdrawn from this incremental review. Neither cited implementation changed in the new commits.
- Earlier checkpoint restore warning: withdrawn. Restore buffers use the arena's validated, fixed shapes; the writes only reject length or range mismatches. No reachable partial-restore failure was established.
Verdict: CLEAN: No in-scope findings remain in the two added model-tax allowance rows.
Checked
- Duplicates and complexity: no new functions, types, constants or changed function bodies.
- Silent failure: no executable code changed. The model-tax reader checks both allowances against source counts.
- Tests: no tests changed; mutation checks do not apply. Validation used source inspection.
- Gates: the new allowances match 3 model-name code lines in
bloomery_serve_metal.rsand 4 ingenerate_metal.rs. Both carryPIN(2026-10-23)and name the missing architecture dispatch program. - Escape catalog: no C1–C4 pattern matches the added table rows.
Notes
The PR body lacks the NVIDIA card line, both commit hashes and gate command output required for GPU evidence. The listed Mac runs have no command output.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bind.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
Review response, commits f660b7c..1723485:
Mac (M1 Pro, after the fixes): |
There was a problem hiding this comment.
Since the last review:
- Earlier duplication item: remains withdrawn. This increment makes
flip_capreusehead_cap. - Earlier checkpoint restore warning: remains withdrawn. Validated, fixed buffer shapes still prevent the proposed partial restore.
Verdict: CLEAN: The incremental changes introduce no proven behavior or quality defect.
Checked
- Duplicates: 0 new functions, types or constants.
flip_capdelegates to the existing owner with the identical expression. Dryer pairs are outside the incremental hunks. - Complexity: no crapper-flagged function changes in this increment.
cutadds error recovery to an existing function. - Silent failure: 2 result-handling sites followed. Restore errors return to the caller; a reset error is included beside the original error.
- Tests: no tests changed. Static mutation check: replacing
head_capwithmargin_capat flip.rs:152 fails the existing cap assertions on the offset row. Tests were not executed. - State: restore lengths come from the arena at open; lane parity bounds every destination write. Missing checkpoints return before installation. Both paths refute mixed-state recovery scenarios.
- Gates: no values moved or cases removed. The added dated unsafe-ratchet comment explains the existing count of 11 implementations.
- Escape catalog: no C1–C4 pattern matches the incremental diff.
Notes
The PR body lacks the NVIDIA card line, both commit hashes and gate command output required for GPU evidence. The listed Mac runs have no command output. Hardware gates were not run during this review.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bind.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
There was a problem hiding this comment.
Verdict: CLEAN: carried from 17234856, not re-reviewed.
The approval of 17234856 stands for 23964846. This pull request's 42 commits are the same patches in the same order: git patch-id --verbatim (the changed lines, the lines around them and whitespace) and the subject are equal for every commit. That review ran under the reviewer instructions, tools and slag ledger that review this head, and it approved.
The base moved, and the files it changed could not be listed (gh api --paginate --jq ended 1: cannot iterate over: null); CI and the landing gates cover them.
A carry covers each patch's own lines and the lines around them. What the base changed elsewhere is covered by CI on this head and by the landing gates.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bind.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
Box evidence for 2396484 (rebased on main db397ea). Machine: the maintainer's box, RTX 3090 + RTX A6000, fixture tier. Move proof (CUDA side is host code only): Landing batch,
Mac (M1 Pro) on the rebased tree: every |
…nt a function constant Up to four same-type row segments run in one dispatch and match the single-tensor kernel bit for bit. The head-normed residual scales each head and raises linear_gate when an input is not finite. Eight SIMD groups match two groups bit for bit. The unsafe pin rises 15 to 16 for objc2's function-constant write.
…s/metal/src/arch/qwen35moe Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…, an all-NaN head is not a token, one dispatch, constants from Rust Batches B0-B2 of the M2.2c review: no REGISTER markers or rustfmt::skip; delta's butterflies renamed off the Metal built-ins; ticket_is_last owns the last-group epilogue for the router and the head; a head whose logits are all NaN raises Logit and stores 0xFFFFFFFF (clause and mutant head_all_nan); zero_ticket and window_pages gone; one dispatch_groups with one refusal; the delta, router and expert geometry generated into the Metal header from Rust constants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…two launches, one segment finishes in the flash, the output gate owned The caller places the barrier between flash and merge; with one segment the flash normalizes, applies sigmoid(gate) (the rule of the CUDA out-gate qwen35moe runs) and writes the layer output, so no merge runs. The launch and the token count read one segment rule (attention_geom.rs, declared once). The re-fetch arm and the queries=2 path are gone; per-kind cache structs replace the disguised arguments; the K loop reads f16 by the hardware conversion, proven over all 65,536 patterns; the band weighs |v| by the softmax weights. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…router, the head and a dispatch chain by the GPU's own stamps concurrent_barrier runs spin_until_set then set_flag on one concurrent encoder: with no barrier a GPU that overlaps them writes 2; with memory_barrier between them it must write 1, and --drop-barrier (the gate's own seam) turns it red. No overlap on the GPU skips the clause by name. queue_overlap (print-only) and concurrent_independent (pinned by encoder_refusals) are gone. metal_matvec_time times router35 and q6k_head_argmax at the target shapes beside their bytes' time and the review's predicted tail, and a chain mode (lone / serial / concurrent, N dispatches) for the per-dispatch cost. Each buffer's time is GPUEndTime - GPUStartTime through Recording::stamps (GpuStamps in stream.rs), so a late host cannot void a row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…e group, bit-identical (B6) The last threadgroup's epilogue ran on thread 0 alone: the router's split add and top-k scan over 256 experts, and the head's scan over every candidate. Now every thread of that group takes a strided share. The router adds each row's splits in the old order and selects by rounds of the group's largest packed key; the head reduces its candidates the same way. Thread 0 keeps the softmax, the shared sigmoid, the fault paths and the ticket reset, so the weights, ids and logits keep their bits. argmax_key and ticket_max_key (a two-half SIMD maximum, since simd_max takes no 64-bit integer) have one owner in ticket.metal. New clause router_tie and mutants router_tie, router_rounds, router_bad, head_stage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
On aarch64 the crate compiled with three unused imports, which -D warnings turns into an error once a Mac build links it (bloomery-metal through bloomery-model). The cross check for x86_64 never saw them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…d its e2e gate against the fixture's reference sets The arena allocates every buffer once at open. The ops implement the chain's ChainOps, one encoder per token, 26 groups and 28 dispatches on the fixture, counted as they are encoded and pinned to count.rs. The pair norms its input on the load (the FFN norm), in P1's order, with the shared rms owners. gate_metal_qwen35moe_e2e: a_free (the CUDA free contract: FREE_BAND over each layer's output, the last argmax, route flips judged as near ties), d_count (groups, dispatches, barriers and device allocation per step), e_token_id (a bad id raises, poisons, and reset recovers); --nodes names the first node past its band; --ops times each op. Mutants conv_tap and embed_no_raise; the kernels gate gains pair_norm with two mutants. The directory is the qwen3moe family's, as in crates/gpu, so the session uses the chain's qwen3moe plan inside its own family. check-arch's rule 4 reads crates/metal/src/bin/ as it reads crates/gpu-gates/src/bin/. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…del file is check_draft compared a fixture draft's full path, so the fixture MTP families could not open at another root. It now takes the stated draft by file name for a fixture identity, as check_file does, and the fixture line decides the content; a draft of another name is refused naming both. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
SegParams borrows its segments and checks their overlap pairwise, so a P1 launch builds no list; the stream swaps two lists that hold their capacity, so a sync allocates nothing. d_count counts allocation calls with a counting global allocator and expects 0 in every steady step. clear_stores zeroes the lane word; free.rs refuses an empty set by name; Arena::open's per-layer body is Loader::layer (R12). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
… of each definition, and the gate-only kernel lives in the gate (B4) common.rs holds the layer, the fault expectations, bits_eq, noted, the sentinel rows and one refusal loop over a table of (name, bad argument) cases: each case refused by name, nothing encoded, outputs unchanged, and the well-formed launch accepted and writing. clauses.rs splits into matvec, norm, embed and seg; clause names are underscored. The oracles define U, RSQRT_ULP, gamma, sigmoid and silu once; each PIN sits on its constant; the delta oracle's sign-flip width is computed from the step's data, and the roll factor of one is gone. gqa256_f16_expand moves out of attention.metal into the attn_half clause's own source text. Every clause has a mutant or a recorded one-off edit that turns it red. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
… and the gate-only kernels Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…he device and a discarded token leaves the state intact (M2.3a-2) Two step-record slots, chosen by pos parity: the head of pos writes id and fault slot pos % 2 and the embed of pos + 1 reads the id there. The stream signals each command buffer on its shared event and waits for that value with the named timeout (one wait per call, no poll, no allocation); a device-only MTLEvent orders consecutive tokens, since untracked buffers on one queue do overlap without it. The fault word reads a slot given the Settled proof that wait returns. gdn_step reads lane pos % 2 and writes lane (pos + 1) % 2, so a dropped ahead token leaves the lane the next token reads. Session::step takes a StepMode (host-fed or chain); no ahead token at the last row; a broken promise drops the ahead token and clears its fault slot; reset clears both slots and both lanes. Clauses b_chain (chain picks and logits equal host-fed, to the last row) and c_resume (a broken promise, then every pick, the logits and both lanes equal the host-fed arm's); d counts one wait per call in both modes; e runs under chain too. Kernel mutant delta_lane_in_place. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…free/flip rule each have one owner both backends call (FIX2) - chain read.rs: layer_plans (kinds x layers -> each layer's mixer and FFN plan; a kinds/layers length mismatch is refused by name) and PlanDims::q35; CUDA's Pre35::read and the Metal session both call layer_plans. CUDA keeps plan_dims(&d): its Dims takes ff from the file's FFN shape. - chain read.rs: file_names, the one owner of the file's apart FFN names; plan_ffn's apart branch and the Metal arena read them. - chain rope.rs: RopeSpec, RopeTable and ggml's recipe, with the test that pins the table to ggml_rope_cache bit for bit; crates/gpu/src/rope_table.rs re-exports them and keeps RopeRows and rope_pair_rn. The Metal arena builds its rows through RopeTable. - refset flip.rs: the free/flip rule both e2e gates read (rel_base, head gap/cap/tie, router tie, held rows) with its tests; gpu-gates' flip keeps its CUDA-only half and re-exports the rest; the Metal copy and gate_qwen3moe_e2e's own rel_base are gone. - metal: the shared event is held as the bindings declare it (Send + Sync), one unsafe impl fewer (pin 12 -> 11); reset waits once, then clears both fault words; the e2e gate's --ops prints the chain step beside host-fed. CUDA side: host code only (imports and one call); no kernel, launch or byte formula moved. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…kernels import by name, as the mat-vec geometry is build.rs still reads each *_geom.rs standalone; the generated MSL is byte-identical. The router's constants stay on its module's surface through a pub use. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…ate left the pure set bloomery-metal reaches crates/model through bloomery-chain, so the purity rule rejects it and `just mac-test` no longer runs its lib tests; lab-metal runs them first, and the pure-crates self-test pins the set without it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
The arena refuses only a cache past the file's trained context and checks every length before it allocates. Past 64 live keys the attention core is two groups: the flash writes its partials, then the merge folds them. f_deep steps the d1k set's 1024-id prompt and its step token, holds every step's count at its live keys and each layer's output to ik's; the merge_first_segment mutant is red on it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
A greedy step chains (the pick is the id the token ahead embeds); a Logits step runs host-fed and returns the head's shared pages, zero copy. The prompt steps host-fed one id each. kept/keepable answer from seqstate: the empty model at 0, the current position, nothing between; cut to the position does nothing, to 0 resets, between is refused by name. t_target holds generate's picks, the Logits row bit for bit against Node::Logits, the prompt's end state and every refusal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
The core (arch/qwen3moe/generate.rs) runs runtime::generate over Plain with the count stop and the tokenizer's end-of-generation set, streaming each pick to a sink. The bin reads $BLOOMERY_REF_MODEL as the CUDA CLIs do, takes --prompt or --tokens, -n, --ctx, --print-ids, streams text to stdout and prints key=value development-loop numbers (open, allocated bytes, prompt and decode walls and tok/s, the stop) to stderr. g_generate holds the core's picks and both stops; lab-metal-e2e smokes the bin on the fixture by ids and by text. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…r group Session::step_profile encodes each of the token's groups on a command buffer of its own through the same MetalOps and reads its GPU interval; Arena::group_bytes is the one owner of the bytes a group moves (routed experts by the router's ids). generate_metal --profile [N] prints per op kind gpu_ms, bytes and GB/s and a total beside the run's decode ms; --profile-layers adds the per-layer lines. p_profile holds the profiled step's picks and logits bit for bit, the group tags against the count model and the weight bytes by two paths. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
… mat-vec scales once a block Router: one row a SIMD group with no split, the RMS norm once per threadgroup in threadgroup memory, and the top-k tail on one SIMD group with parallel partial reads. Its band is re-derived for the new sum order (PIN). Headnorm: each block's head scale applies once to its two head groups, and finiteness is checked on the group sums. metal_matvec_time gains the router and headnorm shapes and their phase arms; a clause pins a non-finite router input. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…he whole SIMD group and folds its segments itself A threadgroup is one (key head, segment) of eight SIMD groups, one query head each; keys load 16 bytes a lane straight into registers with no threadgroup tile. The owning SIMD group appends K and V in one pass (a quad a q8_0 block) instead of one lane's serial stores. Segments follow the key count (one up to 64 keys, a tile a segment up to 128, then two, capped), and the ticket's last threadgroup folds the partials, so the merge dispatch and its group are gone. metal_attention_time times the flash at the session's shapes with phase arms. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…y are the serve crate's, every backend's Vocab (the file's vocabulary as the server's Tokenizer), ChatSurface and TemplateFile (the chat template and the alias a file gives the server), and sampler_factory/sampler_params (the sampler crate's chain as the server's sampler) move from gpu-gates' bind.rs to serve's vocab.rs and sampling.rs, unchanged but for their error type (String, which GateError takes through `?`). bind.rs re-exports them, so every CUDA seat's import stands; the factory's test moves with it. They are host code: the Metal server reads a file through the same owners as the CUDA seats. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
… qwen35moe session server.rs: TargetEngine implements serve::Engine over any runtime::Target beside the file's vocabulary (host code, every OS). prefill is the target's prompt call; next is one step, Want::Argmax for a greedy request (the session chains the pick ahead) and Want::Logits for a sampled one, the row copied into the server's buffer; keepable, cut, reset and ctx_max are the target's rules, and keep_limit names the target's Why. A head whose rows are not the vocabulary's count is refused at construction, a buffer of another length at the step. bloomery-serve-metal: -m PATH, --host, --port, --ctx (--ctx-size, -c; unset, the smaller of 32768 and the file's context_length), --chat-template-file, --alias, --queue-depth and the key flags. One slot; no prompt cache, slot files or image input. The e2e gate's s_serve clause holds the engine over a session of its own to the gate session's host-fed steps: 16 greedy picks, a sampled step's row bit for bit, and the keep rule (FAIL-first: a next that drops the row copy is red). The lib test refuses a head of the wrong row count and a buffer of the wrong length (FAIL-first: without the head check it is red). lab-metal-e2e builds the server. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…he other generate CLIs do Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TG5hgJqn38MRwLefZHyHCJ
…session takes them at a prompt call's marks and cuts back to them Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…ge start is a checkpoint a later request keeps Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…end as kept Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
A sync holds the pending list through its wait, as train 1's review made it, and drops finished buffers in place, so the spare list goes. The timer bounds --trials to the queue. The kernels gate carries the signed 32-bit column refusal and the norm's infinite-epsilon and non-finite-gain cases into its split clause files, and the local ggml helpers become Quant::ggml. The dense mat-vec's non-finite-row raise is off in the head, whose argmax owns a non-finite logit. The head's byte-count const asserts go: the block bytes are gguf's row at run time, and the launcher holds the weights window to the shape. The pre-split clauses.rs the replay kept goes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…architecture's session by name Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…· rms Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…e the error returns, so no step runs on mixed state Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
…vent's ThreadSafe impl) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA
There was a problem hiding this comment.
Verdict: CLEAN: carried from 23964846, not re-reviewed.
The approval of 23964846 stands for 2c563f03. This pull request's 42 commits are the same patches in the same order: git patch-id --verbatim (the changed lines, the lines around them and whitespace) and the subject are equal for every commit. That review ran under the reviewer instructions, tools and slag ledger that review this head, and it approved.
The base moved and also changed Cargo.lock, crates/gpu-gates/src/bind.rs, crates/gpu/src/arch/qwen3moe/body35.rs, tools/unsafe-ratchet.txt, which this pull request changes too. Each of its hunks still applies with the same context lines.
A carry covers each patch's own lines and the lines around them. What the base changed elsewhere is covered by CI on this head and by the landing gates.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen35moe_e2e.rs, crates/gpu-gates/src/bin/gate_qwen3moe_e2e.rs, crates/gpu-gates/src/bind.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Mac port train 2 (#593): the qwen35moe model runs on the Metal device end to end, behind
generate_metaland a llama-server-compatiblebloomery-serve-metal, and the server keeps a chat's prefix through checkpoints of the recurrent state.What it adds:
runtime::Target, withgenerate_metaland a profile step.bloomery-serve-metal. The vocabulary, chat surface and sampler factory move into the serve crate, so every backend shares them.runtime::seqstate's ledger. A checkpoint is each delta layer's live state lane plus its conv ring. The server splits prompt calls at message starts, so a later turn keeps everything up to its last message.chain, the free/flip rule torefset, the qwen3moe plan loop tochain.Train 1's review fixes are carried into the files this train rewrote (last commit).
Evidence on an M4 Pro MacBook (48 GB, 20-core GPU, macOS 26). The machine was in use (load 4.3–5.1), so these are development-loop numbers. Model Qwen3.6-35B-A3B Q4_K_M,
--ctx 4096, a two-turn chat with a 527-token first message:A checkpoint is 73,728,000 bytes for this file, and capacity is 17 at ctx 4096.
Gates on the Mac:
just lab-metal(kernels 55 mutants, device),just lab-metal-e2e(e2e withk_keep, 4 mutants, generate smoke),just mac-metal-lint,just mac-lint(ratchet 3),cargo test -p bloomery-serve,just check-recipes,tools/check-*.sh. Box gates for the moved CUDA host code follow in a comment.AI use: written with Claude Code; the lead session reviewed every round's diff and re-ran the gates.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JBR3rpjQt2A5SP3ZmXNeKA