fixes flaky test in c# test suite - #1008
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Serializes vision inference tests that share a model, preventing intermittent native request failures while preserving parallelism elsewhere.
Changes:
- Adds a class-level
SemaphoreSlim. - Gates both streaming and non-streaming vision requests with guaranteed release.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Do we know why we hit the exception? I would have expected multiple tests using different sessions against the same model to work as the FL session has its own state, and ORT sessions are typically stateless. Is there something at the GenAI level that doesn't support this sort of usage? |
|
my guess without seeing the code is that the different sessions sharing a multi-modal pre-processor? |
|
Is this the correct analysis about what's happening in GenAI? Root cause identified: PR #1008 is exposing the same ORT Extensions tokenizer race previously addressed for text inference in foundry-local#934, but through a second, unprotected tokenizer owned by ORT GenAI’s multimodal processor. The failing path is:
This matches the exact Windows-only exception and mechanism documented in #934. FL’s fl::Tokenizer mutex fixed the primary model tokenizer, but it cannot protect the separate tokenizer created internally by OgaMultiModalProcessor . Recommended fix: fix ORT GenAI, not the C# tests. Add synchronization inside Generators::Tokenizer around Encode() —and other operations touching the same ORTX tokenizer state—so every consumer, including MultiModalProcessor , is protected. Add a concurrent shared-tokenizer/multimodal-processor regression test. Longer-term, ORT Extensions could make cached splitter invocation state per-call or thread-local, but its current code explicitly assumes concurrent calls on one kernel instance do not occur. |
|
Yes, this is what I would guess the problem is. I fixed the tokenizer usage in FL to work around the not-thread sage tokenizer. But it looks like the processor also embeds the tokenizer which causes this problem. Solution is to guard the tokenizer in genai. Or to make the ort-extensions tokenizer thread safe so individual |
|
for now, we could put workaround the problem by guarding the processor and the tokenizer with the same mutex so only one thread can access either at a given time (in foundry-local) |
…ions (#1011) ### Summary Fixes an intermittent Windows `invalid string_view position` failure 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.
Vision_ImageBytesInput_ProducesResponsewas hitting the following error intermittently...Added a class-local SemaphoreSlim gate around vision requests to preserve parallelism while also allowing model sharing across tests