Skip to content

[diffusion]: Fix diffusers executor crash when component residency manager is absent#24573

Merged
mickqian merged 2 commits intosgl-project:mainfrom
qimcis:diffusers-runtime-batching-fixes
May 9, 2026
Merged

[diffusion]: Fix diffusers executor crash when component residency manager is absent#24573
mickqian merged 2 commits intosgl-project:mainfrom
qimcis:diffusers-runtime-batching-fixes

Conversation

@qimcis
Copy link
Copy Markdown
Contributor

@qimcis qimcis commented May 7, 2026

Summary

Fix a --backend diffusers runtime crash introduced by the component residency manager refactor in #23771.

DiffusersPipeline uses the common SyncExecutor, but it was not binding a component residency manager before executing stages the way composed/native pipelines do. After the refactor, the shared executor calls residency hooks such as component_residency_manager.begin_request(...). For diffusers pipelines, that manager was None, so generation failed before the diffusers pipeline ran.

This change initializes the diffusers pipeline residency state and binds the global component residency manager to the executor before forwarding the request

Motivation

Forced diffusers backend models can load successfully but fail on the first generation request:

AttributeError: 'NoneType' object has no attribute 'begin_request'

Testing

1x rtx5090 32GB
black-forest-labs/FLUX.2-klein-4B

Baseline command:

sglang generate \
  --model-path black-forest-labs/FLUX.2-klein-4B \
  --backend diffusers \
  --trust-remote-code \
  --prompt "A compact engineering test image of a red cube on a gray table, studio lighting" \
  --height 512 \
  --width 512 \
  --num-inference-steps 1 \
  --guidance-scale 1.0 \

the pipeline loads:

Loaded diffusers pipeline: Flux2KleinPipeline

but the generation request fails before the diffusers stage runs:

Error executing request ...: 'NoneType' object has no attribute 'begin_request'
AttributeError: 'NoneType' object has no attribute 'begin_request'

After fix command:

sglang generate \
  --model-path black-forest-labs/FLUX.2-klein-4B \
  --backend diffusers \
  --trust-remote-code \
  --prompt "A compact engineering test image of a red cube on a gray table, studio lighting" \
  --height 512 \
  --width 512 \
  --num-inference-steps 1 \
  --guidance-scale 1.0 \

the pipeline loads:

Loaded diffusers pipeline: Flux2KleinPipeline

And the generation request succeeds:

Loaded diffusers pipeline: Flux2KleinPipeline
[DiffusersExecutionStage] finished
Output saved to outputs/flux2_klein_diffusers.png
Pixel data generated successfully

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added the diffusion SGLang Diffusion label May 7, 2026
@qimcis
Copy link
Copy Markdown
Contributor Author

qimcis commented May 7, 2026

maybe we need to add some --backend diffusers ci? i think if i rebase and improve #19213 it would be enough @mickqian

@qimcis
Copy link
Copy Markdown
Contributor Author

qimcis commented May 7, 2026

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci label May 7, 2026
@mickqian
Copy link
Copy Markdown
Collaborator

mickqian commented May 9, 2026

duplicated with #24748

@mickqian mickqian merged commit 8e534e8 into sgl-project:main May 9, 2026
76 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants