Skip to content

qwen27 Metal (M1-M4): projections no longer barrier internally, and XS sums compile out before tensor units (#2900) - #2913

Merged
ashhart merged 2 commits into
mainfrom
lead/q27-pre-m5-barriers
Nov 15, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/q27-pre-m5-barriers

Conversation

@ashhart

@ashhart ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Fixes #2900.

On Apple GPUs without tensor units (M1-M4), each 4-bit projection in zig/src/families/qwen27/quant_gpu.zig ended with its own barrier, although every caller already barriers after its projections. So pairs written to overlap (q with kv, qkv with zba) ran one after the other. Before tensor units, the norm and MLP kernels also wrote group sums (XS) that nothing reads.

  • quant no longer barriers internally; the caller orders the output (doc comment says so). The callers' existing barriers stay.
  • Benches and tools that time dependent launches get explicit barriers. The draft head's two disjoint outputs share one barrier.
  • The norm, input-norm and MLP keys take device.tensorUnits(). With Q27_XS=0 (before tensor units) the sum tails and the padded-row zero-fill compile out, and the grids hold only live rows. M5 builds are unchanged.

Exact by construction: the paired projections write disjoint buffers from a shared input, and the omitted sums have no reader before tensor units.

Tests: recording-encoder tests check the real encoder's bindings and barriers for raw 4/8-bit, group 32/64, both projection pairs, rows 1/8/128/129 and mixed strided members. They also check the norm/MLP defines, grid heights and cache keys for both chip kinds. Three runtime comparisons fail against unchanged main and pass here. qwen27 host: 597/598 (1 skipped). The emitted Metal libraries compile.

Not yet checked on a device: served greedy and seeded replies byte-equal on an M3 Ultra, and the M3 Ultra A/B (expected +0.5-1.2% decode). It lands after those.

@ashhart
ashhart force-pushed the lead/q27-pre-m5-barriers branch from 18fa85f to 57a9a5d Compare November 15, 2026 11:12
@ashhart
ashhart merged commit f83ea06 into main Nov 15, 2026
12 of 20 checks passed
@ashhart
ashhart deleted the lead/q27-pre-m5-barriers branch November 15, 2026 11:13
ashhart added a commit that referenced this pull request Nov 17, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 17, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 17, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 18, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 18, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 19, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 19, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 19, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 20, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 20, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 20, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 21, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 22, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
ashhart added a commit that referenced this pull request Nov 23, 2026
…and argmax

Four glue kernels for Qwen27 rounds, each bit-identical to the kernel it
replaces, with TensorFold's own kept wherever a round does not fit them.

- tf_delta_gdn_columns_1/2/4 replace tf_delta_gdn_tree_slots_* for lone
  trees of up to 4 live states, reading the slot schedule as flow words
  (tree_slots.flows, a new frame field).
- tf_delta_gdn_pre_vectors replaces tf_delta_gdn_pre for four taps over
  128-wide heads with bf16 conv, A_log and dt.
- q27_mlp_rows replaces custom_kernel_q27_mlp_xs where 256 threads run.
- tf_round_pick_chunks/rows replace tf_round_bf16_argmax for Qwen27's two
  callers through Ops.argmaxChunks; other families keep Ops.argmax.
- TF_Q27_FLAT_GLUE=0 at load, or decode_round.setFlatGlue, keeps every
  round on TensorFold's kernels.
- tf-qwen27-glue-ab: the general glue against the flat kernels.

Checked on an M5 Max, alone on 1.2.2: glue-ab equal over 1,204 rounds;
golden, streams, marks, reuse, lanes and served replies equal; a 16-row
verify 3.2% to 4.2% faster. Rebased here with one conflict (main's routed
block fields in gpu_frame.zig) and checked stacked on qk: golden 1024 of
1024.

On main d2b3722 (#2913: XS sums compile out before tensor units),
q27_mlp_rows writes XS only under Q27_XS and its key carries main's .xs,
so M1-M4 keep the flat activation without sums; main's norm and MLP test
now runs with the flat glue off and on.
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.

qwen27 Metal (M1-M4): quant_gpu's own barriers serialize independent projections, and XS sums nothing reads

1 participant