Skip to content

perf(models): opt the remaining families into maskless padded prefill - #3103

Merged
inureyes merged 2 commits into
mainfrom
perf/issue-3101-maskless-padded-prefill-remaining
Nov 16, 2026
Merged

inureyes merged 2 commits into
mainfrom
perf/issue-3101-maskless-padded-prefill-remaining

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Opts GLM4V, GLM4V-MoE, Nemotron-NAS, Cohere2-MoE and EXAONE-MoE into supports_maskless_padded_prefill, so a tile-aligned padded prefill piece of these families skips create_padded_prefill_mask. Follows the five opt-ins of #3097.

  • Cohere2-MoE and EXAONE-MoE already built their own causal and sliding masks and handled a mask-less multi-token forward, so they only needed the opt-in.
  • GLM4V and GLM4V-MoE (text backbones and the VLM wrappers) opt in. Their MRoPE positions did not depend on the mask, but a padded embedding prefill was wrong: the stored image positions cover only the real prompt, so the padded piece fell back to index + rope_deltas for every row, giving the real rows after an image the wrong positions. padded_tail_positions now keeps the stored rows for the real tokens and continues from them for the pad rows.
  • Nemotron-NAS keeps its caches inside the model, out of the engine's reach, which is why it declined padding. It now implements trim_state over those caches and enables both padded and maskless padded prefill.
  • EXAONE-MoE finding: create_padded_prefill_mask is plain causal, so the masked arm ignores the sliding window past it (relative RMS 2.9e-3 from the unpadded forward on the tiny model). The maskless arm matches the unpadded forward exactly, so the opt-in is also the more accurate path there.

Parity gates

Each gate prefills unpadded, padded without a mask, and padded with the padding mask, trims the pad, decodes one token, and compares both rows.

Family Model Maskless vs masked (prefill / decode) Maskless vs unpadded
GLM4V, GLM4V-MoE (text, image positions on and off, ids and embeddings) tiny random weights 0 / 0 0 / 0
Nemotron-NAS tiny random weights 0 / 0 0 / 0
Cohere2-MoE (sigmoid, softmax; 20 tokens past a 16-token window) tiny random weights 0 / 0 6e-8 / 8e-8
EXAONE-MoE tiny random weights 0 / 0 inside the window 0 / 0
glm-4.1v-9b-thinking-4bit checkpoint 0 / 0 0 / 0
llama-3_3-nemotron-super-49b-4bit checkpoint 0 / 0 0 / 0
glm-4.5v-4bit (glm4v_moe) checkpoint 0 / 0 2.5e-2 / 2.2e-2 on both arms alike (MoE padded-width kernel difference)

No benchmark was run: the change drops one [1, 1, L, L] mask per padded piece and moves no arithmetic.

Test plan

  • models::padded_prefill_parity_tests, the Cohere2-MoE and EXAONE-MoE gates, the Nemotron-NAS engine test
  • tests/maskless_padded_prefill_parity.rs on the three local checkpoints, lock-wrapped
  • fmt, narrow clippy, env-var docs, benchmark raw-log check, kernel dtype keys, causal-mask roster test

Closes #3101

GLM4V, GLM4V-MoE, Nemotron-NAS, Cohere2-MoE and EXAONE-MoE now report supports_maskless_padded_prefill, so a tile-aligned padded prefill piece skips create_padded_prefill_mask. Follows the five opt-ins of #3097.

Nemotron-NAS keeps its caches inside the model, out of the engine's trim, so it implements trim_state over them and now accepts padded prefill. The GLM4V family keeps the stored MRoPE positions for the real rows of a padded embedding prefill and continues from them for the pad rows, where it used to fall back to index + rope_deltas for every row and mis-positioned the tokens after an image.

Each family has a parity gate (unpadded, maskless, padding mask, plus the decode after the pad trim): tiny random-weight models in the lib tests, and the glm4v, glm4v_moe and nemotron_nas checkpoints in tests/maskless_padded_prefill_parity.rs. Maskless and masked agree at relative RMS 0 everywhere.

Refs #3072, #3097. Closes #3101
@inureyes inureyes added status:done Completed type:performance Performance improvements priority:low Low priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) labels Nov 15, 2026
@inureyes
inureyes marked this pull request as ready for review November 16, 2026 00:21
@inureyes
inureyes merged commit 36af8be into main Nov 16, 2026
@inureyes
inureyes deleted the perf/issue-3101-maskless-padded-prefill-remaining branch November 16, 2026 00:21
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(models): opt the remaining families into maskless padded prefill

1 participant