Introduce a new ComfyUI plugin to integrate SGLang Diffusion. Adds core integration pieces (generator, model patcher, server API client), executor implementations for multiple model types (flux, qwen_image, zimage, native, anima), node mappings, utilities, example workflows, and tests. Includes README with installation/usage instructions and example workflow JSON files. This commit implements both server (HTTP) and integrated modes, model loading/patching logic, and basic LoRA/video/image API support.
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
"""
|
|
Generic native executor for SGLang Diffusion ComfyUI integration.
|
|
|
|
Runs models directly through ComfyUI without SGLang when no SGLang
|
|
pipeline exists for the model type. The forward pass is delegated
|
|
to the ComfyUI-loaded diffusion model.
|
|
"""
|
|
|
|
from .base import SGLDiffusionExecutor
|
|
|
|
|
|
class NativeExecutor(SGLDiffusionExecutor):
|
|
"""Generic native executor for unsupported SGLang model types.
|
|
|
|
Bypasses SGLang entirely and calls the ComfyUI diffusion model
|
|
directly. This allows SGLDUNETLoader to load any model type
|
|
without requiring an SGLang pipeline.
|
|
"""
|
|
|
|
def __init__(self, generator, model_path, model, config, native_diffusion_model):
|
|
super().__init__(generator, model_path, model, config)
|
|
# Break circular nn.Module reference:
|
|
# comfyui_model.diffusion_model → NativeExecutor (self)
|
|
# NativeExecutor.model → comfyui_model (set by base class)
|
|
# Deregister 'model' from _modules so state_dict() won't infinitely recurse.
|
|
if 'model' in self._modules:
|
|
del self._modules['model']
|
|
# Register native_diffusion_model normally so its weights are visible
|
|
# to ComfyUI's dynamic VRAM loading.
|
|
self.native_diffusion_model = native_diffusion_model
|
|
|
|
def set_lora(self, lora_nickname=None, lora_path=None, strength=None, target=None):
|
|
"""LoRA not supported in native mode."""
|
|
pass
|
|
|
|
def forward(self, *args, **kwargs):
|
|
"""Forward pass: delegate directly to the ComfyUI diffusion model."""
|
|
return self.native_diffusion_model(*args, **kwargs)
|