[PR #3] [MERGED] PyIsolate Update: Production-Ready Process Isolation for ComfyUI #6

Closed
opened 2026-10-26 22:11:30 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/pyisolate/pull/3
Author: @pollockjj
Created: 12/3/2025
Status: ✅ Merged
Merged: 2/14/2026
Merged by: @Kosinkadink

Base: main ← Head: main


📝 Commits (10+)

  • 16ddb98 feat: Add virtual environment support for simple_text_node
  • aee01de feat: Add host path preservation for spawn context
  • 4027e0c fix: Add torch dev/nightly build support
  • 58ba87d feat: Update logging emojis to enhance clarity and add new tests for client snapshot handling and extension safety
  • 7f2b455 refactor: Update logging messages to use consistent book emoji for clarity
  • 13e5c72 Merge remote changes, resolve emoji conflicts (keep book emoji)
  • f045210 feat: Enhance documentation and setup guide; improve error handling and logging in core components
  • 458d11a Enhance logging for path unification and dependency updates; prevent infinite recursion in ProxiedSingleton
  • 846e4cc feat: Enhance RPC handling with callback support; improve logging and path unification
  • ef0a5d7 Add timing and logging for extension loading; ensure 'uv' installation fallback

📊 Changes

92 files changed (+12154 additions, -4693 deletions)

View changed files

➕ .coveragerc (+12 -0)
➕ .github/workflows/build-wheels.yml (+152 -0)
📝 .github/workflows/ci.yml (+13 -9)
📝 .github/workflows/pytorch.yml (+6 -3)
📝 .github/workflows/windows.yml (+1 -1)
📝 .gitignore (+3 -0)
📝 .pre-commit-config.yaml (+2 -2)
📝 README.md (+161 -61)
➕ README_COMFYUI.md (+311 -0)
📝 benchmarks/benchmark.py (+213 -414)
➕ benchmarks/benchmark_harness.py (+115 -0)
📝 benchmarks/memory_benchmark.py (+6 -4)
📝 benchmarks/simple_benchmark.py (+8 -0)
📝 docs/conf.py (+14 -3)
➕ docs/debugging.md (+259 -0)
➕ docs/edge_cases.md (+251 -0)
📝 docs/index.rst (+4 -0)
➕ docs/platform_compatibility.md (+242 -0)
➕ docs/rpc_protocol.md (+275 -0)
📝 pyisolate/__init__.py (+29 -11)

...and 72 more files

📄 Description

PyIsolate Update: Production-Ready Process Isolation for ComfyUI

Major Features

1. Full ComfyUI Integration with Path Unification

Commits: aee01de, 458d11a, 846e4cc, 8699bfa, 029ae2c
ComfyUI-side: 951a6ba7, a62150a3, 230544ac, 852251a0, 04485daa

  • Module-level sys.path unification prevents import errors in spawned processes
  • Host path preservation for multiprocessing.spawn compatibility
  • Automatic ComfyUI root detection and path ordering (ComfyUI root → isolated venv → host paths)
  • Validation layer ensures utils.json_util accessible in all children
  • Zero Impact: Logic only executes in child processes; host ComfyUI startup path remains untouched.

2. Lazy Loading & Caching System

Commits: b4cdd9a
ComfyUI-side: 1a20f4ac, fe3b402a

  • Zero startup penalty: Nodes cached after first spawn, instant on subsequent loads
  • Load at first use: Child processes spawn only when node appears in execution graph
  • Auto-eject: Processes terminate when node no longer in graph
  • Import time tracking shows isolated nodes: 0.0s (cached)
  • Architecture guarantee: Zero runtime overhead for standard (non-isolated) custom nodes

3. Windows Compatibility

Commits: dbca9bb
ComfyUI-side: 8587e20b

  • Manager-based IPC queues replace POSIX-only Queue implementation
  • Spawn context compatibility fixes for Windows multiprocessing
  • Cross-platform validated on Windows, Linux

Expansions

1. Torch Ecosystem Support

Commits: 99e742e, 8d83a4b, 4baa626, 4027e0c

  • Dynamic discovery of torch ecosystem packages (torchvision, torchaudio, etc.) for CUDA version compatibility
  • .pth-based venv inheritance for zero-copy tensor sharing via share_torch=True
  • Support for torch dev/nightly builds via --index-strategy unsafe-best-match (standard uv pattern for non-release version resolution where strict matching fails)
  • Optimized link mode handling for faster venv creation

2. Stateless RPC Implementation

Commits: cd07469, 846e4cc, d785fa3
ComfyUI-side: 6603f42c, d9a5c36c, 54784f33

  • CLIP Stateless RPC Proxy: Automatic serialization for CLIP models across process boundary
  • RPC Callback Support: Bidirectional async communication with context tracking
  • Global RPC instance management for child processes
  • ⚠️ Note: ModelPatcher serialization infrastructure in progress, not feature-complete

3. Tensor Serialization Safety

Commits: 28e7018, a54aa19

  • Custom dict/sequence subclass handling (TorchDict, etc.)
  • CUDA tensor IPC safety checks
  • Unpicklable object detection with fail-loud behavior
  • Inference mode enforcement for shared tensors

Polish

1. Logging Deduplication

Commits: fcb2489, e0540f8
ComfyUI-side: 2d1bb755, fe3b402a, c80c1dbb

  • Child process log filter suppresses messages already shown by host
  • Prevents N×spam from N isolated children
  • Deduplicated patterns: VRAM info, CUDA device, pytorch version, etc.
  • pynvml deprecation warning suppression

2. Documentation

Commits: 029ae2c, f045210

  • Module-level docstrings explaining initialization order
  • Environment variable reference (PYISOLATE_CHILD, PYISOLATE_HOST_SNAPSHOT, PYISOLATE_PATH_DEBUG, PYISOLATE_MODULE_PATH)
  • Path unification timing comments (why module-level execution is critical)
  • Cross-references between client.py and path_helpers.py

3. Unit Tests

Commits: 465c72b, 58ba87d

  • Client snapshot handling tests
  • Extension safety tests
  • Path helpers validation
  • Singleton shared state tests
  • Integration test improvements

Testing

Baseline test: 3 isolated nodes loading in 0.0s (cached), workflow execution in 0.15s

Command: /home/johnj/mysolate/debug/run_debug.sh

Result: ✅ PASS


Statistics

Commit range: 16ddb98..029ae2c (27 commits)
Lines changed: 59 files, +9194/-194 lines
Authors: John Pollock (pyisolate), ComfyUI-side integration


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/pyisolate/pull/3 **Author:** [@pollockjj](https://github.com/pollockjj) **Created:** 12/3/2025 **Status:** ✅ Merged **Merged:** 2/14/2026 **Merged by:** [@Kosinkadink](https://github.com/Kosinkadink) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`16ddb98`](https://github.com/Comfy-Org/pyisolate/commit/16ddb9841f01e7fe8f7f5767a108f6917244cc0b) feat: Add virtual environment support for simple_text_node - [`aee01de`](https://github.com/Comfy-Org/pyisolate/commit/aee01de45331a0017f97f475ec72359c8e9f1cd9) feat: Add host path preservation for spawn context - [`4027e0c`](https://github.com/Comfy-Org/pyisolate/commit/4027e0cd72ef3387b4083edffe51433d39917beb) fix: Add torch dev/nightly build support - [`58ba87d`](https://github.com/Comfy-Org/pyisolate/commit/58ba87d3469e6c068e04f83b6b387e31dab28836) feat: Update logging emojis to enhance clarity and add new tests for client snapshot handling and extension safety - [`7f2b455`](https://github.com/Comfy-Org/pyisolate/commit/7f2b4553347aec1857faeb4b3f9e464b959364b4) refactor: Update logging messages to use consistent book emoji for clarity - [`13e5c72`](https://github.com/Comfy-Org/pyisolate/commit/13e5c72a4b1fb349bd845f53f5222d631859ef0c) Merge remote changes, resolve emoji conflicts (keep book emoji) - [`f045210`](https://github.com/Comfy-Org/pyisolate/commit/f04521024b781f5022424ad3f47c8542231d2bd1) feat: Enhance documentation and setup guide; improve error handling and logging in core components - [`458d11a`](https://github.com/Comfy-Org/pyisolate/commit/458d11a039c91159125ccdb27e8c4664d0bc3c37) Enhance logging for path unification and dependency updates; prevent infinite recursion in ProxiedSingleton - [`846e4cc`](https://github.com/Comfy-Org/pyisolate/commit/846e4ccb4b1428a7c926ba6b416f87e8336c074f) feat: Enhance RPC handling with callback support; improve logging and path unification - [`ef0a5d7`](https://github.com/Comfy-Org/pyisolate/commit/ef0a5d779319065e334eb6269941ce70f038609c) Add timing and logging for extension loading; ensure 'uv' installation fallback ### 📊 Changes **92 files changed** (+12154 additions, -4693 deletions) <details> <summary>View changed files</summary> ➕ `.coveragerc` (+12 -0) ➕ `.github/workflows/build-wheels.yml` (+152 -0) 📝 `.github/workflows/ci.yml` (+13 -9) 📝 `.github/workflows/pytorch.yml` (+6 -3) 📝 `.github/workflows/windows.yml` (+1 -1) 📝 `.gitignore` (+3 -0) 📝 `.pre-commit-config.yaml` (+2 -2) 📝 `README.md` (+161 -61) ➕ `README_COMFYUI.md` (+311 -0) 📝 `benchmarks/benchmark.py` (+213 -414) ➕ `benchmarks/benchmark_harness.py` (+115 -0) 📝 `benchmarks/memory_benchmark.py` (+6 -4) 📝 `benchmarks/simple_benchmark.py` (+8 -0) 📝 `docs/conf.py` (+14 -3) ➕ `docs/debugging.md` (+259 -0) ➕ `docs/edge_cases.md` (+251 -0) 📝 `docs/index.rst` (+4 -0) ➕ `docs/platform_compatibility.md` (+242 -0) ➕ `docs/rpc_protocol.md` (+275 -0) 📝 `pyisolate/__init__.py` (+29 -11) _...and 72 more files_ </details> ### 📄 Description # PyIsolate Update: Production-Ready Process Isolation for ComfyUI ## Major Features ### 1. Full ComfyUI Integration with Path Unification **Commits:** `aee01de`, `458d11a`, `846e4cc`, `8699bfa`, `029ae2c` **ComfyUI-side:** `951a6ba7`, `a62150a3`, `230544ac`, `852251a0`, `04485daa` - Module-level sys.path unification prevents import errors in spawned processes - Host path preservation for multiprocessing.spawn compatibility - Automatic ComfyUI root detection and path ordering (ComfyUI root → isolated venv → host paths) - Validation layer ensures `utils.json_util` accessible in all children - **Zero Impact:** Logic only executes in child processes; host ComfyUI startup path remains untouched. ### 2. Lazy Loading & Caching System **Commits:** `b4cdd9a` **ComfyUI-side:** `1a20f4ac`, `fe3b402a` - **Zero startup penalty:** Nodes cached after first spawn, instant on subsequent loads - **Load at first use:** Child processes spawn only when node appears in execution graph - **Auto-eject:** Processes terminate when node no longer in graph - Import time tracking shows isolated nodes: 0.0s (cached) - **Architecture guarantee:** Zero runtime overhead for standard (non-isolated) custom nodes ### 3. Windows Compatibility **Commits:** `dbca9bb` **ComfyUI-side:** `8587e20b` - Manager-based IPC queues replace POSIX-only Queue implementation - Spawn context compatibility fixes for Windows multiprocessing - Cross-platform validated on Windows, Linux ## Expansions ### 1. Torch Ecosystem Support **Commits:** `99e742e`, `8d83a4b`, `4baa626`, `4027e0c` - Dynamic discovery of torch ecosystem packages (torchvision, torchaudio, etc.) for CUDA version compatibility - .pth-based venv inheritance for zero-copy tensor sharing via `share_torch=True` - Support for torch dev/nightly builds via `--index-strategy unsafe-best-match` (standard `uv` pattern for non-release version resolution where strict matching fails) - Optimized link mode handling for faster venv creation ### 2. Stateless RPC Implementation **Commits:** `cd07469`, `846e4cc`, `d785fa3` **ComfyUI-side:** `6603f42c`, `d9a5c36c`, `54784f33` - **CLIP Stateless RPC Proxy:** Automatic serialization for CLIP models across process boundary - **RPC Callback Support:** Bidirectional async communication with context tracking - Global RPC instance management for child processes - ⚠️ **Note:** ModelPatcher serialization infrastructure in progress, not feature-complete ### 3. Tensor Serialization Safety **Commits:** `28e7018`, `a54aa19` - Custom dict/sequence subclass handling (TorchDict, etc.) - CUDA tensor IPC safety checks - Unpicklable object detection with fail-loud behavior - Inference mode enforcement for shared tensors ## Polish ### 1. Logging Deduplication **Commits:** `fcb2489`, `e0540f8` **ComfyUI-side:** `2d1bb755`, `fe3b402a`, `c80c1dbb` - Child process log filter suppresses messages already shown by host - Prevents N×spam from N isolated children - Deduplicated patterns: VRAM info, CUDA device, pytorch version, etc. - pynvml deprecation warning suppression ### 2. Documentation **Commits:** `029ae2c`, `f045210` - Module-level docstrings explaining initialization order - Environment variable reference (PYISOLATE_CHILD, PYISOLATE_HOST_SNAPSHOT, PYISOLATE_PATH_DEBUG, PYISOLATE_MODULE_PATH) - Path unification timing comments (why module-level execution is critical) - Cross-references between client.py and path_helpers.py ### 3. Unit Tests **Commits:** `465c72b`, `58ba87d` - Client snapshot handling tests - Extension safety tests - Path helpers validation - Singleton shared state tests - Integration test improvements --- ## Testing **Baseline test:** 3 isolated nodes loading in 0.0s (cached), workflow execution in 0.15s **Command:** `/home/johnj/mysolate/debug/run_debug.sh` **Result:** ✅ PASS --- ## Statistics **Commit range:** `16ddb98..029ae2c` (27 commits) **Lines changed:** 59 files, +9194/-194 lines **Authors:** John Pollock (pyisolate), ComfyUI-side integration --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 22:11:30 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/pyisolate#6
No description provided.