Repository navigation
[Conductor] Add Python client API - #4469
Conversation
8d65bed to
171586f
Compare
Icedcoco
left a comment
There was a problem hiding this comment.
Thanks for adding the Python client API. I think the overall direction is useful, and I had a few points that may be worth discussing before merging:
-
In
PyConductorClient::close(),setup_called_remainstrueafter the underlying client is closed. As a result, a subsequenthealth_check()may reportHEALTH_UNREACHABLErather thanHEALTH_NOT_INITIALIZED, and a failed re-setup could leave the state indicating that setup had succeeded. Would it make sense to reset this flag inclose()and update it consistently across setup attempts? -
conductor.pyis installed unconditionally, while_conductoris only built whenWITH_CONDUCTOR=ON. Users who build the package without conductor support will therefore have the Python module present, but importingmooncake.conductorwill fail because the native extension is absent. This does not affect users who do not import the module, but could we consider making the installation conditional or providing a clearer optional-feature behavior? -
The Python conversion currently uses integer keys for
dpandrank_matches, whereas the existing HTTP/msgpack response serializes rank keys as strings. Is the difference intentional? Keeping the shapes aligned might make it easier for clients to switch between the HTTP and Python APIs; alternatively, the distinction could be documented explicitly.
These points seem localized to the new conductor-facing API, and I did not see an obvious regression to the existing non-conductor functionality.
Reset initialization and replace the previous connection on every setup attempt. Explain missing optional Conductor support without masking extension loading errors. Use string rank keys and expose device-memory cache hits as device in the Python API. Add lifecycle and HTTP equivalence regressions, and clarify API conventions in docstrings.
8aaa2dd to
094d67f
Compare
Thanks for the review. I have addressed the three points:
|
|
Heads-up: #4469 and #4588 were merged about a minute apart, and together they break the build on From the The fix looks like a two-line change in |
Description
Expose the existing Conductor RPC client through
mooncake.conductor.ConductorClient, allowing Python applications toregister serving instances, query prefix-cache matches, and inspect Conductor state.
_conductorpybind11 extension for setup, close, health checks, queries, registration, unregistration,service listing, and global view inspection.
with
ValueError.WITH_CONDUCTOR=ON.libasio.soin Conductor-only Python installations so the native extension can resolve its runtimedependency.
Installation rules and argument validation are included here so the Python API is complete when introduced. Default
enablement and release-wheel integration are handled by #4470.
Related PRs and merge order
This is part 2 of the series split from #4457:
Blocks #4470. Remaining merge order: #4469 → #4470.
Together, these PRs replace the scope of #4457.
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Built a new source wheel in a separate build directory with
WITH_CONDUCTOR=ON,WITH_TE=OFF,WITH_STORE=OFF,USE_TENT=OFF, andUSE_ETCD=OFF. Installed that wheel into a new virtual environment and used the server executable built from this same commit.Test commands:
Paths are abbreviated below.
INSTALLED_PYTHONis the new virtual environment's interpreter;CONDUCTOR_BINARYpoints to the newly built server.VERIFY_DIRcontains the external validation helpers.All installed-package tests ran with
PYTHONPATH,PYTHONHOME,LD_LIBRARY_PATH, andLD_PRELOADremoved. The E2E helper preserves the repository's two original tests and replaces only their build-tree import/preload setup with an import from the installed wheel.Test results:
Unit tests pass
Integration tests pass (if applicable)
Manual testing done (describe below)
Fresh Conductor-only wheel build, installation, and isolated import passed. The archive contains
conductor.py, the CPython 3.13_conductorextension, andlibasio.so; imported module paths point into the new virtual environment.118 installed-package tests passed: 80 native registration validation cases, the two original real-server E2E cases adapted as described above, and 36 external regression cases.
The external regressions exercise real ZMQ event ingestion and prefix-cache hits, vLLM golden vectors, SGLang storage tiers, tenant/instance filtering, concurrent queries, registration/unregistration, timeout/error handling, and reconnect/lifecycle behavior. These helpers are validation artifacts, not additional tests committed in this PR.
17 wrapper and project packaging tests passed. The wrapper unit tests use a stub native client; native behavior is covered separately by the installed-package tests above.
Client construction, uninitialized health status, and close passed in an isolated installed-package smoke check.
PR-scoped pre-commit, changed-line formatting, and whitespace checks passed on this branch.
The new wheel is a host Linux wheel, not a manylinux release artifact. Other Python ABIs, accelerator platforms, and hardware execution were not tested in this branch validation.
Checklist
./scripts/code_format.shPR-scoped pre-commit and changed-line formatting passed. API docstrings are included; no standalone documentation page is added.
The human self-review checkbox is left for the submitter to confirm. The change is below the RFC size threshold after excluding tests and configuration; no RFC issue is claimed.
AI Assistance Disclosure