Skip to content

Prepare Mac Metal receipt rounding support and hardware regression coverage - #216

Draft
michaelneale wants to merge 14 commits into
mainfrom
micn/receipts-metal
Draft

michaelneale wants to merge 14 commits into
mainfrom
micn/receipts-metal

Conversation

@michaelneale

@michaelneale michaelneale commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Original problem

Draft follow-on to #180: Mac/Metal receipt support is not enabled yet.

The receipts implementation refuses Metal because existing activation-rounding profiles do not explain prefill arithmetic reliably. Merely admitting MTL0 risks provable audit failures for honest nodes. This draft establishes reproducible Q8_0 kernel evidence and candidate profiles; it deliberately keeps backend admission closed while output-head integration and live qualification are unfinished.

Based on #180 at 5b554478292a319549ce1a5822eee598d8fcfa84. Until that PR lands, the main comparison includes its changes. The follow-on-only comparison is here: two commits, 12 files, approximately 356 added lines plus 68 KiB of synthetic captured fixtures. This does not replace or supersede #180.

Diagnostics

An Apple M5 Max / macOS 27.2.1 native probe of the exact prepared #180 patch queue found two distinct prefill paths:

  • Legacy: half-rounded dequantized weights × half-rounded activations.
  • Tensor API: half-rounded weights × f32 activations whose low 13 fraction bits are truncated, not rounded to nearest. The exponent is preserved.

For the checked-in Q8_0 capture (K=256, M=16, N=17), the production matrix checker reports:

Path Maximum error with Raw Maximum error with candidate
Tensor API 4.23438e-4 7.56634e-8
Legacy 4.23677e-4 9.27801e-8

Decode fits Raw. These are kernel correctness measurements, not end-to-end serving results, performance benchmarks, or general Apple-device qualification.

Fix

  • Add two candidate rounding profiles, including weight rounding in matrix references and near-tie repair effects.
  • Add an explicit Just/CMake Metal capture tool and hardware-generated regression fixtures. Normal Rust tests remain offline. Missing fresh captures or missing Metal fail rather than passing via a skip.
  • Test the actual captured outputs, truncation semantics, unchanged backend admission, and rejection of outputs scaled by 5%.
  • Keep Metal unavailable in the serving/auditing profile table; CPU/CUDA profile selection and audit tolerances are unchanged.
  • Separately replace the base branch's deprecated AtomicU64::fetch_update with try_update, as required by its pinned Rust 1.99.1. The closure and memory ordering are unchanged.

The remaining work and reproducible capture commands are in evals/receipts-metal/README.md. In particular, precomputed head-key projections need to use rounded weight elements, not round an already-aggregated projection. Real serving, signed openings, cached prefixes, sampling, concurrency, splits, wrong-quantization controls and recording overhead remain gates before admission. Q4_K has a separate mismatch and is not included in the candidate scope.

Compatibility

No dependency, ABI, wire-format, hash-domain, backend-admission or native runtime precision-policy changes. The Rust profile enum gains candidate variants, but no production profile table selects them. The capture tool is opt-in and is not a CI policy or lab-admission change. Receipts remain disabled on Metal.

Validation

Completed at 1a268398b723f51da299b74ed26ee123eb3823ad, Rust 1.99.1, Apple M5 Max:

  • cargo fmt -p skippy-receipts --check — pass.
  • just with-lld cargo check --locked -p skippy-receipts — pass.
  • just with-lld cargo clippy --locked -p skippy-receipts --all-targets -- -D warnings — pass.
  • just receipts-metal-build — pass; builds the capture tool and the pinned ggml Metal implementation, with warnings denied for the tool.
  • env -u GGML_METAL_TENSOR_DISABLE target/receipts-metal/receipts-metal-capture and GGML_METAL_TENSOR_DISABLE=1 target/receipts-metal/receipts-metal-capture — actual device captures, both exit 0. Fresh captures reproduce the committed SHA-256s documented in the README.
  • SKIPPY_METAL_CAPTURE_DIR=<fresh-capture-directory> just with-lld cargo test --locked -p skippy-receipts -- --nocapture — 435 unit tests and 7 integration tests pass; documentation tests complete (0 cases).
  • just with-lld cargo test --locked -p skippy-receipts — the full package passes again using the offline fixtures.
  • git diff --check — pass.

Not run: full product/workspace builds, other backends/devices, real-model serving/audit qualification or receipt-overhead benchmarks. This draft changes only the receipts crate and opt-in calibration tooling; it is not ready for Metal enablement or merge as complete support. The native experiment must not be confused with validation of the signed-receipt workflow.

CI repair validation

The Flash Next qualification failed to link common_peg_arena::add_parser; the retained job log shows Cargo reuse from a cache whose key omitted the native source recipe. Ported the two existing main fixes that bind Cargo and sccache outputs to the native patch tree and create the identity directory on cold builds. git diff --check and SKIPPY_PYTHON=/tmp/skippy-ci-repair/automation-venv312/bin/python just ci-automation passed on macOS ARM64, including the cache-isolation regression contracts. The initial automation run lacked pyarrow; the explicit Python 3.12 reporting environment passed. Fresh Spark qualification is pending in CI.

Main CI fixes refreshed — fe82aca50c30

Merged target main cc2a27435e798649a9cb938d600d39722e4a2263, including #254's separate queue/execution budgets and #256's formation-bound peer rendezvous, verified child listener readiness and control availability during preparation. Earlier split qualification failures included connection-refused/timeouts at the leader control port; those older results predate these shared fixes. Other merged CI fixes include Windows Vulkan path handling and the shared Windows GPU smoke workflow.

SKIPPY_PYTHON=/tmp/skippy-ci-repair/automation-venv312/bin/python just ci-automation passed on the merged tree, including deadline, peer identity, listener ownership, log streaming, reporting/publication and workflow contracts. git diff --check and git diff --cached --check passed. This is a normal base merge preserving the PR's feature changes; no additional Rust/native feature change was authored in this refresh. New exact-head source/package/device checks and native inference qualification are pending; earlier native results do not qualify this new head. The previous head remains available in history as 052b72f84b7f6b99b777157945484c1b22593eba.

Acceptance criteria

  • I ran the relevant local checks, or explained why they do not apply.
  • I agree to license my contributions under the Apache License, Version 2.0.

benthecarman and others added 6 commits November 22, 2026 20:48
A client of a node cannot tell which model the node ran. This adds
the shared format of an inference receipt: the Merkle commitments
of a turn, the signed turn root, the VRF challenge, and the checks
a client runs on opened values against the weights of the claimed
model. The node side keeps what a turn needs to be opened by a
replay.

Co-authored-by: Michael Neale <14976+michaelneale@users.noreply.github.com>
A stage reports every ubatch and every change of its KV cells to a
recorder, and replays a recorded turn in a scratch context to open
it. The KV pool is fitted to that: chunked placement leaves pinned
cells alone, a recorded cache keeps the pages of its freed chunks,
and the replay cache is zeroed when it is made.

Skippy ABI 0.1.88.

Co-authored-by: Michael Neale <14976+michaelneale@users.noreply.github.com>
A stage issues a signed receipt with each chat turn when it is
asked to, keeps the turn for a challenge, and opens it. The
audit-receipt command asks a node for a turn and audits it, and
recheck-receipt checks saved evidence again. Receipts are off by
default.

Stage protocol generation 18 adds issue_receipts to the stage
load, so the later stages of a split record their part.

Co-authored-by: Michael Neale <14976+michaelneale@users.noreply.github.com>
The design, the glue checks and every measurement come from the
mesh-llm repository, where the feature was written, without the
parts that describe the audit policy of a Mesh node.
Rust 1.99.1 deprecates fetch_update in favor of try_update. Preserve the compare-and-update closure and memory ordering.

Co-authored-by: Melkor <b36010fa5b9ec1747270cff036f6b47ff5dce56f179564e169fcb6cdc64c836b@buzz.gdk.so>
…backends

Add Q8_0 hardware captures and candidate weight-aware rounding profiles for legacy and tensor-API Metal prefill. Keep Metal admission closed until output-head integration and live receipt qualification are complete.

Co-authored-by: Melkor <b36010fa5b9ec1747270cff036f6b47ff5dce56f179564e169fcb6cdc64c836b@buzz.gdk.so>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Skippy Lab Qualification: Passed

Commit: fe82aca50c30c8d5ef0b298e90259aa6db78bfe8 · PR smoke · Workflow and timings · Saved evidence

Native Spark lab qualification.

Latest successful main: run 45835599636, attempt 1, commit f243a305f497cbe5f897fdbe384235b0a62edf3f. Comparison unavailable: workload inputs changed or could not be verified.

Configuration Outcome Prefill tok/s Prefill vs main Decode tok/s Decode vs main Actions logs
qwen35-4b-standalone Passed 3842.8 Unavailable 63.4 Unavailable Logs
qwen3-coder-30b-a3b-standalone Passed 2833.0 Unavailable 84.9 Unavailable Logs
qwen3-coder-30b-a3b-split Passed 2142.5 Unavailable 54.8 Unavailable Logs
qwen36-35b-a3b-standalone Passed 1982.4 Unavailable 64.5 Unavailable Logs
qwen36-35b-a3b-split Passed 1869.7 Unavailable 40.5 Unavailable Logs
qwen38-flash-next-standalone Passed 732.5 Unavailable 30.0 Unavailable Logs
qwen38-flash-next-split Passed 528.7 Unavailable 25.4 Unavailable Logs

TPS comes from three separate warmed, uncached probes at concurrency 1, each generating exactly 128 tokens. The scored correctness answers and each probe's 64-token warmup are excluded. Each rate is total tokens / total server-reported phase time, not an average of request rates. Client elapsed times and raw responses are retained in throughput-probe.json. These bounded samples are not sustained benchmarks or controlled speedup comparisons. Legacy short-answer receipts and missing or invalid probe evidence show as Unavailable.

Deltas use unrounded rates from matching PR-profile smoke receipts on the latest successful main run, including the nightly smoke evidence. Positive means faster. Changed workload inputs, different serving host classes, unequal phase token counts or missing evidence show Unavailable. Physical Spark placement and runtime conditions can differ; deltas are descriptive, not controlled speedup claims.

Smoke checks cover GPU startup, deterministic endpoint repeats and bounded streaming. They do not establish an AgentX performance score. Nightly history and saved performance baselines are published separately; a saved baseline can be older than the latest successful main run used here. Native build and qualification output streams into each configuration’s Actions log, with per-attempt copies in Saved evidence. Any capture gaps are reported in the log and saved diagnostics. GitHub evidence copies expire after 30 days.

@michaelneale

Copy link
Copy Markdown
Contributor Author

🤖 Diagnosed the failed Spark qualification at 1a26839: qwen38-flash-next-standalone failed while linking skippy-correctness, before serving a model. Lab job job_pdzzs32t8gmty3w reports an undefined common_peg_arena::add_parser from bundled ling3.cpp.o. Its requested variant includes common_peg_token_parser/common_peg_token_not_parser, whereas this prepared source declares a different variant (including common_peg_ac_parser). This is incompatible native-object evidence, consistent with the cache-isolation defect addressed by #212; it is not a Metal receipt numerical failure. I have not established which cache layer first supplied the incompatible object. Six other Spark configurations passed. No cache deletion, blind rerun, or unrelated source fix applied; #216 should incorporate the cache fix when its dependency/base is updated. General CI is still running. These Spark results do not qualify Metal receipts.

@i386 i386 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft feedback (no verdict yet) — reviewed at 1a268398b723f51da299b74ed26ee123eb3823ad, follow-on-only diff on top of #180 (5b554478292a319549ce1a5822eee598d8fcfa84): 12 files, +356/−5.

What I verified on the follow-on:

  • Admission stays closed, as intended. BackendFamily::of returns None for MTL0/MTL1/Metal, and profiles_for for CPU/CUDA never contains MetalTensor or F16Weights — the candidate profiles exist only as enum variants and are not reachable from any production profile table. matrix_candidates_do_not_enable_unqualified_metal_receipts pins this directly.
  • Truncation semantics are precise. MetalTensor discards the low 13 fraction bits toward zero while preserving non-finite values (NaN payloads do not become infinities), and the edge-case test pins −0.0 bit-identity, subnormals, and NaN/Inf behavior. Weight rounding is applied consistently in both the matrix reference and the near-tie repair (column_check), which matches the capture finding that rounding only activations models neither path.
  • The fixtures are honest evidence, not a rubber stamp. Committed captures match the candidate profiles under the production checker (error < 2e-6, zero repair flips), Raw is distinguishable (> 1e-4), and 5%-scaled wrong outputs still fail the production tolerance. Fresh hardware captures override the fixtures via SKIPPY_METAL_CAPTURE_DIR and fail hard when missing, so nothing passes silently.
  • fetch_update → try_update is the pinned-Rust API replacement with unchanged closure and orderings.
  • The capture tool is explicitly opt-in (just receipts-metal-build, never in the offline/default suite), and the README documents provenance and the remaining gates before admission.

On the red CI at head: qwen38-flash-next-standalone (and summary) failed while linking skippy-correctness — the author's diagnosis of an incompatible cached native object from the pre-#212 cache identity is consistent with the failure shape and with the other six configurations passing; it is not a Metal-numerics failure. Since main now carries #212's cache isolation, rebasing this stack (after #180 lands and picks it up) should clear the lane; worth doing before this leaves draft.

Remaining gates before any Metal admission are correctly and exhaustively listed in the description and README. Nothing in this follow-on changes my assessment of #180 itself.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants