Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
4aae74e
Add the ggml block formats of GGUF files
woodsonl Oct 16, 2026
a80b464
Add a reader for basalt's .basalt model file
woodsonl Oct 16, 2026
aa4d285
Test the formats and the reader on the official Q2_0 pack
woodsonl Oct 16, 2026
31514d8
Register F32 and F16 as GGUF formats
woodsonl Oct 16, 2026
f7d1c06
Record basalt's and Qwen's licences for the reader and the fixture
woodsonl Oct 16, 2026
c9820f3
Check every basalt index against its section and pin each refusal
woodsonl Oct 16, 2026
ad2b25f
Refuse negative and non-integer numbers in basalt's indexes and meta
woodsonl Oct 16, 2026
3ccfc3e
Fail the command buffer on a shader-validation report
woodsonl Oct 16, 2026
66ed7de
Raise a shader-validation report from Queue.run
woodsonl Oct 16, 2026
8e46437
Document running the GPU tiers under shader validation
woodsonl Oct 16, 2026
1b28836
Fail a test phase whose validation report nothing raised
woodsonl Oct 17, 2026
8137928
Re-raise a validation report in profile_writer's skip handlers
woodsonl Oct 17, 2026
ca448b7
Correct the shader-validation notes in the test docs
woodsonl Oct 17, 2026
f97f6df
Fail a phase that skips past a validation report
woodsonl Oct 17, 2026
272de21
Name the xfail exception to the validation backstop
woodsonl Oct 17, 2026
53a403f
Set the Flash-Next numerics, acceptance setup and memory budget
woodsonl Oct 16, 2026
c4d4207
Record nvcc's arithmetic for basalt's q8_1 quantizers and one-column …
woodsonl Oct 16, 2026
4f2d6ec
Add basalt's fp helpers, measure the platform, and amend invariant 5
woodsonl Oct 17, 2026
361b42d
Port basalt's q8_1 activation quantizers to Metal
woodsonl Oct 17, 2026
45543ff
WIP: native_mmvq Metal kernel, builders and tests (untested)
woodsonl Oct 17, 2026
c16fef6
Port basalt's native_mmvq to Metal for the pack's ten weight types
woodsonl Oct 17, 2026
ee67f54
Record nvcc's arithmetic for basalt's multi-column mmvq kernel
woodsonl Oct 17, 2026
0fc6b40
Port basalt's iq_parity: dequantizers and native_mmvq for Q2_0, Q3_K,…
woodsonl Oct 17, 2026
6e952be
Quote check_q8_1_finite's criteria in the test and point invariant 5 …
woodsonl Oct 17, 2026
6e58940
Correct the fmax subnormal claim and test each FTZ helper on its own
woodsonl Oct 17, 2026
0363d5e
Pre-fill mmvq test outputs apart and give column invariance a 2-row tail
woodsonl Oct 17, 2026
32a1762
Credit basalt and ggml in the test files that carry their code
woodsonl Oct 17, 2026
7c6ba41
Rewrap matvec.md section 3's paragraph after the fmax correction
woodsonl Oct 17, 2026
14eb4b0
Record nvcc's arithmetic for basalt's routed-expert kernels
woodsonl Oct 17, 2026
5a81cb3
Port basalt's Q2_0 routed-expert kernels to Metal
woodsonl Oct 17, 2026
17f0ec8
Port basalt's grouped-expert parity tests and emulate the experts
woodsonl Oct 17, 2026
5c0b0d0
Test the SwiGLU product's IEEE subnormals on planted values
woodsonl Oct 17, 2026
bc4f122
Check the routed experts against float64 references
woodsonl Oct 17, 2026
f414a39
Point invariant 5 at experts.md and record the down kernel's DEP check
woodsonl Oct 17, 2026
46aabb4
Compare gu2 with the one-row gate/up kernel in every --gu2 call
woodsonl Oct 17, 2026
366b8be
Give ieee_mul IEEE's result for infinities and NaN against zeros
woodsonl Oct 17, 2026
f11c57b
Build the whole-expert reference on the host codec and tighten per_entry
woodsonl Oct 17, 2026
11d14fa
Correct experts.md's .FTZ sentence and down table; complete NOTICE
woodsonl Oct 17, 2026
5415ca8
Describe the division slow path's .FTZ compare precisely
woodsonl Oct 17, 2026
cca8e18
Hand the routed-expert kernels basalt's grp_ptr table
woodsonl Oct 17, 2026
00c01b9
Rewrap the grp_ptr comments to the line width
woodsonl Oct 17, 2026
fb70ad2
Record the arithmetic nvcc compiles for basalt's BF16 GEMVs
woodsonl Oct 17, 2026
1b20225
Port basalt's BF16 GEMVs on fp32 activations to Metal
woodsonl Oct 17, 2026
44f1098
Port basalt's MMVF parity tests and check the kernel bit for bit
woodsonl Oct 17, 2026
dd171e3
State bf16.md's FFMA counts as the static counts they are
woodsonl Oct 17, 2026
a44ca22
Round fma_ftz and mul_ftz up to 2^-126 where FFMA.FTZ does
woodsonl Oct 17, 2026
7014be8
Pin the rounding before the flush in the helper and MMVF tests
woodsonl Oct 17, 2026
6a25f70
Correct the docs' claim that the GPU's flushing matches .FTZ
woodsonl Oct 17, 2026
53638e5
Port basalt's dense_tc window projections to Metal
woodsonl Oct 17, 2026
7230a40
Merge the shader-validation gate's upstream copy (lithos-ai/lithos-me…
woodsonl Oct 17, 2026
fcf7b1c
Let a step pause for host work between GPU passes
woodsonl Oct 17, 2026
8d9b056
Close the host-step findings of a Codex cross-check
woodsonl Oct 17, 2026
aedf0f4
Release Engine.run's claim when an interrupt lands just after it
woodsonl Oct 17, 2026
6a71b49
Take the engine's run claim in one atomic call
woodsonl Oct 17, 2026
eab629b
Interrupt the run with a real signal in the claim's test
woodsonl Oct 17, 2026
089da10
Give the interrupt test its own SIGINT handler
woodsonl Oct 17, 2026
1a4923e
Let the runner hand back the tokens of its own run
woodsonl Oct 17, 2026
83461e5
Close the two findings of the review of the handback
woodsonl Oct 17, 2026
2b4a5ac
Say where a failing task's exception lives
woodsonl Oct 17, 2026
339192e
Refuse a task a second runner already holds
woodsonl Oct 17, 2026
24670c1
Give a task back only while this runner still holds it
woodsonl Oct 18, 2026
89319f6
Port basalt's Q5_K head to Metal
woodsonl Oct 18, 2026
da86cbe
Port basalt's drafter experts to Metal
woodsonl Oct 18, 2026
5fa0249
Store sm_120's NaN encoding at every basalt port store
woodsonl Oct 18, 2026
54eb320
Bind .basalt tensors through read-only windows of the file
woodsonl Oct 18, 2026
73051ab
Emit basalt's single-dispatch GEMVs and q8_1 quantizers as ops
woodsonl Oct 18, 2026
7141a06
Port basalt's Q2_0 CPU expert kernels to ARM NEON
woodsonl Oct 18, 2026
bf9eec3
Port basalt's CPU SwiGLU and glibc expf, held against its recorded x8…
woodsonl Oct 19, 2026
957b125
Build basalt's int8 hyper-connection copies on the host
woodsonl Oct 20, 2026
27d7491
Port basalt's group dequantizers to Metal: fp32, fp16 and BF16 stores…
woodsonl Oct 20, 2026
48c6a2d
Port basalt's hyper-connection write as basalt_gr_post
woodsonl Oct 21, 2026
44f83ea
Port basalt's n-gram block decode path to Metal
woodsonl Oct 22, 2026
edb309f
Port basalt's prompt-path GEMMs and 16-bit conversions to Metal
woodsonl Oct 22, 2026
9e9d573
Merge #98's branch into the copy of the Q5_K head ops
woodsonl Oct 24, 2026
1208d58
Merge #82's branch into the copy of the Q5_K head ops
woodsonl Oct 24, 2026
f3476e3
Emit basalt's Q5_K head, top-1 and proxy top-1 as ops
woodsonl Oct 24, 2026
fcbd800
Transcribe libdevice's math functions in the port contract
woodsonl Oct 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,27 @@ Regenerate the archive and formula together for each version.
| `tests/layers` | torch, transformers, the small checkpoint | each layer's `forward()` oracle vs the HF module on real weights (cos > 0.999, max-abs ≤ scale/64) |
| `tests/models` | torch, the small checkpoint (+ the Metal module for `test_gpu_golden`) | the model oracle vs its HF golden: per-layer hidden states (cos > 0.999) and 48 greedy tokens; the same through the compiled step program on the GPU |

After a kernel or emitter change, run the GPU tiers under Metal shader validation:

```bash
MTL_SHADER_VALIDATION=1 MTL_SHADER_VALIDATION_REPORT_TO_STDERR=1 \
pytest tests/kernels tests/runtime tests/spec tests/layers tests/models
```

Validation reports a load or a store outside its binding, in device, constant or threadgroup memory (measured on an M3
Max under macOS 27), and logs it on the command buffer, which still completes without an error. The runtime raises
each report where the command buffer completes (`Queue.run`, `Queue.profile`, `Engine.run`, `Engine.profile`) as
`RuntimeError: shader validation: <report>`. Under pytest, `tests/conftest.py` also fails the test phase (setup, call or
teardown) in which a command buffer with a report completed, when nothing raised it: a harness caught the error, or a
thread raised it. So the test that ran the kernel fails whatever it checks, in any capture mode (`-s` included), and a
report in a fixture fails the run as an error. A test marked `xfail` reports xfailed instead, and outside pytest only
the raise applies.
`MTL_SHADER_VALIDATION=1` alone is enough; `MTL_SHADER_VALIDATION_REPORT_TO_STDERR=1` adds each full report on
stderr (otherwise it goes to the unified log). Command buffers the runtime does not commit, such as MLX's in the
mlx-lm comparisons, are not checked.

CI runs the contract tier on every push and the other tiers on bare-metal Macs when a maintainer comments
`/mac-test` on the pull request ([CI](docs/ci.md)).
`/mac-test` on the pull request, under validation with `/mac-test --shader-validation` ([CI](docs/ci.md)).

Goldens live in `tests/models/<name>/goldens/` (`<tag>.safetensors` + `<tag>.json`), produced by
`tools/goldens/hf_golden.py` from the HF model in BF16 with eager attention on the CPU; the JSON records the
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ These documents describe the current architecture, implementation contracts, and
| [Serving](design/serving.md) | Startup, request execution, protocol adapters, prefix caching, and streaming |
| [Model adapters](design/models.md) | Checkpoint interpretation, supported model structures, and numerical conventions |
| [Extension contracts](design/extensions.md) | Interfaces for models, formats, operations, drafters, and chip backends |
| [Flash-Next port contract](design/flash-next.md) | Numerics, acceptance setup, and 48 GiB memory budget for the Metal 4 port of basalt's Qwen3.8-Flash-Next Q2_0 pack |

For installation and examples, see the [project README](../README.md).
For development setup and test tiers, see [CONTRIBUTING.md](../CONTRIBUTING.md).
Expand Down
4 changes: 3 additions & 1 deletion docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ tests run as the runner's user and could have rewritten what an earlier run left
`kernels`, `runtime`, `spec`, `layers` and `models`, one pytest run per tier. A test may skip only for a reason
`ALLOWED_SKIPS` lists: a module that did not build, a missing checkpoint, package or chip profile skips silently on a
developer's machine and fails here. `--shader-validation` (`/mac-test --shader-validation`) runs the Metal tiers under
`MTL_SHADER_VALIDATION=1`; use it for kernel and emitter changes (CLAUDE.md).
`MTL_SHADER_VALIDATION=1`, where a validation report on a command buffer the runtime commits fails the test that made
it; MLX's command buffers are not checked ([test tiers](../CONTRIBUTING.md#test-tiers)). Use it for kernel and
emitter changes (CLAUDE.md).

A maintainer starts the lane on a pull request by commenting, after reading the change:

Expand Down
11 changes: 11 additions & 0 deletions docs/design/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ for the extension interface.
| `KernelSpec` | Metal source, entry point, specialization macros, and language version |
| `BufferSpec` | Size, initial data or mapped file range, and lifetime role |
| `OpSpec` | Kernel, bindings, launch geometry, threadgroup storage, and dependency boundary |
| `HostPoint` | Host task inside a step: the boundary after which it starts, the boundary from which later operations wait for it, and the buffers it reads and writes |
| `StepStateLayout` | Shared binary layout for GPU-resident generation control |
| Backend identity | Backend ID and configuration digest associated with the compiled program |
| Context capacity | Bound enforced before a step accesses persistent caches |
Expand All @@ -73,6 +74,13 @@ The runtime replays a static operation sequence. Kernels use active-row counts a
work within their compiled bounds. A later replay can return without doing work after the sequence has
finished. The host submits bounded batches of work and reads output tokens.

A step can pause at a host point for CPU work. The pass before the point signals a shared event; the host
waits for the signal, runs the point's task, and then commits the command buffer that continues the step.
A committed command buffer therefore never waits on the host, so a slow task idles the GPU and cannot trip
the watchdog. A step's tasks run only when the program was live at the start of the step. A failed task, a
command-buffer error, or a timeout ends the run after every committed command buffer finishes, and sets
StepState error 4.

An ICB barrier orders dependent dispatches. The compiler may omit a boundary only after establishing that
the relevant operations can run independently. Inside a megakernel, threadgroup barriers protect local
scratch; cross-worker publication follows Metal's device-memory ordering rules. All spin loops and task
Expand All @@ -91,6 +99,9 @@ Buffers have distinct ownership:
- **Scratch:** temporary activations and partial results; storage may be reused after the last consumer.
- **Parameters:** records owned by a particular program, including its shapes and binding offsets.
- **Output ring:** tokens published by GPU control operations and consumed by the host.
- **Host buffers:** allocated by the session and bound by name (the expert cache, its slot table, staging rows);
they stay resident for every program that names them, because kernels can reach them through GPU addresses held
in other buffers.

Programs within a session can share persistent buffers by name. Parameter records are program-specific.
Scratch allocation must never alias live persistent state, acceptance logs, or output buffers.
Expand Down
Loading