# Local MPS custom-kernel measurement

Machine-readable companion to `/matrix-kernels/`. Updated 2026-07-13.

## Device

- Machine: MacBook Pro Mac17,9
- Chip: Apple M5 Pro
- GPU: 16-core Apple GPU
- Memory: 24 GB unified memory
- Metal: Metal 4
- PyTorch: 2.8.0
- Dtype: float32
- Layout: contiguous real/imag pairs

## Production-shaped qutrit sidecar

Shape: `B32×T128×slots64×input_dim1453`. The loss depends on all recurrent
states and gradients reach the controller.

| backend | median step | feature-steps/s |
|---|---:|---:|
| inline `metal` | 182.315 ms | 22,467 |
| precompiled `metal_native` | 181.585 ms | 22,557 |
| fused `metal_fused` | 8.312 ms | 492,779 |
| `metal_best` | 8.989 ms | 455,674 |

For this run, `metal_fused` was 21.93× faster than inline Metal. This is a
dispatch/materialization result, not a claim about model quality.

## Primitive density scans

Shape: `B32×T128×G64×N×N×2`, nonzero carry, fixed recurrent-state cotangent.

| N | path | forward | backward |
|---:|---|---:|---:|
| 3 | real-pair PyTorch reference | 63.960 ms | 429.262 ms |
| 3 | inline Metal | 0.437 ms | 2.169 ms |
| 3 | precompiled Metal | 0.558 ms | 2.570 ms |
| 4 | real-pair PyTorch reference | 64.448 ms | 590.834 ms |
| 4 | precompiled Metal | 0.783 ms | 4.913 ms |

The reference is a Python/MPS loop with one sequence step per group of
dispatches. It is a baseline for this implementation, not a vendor GEMM
library.

## Numerical checks

At the production qutrit shape, fused versus inline Metal produced:

- state maximum absolute difference: `2.12e-6`
- detached carry maximum absolute difference: `2.09e-6`
- feature-gradient maximum absolute difference: `7.67e-13`
- controller-weight gradient maximum absolute difference: `1.35e-10`
- controller-bias gradient maximum absolute difference: `1.00e-10`
- focused parity/invariant tests: `26 passed`

## Scope

- This is a local timing and parity note.
- It does not establish late-training quality.
- It does not establish an RTX 3090 versus M5 ranking.
- The qutrit sidecar is not canonical SINABRO wiring.
- FP16/BF16 paths remain opt-in and quality-gated.
