Repository navigation
[diffusion] comfyui: start the SGLD worker without re-running ComfyUI's main.py - #43872
Closed
OnePunchMonk wants to merge 1 commit into
Closed
OnePunchMonk wants to merge 1 commit into
OnePunchMonk wants to merge 1 commit into
Conversation
…'s main.py Spawn re-imports __main__ in every worker. Under ComfyUI v0.39.2 that is main.py, which fails in the child because comfy/ is first on sys.path and comfy/utils.py shadows the utils package, so every integrated-mode model failed to load.
OnePunchMonk
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
kevin-mii,
mickqian,
niehen6174,
ping1jing2 and
yichiche
as code owners
October 12, 2026 16:49
Closed
4 tasks done
Collaborator
|
Thanks! This is already fixed in #43504 (same approach, |
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.
Fixes #43873
Motivation
On ComfyUI v0.39.2, every integrated-mode model (SGLDUNETLoader) fails to load. The node raises "The SGLD worker exited while loading the model", and the worker log shows:
The worker is started with multiprocessing spawn, so the child re-imports the parent's
__main__, which under ComfyUI ismain.py. ComfyUI'snodes.pyputsComfyUI/comfyfirst onsys.path, so in the childimport utils.install_utilfindscomfy/utils.pyinstead of ComfyUI'sutils/package.Modifications
__main__.__file__/__spec__only whileDiffGenerator.from_pretrainedstarts the workers, then restore them. The worker never runs ComfyUI's entry script; it only needs sglang modules.init_generatorfrom a host script that fails when re-imported, like ComfyUI'smain.py.Accuracy Tests
No change to model outputs. End to end check with ComfyUI v0.39.2 started the normal way (
python main.py) and a Flux.1-dev SGLDUNETLoader workflow (1024x1024, 25 steps):'utils' is not a packageerror above.Speed Tests and Profiling
N/A
Checklist
test_comfyui_generator.py,test_comfyui_adapters.py,test_comfyui_session.py: 59 passed on a T4.CI States
Latest PR Test (Base): ❌ Run #38280102285
Latest PR Test (Extra): ❌ Run #38280101950
Latest PR Test (AMD ROCm 10): ❌ Run #38280102570