Skip to content

contract: every chip checks each chip's qwen27 control edit matches its source once, so an M4 run sees a stale M5 edit - #3343

Merged
ashhart merged 4 commits into
ashhart:mainfrom
cshintov:bugfix/q27-decode-control-edit
Nov 17, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
cshintov:bugfix/q27-decode-control-edit

Conversation

@cshintov

Copy link
Copy Markdown
Contributor

What this changes

  • Every chip checks every chip's qwen27 control edits. Suite.collect in metal_q27_attn_rows.zig first builds the attention source for both tensor-unit settings and requires each control's edit to occur exactly once. On a mismatch it prints which control, which setting and the count, and returns error.ControlEdit.

Why: #2106's last commit changed q27_attn_prefix's line to MASKED && q27_nonfinite(, and the M5 decode control's edit went stale (fixed in 207ebc7fd). Before M5 the decode control isn't registered, so a pre-M5 run never built that edit, and our M4 contract passed. With this check, a pre-M5 run fails on a stale M5 edit too.

Design

Choice: check the edit's source text once, up front, for both settings, on every chip. It reads source only, so it costs milliseconds and needs no device with tensor units.

Alternatives considered:

Checks

  • Head on main 4ddc28cfc, an M4 Pro (no tensor units).
  • tf-kernel-contract --only qwen27: SUMMARY 30 kernels: 30 pass gates 1-4, 0 fail, 0 known findings; 3 controls: 3 red as planted, 0 missed; 0 limit problems, exit 0.
  • With the decode edit's from put back to const bool masked = q27_nonfinite( (the text before 207ebc7fd), the same run on the M4 exits 1: control edit for decode rows (tensor units true) matches 0 times, not once: const bool masked = q27_nonfinite(, then error: ControlEdit.
  • zig fmt --check: clean. tools/pr_check.py: 0 errors, lean 341 against 341 (0 new).
  • Not run: the M5 contract. The check only reads source text, so it does the same on an M5.

cshintov added a commit to cshintov/TensorFold that referenced this pull request Nov 14, 2026
@ashhart

ashhart commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@cshintov READY. The validation checks all three applicable edits across both tensor-unit settings before selecting the device path. The contract host compile and five launch-map tests pass. A source-only probe also catches missing and repeated M5 anchors.

This applies cleanly beside the Llama GEMM control repair. Serving and kernel arithmetic are unchanged. Queued to land after the 1.2.9 cut.

  • Synthena (Ash's Agent)

@cshintov
cshintov force-pushed the bugfix/q27-decode-control-edit branch from 14ba0d0 to 738e5e1 Compare November 16, 2026 08:02
cshintov added a commit to cshintov/TensorFold that referenced this pull request Nov 16, 2026
cshintov added a commit to cshintov/TensorFold that referenced this pull request Nov 16, 2026
@cshintov

Copy link
Copy Markdown
Contributor Author

Rebased onto main e7e2424 after the 1.2.9 cut (head 738e5e1). The only change is the changelog line, which moved back under Unreleased; a plain merge would have put it in 1.2.9. tf-kernel-contract --only qwen27 on an M4 Pro: 30 of 30 kernels pass, 3 of 3 controls red as planted, exit 0. tools/pr_check.py: 0 errors, lean 337 against 337.

@ashhart
ashhart force-pushed the bugfix/q27-decode-control-edit branch from 738e5e1 to ad1a895 Compare November 17, 2026 01:37
@ashhart
ashhart merged commit b6c8cd3 into ashhart:main Nov 17, 2026
1 of 10 checks passed
ashhart pushed a commit that referenced this pull request Nov 17, 2026
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thank you @cshintov. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @cshintov! This is in TensorFold 1.2.10, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.10

  • Synthena

ashhart added a commit to hobbesd/TensorFold that referenced this pull request Nov 19, 2026
…ask 2)

The ashhart#3343 loop in Suite.collect passed each tensor-unit flag to controlEdit and at_.geometry, which now take the shared-prefix decision, so on the pre-M5 source the decode edit was never checked though the control is registered there. Call sharedPrefix as Attn.init does, so the decode control edit is checked against the pre-M5 source too.
ashhart added a commit to hobbesd/TensorFold that referenced this pull request Nov 19, 2026
…ask 2)

The ashhart#3343 loop in Suite.collect passed each tensor-unit flag to controlEdit and at_.geometry, which now take the shared-prefix decision, so on the pre-M5 source the decode edit was never checked though the control is registered there. Call sharedPrefix as Attn.init does, so the decode control edit is checked against the pre-M5 source too.
ashhart added a commit to hobbesd/TensorFold that referenced this pull request Nov 19, 2026
…ask 2)

The ashhart#3343 loop in Suite.collect passed each tensor-unit flag to controlEdit and at_.geometry, which now take the shared-prefix decision, so on the pre-M5 source the decode edit was never checked though the control is registered there. Call sharedPrefix as Attn.init does, so the decode control edit is checked against the pre-M5 source too.
ashhart added a commit that referenced this pull request Nov 19, 2026
…ask 2)

The #3343 loop in Suite.collect passed each tensor-unit flag to controlEdit and at_.geometry, which now take the shared-prefix decision, so on the pre-M5 source the decode edit was never checked though the control is registered there. Call sharedPrefix as Attn.init does, so the decode control edit is checked against the pre-M5 source too.
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.

2 participants