Skip to content

Qwen3.5 family: prompt chunks on the M5 tensor units (27B prefill about 3x), and the gate for the changed prompt-row arithmetic #562

Closed as not planned

Description

@jkuepker

Qwen3.5-family prompt chunks currently go through the row decoder, which reads every 4-bit weight once per prompt row. On Qwen3.8-27B (M5 Max) that holds cold prefill at about 206–240 tok/s; the Python engine prefills the same checkpoint at 739–846.

The fix changes prompt-row arithmetic, so I'm opening this first to agree on the gate, per CONTRIBUTING. The draft PR is linked below.

Proposed change. Prompt chunks wider than batch_rows (32) run on the tensor units:

  • projections through MLX's NAX 4-bit qmm (affine_qmm_t_nax, the kernel Nemotron's prompt path already uses);
  • causal attention through a NAX kernel adapted from Flash Next's tf_attn256_nax.

Decode and draft windows (≤ 32 rows) keep the row decoder and per-row attention, so their bits, the lane exactness contract and qualify.zig are unchanged. Prompt rows change reduction order: projection sums follow MLX's 64-row NAX tiles, and attention uses an fp32 online softmax over 32-key blocks.

Proposed gate.

  1. An FP64 reference for each projection shape the 27B uses (vocab head included), on identical input rows. Report max, mean and worst per-column error for the row decoder and the NAX path, aiming for NAX error no worse than the row decoder. The same for prompt-chunk attention at context 0 and after 4K cached keys.
  2. Decode bits unchanged: bench_concurrent.py --alone --serial, with drafted equal to "draft": false and concurrent equal to solo.
  3. Greedy fidelity of prompt-chunk sizes (512-row vs 32-row fills): same argmax and greedy continuation at 2K and 8K tokens, plus a long-prompt greedy reply equal to the previous build at 32K and 128K windows.
  4. prefill_cold.py at 2K / 8K / 32K / 64K / 128K, before and after.

Measured so far on M5 Max: 16.7K-token prefill 206 → about 620 tok/s; HumanEval 164 unchanged at 159/164.

Is this the right gate, or should anything be added for the TF_SIMD_FRAGS (M1–M4) layout, which I can't run?

Activity

  1. jkuepker commented on Oct 10, 2026

    @jkuepker
    ContributorAuthor

    Closing: #563 is closed, and the follow-up there (#563 (comment)) explains why nothing is left to port. On 1.0.3 the 27B's prompt rows go through qwen27's tf_lane_reg, which already uses the row decoder's arithmetic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions