Skip to content

fix(vllm): unify weight-transfer HTTP handling - #47

Merged
CalvinXKY merged 1 commit into
mainfrom
aoshen/restore-vllm-timeout-response-parsing
May 30, 2026
Merged

fix(vllm): unify weight-transfer HTTP handling#47
CalvinXKY merged 1 commit into
mainfrom
aoshen/restore-vllm-timeout-response-parsing

Conversation

@aoshen02

@aoshen02 aoshen02 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #22 and rebased over #49 / current main. PR #49 merged the R3 routing-replay work and partially centralized the vLLM weight-transfer timeout path, but current main still had two issues in the vLLM control plane:

  • Response parsing failures were converted to {"ok": True, "raw": ...} in several endpoints, which can hide bad/plain-text responses as success.
  • init_weight_transfer_engine / init_weights_update_group still used a separate timeout path from the rest of the weight-transfer calls.

Why this is not duplicating #49

#49 was a routing replay feature PR. It did touch vllm_engine.py, and it left start_weight_update / finish_weight_update using a timeout helper, but it did not make response parsing fail loud and did not move all weight-transfer control-plane calls to a config-backed timeout. This PR is now scoped to those remaining control-plane fixes.

Changes

  • Replace the old fallback parser with a slime-style _response_json(response) helper:
    • raise_for_status() first.
    • Attach response.text to HTTP errors with Exception.add_note, matching the SGLang engine pattern.
    • Parse JSON directly and let invalid JSON fail instead of returning ok: True.
  • Add --vllm-weight-transfer-timeout-sec (default 900.0) as the vime config knob for vLLM weight-transfer HTTP control-plane calls.
  • Exclude that vime-only config knob from forwarding to vllm serve.
  • Route update_weights, start_weight_update, finish_weight_update, init_weight_transfer_engine, and init_weights_update_group through the same timeout helper.
  • Remove the old SLIME_VLLM_WEIGHT_TRANSFER_*_TIMEOUT_SEC env-var path from this code.

Tests

uv run --active python -m pytest tests/unit/backends/vllm_utils/test_vllm_engine.py tests/unit/backends/vllm_utils/test_arguments.py -q
# 66 passed, 2 warnings in 85.43s

uv run --active pre-commit run --files slime/backends/vllm_utils/arguments.py slime/backends/vllm_utils/vllm_engine.py tests/unit/backends/vllm_utils/test_arguments.py tests/unit/backends/vllm_utils/test_vllm_engine.py
# all selected hooks passed

AI assistance

AI assistance was used to inspect related PRs/reference implementations and update this PR. The human submitter should review every changed line and validate the behavior before merge.

@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 refactors the vLLM engine backend by introducing a helper function _response_json_or_fallback to safely parse JSON responses and handle decoding failures or non-dictionary shapes consistently. It also consolidates the timeout retrieval logic into a helper method _weight_transfer_http_timeout and adds corresponding unit tests. The reviewer recommended making the environment variable parsing within this timeout helper more robust by gracefully handling potential ValueError exceptions and falling back to a default value.

Comment on lines 591 to 596
return float(
os.environ.get(
"SLIME_VLLM_WEIGHT_TRANSFER_UPDATE_TIMEOUT_SEC",
os.environ.get("SLIME_VLLM_WEIGHT_TRANSFER_HTTP_TIMEOUT_SEC", "900"),
)
)

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.

medium

Parsing environment variables directly with float() can raise a ValueError if the variable is set to an empty string or a malformed value (e.g., by a user configuration error). It is safer to use defensive programming to handle empty or invalid values gracefully and fall back to the default timeout of 900.0 seconds while logging a warning.

        val = os.environ.get("SLIME_VLLM_WEIGHT_TRANSFER_UPDATE_TIMEOUT_SEC")
        if not val:
            val = os.environ.get("SLIME_VLLM_WEIGHT_TRANSFER_HTTP_TIMEOUT_SEC", "900")
        try:
            return float(val)
        except ValueError:
            logger.warning(
                "Invalid timeout value %r for weight transfer. Falling back to default 900.0s.",
                val,
            )
            return 900.0

@CalvinXKY

Copy link
Copy Markdown
Collaborator

LGTM. Rebase to solve the conflicts

@aoshen02
aoshen02 force-pushed the aoshen/restore-vllm-timeout-response-parsing branch from 6458b62 to d6af552 Compare May 30, 2026 01:46
@aoshen02 aoshen02 changed the title fix(vllm): restore weight-transfer timeout precedence and JSON response parsing fix(vllm): unify weight-transfer HTTP handling May 30, 2026
@aoshen02
aoshen02 force-pushed the aoshen/restore-vllm-timeout-response-parsing branch 2 times, most recently from 2e56cf5 to 2141840 Compare May 30, 2026 02:12


def _response_json(response: requests.Response) -> dict:
"""Return a JSON response using the same fail-loud behavior as SGLangEngine."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove “as SGLangEngine.”

Route vLLM weight-transfer control-plane responses through a single slime-style JSON helper: raise HTTP errors with response.text attached, then parse the JSON body directly. This removes the previous fallback that converted JSON parse failures into {"ok": True, "raw": ...}.

Replace the weight-transfer timeout env knobs with the vime config flag --vllm-weight-transfer-timeout-sec (default 900s), and make update_weights, start/finish_weight_update, init_weight_transfer_engine, and init_weights_update_group all read the same helper.

Tests cover the new config flag, action-table exclusion, config-driven timeout use, and fail-loud JSON/HTTP error behavior.

Signed-off-by: aoshen02 <aoshen@inferact.ai>
@aoshen02
aoshen02 force-pushed the aoshen/restore-vllm-timeout-response-parsing branch from 2141840 to 84f35cd Compare May 30, 2026 02:24
@CalvinXKY

Copy link
Copy Markdown
Collaborator

LGTM

@CalvinXKY
CalvinXKY merged commit dcbe4b4 into main May 30, 2026
11 of 13 checks passed
momo609 pushed a commit that referenced this pull request Jun 8, 2026
Route vLLM weight-transfer control-plane responses through a single slime-style JSON helper: raise HTTP errors with response.text attached, then parse the JSON body directly. This removes the previous fallback that converted JSON parse failures into {"ok": True, "raw": ...}.

Replace the weight-transfer timeout env knobs with the vime config flag --vllm-weight-transfer-timeout-sec (default 900s), and make update_weights, start/finish_weight_update, init_weight_transfer_engine, and init_weights_update_group all read the same helper.

Tests cover the new config flag, action-table exclusion, config-driven timeout use, and fail-loud JSON/HTTP error behavior.

Signed-off-by: aoshen02 <aoshen@inferact.ai>
@aoshen02
aoshen02 deleted the aoshen/restore-vllm-timeout-response-parsing branch June 8, 2026 14:17
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