Repository navigation
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
…robs ahead of an unchanged reply echo: true puts the prompt's decoded ids in front of text and, with logprobs, each prompt token's entry (null for the first) ahead of the reply's, whose entries stay as without echo. max_tokens 0 with echo returns the prompt alone. Engines without prompt_logprobs, streams, messages bodies and non-boolean values are refused by name; prompt_logprobs keeps its own count.
…m the tokenizer's own FIM tokens With a nonempty suffix the server writes <|fim_prefix|>, the prompt, <|fim_suffix|>, the suffix and <|fim_middle|> from the tokenizer's own tokens, the code read as plain text, and the reply also ends at <|fim_pad|> and <|endoftext|> where the vocabulary holds them. Tokenizers without the three tokens, token-id or list prompts, messages bodies and non-string values are refused by name; without a suffix nothing changes.
ashhart
force-pushed
the
lead/completions-fim
branch
from
November 22, 2026 04:54
391bb1d to
4f4f63f
Compare
This branch has not been 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.
Code-completion clients (editor plugins, and APIs in the style of DeepSeek's and Codestral's FIM endpoints) send OpenAI's
suffixon/v1/completions:promptis the code before the cursor,suffixthe code after it, and the reply is the middle. TensorFold ignoredsuffix. This builds the model's fill-in-the-middle prompt from the tokenizer's own FIM tokens.What this changes
The prompt: in prefix-suffix-middle order, from the tokenizer's own tokens. First whatever the tokenizer puts before any prompt (a beginning-of-text token, if it has one), then
<|fim_prefix|>, the prompt,<|fim_suffix|>, the suffix and<|fim_middle|>.suffix.Client text: the prompt and suffix encode as plain text, so a marker spelled inside the code stays text and can't open a second FIM region.
Where a reply ends: at the model's own end tokens, and at
<|fim_pad|>and<|endoftext|>where the vocabulary has them. They are left out of the text like any end token, andignore_eos: trueturns them off too.suffix, the end set is exactly the model's, as before. The generation now takes its end tokens from the request, which equalssrv.eosfor every existing request.Streaming works.
No suffix: an absent,
nullor emptysuffixleaves the request unchanged.Refused with a 400 naming
suffix:suffix;messages;suffixwithecho: true, since echo would return the FIM prompt, markers included.Issue: n/a. This came from the 16 Nov check of competitor gap docs against main (llama.cpp's infill); no issue or PR covered it.
Stacked on: server: /v1/completions takes echo, the prompt's text and legacy logprobs ahead of an unchanged reply #3526 (
echoon/v1/completions), commits01b7063cdeand12564d479c. This PR addsa1e24f3b9e. Both PRs touchchat.Input,chat.zig's generation setup, the golden corpus anddocs/api.md. Stacking them saves a six-file conflict at landing. Land server: /v1/completions takes echo, the prompt's text and legacy logprobs ahead of an unchanged reply #3526 first, or this PR's head brings both.atc overlap --json: to run after review.Checks on this head
tools/pr_check.py: 0 errors, 1 advisory warning).zig build test-completions-fim-host(new step): 26/26. Against main's sources, 3 of the 5 new tests fail; the other two are an unchanged-behaviour check and the real-tokenizer check.TF_TOKENIZER_DIRSset to the published Qwen3.8-27B, Qwen3.5-0.8B and Nemotron 3.5 Lightning snapshots: the Qwen prompts carry their three whole marks, and Nemotron refuses.zig build test-logprob-offers-host test-eos-policy-host: pass, so echo's tests still pass on this head.zig build test-golden: 328/341 equal, 0 unexpected. That's both PRs' six new cases (suffix-null,suffix-empty,suffix-unsupportedfrom this one), regenerated withfreeze_cases.py. Security goldens 55/55.zig fmt --check,git diff --check: clean.Receipt
n/a for speed: without
suffix, requests are unchanged, with the same prompt ids and the same end set. With it, the prompt is new and the reply runs through the usual lane rounds. A device run on a served Qwen checkpoint is the follow-up.Checklist
The title and description match the head commit.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds.
Synthena (Ash's Agent)