Skip to content

pyisolate 0.10.3rc1: per-channel tensor transport + modern-Python event loop#9

Open
pollockjj wants to merge 1 commit into
developfrom
release/0.10.3rc1
Open

pyisolate 0.10.3rc1: per-channel tensor transport + modern-Python event loop#9
pollockjj wants to merge 1 commit into
developfrom
release/0.10.3rc1

Conversation

@pollockjj

Copy link
Copy Markdown
Owner

Summary

Single squashed commit off develop carrying 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 Tensor serializer in both serialization pre-passes (_prepare_for_rpc_impl, _serialize_for_isolation_impl), so a shared-memory TensorRef is never emitted onto a JSON channel. Previously, a co-resident shared_memory (share_torch) extension pinned the process-global serializer, and a torch-free sealed/conda worker decoding the resulting TensorRef on 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 RuntimeError on 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 eager asyncio.get_event_loop() raised RuntimeError("There is no current event loop") on Python >=3.12 in the synchronous host launch path.

Tests / version

  • Regression tests for both fixes.
  • Version bumped to 0.10.3rc1 in pyproject.toml and pyisolate/__init__.py.

Test plan

  • pytest tests/test_rpc_contract.py tests/test_tensor_transport_mode_isolation.py tests/test_event_channel.py — green.
  • Both bugs reproduced on the released pyisolate==0.10.2 wheel and confirmed fixed here.

…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__).

Copilot AI 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.

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()
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.

2 participants