Skip to content

fix(server): bind parallel tool results to their call IDs for positional OGA templates - #1069

Merged
zaneni6 merged 1 commit into
ROCm:mainfrom
Allegro-ma-non-troppo:wp-30-oga-tool-result-correlation
Nov 19, 2026
Merged

zaneni6 merged 1 commit into
ROCm:mainfrom
Allegro-ma-non-troppo:wp-30-oga-tool-result-correlation

Conversation

@Allegro-ma-non-troppo

Copy link
Copy Markdown
Collaborator

Why

The two positional OGA Qwen templates render tool result bodies in message order without including tool_call_id. If two calls to the same function finish out of order, the model can receive their results under the wrong arguments even when the client sends the correct IDs.

What changed

  • For qwen3.5-oga-hipep:9b and qwen2.5-it-oga-hipep:14b, bind each parallel result to its call ID and order the results by the original call order. This happens after content validation and before prompt-cache lookup or SSE starts, including when tool_choice: "none" disables new calls.
  • Reject missing, duplicate, and unknown associations with HTTP 400 and an error.param pointing to the original request field. Do not match results across turns.
  • Leave single-call history, emitted call IDs, response formats, model templates, and cache policy unchanged.

Verification

Case Before (532081fa) This PR (10863379)
Same IDs and values, reversed delivery Both models could swap the two values Both models return the same mapping for either delivery order; both tokenizers produce identical tokens
Swap only the IDs Both models retained the old mapping Both models follow the new mapping; both tokenizers produce different tokens
Unknown ID with streaming requested HTTP 200 Indexed JSON 400 before SSE; the next valid request succeeds
  • Windows MSVC Release build and CPU tests passed (chat_tools, http_guard). The chat_tools test also passed with /W4 /permissive-.
  • Radeon 8060S: the three targeted HTTP tests passed on each model (6 total, no skips). They cover JSON and SSE, invalid histories and recovery, and named single-call round trips. Qwen3.5 reused all 109 prompt tokens for equivalent reordered history; Qwen2.5 returned the correct mapping with no cache hit.
  • Linux and other model packages were not tested locally. These results are for the PR head, not a build of the PR merged with the current main.

…ates

WP-30: Bind each parallel group before cache lookup and streaming. Opt in the two verified Qwen packages and report association errors against the original messages.
@zaneni6
zaneni6 merged commit b776ad3 into ROCm:main Nov 19, 2026
73 checks passed
zaneni6 added a commit to Allegro-ma-non-troppo/FastFlowLM that referenced this pull request Nov 19, 2026
Resolve the conflict with ROCm#1069 in RestHandler::ensure_model_loaded and
rest_handler.hpp: keep this PR's preflighted load (loaded_selection in
place of current_backend) and set ROCm#1069's positional_tool_results after
the load from the plan's catalog entry and the engine's backend.

Co-Authored-By: Claude <noreply@anthropic.com>
tawei-amd pushed a commit that referenced this pull request Nov 22, 2026
* feat(oga-hipep): Laguna 2.1 and Nemotron 3.5 Lightning

- model_list / model_info: laguna2.1-oga-hipep:33b-a3b and :118b-a8b
  and nemotron3.5-lightning-oga-hipep:30b-a3b, on pinned AMD gpuep
  packages with the upstream config.json
- TemplateChat frontend for the laguna and nemotron-h families,
  registered on oga-hipep only; text input only
- chat: GLM_XML tool calls for Laguna
  (<tool_call>name<arg_key>k</arg_key><arg_value>v</arg_value></tool_call>):
  detection, streaming parser and xgrammar structural tags. The grammar
  holds a string argument, which Laguna writes unquoted, to its
  minLength and maxLength, with the bounded-string rules of the Gemma 4
  grammar, now shared by both. Hy-Memory's template (NPU) also writes
  <arg_key>, but with <tool_sep> after the name, which this parser does
  not read: it stays on Hermes, as before.
- minja: tojson takes ensure_ascii, which Laguna's chat template writes
  for every non-string argument, and the tool-call probe recognises
  Laguna's <arg_key>, though not in Hy-Memory's <tool_sep> dialect,
  whose tool calls keep the polyfills, as before.
- OgaEngine: once a first run gives all-zero logits, a new generator runs
  a prompt's first token on its own. On hip-ep 0.5.3, Laguna 2.1's BOS
  in a run of 8 or more tokens leaves the cache wrong.
- Laguna 2.1 defaults to a 2048-token context. Its packages grow the KV
  cache by concatenation (ai.onnx Attention, past_present_share_buffer
  false), and on hip-ep 0.5.3 each token decoded at a context length the
  process has not decoded at before keeps 6-19 MiB of GPU memory until
  the process exits. On a Radeon 8060S with 96 GB of GPU memory, one
  reply decoded to 2048 tokens takes the process to about 78 GiB
  (Laguna-S) and 35 GiB (Laguna-XS); to 3072 tokens, Laguna-S spills
  past the GPU memory into shared memory, where decoding slows down.
  When that runs out too, Windows resets the GPU (LiveKernelEvent 141)
  and every request fails with "unspecified launch failure (719)" until
  flm restarts, as a package that grows its KV cache the same way did
  at the 32768 default. At 2048 both pass a tool call and its result,
  multi-turn recall, a reply forced to the cap (finish=length) and a
  prompt past it (HTTP 400).
- positional_tool_results on all three: their chat templates write a
  tool result without its tool_call_id, so the server puts the results
  of parallel calls in the order of the calls and refuses a history it
  cannot place (#1069). The API tests' positional cases run on them too.
- tests: chat_tools GLM (string length bounds too), minja and
  Hy-Memory cases; oga_hipep first-run case. cli.md lists the new tags and explains the
  2048 default; changes.py maps the TemplateChat frontend to its
  families.

* ci(hipep): test the TemplateChat families on a PR only when it touches them

A family missing from PR_GPU gets its smallest model on every pull
request that runs Test Windows HIPEP, so laguna2.1-oga-hipep:33b-a3b
and nemotron3.5-lightning-oga-hipep:30b-a3b would join the newest Qwen
and Gemma: 4 models and 69 GB instead of 2 and 33 GB.

- plan.py: laguna and nemotron-h in PR_GPU and PR_GPU_WHEN_TOUCHED,
  like gpt-oss. Their models run on a pull request that touches the
  family (the TemplateChat frontend or their catalog entries) and on
  the full tier.
- README, build-and-test.yml: the new families, and about 500 GB for
  every oga-hipep model, up from 400.

This branch was successfully deployed

1 active deployment
npu-approval — 10863379 Deployed Nov 19, 2026 by Allegro-ma-non-troppo via npu-gate #476
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.

2 participants