Synchronize tokenizer and multimodal preprocessing across shared sessions - #1011
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Baiju Meswani (baijumeswani)
requested review from
Prathik Rao (prathikr) and
Scott McKay (skottmckay)
and removed request for
Copilot
August 18, 2026 05:55
Copilot started reviewing on behalf of
Baiju Meswani (baijumeswani)
August 18, 2026 05:55
View session
Copilot started reviewing on behalf of
Baiju Meswani (baijumeswani)
August 18, 2026 05:56
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Centralizes shared tokenizer and multimodal preprocessing synchronization to prevent concurrent tokenizer-state corruption.
Changes:
- Replaces
Tokenizerwith a synchronizedPreprocessorabstraction. - Routes chat, audio, and embeddings preprocessing through shared synchronization.
- Adds a concurrent vision-session regression test.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
sdk_v2/cpp/CMakeLists.txt |
Registers the new preprocessor source. |
sdk_v2/cpp/src/inferencing/generative/tokenizer.h |
Removes the superseded tokenizer wrapper. |
sdk_v2/cpp/src/inferencing/generative/tokenizer.cc |
Removes the old tokenizer implementation. |
sdk_v2/cpp/src/inferencing/generative/preprocessor.h |
Defines synchronized preprocessing ownership and APIs. |
sdk_v2/cpp/src/inferencing/generative/preprocessor.cc |
Implements synchronized tokenizer and multimodal operations. |
sdk_v2/cpp/src/inferencing/generative/genai_model_instance.h |
Replaces separate preprocessing resources with Preprocessor. |
sdk_v2/cpp/src/inferencing/generative/genai_model_instance.cc |
Creates and exposes the consolidated preprocessor. |
sdk_v2/cpp/src/inferencing/generative/embeddings/embeddings_session.cc |
Routes embedding tokenization through the preprocessor. |
sdk_v2/cpp/src/inferencing/generative/chat/onnx_chat_generator.cc |
Synchronizes chat and media preprocessing. |
sdk_v2/cpp/src/inferencing/generative/chat/chat_template.cc |
Routes template application and encoding through the preprocessor. |
sdk_v2/cpp/src/inferencing/generative/audio/onnx_audio_generator.cc |
Uses synchronized audio preprocessing and stream creation. |
sdk_v2/cpp/src/inferencing/generative/audio/audio_session.cc |
Uses the shared preprocessor for streaming decode setup. |
sdk_v2/cpp/test/sdk_api/vision_session_test.cc |
Tests concurrent sessions sharing one vision model. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Scott McKay (skottmckay)
previously approved these changes
Aug 18, 2026
Scott McKay (skottmckay)
approved these changes
Aug 18, 2026
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
Fixes an intermittent Windows
invalid string_view positionfailure when concurrent vision sessions share the same loaded model.Root cause
ORT Extensions tokenizer encoding is not reentrant. Foundry Local synchronized its model tokenizer previously, but ORT GenAI's shared multimodal processor owns a separate tokenizer that remained unguarded. Concurrent preprocessing could therefore corrupt mutable tokenizer state.
See discussion #1008 (comment) for details.