Skip to content

Allow a server to suppress output token IDs - #846

Open
audreyt wants to merge 1 commit into
incoai:mainfrom
audreyt:feat/server-token-mask
Open

audreyt wants to merge 1 commit into
incoai:mainfrom
audreyt:feat/server-token-mask

Conversation

@audreyt

@audreyt audreyt commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Add an optional --suppress-tokens FILE server option for model-specific output token IDs. The file is read at engine startup and can contain a JSON array or an object with a target_token_ids array. The flag is scoped to a model's command line so switching models in the desktop app cannot carry a mask over to a different tokenizer.

The target sampler excludes those IDs before selection, including the initial token and greedy or sampled DFlash2 verification rows. A suppressed draft proposal has zero target probability. Prompt tokens and raw scoring are unaffected. Startup rejects invalid, duplicate, out-of-vocabulary, and stop IDs. A request that would force a suppressed thinking-end token is refused. With the option omitted, no mask buffer or Metal dispatch is added.

Verification

  • Added frontend-to-native command-line golden coverage and Metal regression coverage for initial and speculative selection, with greedy and sampled lanes and a suppressed draft candidate.
  • make check-python passed: 1,853 tests run, 8 skipped, with compilation, lint, and formatting checks also passing. The focused rerun of the 102 affected launcher, argument, startup, recovery, and packaging tests passed separately.
  • Both target-sampling and target-sampling-16 passed directly with MTL_SHADER_VALIDATION=1.
  • On M5 Max, tested Inkling-2-Mini and its DFlash2 draft through the native serving protocol. The base, single-ID, and existing 3,382-ID T1 configurations each emitted 385 tokens across four requests (first-token greedy, longer greedy, and two sampled).
  • With the flag omitted, the patched and clean upstream d40c250f binaries produced identical token IDs, speculative draft counts, and raw scores on the same requests.
  • Positive control: masking the unmasked first token 200001 changed the first token to 9850. No 200001 appeared in the masked batch, which accepted 273 speculative draft tokens.
  • Existing T1 mask: 0 of 385 output IDs intersected the mask, with 261 accepted draft tokens. The unmasked batch also had no T1 hits on these prompts, so the single-ID control is the direct exclusion test.
  • Native startup refused malformed JSON, booleans, fractions, a padded out-of-vocabulary ID, duplicates, and a stop ID. The native test refused a forced thinking-end conflict and returned identical finite raw scores with the mask enabled or disabled, including for the suppressed ID. A separate Metal regression puts a score-only lane and a generating lane in one batch and checks that only generation is masked; it failed before the lane-selection fix.
  • make check-source check-native-cpu check-native-build passed on the final patch. The full make check run reported Swift app failures; the same three cases reproduced in a focused rerun against the unchanged app bundle (login-shell settings, selected drawer tab visibility, and number formatting in the transcript).
  • The full regular Metal suite stopped in the GGUF projection test while compiling gguf_decode_q4k_m8_a under shader validation. The same pipeline and diagnostic reproduced on clean upstream d40c250f on the same machine.

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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