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.
ComfyUI SGLDiffusion Pipeline Tests
This directory contains tests for each ComfyUI pipeline integration.
Test Files
test_zimage_pipeline.py- Tests for ComfyUIZImagePipelinetest_flux_pipeline.py- Tests for ComfyUIFluxPipelinetest_qwen_image_pipeline.py- Tests for ComfyUIQwenImagePipelinetest_qwen_image_edit_pipeline.py- Tests for ComfyUIQwenImageEditPipeline (I2I/edit mode)
Running Tests
Run all tests
pytest python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/ -v -s
Run a specific test file
pytest python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_zimage_pipeline.py -v -s
Environment Variables
You can configure model paths via environment variables. Model paths support two formats:
- Safetensors file: Path to a single
.safetensorsfile (e.g.,/path/to/model.safetensors) - Diffusers format: HuggingFace model ID or local diffusers directory (e.g.,
Tongyi-MAI/Z-Image-Turbo)
Environment variables:
SGLANG_TEST_ZIMAGE_MODEL_PATH- Path to ZImage model (default:Tongyi-MAI/Z-Image-Turbo)SGLANG_TEST_FLUX_MODEL_PATH- Path to Flux model (default:black-forest-labs/FLUX.1-dev)SGLANG_TEST_QWEN_IMAGE_MODEL_PATH- Path to QwenImage model (default:Qwen/Qwen-Image)SGLANG_TEST_QWEN_IMAGE_EDIT_MODEL_PATH- Path to QwenImageEdit model (default:Qwen/Qwen-Image-Edit-2511)
Examples:
# Using HuggingFace model ID (diffusers format)
export SGLANG_TEST_ZIMAGE_MODEL_PATH="Tongyi-MAI/Z-Image-Turbo"
pytest python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_zimage_pipeline.py -v -s
# Using safetensors file
export SGLANG_TEST_ZIMAGE_MODEL_PATH="/path/to/z_image_turbo_bf16.safetensors"
pytest python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_zimage_pipeline.py -v -s
Test Structure
Each test file follows a similar structure:
- Setup: Creates a
DiffGeneratorwith the appropriate pipeline class - Input Preparation: Creates dummy tensors for latents, timesteps, and embeddings
- Request Preparation: Uses
prepare_requestto convertSamplingParamstoReq - ComfyUI Inputs: Sets ComfyUI-specific inputs directly on the
Reqobject - Execution: Sends request to scheduler and waits for response
- Validation: Checks that
noise_predis retrieved fromOutputBatch
Notes
- These tests use
comfyui_mode=Trueto enable ComfyUI-specific behavior - Tests use pre-processed inputs (latents, timesteps, embeddings) as ComfyUI would provide
- The tests verify that
noise_predcan be retrieved from theOutputBatchafter processing - All tests use dummy/ones tensors for simplicity - in production, these would be actual model outputs