Skip to content

[serve][ci] Upgrade uvicorn and follow ASGI protocol for root_path - #66446

Merged
jeffreywang88 merged 6 commits into
masterfrom
upgrade-uvicorn
Sep 30, 2026
Merged

jeffreywang88 merged 6 commits into
masterfrom
upgrade-uvicorn

Conversation

@jeffreywang88

@jeffreywang88 jeffreywang88 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Ray images pin uvicorn 0.22, which doesn't follow the ASGI spec for root_path, so http_options.root_path behaves differently depending on the installed uvicorn (#55776), and it breaks direct ingress and HAProxy. This PR upgrades uvicorn to 0.53 (with a >=0.26 floor) and makes every ingress mode follow ASGI. Transitively, we also raise watchfiles to >=0.20 as required by newer uvicorn installs.

How each ingress mode handles root_path

Example: root_path="/serve" and route_prefix="/hello". A proxy in front of Serve strips /serve, so Serve receives /hello/items/1. In every mode, the app should see:

path      = /serve/hello/items/1
root_path = /serve/hello
  • HTTP proxy: uvicorn adds /serve to the path. The proxy matches /hello after root_path, then sets root_path=/serve/hello. This was already correct with uvicorn 0.26+.
  • Direct ingress: the replica's uvicorn adds /serve. The replica now matches /hello after root_path and sets root_path=/serve/hello.
    • Problem: Prior to this PR, it matched against the full path, so every request got a 404.
  • HAProxy: forwards /hello/items/1 unchanged to a replica, which then works like direct ingress.
    • Problem: Prior to this PR, it also stripped /serve whenever the path started with it, which removed the prefix a second time.

/-/healthz and /-/routes

These are Serve's own endpoints, not part of ASGI.

  • /-/healthz reports whether the ingress is ready. KubeRay probes, load balancers and HAProxy's replica checks call it.
  • /-/routes returns the route table, like {"/hello": "default"}.

Serve must match them after removing root_path. Direct ingress didn't, so /-/healthz returned 404. HAProxy then marked every replica down, and traffic silently fell back to the proxy actor.

Breaking changes

Requests that still include the prefix, like /serve/hello or /serve/-/healthz, now return 404. Users must strip the prefix at their ingress or unset root_path.

Impact on KubeRay: None

kuberay-project/kuberay#4494 happened because Serve only answered health checks at <root_path>/-/healthz. That was true on uvicorn 0.22 images, and again after #57555, which forced the 0.22 behavior onto uvicorn 0.41. KubeRay's worker readiness probe and head-pod check always call /-/healthz on port 8000, so the pods never became ready.

This PR doesn't cause the same issue. Following ASGI, Serve now expects requests without root_path, so /-/healthz returns 200 when root_path is set, in all three modes. test_http_root_path checks exactly this. Therefore, KubeRay needs no changes.

Related issues

Closes #55776. Supersedes #66443.

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@jeffreywang88
jeffreywang88 requested review from a team as code owners September 24, 2026 04:11
@jeffreywang88 jeffreywang88 added the go add ONLY when ready to merge, run all tests label Sep 24, 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 updates several Python dependencies, including upgrading uvicorn to 0.53.0 and watchfiles to 1.3.0, as well as adding lerobot and removing obsolete packages like aim and dm-control. A critical issue was identified where the Python 3.12 lockfiles (ray_test_py312_cpu.lock and ray_test_py312_cu130.lock) incorrectly reference the Python 3.13 compiled requirements constraint file, which could lead to package incompatibility. These lockfiles need to be regenerated using the correct Python 3.12 constraints.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8519b0e. Configure here.

@ray-gardener ray-gardener Bot added the serve Ray Serve Related Issue label Sep 24, 2026
@jeffreywang88
jeffreywang88 force-pushed the upgrade-uvicorn branch 2 times, most recently from 72f2f6b to f1eb418 Compare September 25, 2026 20:57
@jeffreywang88
jeffreywang88 removed this pull request from stack #66447 September 29, 2026 06:12
@jeffreywang88
jeffreywang88 changed the base branch from serve-root-path-uvicorn to master September 29, 2026 06:12
@jeffreywang88
jeffreywang88 removed the request for review from a team September 29, 2026 06:13
@jeffreywang88

jeffreywang88 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Notes for reviewers: 5182cd4 is new after Elliot's approval for changes only related to dependencies. This commit adapts Ray Serve's behavior to respect the ASGI protocol.

@jeffreywang88 jeffreywang88 changed the title [ci] Upgrade uvicorn and watchfiles dependencies [ci] Upgrade uvicorn and follow ASGI protocol for root_path Sep 29, 2026
@jeffreywang88 jeffreywang88 changed the title [ci] Upgrade uvicorn and follow ASGI protocol for root_path [serve][ci] Upgrade uvicorn and follow ASGI protocol for root_path Sep 29, 2026
Comment thread python/ray/serve/_private/replica.py Resolved
Comment thread python/setup.py Resolved
Comment thread python/ray/serve/_private/haproxy.py Resolved
@jeffreywang88

Copy link
Copy Markdown
Contributor Author

485a7a7: With root_path="/serve", Serve expects requests without the prefix, as if a proxy had stripped it. The tests now call localhost:8000/app1, where Serve actually listens, rather than localhost:8000/serve/app1.

@jeffreywang88

jeffreywang88 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Why can't ray serve support any uvicorn versions?

We need backward-compat handling in the following code, assuming Serve always respects ASGI regardless of the uvicorn version.

root_path=http_options.root_path,

  • uvicorn >= 0.26: we can rely on uvicorn's own root_path handling (uvicorn.Config(root_path=...)) to build the right ASGI scope. uvicorn adds root_path to the front of scope["path"] and scope["raw_path"].
  • uvicorn < 0.26: uvicorn builds the wrong scope. It sets scope["root_path"] but leaves path without the prefix, so we need to adapt it ourselves:
    • Wrap the ASGI app so it adds root_path to the front of scope["path"] and scope["raw_path"];
    • Don't pass root_path to uvicorn.Config, so the scope is built in one place.

@jeffreywang88

Copy link
Copy Markdown
Contributor Author

Premerge https://buildkite.com/ray-project/premerge/builds/73946/canvas passed on an earlier commit: 43867f5.

The latest premerge https://buildkite.com/ray-project/premerge/builds/74061/canvas has also mostly passed, except for a couple of LLM GPU tests that already passed on the earlier commit. There are no LLM-related changes since then, so it should be safe to merge rather than wait for those tests to acquire GPU resources and rerun.

@jeffreywang88
jeffreywang88 merged commit 40fd8ab into master Sep 30, 2026
6 checks passed
@jeffreywang88
jeffreywang88 deleted the upgrade-uvicorn branch September 30, 2026 00:43
elliot-barn pushed a commit that referenced this pull request Sep 30, 2026
## Description
As title.

- **Prerequisite**: Depends on
#66446.
- **DeepGEMM packaging**: The vLLM 0.30.0 wheel now bundles DeepGEMM at
`vllm.third_party.deep_gemm`, pinned to vLLM's fork
(vllm-project/vllm#56876). This change, however, can't be tested
alongside CI because DeepGEMM requires IB setup. CI will
[fail](https://buildkite.com/ray-project/premerge/builds/73952/table?jid=01a0daa5-650f-492e-a98e-2cff57c63c4b&tab=output)
without [removing
DeepGEMM](https://github.com/ray-project/ray/pull/66384/changes#diff-9a06c622586d761628d2e83c393109b8885f94d700a04383a68f3981ac6878f2L107).
- **Quantization test changes**: vLLM 0.30.0 dropped support for GPTQ
checkpoints with `desc_act=True`
(vllm-project/vllm#54809). The old
`neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16` checkpoint uses
it, so every replica failed at engine config time, and therefore the
service never became healthy. `RedHatAI/Qwen3.5-9B-quantized.w4a16` is a
similar-size replacement: 4-bit with static activation ordering, and it
fits on A10G. PD configs set `VLLM_SSM_CONV_STATE_LAYOUT=DS`, which NIXL
requires for hybrid models.

## Related issues
> Link related issues: "Fixes #1234", "Closes #1234", or "Related to
#1234".

## Additional information
> Optional: Add implementation details, API changes, usage examples,
screenshots, etc.

---------

Signed-off-by: Jeffrey Wang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
elliot-barn added a commit that referenced this pull request Oct 1, 2026
Resolve deplock conflicts from #66446 (uvicorn 0.53.0 / watchfiles 1.3.0): keep the retired Windows torch27 locks deleted and regenerate all locks with raydepsets.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
ray-project#66446)

## Description

Ray images pin `uvicorn` 0.22, which doesn't follow the ASGI spec for
`root_path`, so `http_options.root_path` behaves differently depending
on the installed uvicorn (ray-project#55776), and it breaks direct ingress and
HAProxy. This PR upgrades uvicorn to 0.53 (with a `>=0.26` floor) and
makes every ingress mode follow ASGI. Transitively, we also raise
`watchfiles` to `>=0.20` as required by newer `uvicorn` installs.

### How each ingress mode handles `root_path`

Example: `root_path="/serve"` and `route_prefix="/hello"`. A proxy in
front of Serve strips `/serve`, so Serve receives `/hello/items/1`. In
every mode, the app should see:

```
path      = /serve/hello/items/1
root_path = /serve/hello
```

- **HTTP proxy:** uvicorn adds `/serve` to the path. The proxy matches
`/hello` after `root_path`, then sets `root_path=/serve/hello`. This was
already correct with uvicorn 0.26+.
- **Direct ingress:** the replica's uvicorn adds `/serve`. The replica
now matches `/hello` after `root_path` and sets
`root_path=/serve/hello`.
- **Problem**: Prior to this PR, it matched against the full path, so
every request got a 404.
- **HAProxy:** forwards `/hello/items/1` unchanged to a replica, which
then works like direct ingress.
- **Problem**: Prior to this PR, it also stripped `/serve` whenever the
path started with it, which removed the prefix a second time.

### `/-/healthz` and `/-/routes`

These are Serve's own endpoints, not part of ASGI.
- `/-/healthz` reports whether the ingress is ready. KubeRay probes,
load balancers and HAProxy's replica checks call it.
- `/-/routes` returns the route table, like `{"/hello": "default"}`.

Serve must match them **after** removing `root_path`. Direct ingress
didn't, so `/-/healthz` returned 404. HAProxy then marked every replica
down, and traffic silently fell back to the proxy actor.

## Breaking changes

Requests that still include the prefix, like `/serve/hello` or
`/serve/-/healthz`, now return 404. Users must strip the prefix at their
ingress or unset `root_path`.

### Impact on KubeRay: None
kuberay-project/kuberay#4494 happened because
Serve only answered health checks at `<root_path>/-/healthz`. That was
true on uvicorn 0.22 images, and again after ray-project#57555, which forced the
0.22 behavior onto uvicorn 0.41. KubeRay's worker readiness probe and
head-pod check always call `/-/healthz` on port 8000, so the pods never
became ready.

This PR doesn't cause the same issue. Following ASGI, Serve now expects
requests without `root_path`, so `/-/healthz` returns 200 when
`root_path` is set, in all three modes.
[test_http_root_path](https://github.com/ray-project/ray/pull/66446/changes#diff-2351bd6cf47275a74cc504b065e417ee6c550affc762df3d90e2e7f2ecb277f2R311)
checks exactly this. Therefore, KubeRay needs no changes.


## Related issues
Closes ray-project#55776. Supersedes ray-project#66443.

## Additional information
> Optional: Add implementation details, API changes, usage examples,
screenshots, etc.

---------

Signed-off-by: Jeffrey Wang <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description
As title.

- **Prerequisite**: Depends on
ray-project#66446.
- **DeepGEMM packaging**: The vLLM 0.30.0 wheel now bundles DeepGEMM at
`vllm.third_party.deep_gemm`, pinned to vLLM's fork
(vllm-project/vllm#56876). This change, however, can't be tested
alongside CI because DeepGEMM requires IB setup. CI will
[fail](https://buildkite.com/ray-project/premerge/builds/73952/table?jid=01a0daa5-650f-492e-a98e-2cff57c63c4b&tab=output)
without [removing
DeepGEMM](https://github.com/ray-project/ray/pull/66384/changes#diff-9a06c622586d761628d2e83c393109b8885f94d700a04383a68f3981ac6878f2L107).
- **Quantization test changes**: vLLM 0.30.0 dropped support for GPTQ
checkpoints with `desc_act=True`
(vllm-project/vllm#54809). The old
`neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16` checkpoint uses
it, so every replica failed at engine config time, and therefore the
service never became healthy. `RedHatAI/Qwen3.5-9B-quantized.w4a16` is a
similar-size replacement: 4-bit with static activation ordering, and it
fits on A10G. PD configs set `VLLM_SSM_CONV_STATE_LAYOUT=DS`, which NIXL
requires for hybrid models.

## Related issues
> Link related issues: "Fixes ray-project#1234", "Closes ray-project#1234", or "Related to
ray-project#1234".

## Additional information
> Optional: Add implementation details, API changes, usage examples,
screenshots, etc.

---------

Signed-off-by: Jeffrey Wang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Serve] When using the latest version of uvicorn, the root_path parameter is ineffective.

4 participants