pyisolate 0.10.3rc1: per-channel tensor transport + modern-Python event loop#9
Open
pollockjj wants to merge 1 commit into
Open
pyisolate 0.10.3rc1: per-channel tensor transport + modern-Python event loop#9pollockjj wants to merge 1 commit into
pollockjj wants to merge 1 commit into
Conversation
…nt loop
Serialize torch tensors before the registry's mode-bound "Tensor" serializer in both serialization pre-passes so a shared-memory TensorRef is never emitted onto a JSON channel. This fixes KeyError('data') in torch-free sealed/conda workers when a shared_memory (share_torch) extension is co-resident with a json (sealed/conda) extension. CUDA-IPC routing is evaluated at call time so configured CUDA tensors are not downgraded.
Acquire the event loop in AsyncRPC.__init__ without raising on Python >=3.12: prefer the running loop, then the thread's installed loop, and create one only as a last resort. Fixes RuntimeError('There is no current event loop') in the synchronous host launch path.
Add regression tests for both fixes and bump version to 0.10.3rc1 (pyproject and __init__).
There was a problem hiding this comment.
Pull request overview
This PR prepares the 0.10.3rc1 release by fixing two pre-existing issues in 0.10.2: (1) tensor serialization being incorrectly pre-encoded via the process-global registry instead of deferring to the per-channel transport, and (2) AsyncRPC failing to construct on Python 3.12+ when no current event loop exists (sync host launch path). It also adds regression tests and bumps the version.
Changes:
- Defer torch tensor encoding in the RPC/host serialization pre-passes so the selected transport (JSON vs shared-memory/CUDA IPC) decides the wire format.
- Make
AsyncRPC.__init__acquire an event loop safely across “running”, “installed”, and “none installed” scenarios (Python 3.12+ compatible). - Add regression tests for both fixes and bump version to
0.10.3rc1.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pyisolate/_internal/rpc_serialization.py |
Defers tensor handling ahead of registry serializer to preserve per-channel tensor transport selection. |
pyisolate/_internal/model_serialization.py |
Defers tensor handling ahead of registry serializer and reads CUDA-IPC env at call time (vs import time). |
pyisolate/_internal/rpc_protocol.py |
Updates AsyncRPC loop acquisition to avoid Python 3.12+ get_event_loop() failure when no loop is installed. |
tests/test_tensor_transport_mode_isolation.py |
New regression coverage for per-channel tensor transport and runtime CUDA-IPC env evaluation. |
tests/test_tensor_shared_memory.py |
New regression coverage for CPU shared-memory tensor “zero-copy” semantics. |
tests/test_rpc_contract.py |
New regression coverage for AsyncRPC construction behavior across event-loop states. |
tests/test_event_channel.py |
Switches tests to asyncio.run() to avoid reliance on deprecated/changed get_event_loop() behavior. |
pyproject.toml |
Version bump to 0.10.3rc1. |
pyisolate/__init__.py |
Version bump to 0.10.3rc1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+52
to
54
| if os.environ.get("PYISOLATE_ENABLE_CUDA_IPC") == "1": | ||
| return data | ||
| return data.cpu() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Single squashed commit off
developcarrying the two 0.10.3rc1 fixes plus the version bump. Both bugs are pre-existing in released 0.10.2 and were reproduced against the released wheel.Per-channel tensor transport (fixes
KeyError('data')in torch-free sealed/conda workers)Serialize torch tensors before the registry's mode-bound
Tensorserializer in both serialization pre-passes (_prepare_for_rpc_impl,_serialize_for_isolation_impl), so a shared-memoryTensorRefis never emitted onto a JSON channel. Previously, a co-residentshared_memory(share_torch) extension pinned the process-global serializer, and a torch-free sealed/conda worker decoding the resultingTensorRefon its JSON channel crashed on the missing"data"key. CUDA-IPC routing is evaluated at call time so configured CUDA tensors are not downgraded to CPU.Modern-Python event loop (fixes
RuntimeErroron Python >=3.12)AsyncRPC.__init__acquires the event loop without raising when constructed outside a running loop: prefer the running loop, then the thread's installed loop, and create one only as a last resort. Previously the eagerasyncio.get_event_loop()raisedRuntimeError("There is no current event loop")on Python >=3.12 in the synchronous host launch path.Tests / version
0.10.3rc1inpyproject.tomlandpyisolate/__init__.py.Test plan
pytest tests/test_rpc_contract.py tests/test_tensor_transport_mode_isolation.py tests/test_event_channel.py— green.pyisolate==0.10.2wheel and confirmed fixed here.