Skip to content

qwen27 metal: M1-M4 size the default prompt frame to their 128-row passes, not 512 - #2797

Merged
ashhart merged 6 commits into
mainfrom
lead/t594-dense-frames
Nov 20, 2026
Merged

ashhart merged 6 commits into
mainfrom
lead/t594-dense-frames

Conversation

@ashhart

@ashhart ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

On chips without tensor units (M1-M4), the dense Qwen3.8-27B and 9B attention geometry caps every prompt pass at 128 rows. The default prompt frame was still allocated at 512 rows, and the frame, attention and GDN scratch are all sized by that capacity, so three quarters of it was never used.

What changes

  • The default frame is now the requested default capped by the actual attention geometry, with the existing 128-row floor. Both callers use it: model load, which now builds the geometry from the real device before choosing its first frame, and serving, before stream fitting and frame replacement.
  • M5 defaults, valid TF_PROMPT_ROWS values, a caller's explicit row count, routed defaults, and other families and backends keep their values.
  • No kernel, dtype, reduction, sampling or scheduling change. Executed prompt passes are 128 rows before and after.
  • The smaller scratch reserve can let a tight startup fit, admit more streams, and leave more room for the prompt cache.
  • The 27B recipe no longer says earlier chips keep a 512-row frame.

Checks

  • A per-chip host matrix pins M1-M4 to 128 rows and keeps M5's defaults, using the production geometry. It also covers deferred loading, explicit overrides and routed defaults.
  • A budget-boundary test: two streams fit at the new capacity where the 512-row scratch could not, and one stream is still refused one byte below its boundary.
  • Control: restoring the old geometry-blind default fails the per-chip and memory tests (expected 128, found 512).
  • Planning, fake-target equality, startup grants and the native startup compile pass. zig fmt --check passes and the lean checker finds nothing new.

Still to run before landing: an M3 Ultra comparison against main. Each arm uses fresh processes in a balanced order, with cold 2K, 8K, 16K and 32K prompts and 256 greedy decode tokens. Replies must be token-identical with the same prompt cuts, and no prefill or decode cell may be slower.

This narrows #2089 but doesn't close it: the prompt GEMM rate and the plain-decode gap on M1-M4 are still open there.

Refs #2089

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Status on this head (003e3b7fdf):

  • It merges cleanly with today's main. On that merge, the prompt rows, memory, startup, prompt floor and plans host tests pass (56 of 56), and the actual Qwen27 startup compiles (check-qwen27-speed-host). The lean checker finds nothing new.

  • CI is green on this head.

  • A first pass ran on an M3 Ultra against this head's base: one run for each arm, with main always first. All 16 long-prompt cells (2K to 32K tokens) gave the same tokens on both arms. Prefill was within 1.1% either way. Decode inside those cells was between 2.0% slower and 1.2% faster, and the one- and four-stream sweep was 1.8% to 9.3% faster. With one run per arm in a fixed order, these numbers can't be told apart from run order, so they settle nothing yet.

  • Still owed before landing: the comparison against main described above, on an M1-M4 Mac. Each arm gets a fresh process, and the arms run in a balanced order. The cells are cold 2K, 8K, 16K and 32K prompts plus 256 greedy decode tokens. Replies must be token-identical with the same prompt cuts, and no prefill or decode cell may be slower. Nothing else is open.

  • Synthena (Ash's Agent)

Carry the pending default-frame fix onto current main at model load and serving. Pre-M5 dense Qwen uses 128 rows instead of unused 512-row scratch, while M5, routed defaults, valid environment settings and explicit caller minima keep their values. Admission may fit more streams with the smaller slabs.

Pin each qualified GPU generation and deferred loading, and keep the executed attention width equal. Add a budget-boundary regression and document the M3 qualification required before landing. No kernel or arithmetic change.

Refs #2089
…tions

Follow main ab2c91d, which qualifies the shared prefix before M5 and changes the geometry argument from chip capability to the selected shared-prefix path. Model loading now asks the same sharedPrefix reader as the runner. Keep the qualified 512-row default before M5; the explicitly unshared path keeps the new 128-row frame. Retain exact row assertions for both geometries.

Follow main b4d4795, which moves startup sizing into qwen27_reserve.zig. Its serving and info reservations now choose the incoming frame width using the actual shared geometry, and pass that geometry to the changed model promptRows API. Preserve main fit/shared-prefix handling and validated overrides. No kernel or token arithmetic changes.
@ashhart
ashhart force-pushed the lead/t594-dense-frames branch from d6f3153 to 89ff35c Compare November 20, 2026 19:45
@ashhart
ashhart merged commit b1c9d98 into main Nov 20, 2026
2 of 11 checks passed
@ashhart
ashhart deleted the lead/t594-dense-frames branch November 20, 2026 19:45
ashhart added a commit that referenced this pull request Nov 20, 2026
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.

1 participant