Repository navigation
Conversation
The CUDA server (tensorfold/cuda/server.py) held tool calls back while they were generated and sent them only once the reply ended. A long call, such as writing a whole index.html, left the SSE stream silent for minutes, and clients behind LiteLLM dropped the connection after ~300 s idle. The answer now feeds ToolCallStreamer, as server/app.py already does, and its argument deltas go out each round. The handler sends only the calls the streamer could not follow. Requests with parallel_tool_calls=false keep the end parser, which picks their single call. Tests: the streamed required-call test checks the header plus argument deltas, a new test covers parallel_tool_calls=false sending the call whole, and the stop-string helper merges streamed arguments by index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
olexale
force-pushed
the
cuda-stream-tool-call-arguments
branch
from
September 29, 2026 22:01
eb66778 to
77619a9
Compare
ashhart
added a commit
that referenced
this pull request
Sep 30, 2026
…t resends resume (#124), streamed tool calls (#114) - CUDA prompts take bf16 activations by default; --prefill-fp8 restores FP8 prompts; both ranks agree on the precision; block-scaled FP8 checkpoints load (#126) - Flash Next keeps each prompt's state one token early, so identical resends and next thinking turns resume (#124) - Tool-call arguments stream as they are written on the CUDA server (#114) - Before M5, Flash Next hyper-connection projections of 8+ rows run in 8-row tiles with the per-row bits - --checkpoint-slots on CUDA (#125)
Owner
|
We measured it on a GB10 with Flash Next and a request that writes one file in a 3,236-token tool call: before, the whole call arrived at once when the reply ended, at 33.7 s; with your change its name arrives at 0.51 s and the first argument byte at 0.57 s, never more than half a second apart, and the joined call is byte-identical to the unstreamed one by token sha. The CUDA server now feeds the reply's answer text, never its reasoning, to the same streamer the Mac server uses, so every CUDA family gets the streaming, and a call cut at max_tokens streams a partial call with finish_reason length, as on the Mac. Decode and replies are unchanged, at one and four streams. |
BlivionIaG
referenced
this pull request
in BlivionIaG/TensorFold
Oct 20, 2026
…t resends resume (ashhart#124), streamed tool calls (#114) - CUDA prompts take bf16 activations by default; --prefill-fp8 restores FP8 prompts; both ranks agree on the precision; block-scaled FP8 checkpoints load (ashhart#126) - Flash Next keeps each prompt's state one token early, so identical resends and next thinking turns resume (ashhart#124) - Tool-call arguments stream as they are written on the CUDA server (#114) - Before M5, Flash Next hyper-connection projections of 8+ rows run in 8-row tiles with the per-row bits - --checkpoint-slots on CUDA (ashhart#125)
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.
The CUDA server sends nothing while a tool call is being written. A reply that writes a whole file in one
writecall streams no bytes until the reply ends, so clients with an idle timeout drop it: pi through LiteLLM, and Node'sfetch(undici), both cut the body after ~300 s of silence and reportterminated. The harness retries, the same prompt regenerates the same call, and it fails again at the same place.This is the second half of #99, which its author closed. That PR sent empty keepalive deltas. This one streams the call's arguments as they are written, the way the Mac server already does, so the client sees progress and gets the call without waiting for the end parser. References are at
main(7a00336).Cause
App.runhides tool-call markup from the answer (src/tensorfold/cuda/server.py:304),on_tokensemits only visible text (:332), and the handler sends the calls only afterrunreturns (:532). The Mac server feeds the answer intoToolCallStreamerand emits its deltas as they arrive (src/tensorfold/server/app.py:431). The CUDA server never got that step.The change
runbuilds aToolCallStreamer(tools)when the request has tools and allows parallel calls. Each round it feeds the raw answer (never the reasoning) and emits the streamer's deltas after the visible-text delta: a header with the call'sidandname, thenargumentspieces.runreturnscalls_streamed, the number of calls already sent. The handler sends only the calls after those, i.e. the ones the streamer could not follow, from the end parser as before.parallel_tool_calls: falsekeep the end parser, which picks their single call (parallel_tool_calls: falseis ignored, so a reply can carry several tool calls #21).Tests
tests/test_cuda_tool_choice.py: the streamed required call now arrives as one header namingget_weatherfollowed by argument deltas that join to{"city": "Oslo"}. A new test checks thatparallel_tool_calls: falsestill sends the call in one piece.tests/test_cuda_stop_strings.py: the streaming helper merges argument deltas by index. The stop-string test that puts a second call afterSTOPstill gets only the first call, so a call past the cut does not stream.On macOS the full suite gives 2956 passed, 701 skipped. On a DGX Spark (NVIDIA PyTorch 26.07), the 21 files that exercise the CUDA server and
ToolCallStreamergive 649 passed, 15 skipped, against 648 onmain; the extra one is the new test.On the GPU
One DGX Spark (GB10),
Vontra/Qwen3.8-Flash-Next-MLX-4bit-MTP,--parallel 3 --context 262144 --kv-dtype int8 --mtp-drafts 6 --mtp-confidence 0.60 --ple-on-ssd. One streamed request offering awrite(path, content)tool, asking for a single-file Breakout game in one call:main(7a00336)index.html, 47,443 charsThe two replies are identical: the change sends the same tokens, only earlier. With thinking on, this branch streamed 25k characters of reasoning, then the call from 156 s to the end at 517 s (35,035 tokens, a 71,617-character file) with no gap over 0.5 s. On
mainthat call's 361 s would pass silent, over the ~300 s idle cut of Node'sfetchand LiteLLM.Not covered
parallel_tool_calls: falserequests still hold their call until the reply ends.