Skip to content

Regenerate from numen-tech/mlx implied-bias quantized matmul; QuantizedEmbedding passes a 0-d bias through - #8

Merged
jeethu merged 7 commits into
prismfrom
prism-190-implied-bias
Oct 4, 2026
Merged

jeethu merged 7 commits into
prismfrom
prism-190-implied-bias

Conversation

@jeethu

@jeethu jeethu commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

For numen-tech/gemma4-qat#190 (epic numen-tech/gemma4-qat#178, Phase 2). Its fork dependency has landed: numen-tech/mlx#6 and #7 are merged into prism-0.32.2-fixes, and Source/Cmlx/mlx now points at that merged head, a7ed9286. Ready to merge.

What

  • Source/Cmlx/mlx moves to numen-tech/mlx prism-0.32.2-fixes a7ed9286 (merged Regenerate from numen-tech/mlx 2f0e44f9: re-land the counter fixes (gemma4-qat #181) #6 + Bump mlx to b2c93bd1: build and hash each custom kernel variant once, bounded memo (gemma4-qat #189) #7). That fork change makes a 0-d biases an implied-bias factor f: the kernels form scales * T(f) in the scales' dtype, bit-identical to a materialized bias.
  • Regeneration: tools/update-mlx.sh, run with LC_ALL=C.
    • Adds the _ib kernel variants to mlx-generated/metal/quantized{,_nax}.h and mlx-generated/quantized{,_nax}.cpp.
    • Updates the mlx-c header doc comment and moves the Metal.hpp stamp.
    • The script's glob reordered cuda_jit_sources.h, with identical content. That reorder was discarded, so the committed order is kept.
  • MLXNN: QuantizedEmbedding.callAsFunction passes a 0-d biases straight through to dequantized, instead of biases[x] (a 0-d array has no rows to gather). QuantizedLinear already hands biases straight to quantizedMM.

Commits

Commit Bump Change
a3095b7 mlx 0e7a5b09 Kernels and the MLXNN pass-through
9eefbc4 5a7aeace Rounding contract (header doc only; no kernel source change)
275bd52 6fa3f0cc CUDA materializes (ops.cpp only)
276c309 477f91ad Simplified plumbing
19f5427 a84b8d07 JIT fix: the implied_bias template arg only on the implied branch; without it affine_sym_qmv failed at pipeline creation
89b625c 499fc3e2 CPU implied-bias path kept and the bias dtype check restored (ops.cpp and the CPU backend; only the Metal.hpp stamp regenerates)
dd0cf30 a7ed9286 Merged fork head: #7 gives the implied-bias factor a zero gradient (stop_gradient in materialize_implied_bias; QuantizedMatmul vjp/jvp no longer throw) and condenses comments. Regenerates comment-only changes in mlx-generated/metal/quantized.h and quantized.cpp, plus the mlx-ops.h docs and the Metal.hpp stamp. No forward-path change.

Verification

The tests ran in numen-tech/gemma4-qat (perf/190-implied-bias, pinned to 89b625c; re-checked at dd0cf30 where noted):

jeethu added 6 commits October 3, 2026 19:51
…l, gemma4-qat ml-explore#190)

Bumps Source/Cmlx/mlx to numen-tech/mlx fork/190-implied-bias head 0e7a5b09: a 0-d `biases`
array passed to `quantized_matmul`/`dequantize` in mode "affine" is an implied-bias factor f,
and the kernels form `bias = f * scale` in place of loading a per-group bias (bit-identical to
a materialized bias, including fp16 subnormal scales). tools/update-mlx.sh (run with LC_ALL=C)
regenerates the `_ib` kernel variants into mlx-generated/metal/quantized{,_nax}.h and
mlx-generated/quantized{,_nax}.cpp; the Metal.hpp commit stamp moves.

MLXNN: `QuantizedEmbedding.callAsFunction` passes a 0-d `biases` through to `dequantized`
unindexed (there are no rows to gather) instead of `biases[x]`. `QuantizedLinear` already
hands `biases` straight to `quantizedMM`, and `Module.update` compares shapes, so a loader
that installs the factor also builds its placeholder with shape `[]`.
…ct, gemma4-qat ml-explore#190)

Bumps Source/Cmlx/mlx to fork/190-implied-bias head 5a7aeace: a 0-d `biases` factor f now
stands, by contract, for the materialized bias `scales * T(f)` formed in the scales' dtype T,
and `quantized_matmul`/`dequantize` materialize that bias up front whenever the `_ib` kernels
cannot honor it exactly -- the activations promoted the scales, or the bit width (3/5/6) has
no `_ib` instantiation in the prebuilt metallib this package ships. tools/update-mlx.sh (run
with LC_ALL=C) regenerates nothing but the mlx-c header copy (the new doc comment on
quantized_matmul/dequantize) and the Metal.hpp commit stamp: no kernel source changed.
… CUDA, gemma4-qat ml-explore#190)

ops.cpp only, so tools/update-mlx.sh leaves mlx-generated/ unchanged. Its glob emitted cuda_jit_sources.h in a different order (the same entries, sorted content identical), so the committed ordering is kept.
…e implied branch)

The previous regeneration always appended the implied_bias template arg,
which the JIT build could not compile for affine_sym_*/fp_* kernels
(ParoQuantMLXTests crashed at affine_sym_qmv pipeline creation). No
generated kernel source changes; only the submodule pin moves.
…emma4-qat ml-explore#190)

ops.cpp and the CPU backend only: tools/update-mlx.sh (LC_ALL=C) regenerates
nothing but the Metal.hpp commit stamp.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T09:59:23.574620Z dd0cf30 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…ero implied-bias factor gradient, gemma4-qat ml-explore#190)
@jeethu
jeethu merged commit ee28a76 into prism Oct 4, 2026
@jeethu
jeethu deleted the prism-190-implied-bias branch October 4, 2026 11:02
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.

1 participant