Skip to content

bug: cover list_models tolerance for stale replica uids - #5168

Merged
qinxuye merged 3 commits into
xorbitsai:mainfrom
OliverBryant:test/list-models-stale-uid-5167
Jul 28, 2026
Merged

bug: cover list_models tolerance for stale replica uids#5168
qinxuye merged 3 commits into
xorbitsai:mainfrom
OliverBryant:test/list-models-stale-uid-5167

Conversation

@OliverBryant

Copy link
Copy Markdown
Collaborator

What

Adds regression tests for SupervisorActor.list_models so a failed model launch can no longer break GET /v1/models.

Why (#5167)

When a model launch fails during engine init (e.g. vLLM Engine core initialization failed), the worker may still report the replica uid via worker.list_models() while the supervisor has already dropped its _model_uid_to_replica_info entry. Before #5087, list_models looked that uid up directly and raised a bare KeyError ('qwen3.5'), so GET /v1/models returned 500 and every healthy model disappeared from the list.

#5087 (commit 40e52832c) already fixed the behavior by skipping stale, un-tracked uids, but the path had no test coverage. These tests lock that behavior in.

Tests

  • test_list_models_drops_stale_uid_without_replica_info — worker reports both a healthy qwen3-0 and a stale qwen3.5-0 left by a failed launch; asserts the stale uid is dropped (no KeyError) and qwen3 is still listed with the correct replica count. Reverting the fix: drop stale running models without replica info in supervisor.list_models #5087 guard makes this test fail with KeyError.
  • test_list_models_returns_healthy_models — multi-replica happy-path baseline.

Both pass; pre-commit (black/flake8/isort/mypy/codespell) is green.

@XprobeBot XprobeBot added this to the v2.x milestone Jul 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new test file xinference/core/tests/test_list_models.py to verify that list_models correctly drops stale model UIDs lacking replica information and returns healthy models. The feedback suggests improving code readability by adding type annotations to DummySupervisor and making the test assertions more robust by verifying the exact size of the returned dictionary.

Comment thread xinference/core/tests/test_list_models.py Outdated
Comment thread xinference/core/tests/test_list_models.py
@OliverBryant OliverBryant changed the title test(supervisor): cover list_models tolerance for stale replica uids (#5167) bug: cover list_models tolerance for stale replica uids (#5167) Jul 13, 2026
@XprobeBot XprobeBot added the bug Something isn't working label Jul 13, 2026
@OliverBryant
OliverBryant force-pushed the test/list-models-stale-uid-5167 branch from 4da5b92 to 963a3e1 Compare July 13, 2026 03:52
@OliverBryant OliverBryant changed the title bug: cover list_models tolerance for stale replica uids (#5167) bug: cover list_models tolerance for stale replica uids Jul 13, 2026
@OliverBryant
OliverBryant force-pushed the test/list-models-stale-uid-5167 branch from 963a3e1 to 80e95d4 Compare July 13, 2026 04:23
@OliverBryant

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@XprobeBot XprobeBot modified the milestones: v2.x, v3.x Jul 19, 2026
…orbitsai#5167)

A failed model launch (e.g. vLLM engine core init failure) can leave a
worker reporting a replica uid the supervisor no longer tracks in
_model_uid_to_replica_info. Before xorbitsai#5087 this raised a bare KeyError from
list_models, so GET /v1/models returned 500 and hid all healthy models.

Add regression tests asserting list_models drops the stale, un-tracked
uid instead of raising, and still lists healthy models with the correct
replica count.
Extend the list_models regression suite to the multi-worker cache
fallback path: when one worker's list_models() times out or crashes,
the supervisor must serve that worker's last cached result and still
merge healthy workers, and a worker that fails before ever caching
must not break the healthy listing.

Disabling the _fetch_one fallback makes the cache test fail.
Two changes on main broke the fixtures:

- list_models now reads _worker_model_gpu_memory to surface per-model
  GPU memory in /v1/models; DummySupervisor must provide it.
- build/parse_replica_model_uid switched to a reserved '-rep{n}' suffix
  (xorbitsai#5198) so names like 'llama-2' are no longer ambiguous. Build replica
  uids via build_replica_model_uid instead of hardcoding '-0', so the
  fixtures track the format automatically.
@OliverBryant
OliverBryant force-pushed the test/list-models-stale-uid-5167 branch from 52014d3 to 4f7a14c Compare July 27, 2026 07:23

@qinxuye qinxuye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qinxuye
qinxuye merged commit b8ce640 into xorbitsai:main Jul 28, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants