Repository navigation
server: opt-in committed token IDs on chat and completion streams - #3285
Conversation
526328b to
d3acbec
Compare
|
CUDA check on an NVIDIA GB10 (sm_121), built from this change's previous head 526328b (the current head only moves the sink callback from
|
d3acbec to
be07074
Compare
|
Rebased onto main d6e9820 as be07074, keeping #3206's logprobs as they are. #3206 projects logprob entries onto prose, reasoning and tool calls, and a token shown in parts gets one entry per part, so one offset plus a run of IDs no longer describes a chunk's entries. The anchor now carries Host checks on the new head:
|
be07074 to
9baaafd
Compare
A stream that sends stream_options.tensorfold_token_stream_version: 1 interleaves tensorfold.token.chunk events (offset and committed IDs) with the usual chunks, and each chunk carries a tensorfold_stream anchor (token count, last ID, and each logprob entry's raw token position, shaped like the chunk's logprobs). Engine integrations such as exo's proposed TensorFold backend need the real IDs while generation runs, without retokenizing text that merges UTF-8 pieces, reasoning or tool syntax. capabilities --json advertises token_stream_versions [1]. Without the option the wire output is unchanged.
9baaafd to
9276208
Compare
TensorFold 1.2.9 ships token stream protocol version 1 (ashhart/TensorFold#3285). Point the requirement at the release and show where to get tensorfold-native: the release archives, or Homebrew on macOS.
An engine integration needs the committed token IDs while a stream runs, and the semantic deltas can't give them: one chunk can merge several tokens, split a UTF-8 character, or leave out reasoning and tool syntax, and retokenizing text is not exact. exo's TensorFold backend (proposed, not yet opened upstream) is the first user.
A client opts in with
stream_options.tensorfold_token_stream_version: 1on a streaming chat or completions request. The stream then interleavestensorfold.token.chunkevents (offset,token_ids) with the usual chunks, and every chunk carriestensorfold_stream(token_count, the lasttoken_id, andlogprob_positionswhen it has logprob entries: each entry's raw token position, shaped like the chunk'slogprobswithcontent,reasoning_contentandtool_callsgroups).capabilities --jsonliststoken_stream_versions: [1]. Unknown versions, non-streaming requests and Cortheon multi-round replies get a 400 before admission. Without the option the wire output is unchanged and the sink's token callback is null, so the default path does no extra work.docs/api.mddocuments the contract.Checked on macOS (M5 Max):
zig build test-token-stream-host: 27/27 on this head.zig build -Dfixed-cpu test-server-cpu: passes apart fromtest-server-deepseek-chat-host, which fails the same way on main at 948e748 (a DeepSeek V4.1 namespace prompt pin), so it is not from this change.The same change on ab78aef (this head differs only by main's
.asked = input.cancelon the same line ofchat.zig), built as the Metalnativebinary, servedmlx-community/Qwen3.5-2B-MLX-4bitthrough exo. At temperature 0 the exo path and direct TensorFold gave the same output hash, single and concurrent, and a stream dropped mid-reply released the native request within 0.2 s.Synthena (Ash's Agent)