Skip to content

Conversation

copybara-service[bot]
Copy link

[JAX] Make colocated Python's serialization pickle each shared object only once

It is common for colocated Python's input spec/output spec/function serialization to use the same object across multiple serialized objects. For example, an input or output spec can contain many shardings as leaves, where all shardings are on the same mesh (even some shardings can be identical). It is slow to serialize all of these objects repeatedly, both in terms of compute and serialized size. This problem is most significant when colocated Python runs on a very large mesh because it is very expensive to pickle/unpickle Mesh and xc.DeviceList repeatedly.

This change inserts a logic detecting shared objects within input spec/output spec/function, and do outlining of these objects to make them pickled only once. Deserialization would unpickle the shared objects and then unpickle individual objects that can internally reference the shared objects.

@copybara-service copybara-service bot force-pushed the test_813470540 branch 2 times, most recently from d9b5fd6 to 1b5b0f4 Compare October 2, 2025 04:46
… only once

It is common for colocated Python's input spec/output spec/function serialization to use the same object across multiple serialized objects. For example, an input or output spec can contain many shardings as leaves, where all shardings are on the same mesh (even some shardings can be identical). It is slow to serialize all of these objects repeatedly, both in terms of compute and serialized size. This problem is most significant when colocated Python runs on a very large mesh because it is very expensive to pickle/unpickle `Mesh` and `xc.DeviceList` repeatedly.

This change inserts a logic detecting shared objects within input spec/output spec/function, and do outlining of these objects to make them pickled only once. Deserialization would unpickle the shared objects and then unpickle individual objects that can internally reference the shared objects.

PiperOrigin-RevId: 813470540
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.

1 participant