Repository navigation
fix(slurm): complete proxy lifecycle and overload validation #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nabinchha
merged 5 commits into
feat/slurm-execution
from
codex/1103-slurm-proxy-lifecycle
Oct 30, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
30a420e
fix(slurm): monitor health and drain endpoints
nabinchha f499303
test(slurm): add live vLLM overload acceptance
nabinchha d7a3db1
test(slurm): record live overload acceptance
nabinchha 033b5ae
fix(slurm): reject success after health failure
nabinchha 868268d
fix(slurm): signal endpoint tasks before draining
nabinchha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
105 changes: 105 additions & 0 deletions
105
packages/data-designer-slurm/src/data_designer/slurm/runtime/health.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Continuous aggregate health checks for a running allocation.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import http.client | ||
| import json | ||
| import time | ||
| from collections.abc import Mapping | ||
| from datetime import UTC, datetime | ||
|
|
||
| from data_designer.slurm.runtime.errors import SlurmRuntimeError, SlurmRuntimeErrorCode | ||
| from data_designer.slurm.state import ( | ||
| AttemptReadiness, | ||
| DeploymentReadiness, | ||
| ProbeEvidence, | ||
| ProbeOutcome, | ||
| ReadinessState, | ||
| SlurmStateWriter, | ||
| ) | ||
|
|
||
| _HEALTH_TIMEOUT_SECONDS = 6.0 | ||
| _MAXIMUM_HEALTH_BYTES = 4096 | ||
|
|
||
|
|
||
| def monitor_runtime_health( | ||
| writer: SlurmStateWriter, | ||
| readiness: AttemptReadiness, | ||
| endpoint_ports: Mapping[str, int], | ||
| *, | ||
| poll_interval_seconds: float = 1.0, | ||
| ) -> None: | ||
| """Publish health evidence until readiness stops or a required endpoint fails. | ||
|
|
||
| The allocation controller owns process termination and attempt finalization. | ||
| This monitor fails on service loss even if all serving processes remain alive. | ||
| """ | ||
| if poll_interval_seconds <= 0: | ||
| raise ValueError("health poll interval must be positive") | ||
| if set(endpoint_ports) != {deployment.deployment_id for deployment in readiness.deployments}: | ||
| raise ValueError("health endpoints must match readiness deployments") | ||
| while readiness.state is ReadinessState.READY: | ||
| readiness = writer.write_readiness(probe_runtime_health(readiness, endpoint_ports)) | ||
| if readiness.state is ReadinessState.FAILED: | ||
| raise SlurmRuntimeError(SlurmRuntimeErrorCode.STEP_FAILED, "required inference service lost health") | ||
| time.sleep(poll_interval_seconds) | ||
| readiness = writer.load_readiness(readiness.shard_id, readiness.attempt_id) | ||
|
|
||
|
|
||
| def probe_runtime_health(readiness: AttemptReadiness, endpoint_ports: Mapping[str, int]) -> AttemptReadiness: | ||
| """Check every logical endpoint and preserve per-deployment backend counts.""" | ||
| deployments: list[DeploymentReadiness] = [] | ||
| for deployment in readiness.deployments: | ||
| count = _ready_backend_count(endpoint_ports[deployment.deployment_id], deployment.expected_backends) | ||
| healthy = count == deployment.expected_backends | ||
| observed_at = datetime.now(UTC) | ||
| deployments.append( | ||
| deployment.model_copy( | ||
| update={ | ||
| "state": ReadinessState.READY if healthy else ReadinessState.FAILED, | ||
| "ready_backends": count, | ||
| "last_probe": ProbeEvidence( | ||
| observed_at=observed_at, | ||
| outcome=ProbeOutcome.SUCCESS if healthy else ProbeOutcome.FAILURE, | ||
| reason_code="runtime_healthy" if healthy else "runtime_health_lost", | ||
| redacted_message=f"{count} of {deployment.expected_backends} backends ready", | ||
| ), | ||
| } | ||
| ) | ||
| ) | ||
| return readiness.model_copy( | ||
| update={ | ||
| "revision": readiness.revision + 1, | ||
| "updated_at": datetime.now(UTC), | ||
| "state": ( | ||
| ReadinessState.READY | ||
| if all(deployment.state is ReadinessState.READY for deployment in deployments) | ||
| else ReadinessState.FAILED | ||
| ), | ||
| "deployments": tuple(deployments), | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| def _ready_backend_count(port: int, expected: int) -> int: | ||
| connection = http.client.HTTPConnection("127.0.0.1", port, timeout=_HEALTH_TIMEOUT_SECONDS) | ||
| try: | ||
| connection.request("GET", "/health", headers={"Connection": "close"}) | ||
| response = connection.getresponse() | ||
| body = response.read(_MAXIMUM_HEALTH_BYTES + 1) | ||
| if response.status not in {200, 503} or len(body) > _MAXIMUM_HEALTH_BYTES: | ||
| return 0 | ||
| payload = json.loads(body) | ||
| if not isinstance(payload, dict) or type(payload.get("backends")) is not int or payload["backends"] != expected: | ||
| return 0 | ||
| count = payload.get("backends_ready") | ||
| if type(count) is not int or not 0 <= count <= expected: | ||
| return 0 | ||
| return count if response.status == 200 or count < expected else 0 | ||
| except (OSError, http.client.HTTPException, ValueError): | ||
| return 0 | ||
| finally: | ||
| connection.close() |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the client's last
dd_require_runningcheck, the monitor can saveFAILEDreadiness before cleanup stops it.dd_stop_stepsignores its exit status, and the controller then runssucceed._succeedreplaces readiness withSTOPPEDand publishes the winner without checking the recorded failure. An attempt can therefore succeed despite a recorded loss of required backend health.After stopping the monitor, check its saved readiness before allowing success.
Prompt To Fix With AI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 033b5ae. After cleanup stops the monitor,
_succeedloads its final persisted readiness and rejects winner publication if it contains a health failure, including failure evidence retained inSTOPPEDreadiness. Failure cleanup also preserves terminal readiness so the attempt can be marked failed without an invalidSTOPPEDβFAILEDreadiness transition.Regression tests cover a late health failure with a valid candidate output, retained failure evidence after readiness stops, and failure cleanup after winner publication fails. Validation: full Slurm suite 2,116 passed, 1 skipped; focused proxy/health/admission suite 54 passed.