Repository navigation
Gemma on M5 Ultra: no drafts for a step whose rows all have prompts over 16,384 tokens - #2699
Merged
Merged
Conversation
…ver 16,384 tokens Under the two-draft policy on M5 Ultra, MTPAutomaticVerificationPolicy.maxDraftPromptTokens gives gemma-4-26b-qat-4bit a prompt limit of 16,384 tokens, passed to CBv2MTPConfig.maxDraftPromptTokens. A plan whose speculation-eligible decode rows all have prompts over the limit runs at depth 0 as ordinary chained decode; a row under the limit keeps the chip's table, so a long-prompt row never stops another row from drafting. On M5 Ultra two or more decode rows already run without drafts, so this changes only a long-prompt row decoding alone. DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS=0 removes the limit and a positive integer moves it; the provider's launchd job forwards it. Other chips, models and the one-draft policy are unchanged.
MTPAutomaticVerificationPolicy.gemmaPromptLimitOnByDefault (true) decides whether an unset DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS applies M5 Ultra's 16,384 limit. With it false, an unset setting passes no limit, the engine behaviour from before the limit; an explicit positive value still applies it and 0 stays off. Tests cover both defaults.
The policy tests pass onByDefault explicitly, and the process-value check compares against gemmaPromptLimitOnByDefault, so turning the default off changes only gemmaPromptLimitDefaultCanBeSwitchedOff's first expectation.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 24, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gemma 4 26B QAT on M5 Ultra, under the two-draft policy, gets a prompt limit of 16,384 tokens. A decode step whose
drafting-eligible rows all have prompts over the limit runs without drafts, as ordinary chained decode. A row at or
under the limit keeps the chip's table, so a long-prompt row never stops another row from drafting. On M5 Ultra two or
more decode rows already run without drafts, so this changes only a long-prompt row decoding alone. There, two-draft
rounds cost more than they gain.
The engine side is mlx-swift-lm #546, the plan-time cohort check behind
CBv2MTPConfig.maxDraftPromptTokens. With thelimit unset, #546 runs the current engine path. This branch is stacked on #2689 (SDK pin
e7918994a7, which alreadyhas the config field), so it builds as is. The behaviour follows once the pin includes #546.
DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS=0turns it off: the provider then passes no limit, and the engine runs exactly asbefore.
Linked issue
Closes #
Evidence for the limit
Production request profiles (0.10.17, M5 Ultra, rows decoding alone): two drafts ÷ plain by prompt bin, ×1.04–1.09
under 2K, ×0.95 at 4–12K, ×0.82 at 16–24K, ×0.73–0.63 at 24–64K.
Quiet M5 Ultra A/B on the same requests (lone rows, Gemma card sampling; report questions, code, CSV records to JSON,
multi-turn chat; ABBA):
On an earlier release-candidate build (the whole-request form of this limit) lone rows over 16,384 decoded ×1.075
(n 48). T = 0 output matched the previous build at or under the limit and matched MTP-off decode over it (56/56).
Change
MTPAutomaticVerificationPolicy.maxDraftPromptTokens(modelID:chipName:...):the offline benchmark override.
gemmaPromptLimitOnByDefault(true) is the build default. Turning it false in one line leaves an unset setting withno limit.
EngineV2SlotFactorypasses the value toCBv2MTPConfig.maxDraftPromptTokensand logs it once per slot.DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS(read once per process; the provider's launchd job forwards it):0,off,falseorno: no limit;Test plan
MTPConfigTests:gemmaQATLongPromptsOnM5UltraDecodeWithoutDrafts: 16,384 on M5 Ultra; the setting moves it or removes it; nil forevery other chip, model, the one-draft policy and the benchmark override, whatever the setting;
gemmaPromptLimitDefaultCanBeSwitchedOff: with the build default off, an unset setting gives no limit; a positivesetting still applies, and
0stays off;gemmaDraftPromptLimitParsesTheEnvironment;gemmaDraftPromptLimitRollbackIsForwarded.rows at the limit draft; a row over the limit beside a row under it keeps the table's depth; no limit, unchanged.
exactly
gemmaQATLongPromptsOnM5UltraDecodeWithoutDrafts,gemmaPromptLimitDefaultCanBeSwitchedOffandgemmaDraftPromptLimitRollbackIsForwarded.DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS=0(sameapp, ABBA, pre-declared bar): mixed concurrency (one long row with three short, and one with one), lone rows over
and under the limit, and T = 0 identity.
Components touched
Protocol / interface changes
DARKBLOOM_GEMMA_MTP_MAX_PROMPT_TOKENS(documented).Documentation impact
docs/reference/configuration.md,docs/provider/cli-reference.md,docs/architecture/inference.md(Gemma two-draft policy).Changelog
changelog.d/gemma-m5-ultra-long-prompt-plain-decode.mdand ranpython3 scripts/changelog.py check.Notes
differently, and near-ties can split. So a long-prompt row decoding alone matches MTP-off decode, not the previous
MTP-on output.
tables draft at two or more rows.
Before And After
flowchart LR S[Gemma QAT decode step on M5 Ultra] --> P{every drafting-eligible row's prompt > 16,384?} P -- no --> D[the chip's table, as before] P -- yes --> T[depth 0: ordinary chained decode]Refactor Pass
Refactor pass: no change justified.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.