Repository navigation
qwen_m2_decode: --m-per-prompt (per-prompt max_len, as the M1 reference ran) - #27
Conversation
…mpt) + new tokens The M1 reference ran ANEForge generate() without max_len, so its six attention programs (ctx oh/inv [1,M,1], mask [1,1,M], KV states [2,M,256]) were built at M = len(prompt) + 32 per prompt; the M2 run used M = 50 for all. configure(m) scales every manifest dimension equal to max_len to m, takes the programs whose shapes change from <per-m-dir>/M<m>/prog_NNN and the rest from the max_len 50 set, and zeroes the states at the new shapes. Host tests: the context tables and rope rows at M equal the dump-checked M=50 tables cut to M, and per-M program, port-table and state selection.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01d5aec109
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ap.add_argument("--ane-run", default="/var/tmp/inst/tools/ane-run") | ||
| ap.add_argument("--timeout", type=int, default=120) | ||
| ap.add_argument("--summary", action="store_true") | ||
| ap.add_argument("--m-per-prompt", action="store_true", |
There was a problem hiding this comment.
Author the commit with the required repository identity
The reviewed commit is authored and committed as Codex <codex@openai.com>, but this repository requires every commit to use Joshua Warren <816217+joshuaswarren@users.noreply.github.com>. Recreate this commit with the mandated author and committer identity before it is integrated.
AGENTS.md reference: AGENTS.md:L250-L257
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reproduced: GET /repos/joshuaswarren/omarchy-ane/commits/01d5aec1095cad8f3deb5343229b8d26ce573ce1 reports author and committer Joshua Warren <816217+joshuaswarren@users.noreply.github.com>, and git log --format="%an <%ae> | %cn <%ce>" origin/main..HEAD shows the same for the one commit in this PR. No Codex identity is in the branch.
| path = Path(args.ports_dir) / prog / "ports.resolved.json" if args.ports_dir \ | ||
| else Path(args.anec_dir) / prog / "ports.json" | ||
| if pr != pr0: | ||
| anec_dir = path_dir = Path(args.per_m_dir) / f"M{m}" |
There was a problem hiding this comment.
WARNING: A missing or out-of-range per-M table raises FileNotFoundError, not Refuse
<per-m-dir>/M<M>/prog_NNN/ports.json is read at line 161 with no existence check, and __main__ only catches Refuse (line 408), so a run with the default --per-m-dir /var/tmp/qwen-perM that has not been built, or a prompt whose len(prompt) + new_tokens exceeds the largest prepared M, dies with a raw traceback instead of the documented REFUSE: message and exit 2. The rest of configure is careful to raise Refuse with the offending path, so this is the one input that fails unhelpfully. Consider validating the per-M directory up front (and that m is within the prepared range) before the loop.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
There was a problem hiding this comment.
Fixed in 28dc62c: configure raises Refuse naming the port table and ANEC when either is missing, so a max_len without a prepared set exits 2 with REFUSE:. Test: configure(6) with no M6 set.
| name = "ports.json" | ||
| else: | ||
| anec_dir = Path(args.anec_dir) | ||
| path_dir, name = (Path(args.ports_dir), "ports.resolved.json") if args.ports_dir \ |
There was a problem hiding this comment.
SUGGESTION: --ports-dir is silently ignored for the per-M programs
When a program's shapes change at M, the port table always comes from <per-m-dir>/M<M>/prog_NNN/ports.json; the resolved tables under --ports-dir (the ports.resolved.json produced by qwen_m2_conform.py) are never consulted for those six attention programs. If a resolved table is required for conformance, a run with both --m-per-prompt and --ports-dir fails at line 162 with wrong program or unresolved exceptions on a table the user never meant to use, with nothing pointing at the flag combination. Either honour --ports-dir for the per-M programs or refuse the combination explicitly.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
There was a problem hiding this comment.
Kept as documented in the module docstring: the per-M programs come from <per-m-dir>/M<M>/prog_NNN/{program-0.anec,ports.json}. --ports-dir holds conformance-resolved tables for the max_len 50 programs only; no resolved tables exist at other M. The derived per-M tables carry no exceptions (all 38 resolutions at max_len 50 were identity), so the failure described does not occur.
| prog = f"prog_{i:03d}" | ||
| path = Path(args.ports_dir) / prog / "ports.resolved.json" if args.ports_dir \ | ||
| else Path(args.anec_dir) / prog / "ports.json" | ||
| if pr != pr0: |
There was a problem hiding this comment.
SUGGESTION: The per-M table is validated by element count only, not by shape
pr != pr0 routes a program to the per-M directory, and the check at lines 168-170 then compares int(np.prod(shape)) per port. A per-M table whose port dimensions are permuted relative to the manifest at M (for example mask as [1, M, 1] where the manifest says [1, 1, M]) has the same element count and passes, and ane_call reshapes the host arrays to the port shape, so the run would proceed with a silently wrong surface layout. This was low-risk when every table came from one compiled set; with per-M tables from a separate directory it is the main guard against a stale or mismatched table, so comparing the shape list itself would be stronger.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
There was a problem hiding this comment.
Fixed in 28dc62c: ports are compared by their non-unit dimensions in order (port tables are NCHW, the manifest shapes are not, so the leading 1s differ). The 38 max_len 50 tables and the max_len 43 tables pass; a [2, 3, M] table for a [2, M, 3] port is refused (test case M5).
Code Review SummaryStatus: No Issues Found | Recommendation: Merge All three findings from the previous review are resolved in Files Reviewed (2 files)
Previous Review Summary (commit 01d5aec)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 01d5aec)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files)
Reviewed by free · Input: 0 · Output: 0 · Cached: 0 |
… not element counts A missing port table or ANEC (a max_len without a prepared per-M set) now raises Refuse (exit 2) instead of a FileNotFoundError traceback. Ports are checked against the manifest by their non-unit dimensions in order, so a table with permuted dimensions of the same size no longer passes; the 38 max_len 50 tables and the max_len 43 tables match this way.
The M1 reference (chunk_00) ran ANEForge
generate()without max_len, so its six attention programs (prog_006/012/018/025/031/037: ctx oh/inv [1,M,1], mask [1,1,M], KV states [2,M,256]) were built at M = len(prompt) + 32 per prompt (43..50), while the M2 decode used M = 50 for every prompt.--m-per-promptdecodes each prompt at that M: every manifest dimension equal to max_len becomes M, the programs whose shapes change come from<per-m-dir>/M<M>/prog_NNN/{program-0.anec,ports.json}, the other 32 from the M = 50 set, and the resident states restart as zeros at the new shapes.--dump(an M = 50 execution) is refused with it.Tests (
tests/test_qwen_m2_decode.py): the context tables and rope rows at M = 43..50 equal the dump-checked M = 50 tables cut to M; per-M program, port-table and state selection, and a port table built for another M is refused.pytest tests/test_qwen_m2_decode.py tests/test_qwen_precision.py tests/test_qwen_m2_conform.py tests/test_qwen_prog_run.py: 19 passed. Host smoke against the real manifest and the converted M = 43 tables: exactly the six attention programs switch to the per-M dir, KV states (2, 43, 256).No device run. A max_len 50 run of the M1 reference on H13 gives logits bit-identical to chunk_00, so M does not change the reference; the mode stays for an H14 check of the same property.