Skip to content

[Fix] comfyui: Fix server-mode bugs in the SGLDiffusion plugin - #44082

Open
OnePunchMonk wants to merge 20 commits into
sgl-project:mainfrom
OnePunchMonk:fix/comfyui-sgld-server-mode
Open

OnePunchMonk wants to merge 20 commits into
sgl-project:mainfrom
OnePunchMonk:fix/comfyui-sgld-server-mode

Conversation

@OnePunchMonk

@OnePunchMonk OnePunchMonk commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #44083. Split out of #43536 per review: these are the server-mode fixes, which were moved here as lower priority.

Summary

Fixes for the SGLDiffusion ComfyUI plugin when it talks to an SGLD server. One commit per fix. Bug numbers below match the list in the issue.

  • Bug 1: server-mode nodes sent local paths a remote server can't read. The generic video node sent a local temp path as input_reference and a client-side output_path; the H3 node built file:// URIs for keyframes and references. Local references are now uploaded via multipart (a local video-to-video source goes up as video_reference), output_path is no longer sent (the result is downloaded if the server's path isn't local), H3 image conditions are embedded as base64 data: URIs, and local video/audio references against a confirmed-remote server raise a clear error.
  • Bug 2: SGLDVideoInput didn't implement ComfyUI's VideoInput contract. get_components() returned a bare list and save_to dropped format/codec/metadata. The node now prefers ComfyUI's file-backed VideoFromFile, and the fallback fails loudly.
  • Bug 3: reported video width/height could be wrong. The generic video node reported the requested size even when the server resolved a different one. It now reads the server's size field. (Same commit as bug 2.)
  • Bug 4: hardcoded 300s timeout on image requests. Added a configurable image_timeout (default unchanged).
  • Bug 5: batched image inputs were silently truncated to the first image. Now raises a clear error.
  • Bug 6: LoRA strength wasn't settable in server mode. /set_lora accepts strength; it's now threaded through the client and node.
  • Bug 7: server-mode video jobs had no progress bar and ignored Cancel. generate_video takes progress_callback / check_interrupt, wired to comfy.utils.ProgressBar and throw_exception_if_processing_interrupted. Limits: the server reports progress only as 0 then 100, and Cancel stops the client waiting but the server job keeps running (no abort endpoint yet).

Tests

test/test_sgld_server_mode.py (new): 19 tests covering the fixes above, using stubbed comfy/folder_paths modules (no ComfyUI install or GPU). test/test_h3_request.py updated for the bug 1/6/7 behavior changes (base64 image URIs instead of file://, real temp files since the client now validates file_path locally); existing assertions kept. 30/30 pass on CPU.

Note: until #43536 lands, these tests need the sglang runtime importable, since the import guard that lets the plugin load without it is in that PR.


CI States

Latest PR Test (Base): ❌ Run #40627090702
Latest PR Test (Extra): ❌ Run #40627090727
Latest PR Test (AMD ROCm 10): ❌ Run #40627090636

…t requests

Both image endpoints hardcoded timeout=300, with no way to raise it. A
large image job, or a first request that triggers torch.compile/warmup on
the server, can need more than 300s and the client would time out with no
recourse.

Add a configurable image_timeout constructor param to
SGLDiffusionServerAPI (default 300, unchanged) and expose it as an
optional input on SGLDiffusionServerModel.
…he first image

get_image_path (used by the image, video, and H3 nodes) saved only
image[0] from a batched IMAGE input, silently dropping the rest of the
batch with no warning.

Raise a clear ValueError when a batch of more than one image is passed,
instead of silently keeping just the first.
SGLDiffusionServerAPI.set_lora and the SGLDiffusionServerSetLora node had
no strength parameter, even though the server's /set_lora endpoint
accepts one (default 1.0). There was no way to dial down a LoRA's effect
through this node.

Thread strength through the client and expose it as a node input.
…and wrong reported dimensions

SGLDVideoInput.get_components returned [video_path] instead of a
VideoComponents, so any downstream node reading frames/audio from it would
crash; save_to silently dropped format/codec/metadata. Separately, the
generic video node always reported the *requested* width/height even when
the server resolved a different size (e.g. to match an image-to-video
input's aspect ratio).

Prefer ComfyUI's own file-backed VideoFromFile, which probes the real file
and is immune to both problems; keep SGLDVideoInput only as a fallback
that now fails loudly instead of silently doing the wrong thing. Read the
generic video node's reported size from the server's response.
…te server can't read

The generic video node sent local temp-file paths as input_reference and
a client-side temp directory as output_path; the H3 node built file://
URIs for keyframes/references. None of that is readable by an SGLD server
on another machine (the image node already avoided this by uploading the
file).

Upload a local input_reference via multipart instead of sending its path.
Never send output_path to the server; let it pick its own location and
download the result through GET /videos/{id}/content when the server's
own file_path isn't locally readable. For H3, embed image conditions
inline as base64 data: URIs (the server's material loader already
supports these) and only build a file:// URI for video/audio references
when the SGLD server is confirmed local, raising a clear error otherwise
instead of silently building a URI that will fail remotely.
…video jobs

generate_video takes progress_callback and check_interrupt; both video nodes
wire them to comfy.utils.ProgressBar and
throw_exception_if_processing_interrupted, and let the interrupt through
instead of wrapping it in RuntimeError. Polling sleeps in 1s slices so Cancel
is prompt. The server job itself is not aborted (video_api has no abort yet).
# Conflicts:
#	python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/nodes.py
#	python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/utils.py
OnePunchMonk added a commit to OnePunchMonk/sglang that referenced this pull request Oct 14, 2026
…yui-sgld-nodes

Resolve the overlap in server_api.py and nodes.py: keep the multipart
upload of a local input_reference and the no-output_path request from
sgl-project#44082, and carry enhance_prompt, video_path, request logging, LoRA
stacking and merge_mode from this branch onto it.

Tests: stub comfy.utils/model_management in the harness, give the fake
completed jobs a local file_path, and unpack the video node's new
revised_prompt output.
…sending its path

generate_video takes video_path for video-to-video. A local file is now
sent as the multipart video_reference the server already accepts, so a
server on another machine can read it; URLs and server-side paths are
still sent as video_path.
@github-actions github-actions Bot added the lora label Oct 15, 2026
@OnePunchMonk OnePunchMonk changed the title [diffusion] comfyui: fix server-mode bugs in the SGLDiffusion plugin [Fix] comfyui: Fix server-mode bugs in the SGLDiffusion plugin Oct 16, 2026
…ng /content

A completed job uploaded to cloud storage has a url and no file_path, and
/videos/{id}/content answers 400 for it. The 400 was caught as a poll
error, but the status poll had just reset the error counter, so the node
kept polling until max_wait_time. Return such a job as is so the node
fetches the url, and localize the result outside the poll loop so a real
download error fails at once.
OnePunchMonk added a commit to OnePunchMonk/sglang that referenced this pull request Oct 21, 2026
Rebuilds the branch on the current sgl-project#44082 head and keeps only the VIDEO
input on the generic video node and the enhance_prompt toggle with a
revised_prompt output on the image and video nodes.

Drops the checkpoint sweep, the audio-video node (ComfyUI's Get Video
Components already returns AUDIO from the VIDEO output), the LoRA list and
stack nodes, and the separate test files; the tests now live in
test_sgld_server_mode.py.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion lora

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [diffusion] ComfyUI plugin: server-mode bugs in SGLDiffusion nodes

1 participant