Enable model-selected Engine chat batching - #1071
Draft
bmehta001 wants to merge 2 commits into
Draft
Conversation
Use each model's genai_config batching contract so independent chat sessions can share an ORT GenAI Engine while Generator models retain their existing behavior. Files changed: - Add the owner-thread Engine dispatcher and per-session adapter. - Route chat creation, continuation, cancellation, usage, and option changes through the selected backend. - Parse and validate static and dynamic Engine configuration. - Add configuration, template, concurrency, and search-option coverage. - Pin ORT GenAI and packaging to 0.15.3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b90e66e-af55-404d-b606-7899f6f73c54
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Remove compatibility branches for OGA releases without Engine support so missing APIs fail during compilation instead of at model load. Files changed: - sdk_v2/cpp/CMakeLists.txt - sdk_v2/cpp/src/inferencing/generative/chat/chat_session.cc - sdk_v2/cpp/src/inferencing/generative/genai_model_instance.cc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9b90e66e-af55-404d-b606-7899f6f73c54
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.
Summary
genai_config.jsonChatSessionsmax_batch_sizeEngine integration details
Missing assistant-turn boundary
ORT GenAI Engine does not append or retain a generated EOS token in the request's logical sequence. A later
BeginTurnmust therefore include the model-specific tokens that close the prior assistant turn before introducing the next user turn. The Generator path already retains EOS, so reusing its append fragment caused dynamic Engine sessions to lose conversational context even though the request and KV cache remained resident.This change derives the continuation boundary from the model's own chat template using a synthetic assistant marker, removes the marker, and submits the remaining boundary plus new-turn fragment. This avoids hard-coding Qwen token IDs or template syntax.
Per-turn output limits
The initial Engine turn received
max_output_tokens, but retained turns calledBeginTurnwithoutOgaTurnOptions. Foundry could stop reading at its external limit while the Engine still considered the turn active, making the next continuation invalid and allowing uncapped work when callers relied on the default limit.Every Engine turn now receives an explicit resolved limit, including the 2048-token text default. Foundry waits for the corresponding terminal event, consumes exact per-turn Engine usage, and recreates retained state when request-level sampling settings that are baked into
OgaGeneratorParamschange.Backend contract
engine.dynamic_batchingengine.static_batchingEngine selection is limited to text chat models. Multimodal Engine declarations fail at model load rather than failing later during a request.
Validation
mainEngine APIs4,6,8, and10sapphirewhile a peer request concurrently returned14Dependency assumption
This draft pins
Microsoft.ML.OnnxRuntimeGenAI.Foundryto 0.15.3. It assumes that release contains the validated Engine C/C++ API and the static batching capacity behavior currently available in the tested upstream build.