Repository navigation
Conversation
agx3_matrix_encode_mma8 only packed the 14-byte AGX3C (M5) form. The AGX3B table has the 12-byte f32matmad8x8 that Apple's compiler emits for simdgroup_float8x8 / simdgroup_half8x8 multiply-accumulate on applegpu_g16g (M4), so encode it as well: the same anonymous fields as on AGX3C (2 D, 18 A, 35 B, 52 C, 26/43/60 operand types, 27/29, 44/46, 61/63 cache and discard, 11 D cache, 59 = 1 for a multiply without C), all operands through the register-pair form (r0..r95), and six wait slots instead of eight. A and B may differ in type, as Metal's half/float mixes do, through a new optional b_input_type; AGX3C still takes one input type and refuses a different B. The witnesses are metal-tt -arch applegpu_g16g builds of MSL kernels that load every A, B and C fragment from, and store every D to, a distinct offset, so each MAC's operand registers are known from the surrounding loads and stores rather than from the MAC itself. All 177 MACs found that way (123 fp32, 51 fp16 A and B, three simdgroup_multiply and mixed-type examples) reproduce byte for byte; the test carries the 54 that cover every cache, discard, wait and type combination seen, plus refusals. This adds the encoding only. Nothing selects it yet: the compiler still asserts AGX3C for cmat_muladd_agx and the packer refuses MATMAD8 off AGX3C, so no shader changes. Outside this tree, the fp32-operand form drives a cooperative-matrix lowering on an M4 Mac mini (T8132) with another kernel and Mesa tree, where Vulkan GEMMs match the CPU bit for bit from 8x8x8 to 1024x1024x1024. The fp16-operand forms are from Metal output only: that lowering widens fp16 to fp32 before the instruction. Signed-off-by: Sean Dolbec <sdolbec1@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
techmore
marked this pull request as ready for review
November 2, 2026 02:58
[Low impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issues were found. SummaryAdds the 12-byte AGX3B matrix multiply-accumulate form with separate A and B types.
Reviews (2) · Last reviewed commit: "agx: compare the AGX3C B type against A'..." · Reviewed by Greptile |
agx3_matrix_encode_mma8 compared b_input_type with the raw input_type, so on AGX3C a descriptor that left input_type at its fp16 default of 0 and named B as fp16 was refused, although both inputs are fp16. Default A's type first and compare B against that. Shader callers leave B unset and are unaffected. AGX3BMma8MetalWitnesses now checks that naming B's type, equal to A's (including A left at 0), packs the same AGX3C bytes as leaving it unset, and that the default fp16 A with an fp32 B is still refused. Signed-off-by: Sean Dolbec <sdolbec1@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Aurora downstream draft: aurora-silicon#191 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
agx3_matrix_encode_mma8only packed the 14-byte AGX3C (M5) form. This commit adds the 12-byte AGX3Bf32matmad8x8that Apple's compiler emits on G16 (applegpu_g16g, M4) forsimdgroup_float8x8/simdgroup_half8x8multiply-accumulate. It uses the same anonymous fields as the AGX3C encoder:simdgroup_multiply(no C)A and B may have different types, as Metal's half/float mixes do. This works through a new optional
b_input_typeinagx3_matrix_mma8_desc(0 = same as A). AGX3C still takes one input type and now refuses a different B explicitly.Why
The AGX3B table already has this form, but nothing encoded it, so cooperative matrices existed only on M5. On M4, the same instruction emitted by another Mesa tree took MLX 4-bit matmul from about 0.8-0.9 to 1.3-1.6 TFLOP/s, and 512-token prefill of 4-bit models went up 1.1-2.1x. These numbers come from our receipts, measured on the GravityLinux Apple9 stack, not on this tree. PR 2 (
m4/agx3b-cooperative-matrix) wires this encoding up, opt-in.Evidence
metal-tt -arch applegpu_g16g. Each kernel loads every A, B and C fragment from a distinct offset and stores every D to one. So each MAC's operand registers are known from the loads and stores around it, not from the MAC itself.simdgroup_multiplyor mixed-type examples.c_zero, and AGX3C with a mixed B type.agx3b_tables.cputs these fields.Tests run
agx_tests503 tests, 502 passed, 1 skipped (NativeFMA.ExactDyadicOracle, which also skips on the base). The base has 502 tests, 501 passed.NativeForms.AGX3BMma8MetalWitnessespasses. See the INDEX notes for how the macOS build was set up.agx_tests496 passed and 1 skipped in a release build; 502 passed and 1 skipped with-Db_ndebug=false. The Vulkan driver and drm-shim built.Remaining hardware test plan
applegpu_g17poutput forsimdgroup_float8x8, comparing it against these vectors would close this.Risks and limitations
cf 00 56 ..., a different layout) is not mapped. bf16 is refused, because we have no AGX3B bf16 witness.agx3_matrix_mma8_desc. Existing aggregate initialisers keep their meaning.🤖 Generated with Claude Code