model: GDN column-parallel prefill out-proj, and gdn/tp.py becomes the single base (#64, #41) #86

Merged
Grok merged 4 commits from agy/issue-64 into master 2026-09-25 23:52:19 +02:00
Owner

Ports upstream tt-metal PR #57377 (column-parallel GDN prefill out-projection) into the
vendored production sources behind QWEN36_GDN_OUTPROJ_COLPAR=1, default OFF, with a
QWEN36_GDN_OUTPROJ_COLPAR engaged banner. Prefill's out-proj becomes all-gather + matmul
(all_gather_minimal_matmul_async); decode is untouched and keeps the row-sharded weight.

This PR also establishes patches/prod-local-metal/.../tt/gdn/tp.py as the single base
file
(owner decision, 2026-09-25). Three branches claim that path and only one file can be
mounted there. This one is the production-shaped source: it reads QWEN_GDN_CONV_GATES,
QWEN_GDN_FUSED_INPLACE and QWEN_GDN_PACKED_QKV, which the unit sets and which every number
we hold was measured with. The 1936-line copy on agy/issue-50 reads none of the three, so
mounting it would silently drop the fused-GDN path. Later GDN work rebases onto this file.

Result (LEDGER R-2026-09-25-gdn-colpar): on the 2-chip simulator only, COLPAR=1 vs
COLPAR=0 agree at PCC 0.999996 at seq 128 and 2048, max abs diff 0.031, both arms ≥ 0.99996
PCC against an fp32 PyTorch reference. No ttsim number is a performance number and none is
claimed: there is no hardware run, so the lever stays open — it must be A/B'd with
CAND_ENV="-e QWEN36_GDN_OUTPROJ_COLPAR=1" through bench/ab/sweep-32k.sh before anyone calls
it a win. Cost if enabled: a second column-sharded out-proj weight, ~765 MiB/device over 48
GDN layers plus a ~50 MiB gather buffer — fine at ≤32k, competes with the KV pool at 128k/256k.

Changes made while merging master in

  • flake.lock: master's taken. The branch's lock still pinned tt-metal at
    file:///home/orchestra/ttm-build/src; PR #68 moved that to the public pin, and shipping the
    local path would break CI and every other clone. The colpar code is mounted over the image,
    so it does not depend on the Nix tt-metal pin.
  • flake.nix and scripts/sim-run.sh: the hardcoded /nix/store/…-expat-2.8.2/lib path is
    dropped.
    A literal store path breaks after a GC and on any other machine. Master had also
    deleted that whole shellHook — the Nix ttnn runtime shell now lives in nix/sim/flake.nix.
    If the simulator really needs expat, it belongs there as pkgs.expat, not as a literal
    path
    — flagging rather than guessing, since I cannot verify it without the sim host. The
    same commit's writable-TT_METAL_HOME copy went with that deleted shellHook.
  • bench/ab/sweep-32k.sh: master's taken. It is a ttx driver now and already supports this
    arm generically via CAND_ENV, with the identity check driven by the arm's [expect]
    banners, so the bespoke gdn-colpar case is redundant.
  • Hardened the packed-decode gate. The optional import of
    recurrent_gated_delta_rule_decode_packed_ttnn exists so the module imports under the
    simulator, but the _packed gate did not test it: a tree with the ttnn kernel and no Python
    wrapper would take the packed branch and die on a None call. The gate now includes it.

Verification

The unit now mounts an eighth source. bench/arms/prod.toml derives its overlay from the
patches/prod-local-metal tree, so tools/ttx/tests/test_prod_matches_nix.py keeps arm and
unit in lockstep automatically — passing. Diffed the vendored file against the image copy
used by the bfpq arms: every difference is either behind the default-off colpar flag, the new
optional dtype= parameter on _silu_mul (default None, unchanged call), or the bfpq
branch's own QWEN36_ATTN_GDN_BF4 hook, which is not production and which the bfpq arms mount
themselves. No default-path behaviour change.

Post-PR-#68 hygiene after the merge: docs/ still 11 files, no root CLAUDE.md, AGENTS.md
still the lean rewrite, QWEN36_PREFILLED_SLOTS_FIX still in qwen36_vllm.py, nothing PR #68
deleted came back. Locally green: nixfmt --check, check-cited-records.py, shellcheck,
nix flake check, and the 41 ttx unit tests.

Refs #64, #41.

🤖 Generated with Claude Code

Ports upstream tt-metal PR #57377 (column-parallel GDN prefill out-projection) into the vendored production sources behind **`QWEN36_GDN_OUTPROJ_COLPAR=1`, default OFF**, with a `QWEN36_GDN_OUTPROJ_COLPAR engaged` banner. Prefill's out-proj becomes all-gather + matmul (`all_gather_minimal_matmul_async`); **decode is untouched** and keeps the row-sharded weight. **This PR also establishes `patches/prod-local-metal/.../tt/gdn/tp.py` as the single base file** (owner decision, 2026-09-25). Three branches claim that path and only one file can be mounted there. This one is the production-shaped source: it reads `QWEN_GDN_CONV_GATES`, `QWEN_GDN_FUSED_INPLACE` and `QWEN_GDN_PACKED_QKV`, which the unit sets and which every number we hold was measured with. The 1936-line copy on `agy/issue-50` reads **none** of the three, so mounting it would silently drop the fused-GDN path. Later GDN work rebases onto this file. **Result** (LEDGER `R-2026-09-25-gdn-colpar`): on the **2-chip simulator only**, COLPAR=1 vs COLPAR=0 agree at **PCC 0.999996** at seq 128 and 2048, max abs diff 0.031, both arms ≥ 0.99996 PCC against an fp32 PyTorch reference. **No ttsim number is a performance number** and none is claimed: there is no hardware run, so the lever stays **open** — it must be A/B'd with `CAND_ENV="-e QWEN36_GDN_OUTPROJ_COLPAR=1"` through `bench/ab/sweep-32k.sh` before anyone calls it a win. Cost if enabled: a second column-sharded out-proj weight, **~765 MiB/device** over 48 GDN layers plus a ~50 MiB gather buffer — fine at ≤32k, competes with the KV pool at 128k/256k. ## Changes made while merging master in - **`flake.lock`: master's taken.** The branch's lock still pinned tt-metal at `file:///home/orchestra/ttm-build/src`; PR #68 moved that to the public pin, and shipping the local path would break CI and every other clone. The colpar code is mounted over the image, so it does not depend on the Nix tt-metal pin. - **`flake.nix` and `scripts/sim-run.sh`: the hardcoded `/nix/store/…-expat-2.8.2/lib` path is dropped.** A literal store path breaks after a GC and on any other machine. Master had also deleted that whole `shellHook` — the Nix ttnn runtime shell now lives in `nix/sim/flake.nix`. **If the simulator really needs expat, it belongs there as `pkgs.expat`, not as a literal path** — flagging rather than guessing, since I cannot verify it without the sim host. The same commit's writable-`TT_METAL_HOME` copy went with that deleted shellHook. - **`bench/ab/sweep-32k.sh`: master's taken.** It is a ttx driver now and already supports this arm generically via `CAND_ENV`, with the identity check driven by the arm's `[expect]` banners, so the bespoke `gdn-colpar` case is redundant. - **Hardened the packed-decode gate.** The optional import of `recurrent_gated_delta_rule_decode_packed_ttnn` exists so the module imports under the simulator, but the `_packed` gate did not test it: a tree with the ttnn kernel and no Python wrapper would take the packed branch and die on a `None` call. The gate now includes it. ## Verification The unit now mounts an eighth source. `bench/arms/prod.toml` derives its overlay from the `patches/prod-local-metal` tree, so `tools/ttx/tests/test_prod_matches_nix.py` keeps arm and unit in lockstep automatically — **passing**. Diffed the vendored file against the image copy used by the bfpq arms: every difference is either behind the default-off colpar flag, the new optional `dtype=` parameter on `_silu_mul` (default `None`, unchanged call), or the bfpq branch's own `QWEN36_ATTN_GDN_BF4` hook, which is not production and which the bfpq arms mount themselves. **No default-path behaviour change.** Post-PR-#68 hygiene after the merge: `docs/` still 11 files, no root `CLAUDE.md`, `AGENTS.md` still the lean rewrite, `QWEN36_PREFILLED_SLOTS_FIX` still in `qwen36_vllm.py`, nothing PR #68 deleted came back. Locally green: `nixfmt --check`, `check-cited-records.py`, `shellcheck`, `nix flake check`, and the 41 ttx unit tests. Refs #64, #41. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Port upstream tt-metal PR #57377 (merged 2026-09-23) into production model sources:
- Wire column-parallel out-projection in GDN prefill via all_gather_minimal_matmul_async
  behind QWEN36_GDN_OUTPROJ_COLPAR=1 (default 0/OFF).
- Provide agmm_gather_buffer on tt_ccl for persistent ping-pong gather buffers
  avoiding in0 corruption under device skew (PR #57377 / issue #57458).
- Log self-identifying 'QWEN36_GDN_OUTPROJ_COLPAR engaged' banner on layer init.
- Expose gdnOutprojColpar in modules/tenstorrent-serving.nix with bind-mount.
- Support 'gdn-colpar' arm and gdn/tp.py mount in bench/ab/sweep-32k.sh.

Memory accounting:
- Adds [6144, 2560] bfp8 weight per device across 48 GDN layers = ~765 MiB/device
  weight memory plus 50 MiB shared DRAM ping-pong buffer on tt_ccl.
- Safe at <=32k standard benchmark; competes with prefix cache pool at 128k/256k.

Co-Authored-By: Gemini 3.8 Flash via agy <noreply@google.com>
Prior to this change, upstream PR #57377 (column-parallel GDN prefill out-
projection via all_gather_minimal_matmul_async) had been ported behind
QWEN36_GDN_OUTPROJ_COLPAR=1, but its numerical equivalence against the
row-parallel fallback on a 1x2 mesh (TP=2) had not been validated in
simulation. Furthermore, running the 2-chip simulator in the local runtime
was blocked by a flake.lock narHash mismatch for the local tt-metal source,
a missing expat runtime symbol, read-only Nix store access in the profiler,
and an un-guarded import of an experimental delta rule op.

Fix the runtime environment and vendor imports, and add a 2-chip Blackhole
simulation correctness test (bench/probes/test_gdn_colpar_sim.py).
On 27B GDN shapes (dim=5120, value_dim=6144), COLPAR=1 (AGMM) and COLPAR=0
(row-parallel + reduce_scatter) agree with PCC = 0.999996 and max abs diff
0.03125 at both seq 128 and seq 2048 (bench/runs/gdn-colpar-sim-20260925T072336Z.jsonl).
Both arms achieve PCC = 0.999967 against the FP32 PyTorch reference.

Co-Authored-By: Gemini 3.8 Flash via agy <noreply@google.com>
# Conflicts:
#	bench/ab/sweep-32k.sh
#	flake.lock
#	flake.nix
gdn/tp.py: this is the base; harden the packed-decode gate and record the colpar scope
All checks were successful
tt-stack-ci / Report upstream drift (pull_request) Successful in 13s
tt-stack-ci / Build simulators and check the host module (pull_request) Successful in 39s
ccbbf080ce
The vendored gdn/tp.py is now a single file with three claimants, so it has to be the
production-shaped one: it reads QWEN_GDN_CONV_GATES, QWEN_GDN_FUSED_INPLACE and
QWEN_GDN_PACKED_QKV, which the unit sets and which every number we hold was measured
with. The competing 1936-line copy on agy/issue-50 reads none of them.

The optional import of recurrent_gated_delta_rule_decode_packed_ttnn exists so the
module imports under the simulator, but the packed branch did not test it: a tree with
the ttnn kernel and no Python wrapper would take that branch and die on a None call.
The gate now includes the import.

The LEDGER entry states the scope the record actually supports: simulator-only
equivalence at PCC 0.999996, no hardware run, so the lever is open and no speed claim
follows -- plus the ~765 MiB/device weight cost if it is ever turned on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Grok merged commit 85fe82afbc into master 2026-09-25 23:52:19 +02:00
Author
Owner

agent-gateway closeout (merged): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (merged): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!86
No description provided.