Repository navigation
Conversation
|
Review against main e9b69ed. #1400 and #1401 are on our devices now; this one needs its oracle settled first. The host dot accumulates in FP32 left to right, and the test reference repeats the same proposed BF16 steps in FP64 ( What would settle it: reproducible inputs, weights and MLX outputs pinned to the MLX version and operation, at the real E4B dimensions (256 inputs, 2560 hidden), checked step by step: the RMS intermediate rounding, the projection accumulation, GELU and the scalar steps ( E4B stays refused and no served GPU operator is added here, so nothing regresses meanwhile. Thank you for the candid receipt; it made this easy to pin down. |
|
Thanks, agreed on all points. Two commits on top:
The new test (
The bound, labelled in the file header: with more than one row MLX takes another kernel ( Tests: |
|
Thank you, this settles the oracle question. It is what we asked for:
The host tests pass here on the branch rebased onto main. Three small things:
We'll run the oracle on our M3 and M5 Ultras to see whether MLX's one-row prints change by chip. If they do, we'll ask |
…16 steps, checked against a float64 reference (ashhart#1222)
…shapes, pinned to MLX 0.32.4
…mv and rms_norm trees, GELU flushes subnormals)
b7d0bbf to
078f52c
Compare
|
Thanks @Mirrdhyn, all three are done. The branch sits on current main with only your three commits. The description names the MLX prints as the oracle and the float64 reference as a consistency check. The We merged it onto main again. fmt and lean are clean, and One small thing: Next we'll run the oracle on an M5 Ultra with MLX 0.32.4 and compare its prints with the committed fixture. If they differ from your M4 Max's, we'll ask you to name the chips in the header's bound. Otherwise this is ready. |
|
This is in TensorFold 1.1.8, released today. Thank you, @Mirrdhyn! |
What this changes
Part of #1222, on current main (#1400 and #1401 have landed).
layer_input.zig: the per-layer inputs (model projection, scale, norm, sum with the token table row, mix) and each layer's per-layer block (gate with GELU, projection, post norm, residual and layer scalar), on the host, following MLX's arithmetic at one row: the bf16 gemv's tree,rms_norm's twosimd_sums with a correctly roundedrsqrt, GELU flushing subnormals as the GPU does, and the weak scalars rounded to bf16 before the product.cuda_layer_input.zigis its CUDA-build twin (the twin test covers it), so a CUDA test can import it.The oracle
tools/zig/gemma4_e4b_layer_input_oracle.py, pinned to MLX 0.32.4 and mlx-lm 0.32.2 (Metal), runs MLX at the E4B's shapes (2560 hidden, 256 inputs) on seeded inputs and weights, so no checkpoint weights are stored. The fixturetools/zig/fixtures/e4b_layer_input_mlx.json(14 KB) holds the SHA-256 of MLX's bf16 output at every step, for 3 layers by 4 tokens, plus the GELU table over all finite bf16 inputs.layer_input_mlx_test.zigchains the host's steps and compares each step's print with MLX's: all 13 steps equal,inputs()andapply()end to end too. On a mismatch it names the first token, layer and step that differ.The float64 reference in
layer_input.zig's tests is an internal consistency check only; the MLX prints are the oracle.Bound: with more than one row MLX takes another kernel (
gemv_wideor the GEMM), whose bf16 outputs differ from the one-row call on at most 0.05% of the values (M = 2 to 64 measured). The host does not reproduce that path. Equality is measured on an M4 Max with MLX 0.32.4.Receipt
test4770/4796 (26 skipped),test-gemma4-config108/109 (1 skipped: the optional raw-output file is not in the tree),test-goldenpasses;zig fmtclean;lean_check.py428, as on main.