feat(inference): per-request VLM model override#64
Merged
Conversation
Adds an optional `model` field to `DescribeRequest` and `CropDescribeRequest` so callers can pick a different upstream model per request without a server reload. Threaded through `TrioCore.analyze_video/analyze_frame` and `BaseBackend.generate/stream_generate`. `RemoteHTTPBackend` honors the override on the OpenAI-compatible chat.completions call (falls back to the configured `remote_vlm_model` when omitted). Local backends (transformers, mlx, tome, compressed) log a one-shot warning and ignore the override since they cannot swap models per request — `BaseBackend._warn_model_override_once` centralizes this. Use case: route VLM scene-describe and segmentation ground-region requests to different upstream Qwen models from a single trio-core instance. Tests: two new RemoteHTTPBackend tests cover the override path and the fallback to the configured default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Description
Adds an optional
modelfield toDescribeRequestandCropDescribeRequestso callers can pick a different upstream model per request without restarting the server. The cortex client uses this to route VLM scene-describe and segmentation ground-region requests to different upstream Qwen models from a single trio-core instance (e.g.qwen3-vl-flashfor scenes,qwen3.6-plusfor segmentation).Type of Change
Changes
DescribeRequest/CropDescribeRequest: add optionalmodel: str | None(defaultNone)/api/inference/describeand/api/inference/crop-describehandlers: forwardreq.modelintoengine.analyze_frame(...)TrioCore.analyze_video/analyze_frame: accept and forwardmodelBaseBackend.generate/stream_generate: gain optionalmodelkwargRemoteHTTPBackend: usesmodel or self._remote_modelin the upstreamchat.completions.createcall; log line includes the effective modelBaseBackend._warn_model_override_once(model)— one warning per backend instance, then ignore (local backends can't swap models per-request)When the request omits
model, behavior is identical to today.Test Plan
python -m pytest tests/ -vfor backends/engine/config/inference_router → 60 passed)test_generate_uses_per_request_model_override— asserts the OpenAI client receives the per-request modeltest_generate_falls_back_to_configured_model— asserts fallback to_remote_modelwhen override isNonepython examples/run_regression.py) — not run; this PR doesn't change inference math (only routes the model name through), and remote inference depends on a live DashScope endpointChecklist
modelis optional with defaultNoneand existing callers are unaffected🤖 Generated with Claude Code