← Back to Pull requests

fix(api): avoid routing turns for audio capability queries #6141

Open
unknown opened this pull request with 333 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 16, 2026 11:27 UTC
Author

With two replicas and autoscaling disabled, querying audio capabilities immediately before each realtime connection repeatedly selects the same session replica. When the first session remains open at the default one-session limit, the second connection receives capacity_exceeded while the other replica is idle. The capabilities preflight is already documented in doc/source/user_guide/realtime.rst.

The capabilities lookup advances the same round-robin scheduler as realtime discovery, so each preflight/connection pair consumes two turns.

Add an inspection option to the existing model lookup and use it for audio capabilities. Inspection follows the current replica-selection policy without advancing the shared scheduler, preserving its draining and avoidance checks. Capabilities still come from the loaded adapter. If the first inspected replica is still loading, the probe tries the remaining eligible replicas in policy order without advancing the inference cursor. Default inference routing, P/D lookup behavior, and adapter implementations remain unchanged. General capacity-aware session retries are outside this change.

| Two-replica request pattern | Before | After |
| --- | --- | --- |
| Session-opening lookups only | 0, 1, 0, 1 | 0, 1, 0, 1 |
| Capabilities before each lookup | 1, 1, 1, 1 | 0, 1, 0, 1 |
| Two connections with preflights, first kept open | Second refused | Both start, one per replica |

Regression coverage in xinference/api/tests/test_audio_capabilities.py checks unchanged response/access behavior, alternation through two realtime runtimes, and preservation of replica selection when replica 0 is unavailable or draining. xinference/api/tests/test_realtime_api.py checks that the second session starts on the other replica while the first remains open.

VALIDATION: On Ubuntu 24.04.5 at eb2f5880 (base 4615ec0d; the last commit was checked against e585c1e1), xinference/api/tests/test_audio_capabilities.py passes 10/10 on Python 3.12.3 with Transformers 5.23.0, on Python 3.12.3 with the Transformers 4.57.6 CI pin, and on Python 3.10.22; with the production file reverted to e585c1e1, the new readiness cases fail. On Python 3.12, the test modules that exercise the changed module, including the real-cluster xinference/core/tests/test_restful_api.py, give 2013 passed, 7 failed and 24 skipped; no test fails there that does not also fail on the previous head in that environment. Pre-commit (isort, mypy, codespell) passes on the changed files, and mypy over all 1176 source files reports no issues.

AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).

Diff: 333 lines (+249 / -84) across 4 files Reviewer: Jackmeson1 Review duration: 586m
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 333 lines diff across 4 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
46%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.348
Shallow Review Depth shallow_review_depth
0.344
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #6141"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 46.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 47.1% (MEDIUM) · Higher = larger blast radius
47.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 46.7% · Lower = rushed or shallow review
46.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 25.1% · Safe to merge
25.1%