Skip to content

[core][3/7] Allow several expressions and exists operators in one label selector - #66550

Closed
YashwanthRanjanSingaravel wants to merge 1 commit into
yashwanth/topology-spread-2-apifrom
yashwanth/topology-spread-3-label-selector-exists
Closed

YashwanthRanjanSingaravel wants to merge 1 commit into
yashwanth/topology-spread-2-apifrom
yashwanth/topology-spread-3-label-selector-exists

Conversation

@YashwanthRanjanSingaravel

Copy link
Copy Markdown
Contributor

Changes

  • Adds exists() and !exists() label selector operators.
  • One value can hold several expressions, like exists(),!in(a,b).
  • Every expression in a value must hold.
  • !in alone still matches nodes without the key.
  • Autoscaler v2 matches the new operators.

dstrodtman added a commit that referenced this pull request Oct 7, 2026
…es (#66672)

## Why are these changes needed?

Style and grammar pass over the 13 Ray Core pages under
`doc/source/core/fault-tolerance/` and `doc/source/core/scheduling/`,
against `doc/source/ray-contribute/writing-style.md` and its "Writing
Ray Core docs" terms. This is the fourth prose layer of the Ray Core
stack. It's stacked on #66667 (design patterns), which is stacked on
#66666 (tasks, actors, and objects), #66642 (top-level pages), #66640
(Core Vale term library), and #66605 (the `ray-core/` to `core/` move).
A later layer covers `compiled-graph/`, `direct-transport/`,
`internals/`, and the remaining pages.

The edits are voice, person, tense, word choice, and list structure.
First-person plural is now "you" or an imperative. Per the Core terms
table, "Fault Tolerance", "Placement Group", and "Object Store" are now
lowercase, prose uses of `ObjectRef` are now "object ref", and
"retriable" is now "retryable". Inline enumerations and parenthetical
asides are now lists or separate sentences, and the three bold
`**Note:**` labels on `accelerators.md` are now note admonitions. On the
fault tolerance landing page, the MyST conversion had collapsed the two
failure classes into one paragraph ("two classes: 1\. application-level
failures 2. system-level failures Bugs in..."). That's now a two-item
list.

Headings changed only in case, except two on `labels.md`: "Specify label
requirements for a local RayCluster" now says "Ray cluster", because the
section is about a local `ray.init` cluster rather than the KubeRay
custom resource, and "Using labels with autoscaler" is now "Use labels
with the autoscaler". Both keep their old URL fragments through MyST
labels named after the old slugs. No link in `doc/source` targets any
changed slug. No code block, role target, or URL changed beyond the
fixes below.

### Fixes

Each of these is checked against the source tree or the page's own
output:

- `labels.md`: the example ran `ray start --head --labels-files=...`.
The flag is `--labels-file` (`python/ray/scripts/scripts.py`), as the
prose above it already said.
- `labels.md`: the `label_selector` example used `"test-lable-key"`,
which didn't match the `test-label-key` in the sample output.
- `placement-group.md`: the inline span `{"CPU": 1, "GPU: 1"}` had a
misplaced quote. It's now `{"CPU": 1, "GPU": 1}`.
- `accelerators.md`: "never release it" in a code comment is now "never
releases it".

### Lines left for open PRs

Four open PRs edit these pages, so the lines they touch or insert next
to are unchanged here. Each PR's change still applies cleanly on top of
this branch in a 3-way merge:

- #66550 (label selector operators): the operator table in `labels.md`
and the paragraph after it. That table still has curly quotes inside its
code spans, such as `{“key”: “value”}`, which aren't valid Python, and
"Label matches anything by one value" probably means "but". Fixing
either here would conflict with #66550, so they're left for that PR or a
follow-up.
- #66449 and #66368 (Biren and Cambricon accelerators): the
supported-accelerators table rows and the tab-items they insert between.
The "Inside a task or actor" paragraph in `accelerators.md` still has an
"e.g." and a parenthetical for the same reason.
- #65974 (resource dictionary keys): the bundle paragraph and its list
in `placement-group.md`, and the "You can also explicitly specify..."
paragraph in `resources.md`, which still says "via".

### Pre-existing claims, tracked separately

These claims were already on the pages, and this pass kept them as
written. They don't block this PR. #66790 fixes the mechanical ones and
#66791 corrects the ones that the source settles, both stacked on
#66677. The rest need a Core engineering decision and are tracked
separately:

- `scheduling/index.md`: the DEFAULT strategy "first favors nodes that
already have tasks or actors scheduled, for locality". The
locality-aware scheduling section describes locality as task-argument
locality that takes precedence over DEFAULT. Is "for locality" in the
DEFAULT description the same concept? The page also says "By default,
`k` is 20% of the total number of nodes", but the table above it
describes a `RAY_scheduler_top_k_absolute` floor.
- `placement-group.md`: the PACK example says "both bundles have to be
created on the same node", and the next sentences say PACK is a soft
policy that spreads bundles when they don't fit. Is "have to" right for
PACK?
- `fault-tolerance/gcs.md`: the KubeRay tab is titled "KubeRay
(officially supported)", but the note and the comparison table limit
official support to KubeRay for Ray Serve fault tolerance. Should the
title name that scope?
- `scheduling/memory-management.md`: the prose names a "Reference
Creation Site" column, but the `ray memory` sample output labels that
column "Call Site". The page also says each entry shows "the size of the
object in bytes", while the sample shows MiB.
- `scheduling/ray-oom-prevention.md`: the active-worker policy
prioritizes retryable "tasks", defined as `max_retries` or
`max_restarts` greater than 0. `max_restarts` applies to actors. Should
"tasks" be "workers"? Separately, "how to address memory issues" links
to the `addressing-memory-issues` label, which sits on a section of help
links only.
- `scheduling/resources.md`: the lead-in says Ray configures "logical
resources" with the rules that follow, but the last rule says object
store memory isn't a logical resource.
- `scheduling/labels.md`: the opening says labels control scheduling
"for KubeRay", but the page also covers `ray start` and local
`ray.init`. Are labels KubeRay-specific?

## Related issue number

None. Not a duplicate. #66550, #66449, #66368, and #65974 edit these
pages; see above.

## Checks

- `vale` on the 13 pages from the repo root: 687 alerts before the pass,
111 after. The remaining alerts are intentional passives where the page
names no actor, accelerator vendor acronyms in tab titles, "currently"
where it marks a temporary limitation or alpha feature, the "What is"
and "How do I" question headings on `ray-oom-prevention.md`, "cannot"
and "It is" inside warning admonitions, and alerts on the protected
lines above. The second commit adds `retryability` and `reconstructable`
to the `Core` accept list. Across `doc/source` that removes 3 alerts and
adds none.
- `codespell` on the 13 pages: clean. Curly quotes outside the protected
table are now ASCII.
- Per-file invariant check against the pre-edit files: fenced-code
count, role-target multiset, and URLs unchanged. The only anchor change
is the two legacy-slug labels on `labels.md`. Line-count changes come
from the new lists, the three note admonitions, and the definition-list
restructures in `memory-management.md` and `resources.md`.
- `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check`: clean.
Two `{ref}` roles in `fault-tolerance/` were hard-wrapped and are now
joined.
- 3-way merge of each open PR's change onto this branch: clean for all
four.
- Meaning review
([review](#66672 (review))):
of 365 changed blocks, 55 were cosmetic, and 306 of the other 310
preserved their meaning against the Ray source tree. The third commit
(8b782c4) restores the four that shifted a claim.
- Full `-W` doc build: relying on the Read the Docs preview.

AI assistance (Claude Code) was used to draft these edits.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 7, 2026
…66790)

## Why are these changes needed?

The Ray Core style-pass stack, #66642 through #66677, flagged
pre-existing problems in the pages it edited and left them as written,
because a style pass shouldn't change claims. This PR fixes the ones
that don't change a technical claim. It's stacked on #66677, the top of
that stack, because it edits lines on pages across every layer.

Each fix is settled by the page itself, its own code sample, or a
renamed symbol:

- `configure.md`: the default worker port range 10002 to 19999 holds
9,998 ports, so the per-node worker maximum is 9,998, not 10,000.
- `user-spawn-processes.md`: the deprecation note told readers to enable
`process_group_cleanup_enabled`, which L19 of the same page says is on
by default.
- `type-hint.md`: the Pattern 2 sample uses `ray` and `ObjectRef`
without importing them.
- `actors/terminating-actors.md`: the front-matter description said
cleanup runs when `ray.shutdown` is called, which the page never says.
It now names the `__ray_shutdown__` method the page covers. The
`sys.exit` sentence sits below the Python, Java, and C++ tabs, so it now
scopes `sys.exit` to Python.
- `objects/object-spilling.md`: the CLI tab wrapped a `ray start` shell
command in a `{doctest}` fence. It's now `bash`.
- `patterns/nested-ray-get.md` and
`patterns/out-of-band-object-ref-serialization.md`: the front-matter
descriptions contradicted their page bodies ("serializes execution",
"can let its value be reclaimed early"). They now summarize what the
bodies say.
- `scheduling/memory-management.md`: the prose named a "Reference
Creation Site" column, but every `ray memory` sample on the page labels
it "Call Site". "In Ray 1.3 and later" is gone, since every supported
release is 2.x.
- `scheduling/ray-oom-prevention.md`: "how to address memory issues"
linked to a label left on the "Questions or issues?" section after
#63652 deleted the section it named. It now links to the out-of-memory
troubleshooting guide that #63652 expanded, and the orphaned label is
gone. Nothing else in `doc/source` targets it.
- `scheduling/resources.md`: the lead-in said the rules configure
"logical resources", but one rule in the list says object store memory
isn't a logical resource.
- `compiled-graph/overlap.md`: overlap "reduces" latency by about 14%,
rather than "improves" it. The page's output shows 1.0670 s to 0.9211 s.
- `compiled-graph/profiling.md`: NVIDIA's product is Nsight Systems. A
`(nsight-system-profiler)=` label keeps the old heading fragment
working.
- `internals/token-authentication.md`: two notes said that new HTTP
services must add the middleware and header injection themselves. The
first one goes, and the one in the "Adding token authentication to new
services" section stays.
- `examples/monte-carlo-pi.md`: the task takes exactly `num_samples`
samples, not "up to".
- `examples/index.md`: five link texts didn't match the titles of the
notebooks they link to. They now render the live titles.
- `internals/object-spilling.md`: "GCS" in the cloud storage passages
meant Google Cloud Storage, which reads as Ray's GCS on a Ray Core page.
`ReleaseFreedObject` is now `ReleaseFreedLocalObject`, renamed in
#63218. The two `PopDeleteWorker` links pointed at different lines of
`worker_pool.cc`, and the `blob/master` anchors had drifted. Those three
links are now pinned to a commit. The page's other `blob/master` links
have drifted too and need symbol-by-symbol remapping, which is left for
a follow-up.
- `internals/ray-event-exporter.md`: the Step 5 link text named
`AddEvent()`, but the function at the pinned commit and on master is
`AddEvents()`. The Step 6 `AggregatorAgent` link pointed at the default
event list, at the same anchor as Step 4, rather than the class.
- `internals/metric-exporter.md`: the `SetMetricValue()` link pointed at
a call site in `metric.cc`. It now points at the definition, which other
links on the page already use.

Not included: two typos in the `scheduling/labels.md` operator table,
curly quotes in code spans and "anything by one value", which sit on
lines that #66550 edits.

## Related issue number

None. Not a duplicate: I searched open PRs touching `doc/source/core/`
and `doc/source/ray-core/`. Open PRs editing these pages are this stack,
#66464 (Compiled Graph deprecation banners, on lines this PR doesn't
touch), and #66550 (left alone as described above).

## Checks

- Docs-only: every change is in a `.md` file under `doc/source/core/`,
so no library tests run.
- `vale` on the 18 changed files from the repo root: the same alerts as
the base branch, with none added.
- `codespell` on the changed files: clean.
- `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the
changed files: clean.
- Every link changed here was checked against the file at its pinned
commit, at the line it names.
- `pre-commit`: passed.
- Full `-W` doc build: relying on the Read the Docs preview.

AI assistance (Claude Code) was used to draft these edits. Draft until
the submitter has reviewed every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 7, 2026
…66791)

## Why are these changes needed?

The Ray Core style-pass stack, #66642 through #66677, flagged
pre-existing claims that looked inconsistent with the source, and kept
them as written. This PR corrects the ones that current source settles.
Each one either lags a deliberate code change or never matched the code.
None traces to a code regression, so for each one the source describes
the intended behavior.

It's stacked on #66790, the mechanical fixes for the same pages, which
is stacked on #66677.

**For Core reviewers:** these corrections change what the docs say, so
please confirm them. Each item cites the source it rests on, at master
`5cf675f`, and the history of the disagreement. Items marked **confirm**
carry a specific point to check.

### Top-level pages

- `head-node-memory-management.md`: the note claimed KubeRay ignores
memory and CPU requests, but KubeRay uses the CPU request when the CPU
limit is absent (`ray-operator/controllers/ray/common/pod.go`). Per
review, the note now states the general rule without naming resource
types: set requests equal to limits, because KubeRay configures Ray's
logical resources from the limits. The note was wrong from the start, in
#58695.
- `handling-dependencies.md`, the paths and URIs rules: a local path can
also be a file, such as a local archive for `working_dir` or a `.whl`
for `py_modules`, as the page's own API reference says. Remote URIs can
be `.zip`, `.tar.gz`, `.tgz`, or `.tar.xz` archives, per
`python/ray/_private/runtime_env/packaging.py`. Remote tar archives
arrived in #62813, first released in 2.56.0, and #65742. **Confirm**
that the single top-level directory rule applies to tar archives too.
- `handling-dependencies.md`: `image_uri` is a `str`
(`python/ray/runtime_env/runtime_env.py`), not a `dict`. #49752 carried
`(dict)` over from the `container` field.
- `ray-generator.md`: `ObjectRefGenerator` isn't a Python generator and
doesn't fully implement the generator interface: `send`, `throw`, and
`close` raise `NotImplementedError`
(`python/ray/_private/object_ref_generator.py`). The sentence now says
only that you can iterate with a `for` loop.
- `tips-for-first-time.md`: the first value `ray.wait()` returns is a
list of ready refs (`python/ray/_private/worker.py`), as the page's API
table and sample, which indexes `done_id[0]`, already show.
- `resource-isolation-with-cgroupv2.md`: the default minimum reserved
system memory is `500 * (1024**2)`
(`python/ray/_private/ray_constants.py`). The listing wrote `0.5 *
1024**3`, which is 512 MiB, beside a `#500MiB` comment.
- `type-hint.md`: the `ActorProxy` handle sample called `func.remote()`
on an undecorated function and omitted its `actor` argument and its
imports. It now decorates `func`, passes the handle, and imports what it
uses. **Confirm** that passing the handle into a task is the intended
illustration.

### Tasks, actors, and objects

- `tasks/nested-tasks.md`: Ray pickles and exports a remote function on
its first `.remote()` call, in `RemoteFunction._remote()`
(`python/ray/remote_function.py`), not at definition. Export has been
lazy since before the note was written, in Ray 0.7. **Confirm** that
cloudpickle captures `f` at that point, or say if the note should go.
- `actors/concurrency-group-api.md`: the Java sample set both groups to
a maximum concurrency of 1, while the prose and the Python sample say 2
for `io` and 4 for `compute`. The Java sample now matches. This is a
code change in an untested `java` block.
- `objects/serialization.md`: drops "Most Python distributions default
to Pickle protocol 3". No supported Python does: `python/setup.py`
requires 3.10 or later, where the default is 4 or 5. The sentence went
stale when Ray dropped Python 3.7 in 2.9.0.
- `actors/index.md`: `ray.cancel` defaults `recursive` to `True`
(`python/ray/_private/worker.py`), and always has, so recursive
cancellation is the default and `recursive=False` opts out.
- `tasks/dynamic-generators.md`: adds the caveat from the page's own
sample, `doc_code/generator.py` (`__dynamic_generator_pass_start__`),
which says to avoid passing the generator because the extra `ray.get`
blocks the driver.

### Design patterns

- `patterns/ray-get-too-many-objects.md`: fetching too many objects "can
lead to" failure rather than "leads to" it, matching the next paragraph
and the sample's "if NUM_TASKS is large enough".
- `patterns/out-of-band-object-ref-serialization.md`: the pin lasts for
the lifetime of the worker that serialized the ref.
`python/ray/_private/serialization.py` adds a never-removed local
reference in the serializing process. The object is also gone if its
owner dies. **Confirm** the borrower case: when the serializer isn't the
owner, the owner cleans up a failed borrower's references
(`src/ray/core_worker/reference_counter.cc`). An automated review on
#66667 said the deserializing worker holds the pin instead. The source
comment at the pin site says the serializing worker does.

### Fault tolerance and scheduling

- `scheduling/index.md`: `k` is the larger of
`RAY_scheduler_top_k_absolute` and the rounded-down product of the node
count and `RAY_scheduler_top_k_fraction`
(`src/ray/raylet/scheduling/policy/hybrid_scheduling_policy.cc`). With
the defaults, that's 20% of nodes, rounded down, and at least 1.
- `scheduling/placement-group.md`: PACK is a soft policy, as the same
paragraph says, so Ray "tries to" put both bundles on one node. Only
STRICT_PACK requires it.
- `scheduling/ray-oom-prevention.md`: the policy ranks workers, and
`LeaseSpecification::IsRetriable()`
(`src/ray/common/lease/lease_spec.cc`) treats any nonzero `max_retries`
or `max_restarts`, including `-1`, as retryable.
- `fault-tolerance/objects.md`: `RAY_TASK_MAX_RETRIES` overrides only
the default `max_retries` for remote functions, when the option isn't
set (`python/ray/remote_function.py`). Tasks that set `max_retries`, and
actor tasks with `max_task_retries`, still reconstruct. The "entirely"
wording came in #27573, after #25189 introduced the variable as a
default override.
- `fault-tolerance/actors.md`: `ActorUnavailableError` retries apply to
any nonzero `max_task_retries`. `-1` retries without limit
(`src/ray/core_worker/task_manager.cc`, and the `max_task_retries`
docstring in `python/ray/actor.py`), as L21 of the same page already
counts it.
- `fault-tolerance/index.md`: a task pinned by a node-specific custom
resource "can't be retried on other nodes", the wording of the example's
own comment in `doc_code/fault_tolerance_tips.py`, rather than "won't be
retried".
- `scheduling/resources.md`: the whole-number rule above 1 is enforced
for GPUs (`python/ray/includes/task_options_utils.pxi`), while
`neuron_cores` rejects any fractional value
(`python/ray/_private/accelerators/neuron.py`) and TPU accepts only 1,
2, 4, or 8 (`python/ray/_private/accelerators/tpu.py`).
- `scheduling/memory-management.md`: on macOS, Ray caps the default
object store at 2 GiB (`MAC_DEGRADED_PERF_MMAP_SIZE_LIMIT` in
`python/ray/_private/ray_constants.py`) and raises an error for a larger
requested size unless `RAY_ENABLE_MAC_LARGE_OBJECT_STORE=1`
(`python/ray/_private/services.py`). The cap arrived in #21224.
- `scheduling/placement-group.md`: no code reads `NVIDIA_GPU_CLIQUE`.
The variable supplies the value of the `ray.io/gpu-domain` label, which
is what the feature acts on, as the example below the sentence shows.

### Compiled Graph, Ray Direct Transport, and internals

- `direct-transport/index.md`: both the Gloo and NCCL examples call
`create_collective_group`, so the difference worth listing is
`backend="nccl"` against `backend="torch_gloo"`
(`doc_code/direct_transport_gloo.py` and `direct_transport_nccl.py`).
- `internals/task-lifecycle.md`: for a normal task, the executor's
raylet pulls remote arguments before it grants the lease
(`src/ray/raylet/local_lease_manager.cc`,
`lease_dependency_manager.cc`), as a later step on the same page says.
The executor reads them from the local store.
- `internals/port-service-discovery.md`: the raylet spawns worker
processes, and the core worker inside each one is a C++ library. #66677
restores the original wording, and this states it precisely.
- `internals/object-spilling.md`:
- Spill selection isn't LRU. `TryToSpillObjects` walks
`pinned_objects_`, an unordered `absl::flat_hash_map`
(`src/ray/raylet/local_object_manager.h`). LRU is the Plasma eviction
policy for secondary copies, which the page covers separately.
- Proactive spilling starts when the fraction of primary bytes is at
least the threshold, `>=` in `src/ray/raylet/node_manager.cc`, as the
page's trigger table says.
- `object_spilling_threshold` is a fraction of object store capacity,
the configured size, not of available memory (`node_manager.cc`,
`ObjectManager::GetMemoryCapacity()`).
- `max_io_workers` limits each IO worker type separately
(`TryStartIOWorkers` in `src/ray/raylet/worker_pool.cc`), as the worker
pool section of the page already says.
- `internals/metric-exporter.md`: C++ metrics register in their
`ray::stats` constructors when OpenTelemetry is on
(`src/ray/stats/metric.h`), not lazily on first use. Recording an
unregistered name fails a `RAY_CHECK`
(`src/ray/observability/open_telemetry_metric_recorder.cc`). "Lazy
registration" becomes "Idempotent registration", which is what that
bullet describes.

## Related issue number

None. Not a duplicate: I searched open PRs touching `doc/source/core/`
and `doc/source/ray-core/`. Open PRs editing these pages are this stack,
#66464 (Compiled Graph deprecation, on lines this PR doesn't touch), and
#66550 (label selector operators, on lines this PR doesn't touch).

Questions from the style pass that need a Core decision rather than a
source check aren't in this PR. Examples are the `DAGNode.execute()`
deprecation framing, the DEFAULT scheduling strategy's locality wording,
the official KubeRay support scope for GCS fault tolerance, and the Ray
event exporter baseline. They're tracked separately for Core
engineering.

## Checks

- Docs-only: every change is in a `.md` file under `doc/source/core/`,
so no library tests run. The two sample edits, in `type-hint.md` and
`concurrency-group-api.md`, are untested `python` and `java` blocks.
- Every cited claim was re-checked on master `5cf675f`, and the
disagreement's history was traced through release tags to rule out a
code regression.
- `vale` on the 26 changed files from the repo root: four alerts removed
and one added, `Google.Parens` on `image_uri (str)`, which matches the
field-type format of its sibling entries.
- `codespell` on the changed files: clean.
- `doc/.claude/skills/ray-soft-wrap/scripts/softwrap.py --check` on the
changed files: clean.
- `pre-commit`: passed.
- Full `-W` doc build: relying on the Read the Docs preview.

AI assistance (Claude Code) was used to research and draft these edits.
Draft until the submitter has reviewed every changed line and a Core
reviewer has confirmed the claims.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Oct 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

@github-actions github-actions Bot closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant