Skip to content

[core] (FreeObjects 3/n) Gut internal free - #64037

Merged
Sparks0219 merged 8 commits into
ray-project:masterfrom
aaronlinear:aaron/deprecate-internal-free
Aug 11, 2026
Merged

Sparks0219 merged 8 commits into
ray-project:masterfrom
aaronlinear:aaron/deprecate-internal-free

Conversation

@aaronlinear

Copy link
Copy Markdown
Contributor

Description

There is currently a method _internal.free that explicitly frees a ref's objects' copies across the cluster (primary and secondary). This calls into the FreeObjects path that then frees the primary copy and broadcasts frees to other nodes (if local_only=false). For more information on this, please read #63218. In the new implementation of FreeObjects, we remove this broadcast, which means all copies will only be locally deleted now. This introduces slight regression (although secondary copies will eventually be evicted). Since _internal.free has been deprecated for ~11 months now, the decision is made to just remove it.

Current Use Case Considerations

Ray Data Split

Ray Data in one use case touches upon internal free. However, the default case for the internal free codepath is usually false. Furthermore, it seems that they do not necessarily need this functionality and can just wait for object free. There ends up being a lot of cleanups for Ray Data because of flags that are no longer necessary due to the removal of this codepath. All these flags are defaulted to false.

Java Internal Free

Java runtime also has an internal free implementation that plumbs into the same codepath as cython. We decide to not support multi-language runtimes, and thus do not want to continue supporting this.

Out of Band Serialization / Deserialization

There is current support for out of band serialization / deserialization through cloudpickle, which would then rely on internal free for freeing the underlying object. We do not want to continue supporting this, and thus remove this.

Testing Usecases

Some testing use cases who only test adjacent conditions have maintained functionality. However, some test cases that purely test _internal.free or are largely coupled with _internal.free are removed.

Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>
Signed-off-by: aaron.li <[email protected]>

@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 removes the deprecated internal free API and the associated OBJECT_FREED error across Python, Java, and C++ components, including the removal of eager memory deallocation logic in Ray Data. The review feedback highlights a potential Java compilation failure due to a missing update in InternalApi.java, recommends reserving the deleted protobuf tag in SpillObjectsRequest to maintain wire compatibility, and suggests keeping eager_free as a deprecated attribute in DataContext to prevent backward-compatibility issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/ray/protobuf/core_worker.proto Resolved
Comment thread python/ray/data/context.py Resolved
@aaronlinear
aaronlinear marked this pull request as ready for review June 20, 2026 00:02
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Jun 20, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

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 Jul 4, 2026
@aaronlinear aaronlinear removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jul 5, 2026
…nternal-free

# Conflicts:
#	ci/lint/pydoclint-baseline.txt
#	python/ray/_private/internal_api.py
#	python/ray/data/_internal/block_batching/iter_batches.py
@aaronlinear
aaronlinear requested a review from a team as a code owner July 14, 2026 05:35
@aaronlinear aaronlinear added the go add ONLY when ready to merge, run all tests label Jul 14, 2026
@edoakes edoakes removed the community-contribution Contributed by the community label Jul 23, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

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 Aug 7, 2026
@Sparks0219

Copy link
Copy Markdown
Contributor

unstale

// using the internal free() call. We will only recover this object if it is
// needed for reconstruction of another downstream object.
// using the internal free() call. This call is now deprecated, but we still
// keep this error for backwards compatibility.

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.

RIP sad

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

LGTM, can you approve the data changes @goutamvenkat-anyscale? 🙏

@github-actions github-actions Bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Aug 10, 2026
…nternal-free

Signed-off-by: Aaron <[email protected]>

# Conflicts:
#	python/ray/data/_internal/block_batching/iter_batches.py
#	python/ray/data/context.py
#	python/ray/data/iterator.py
#	python/ray/data/tests/test_zip.py

@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

Reviewed by Cursor Bugbot for commit 502f299. Configure here.

Comment thread src/ray/protobuf/core_worker.proto Resolved
@Sparks0219
Sparks0219 enabled auto-merge (squash) August 11, 2026 07:37
@Sparks0219
Sparks0219 merged commit c3201c3 into ray-project:master Aug 11, 2026
7 checks passed
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
## Description
There is currently a method `_internal.free` that explicitly frees a
ref's objects' copies across the cluster (primary and secondary). This
calls into the FreeObjects path that then frees the primary copy and
broadcasts frees to other nodes (if `local_only`=false). For more
information on this, please read ray-project#63218. In the new implementation of
FreeObjects, we remove this broadcast, which means all copies will only
be locally deleted now. This introduces slight regression (although
secondary copies will eventually be evicted). Since `_internal.free` has
been deprecated for ~11 months now, the decision is made to just remove
it.

## Current Use Case Considerations
### Ray Data Split
Ray Data in one use case touches upon internal free. However, the
default case for the internal free codepath is usually `false`.
Furthermore, it seems that they do not necessarily need this
functionality and can just wait for object free. There ends up being a
lot of cleanups for Ray Data because of flags that are no longer
necessary due to the removal of this codepath. All these flags are
defaulted to false.

### Java Internal Free
Java runtime also has an internal free implementation that plumbs into
the same codepath as cython. We decide to not support multi-language
runtimes, and thus do not want to continue supporting this.

### Out of Band Serialization / Deserialization
There is current support for out of band serialization / deserialization
through cloudpickle, which would then rely on internal free for freeing
the underlying object. We do not want to continue supporting this, and
thus remove this.

### Testing Usecases
Some testing use cases who only test adjacent conditions have maintained
functionality. However, some test cases that purely test
`_internal.free` or are largely coupled with `_internal.free` are
removed.

---------

Signed-off-by: aaron.li <[email protected]>
Co-authored-by: aaron.li <[email protected]>
Co-authored-by: Aaron <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
## Description
There is currently a method `_internal.free` that explicitly frees a
ref's objects' copies across the cluster (primary and secondary). This
calls into the FreeObjects path that then frees the primary copy and
broadcasts frees to other nodes (if `local_only`=false). For more
information on this, please read ray-project#63218. In the new implementation of
FreeObjects, we remove this broadcast, which means all copies will only
be locally deleted now. This introduces slight regression (although
secondary copies will eventually be evicted). Since `_internal.free` has
been deprecated for ~11 months now, the decision is made to just remove
it.

## Current Use Case Considerations
### Ray Data Split
Ray Data in one use case touches upon internal free. However, the
default case for the internal free codepath is usually `false`.
Furthermore, it seems that they do not necessarily need this
functionality and can just wait for object free. There ends up being a
lot of cleanups for Ray Data because of flags that are no longer
necessary due to the removal of this codepath. All these flags are
defaulted to false.

### Java Internal Free
Java runtime also has an internal free implementation that plumbs into
the same codepath as cython. We decide to not support multi-language
runtimes, and thus do not want to continue supporting this.

### Out of Band Serialization / Deserialization
There is current support for out of band serialization / deserialization
through cloudpickle, which would then rely on internal free for freeing
the underlying object. We do not want to continue supporting this, and
thus remove this.

### Testing Usecases
Some testing use cases who only test adjacent conditions have maintained
functionality. However, some test cases that purely test
`_internal.free` or are largely coupled with `_internal.free` are
removed.

---------

Signed-off-by: aaron.li <[email protected]>
Co-authored-by: aaron.li <[email protected]>
Co-authored-by: Aaron <[email protected]>
gaurav0107 added a commit to gaurav0107/ray that referenced this pull request Nov 25, 2026
Master converted the Ray Core user guide to MyST Markdown (ray-project#66430) and
moved it from doc/source/ray-core to doc/source/core (ray-project#66605), so the
.rst edits from this PR no longer apply. Re-apply them to the .md pages:

- core/patterns/out-of-band-object-ref-serialization.md: add the intro
  paragraph naming both out-of-band channels, retitle the existing
  example as "pickle and cloudpickle", and add the "hex string
  round-trip" section that includes the doc_code example.
- core/objects/serialization.md: the "Serializing ObjectRefs" section
  that held the seealso was removed in ray-project#64037, so add the cross-link as
  a bullet under "Serialization notes" instead.

The doc_code example moved with the directory rename and is unchanged.

Signed-off-by: Gaurav Dubey <[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.

5 participants