Skip to content

[core][move semantics][4/n] Consumer raylet records which pulls are moves - #67041

Merged
Sparks0219 merged 2 commits into
masterfrom
karticam/consumer-learns-is-move
Nov 24, 2026
Merged

Sparks0219 merged 2 commits into
masterfrom
karticam/consumer-learns-is-move

Conversation

@karticam

@karticam karticam commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

This is PR 4 of a series of PRs to implement move semantics for plasma objects in core.

The complete design doc is here: https://docs.google.com/document/d/1ZJhgRmwVyKfNCR21CWf6xMcc0B6HJwSPQsfebTRvnnE/edit?tab=t.0#heading=h.7wcod1f9afpg

After #66803, an actor task's spec says which of its by-ref args it consumes (TaskArg.is_move). This PR carries that flag to the raylet of the node where the actor runs, and makes that raylet remember, for each such arg it has to pull, that the pull is a move. Nothing reads the record yet: the next PR uses it on the receive path to pin the pulled copy as the object's new primary copy and report that to the owner.

Changes

  1. TaskSpecification::GetDependencyIsMove(). One bool per entry of GetDependencies(), in the same order.

  2. The flag travels with the arg wait. BeginArgsFetch and the AsyncWaitForArgs callback take the vector; RayletIpcClient::WaitForActorCallArgs sends it in a new is_move: [bool] field of WaitForActorCallArgsRequest, parallel to object_ids.

  3. The raylet records it when it starts a pull. ProcessWaitForActorCallArgs → AsyncWait → LeaseDependencyManager::StartOrUpdateWaitRequest(worker, refs, is_move). In the branch that handles a non-local arg, right before the pull, a moved arg is recorded with ObjectManager::MarkMovePull. If the object is not local but a pull for it already exists (a ray.get in flight, or another worker's ray.wait), the arg is still recorded and no second pull is started. An arg that is already local is neither pulled nor recorded; a later PR handles that case. StartOrUpdateWaitRequest is also used for an ordinary ray.wait; that caller passes an empty is_move vector, so a plain ray.wait never records anything.

  4. ObjectManager keeps the record. It is a set of object IDs. The set is written on the main thread (MarkMovePull adds, CancelPull removes) and will be read on the RPC threads (IsMovePull, from ReceiveObjectChunk, once per chunk, in the next PR), so it is guarded by a mutex; reads take a shared lock.

    An object is removed from the set when its last pull ends, not its first (there could be multiple pulls for the same object). PullManager already tracks which pulls still need an object and tells CancelPull which objects nobody needs any more; the record is erased only for those. So if two pulls want the same object (a ray.get in flight plus the actor's wait, or c.remote(r, r)), ending one of them keeps the record.

Tests

  • task_spec_test: GetDependencyIsMove on the TestArgIsMove fixture.
  • lease_dependency_manager_test: a moved, a plain and a local moved arg (one record, two pulls); a plain ray.wait records nothing; a moved arg whose pull already exists from a ray.get or from another worker's wait; the same moved arg passed twice starts one pull.
  • object_manager_test: the record is idempotent, survives cancelling one of two pulls, and is dropped with the last one.
  • python/ray/tests/test_consume_once.py (32 passed), and a two-node script covering a cross-node consume with a plain arg, c.remote(r, r), a same-node consume, an owner ray.wait(fetch_local=True) before the consume, and a plain ray.wait inside an actor.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@karticam karticam added core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests labels Oct 15, 2026
@karticam
karticam marked this pull request as ready for review October 15, 2026 04:44
@karticam
karticam requested a review from a team as a code owner October 15, 2026 04:44
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@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.

Stale Bugbot comment from a previous run.

Comment thread src/ray/object_manager/object_manager.h Resolved
@karticam
karticam added this pull request to stack #66768 October 15, 2026 04:47
@karticam karticam added the unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. label Oct 16, 2026
@karticam
karticam force-pushed the karticam/consumer-learns-is-move branch from 69d2a94 to 3303ac6 Compare October 21, 2026 05:14
Comment thread src/ray/common/tests/task_spec_test.cc Resolved
Comment thread src/ray/flatbuffers/node_manager.fbs Resolved
@karticam
karticam force-pushed the karticam/consumer-learns-is-move branch from 3303ac6 to 85674f6 Compare November 3, 2026 03:00
@karticam
karticam force-pushed the karticam/consumer-learns-is-move branch from 85674f6 to 10b5bda Compare November 3, 2026 03:07

@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 and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

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 10b5bda. Configure here.

Comment thread src/ray/common/task/task_spec.h Resolved
@karticam
karticam force-pushed the karticam/consumer-learns-is-move branch from 10b5bda to ab45efc Compare November 14, 2026 02:36
@Sparks0219
Sparks0219 force-pushed the karticam/consumer-learns-is-move branch from ab45efc to da8fdf6 Compare November 16, 2026 00:18
@karticam
karticam force-pushed the karticam/consumer-learns-is-move branch from da8fdf6 to cc961aa Compare November 18, 2026 04:07
Base automatically changed from karticam/is-move-in-task-args to master November 18, 2026 07:11
@Sparks0219
Sparks0219 force-pushed the karticam/consumer-learns-is-move branch from cc961aa to 8a30ecb Compare November 18, 2026 07:11

@Sparks0219 Sparks0219 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.

👍

@Sparks0219
Sparks0219 merged commit d9e1f69 into master Nov 24, 2026
6 checks passed
@Sparks0219
Sparks0219 deleted the karticam/consumer-learns-is-move branch November 24, 2026 17:45
Sparks0219 pushed a commit that referenced this pull request Nov 24, 2026
…as the primary copy and reports it to the owner (#67093)

This is PR 5 of a series of PRs to implement move semantics for plasma
objects in core.

The complete design doc is here:
https://docs.google.com/document/d/1ZJhgRmwVyKfNCR21CWf6xMcc0B6HJwSPQsfebTRvnnE/edit?tab=t.0#heading=h.7wcod1f9afpg

After #67041, the raylet of the node where a consuming actor runs knows
which of the objects it pulls are moves. This PR acts on that record
when such an object arrives: the received copy is pinned as the object's
new primary copy and the owner is told where the primary copy now lives.
The producer's copy is not freed yet; that is in a future PR.

# Changes
1. **Receiving a move keeps the object alive until it is pinned.**
`ObjectBufferPool::WriteChunk` now returns whether the chunk it wrote
sealed the object, and takes `defer_release`. With it set, the sealing
chunk seals the object but keeps the plasma store reference that was
taken when the object was created. The reason: the seal happens on the
RPC thread, the pin happens later on the main thread, and in between a
sealed copy that nobody references is just another evictable object.
Holding the reference across that window is what stops the store from
evicting the fresh copy before it is pinned. `ReleaseObject` drops the
reference once the pin is done.
2. **`AbortCreate` skips an object sealed this way** (i.e. by move
semantic method). This is because the store rejects aborting a sealed
object, and the pull that owns the object is cancelled by the store's
own "object added" notification, which in-turn triggerse `AbortCreate`
which lands before the pin.
3. **The raylet pins the move when the store reports the object as
local.** The pin happens in `NodeManager::HandleObjectLocal`. If the
object has a move record, it calls `PinAndReportMovedObject` first. Only
then does it call `LeaseDependencyManager::HandleObjectLocal`, which
cancels the wait pull and drops the record. This order is safe for one
reason. `PlasmaStore::SealObjects` invokes `add_object_callback` before
Seal returns to `WriteChunk`, and that callback posts
`HandleObjectLocal` to the main service. `ReceiveObjectChunk` posts its
`ReleaseObject` only after `WriteChunk` returns. So the pin always runs
before the release. The chunk ack in `HandlePush` is unchanged. An
object without a record is handled as before.
4. **`NodeManager::PinAndReportMovedObject`.** Same steps as
`HandlePinObjectIDs` for one object: skip if the owner is known dead.
Also skip if fetch from plasma fails, if the object is gone or pending
deletion. If everything is fine, it calls `PinObjectsAndWaitForFree` and
then reports to the owner.
5. **The owner learns the new primary.** `ObjectLocationUpdate` gains a
`primary_moved_to_node_id` field.
`OwnershipBasedObjectDirectory::ReportObjectPrimaryMoved` sends it
through the existing `UpdateObjectLocationBatch`. That batch already
carries the ADDED update that `ObjectManager::HandleObjectAdded` sent
for the same object, so the move report is always ordered after it. If
that ADDED update is still waiting in the buffer, because a batch to the
owner is in flight, the two go out as one message. On the owner,
`HandleUpdateObjectLocationBatch` calls the existing
`UpdateObjectPinnedAtRaylet`. From then on the consumer's node holds the
primary copy. If that node dies, the object is reconstructed or reported
lost, like any other primary copy. Losing the producer's node no longer
loses the object.
6. `ObjectManager::DebugString` reports the number of move records, and
`NodeManager::DebugString` the number of received moves pinned or not
pinned. All zero on a node that never receives a move.

---------

Signed-off-by: kartica.modi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants