Repository navigation
serve: advance GLM and DSML tool calls from their cursor, scanning and streaming only the new text - #1010
Conversation
…d streaming only the new text
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains.
Non-blocking
⚠ Guard scanning independently of allocation: crates/serve/tests/callstream.rs:643. Replacing the cursor search at crates/serve/src/glmxml.rs:334 with self.buf.find(m.call_close) preserves the output and allocation assertions while restoring quadratic scanning.
For N equal b-byte argument pushes, the search ranges contain at least b × N × (N+1)/2 argument bytes [derived]; elapsed time is only printed. Add a deterministic bound on search work so this regression fails the test.
Checked
Duplicates: dryer reported zero candidate pairs. Qwen, GLM, and DSML share Reading, held, and read_value in callstream.rs; grammar transitions remain format-specific.
Complexity: diagnostics report new GLM CallRead::advance = 25 and DSML InvokeRead::advance = 19. Both use grammar-state matches. Complexity alone yields no finding.
Silent failure: typed GLM JSON failures reach KvError; malformed DSML returns content or Diverged. Name stages precede value stages.
Tests (static mutation analysis): omitting sent-length updates, accepting changed argument prefixes, ignoring divergence, or releasing held tag tails contradicts the changed unit assertions. Replaying cut arguments fails fragment equality; swallowing completed argument errors fails the integration assertions.
Gates: the Qwen allocation gate is extended to GLM, Solar, and DSML; its cap remains 128 times argument bytes. The PR body supplies FAIL-first allocation output.
Escape catalog: C1–C4 do not match the changed Rust files. No ledger lessons apply.
Notes
Validation was static; Rust tests were not rerun. The PR reports host-test results.
Add the measured base/head hashes, exact model filename, and just gate-* command output to complete the supplied performance/GPU evidence. The card line and application probe alone do not qualify.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
GLM, Solar, DSML 도구 호출 스트림이 push마다 전체 버퍼를 다시 읽던 것을 새로 들어온 텍스트만 읽도록 바꿨습니다.
What and why
Streaming a tool call in the GLM key/value markup (also used for Solar) or in DSML re-parsed the whole buffer on every push and re-escaped and cloned all arguments so far, so one long string argument cost quadratic time and memory. Qwen's XML stream already reads from a cursor. This PR gives the GLM and DSML scans the same shape: each keeps its own cursor, reads only the new text and sends only the new arguments. The cursor, the sent length and the value reader live once in
crates/serve/src/callstream.rs, and the Qwen scan uses them too.Release notes: Changed: streaming a long tool-call argument in the GLM, Solar and DSML formats now costs time and memory linear in its length instead of quadratic.
Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": removed. The call cursor, sent-length bookkeeping and value reader thatqwenxml.rscarried now live incrates/serve/src/callstream.rs:70(Reading) and:293(read_value), andglmxml.rs,dsml.rsandqwenxml.rsall use them.What I ran
Allocation and host time for one string argument of 294000 bytes streamed in 3000 lines, one push per line, from
crates/serve/tests/callstream.rs(hw_long_string_stream_is_linear, debug build):Output of that command on the base code:
The test limits allocation to 128 times the argument bytes and covers both Qwen framings, GLM, Solar and DSML.
Host tests:
The six results are
lib,callstream,dsml,glmxml,hermesandqwenxmlin that order.Real binary on an RTX 5090, with an existing Qwen3.6-35B-A3B Q4_K_M model.
bloomery-servewas started once per template (Qwen3-Coder, GLM, Solar, V4.1 DSML) with--model qwen3 --ctx 8192 --parallel 1 --no-mmprojand--chat-template-filefor the three non-Qwen templates. A forced call with a 4864-byte string argument was sent once without and once withstream, and the streamed fragments were joined and compared byte for byte with the non-stream arguments:AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.