Skip to content

feat(inference): add mooncake-master entrypoint and Kubernetes Mooncake client setup (ENG-9128) - #4916

Open
cabrinha wants to merge 2 commits into
mainfrom
feat/k8s-mooncake-offload-eng-9128
Open

cabrinha wants to merge 2 commits into
mainfrom
feat/k8s-mooncake-offload-eng-9128

Conversation

@cabrinha

@cabrinha cabrinha commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Keeps Mooncake KV-cache offload configuration and launch logic inside prime-rl (matching prime-rl#4887's thin-orchestrator boundary) for ENG-9128.

  • Mooncake master module (python -m prime_rl.entrypoints.mooncake) (prime_rl.configs.mooncake.MooncakeMasterEntrypointConfig, src/prime_rl/entrypoints/mooncake.py): reads mounted inference.json (and optional --role-configs /etc/prime-rl/inference-prefill.json /etc/prime-rl/inference-decode.json for disaggregated PrimeRuns), derives -default_kv_lease_ttl and optional disk path, and execs mooncake_master.
  • Kubernetes mooncake_client setup in inference_local (src/prime_rl/entrypoints/inference.py, src/prime_rl/utils/process.py):
    • Reuses wait_for_port (extended with optional process: Popen early-exit checking) to wait for master RPC (50051) and HTTP metadata (8080).
    • Starts mooncake_client when cpu.num_bytes > 0 (reading PRL_INFERENCE_HOST / POD_IP, with cluster MOONCAKE_DEVICE_NAME taking precedence over recipe offload.device_name), writes the standalone-store MOONCAKE_CONFIG_PATH JSON, sets PYTHONHASHSEED=0, watches mooncake_client mid-run (triggering SIGTERM shutdown on unexpected exit, matching watch_router), and cleans up on shutdown.
    • Fails fast when kv_cache_offload.type == "mooncake" runs without either MOONCAKE_MASTER_HOST or MOONCAKE_CONFIG_PATH. Also sets PYTHONHASHSEED=0 for native offload.
  • Validation & docs (packages/prime-rl-configs/src/prime_rl/configs/rl.py, src/prime_rl/entrypoints/rl.py, src/prime_rl/entrypoints/launcher.py, docs/inference.md): moves the local Mooncake check to rl() / launch() via require_mooncake_store (failing before prepare_run / pre_download_model when slurm=None and neither MOONCAKE_MASTER_HOST nor MOONCAKE_CONFIG_PATH is set) so Kubernetes RLConfig / dump_rl_components accepts type = "mooncake"; SLURM launch templates remain untouched.

Companion PR

Verification

  • uv run --frozen ruff check and ruff format --check: passed
  • uv run --frozen pytest tests/unit/test_pd_launch.py tests/unit/test_router_launch.py tests/unit/test_modelexpress_server.py (12 passed)
  • uv run --frozen pytest tests/unit/test_configs.py -k "mooncake or pd_role or pd_bidirectional or pd_spill or dump_rl_components or default_moe_backend or for_pd_role" (8 passed)

@wiz-prime-intellect

wiz-prime-intellect Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 3 Medium
Software Management Finding Software Management Findings -
Total 3 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

@cabrinha
cabrinha force-pushed the feat/k8s-mooncake-offload-eng-9128 branch from a4f7a3c to 90e443f Compare December 2, 2026 22:56
@cabrinha
cabrinha marked this pull request as ready for review December 2, 2026 22:56
@cabrinha
cabrinha force-pushed the feat/k8s-mooncake-offload-eng-9128 branch from 90e443f to 7dbd184 Compare December 3, 2026 00:09
Comment thread src/prime_rl/entrypoints/mooncake.py Resolved
@cabrinha
cabrinha force-pushed the feat/k8s-mooncake-offload-eng-9128 branch from 3f18da8 to 54d3af0 Compare December 3, 2026 21:00
@cabrinha
cabrinha requested a review from samsja December 3, 2026 21:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants