Skip to content

fix: gate feature-injection kwargs on TensorRT backend in SD1.5/2.1 UNet call#32

Open
forkni wants to merge 1 commit into
dotsimulate:SDTD_040_beta_releasefrom
forkni:fix/fio-cache-backend-gate
Open

fix: gate feature-injection kwargs on TensorRT backend in SD1.5/2.1 UNet call#32
forkni wants to merge 1 commit into
dotsimulate:SDTD_040_beta_releasefrom
forkni:fix/fio-cache-backend-gate

Conversation

@forkni

@forkni forkni commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • StreamDiffusion.unet_step()'s SD1.5/2.1 branch unconditionally passed fio_cache/fi_strength/fi_threshold to self.unet(...). Those kwargs are TensorRT-engine-only (feature-injection); on any non-TRT backend (acceleration: none/xformers/sfast) this raised TypeError: UNet2DConditionModel.forward() got an unexpected keyword argument 'fio_cache' on every frame.
  • The SDXL branch already gated these kwargs behind self._check_unet_tensorrt(); this fix applies the same gate to the SD1.5/2.1 branch.
  • Adds tests/unit/test_unet_call_backend_gate.py, a regression test that constructs StreamDiffusion via __new__ and drives the real call site with a real (patched) tiny UNet — no model download required.
  • Single focused commit, cherry-picked from forkni/StreamDiffusion@SDTD_040_beta_release (internal PR feat: TRT 10.16.1.11 + FP8 quantization (V2V/CN/IPA) + CUDA hot-path optimizations #12).

Test plan

  • Cherry-picked cleanly onto current SDTD_040_beta_release tip, no conflicts.
  • File-scoped diff (src/streamdiffusion/pipeline.py, new tests/unit/test_unet_call_backend_gate.py).
  • New test covers: non-TRT call no longer raises, non-TRT UNet never receives FI kwargs, TRT engine still receives FI kwargs (no regression).

…Net call (#12)

The SD1.5/2.1 branch of unet_step() unconditionally passed kvo_cache/fio_cache/
fi_strength/fi_threshold to self.unet(...). The import-time diffusers patch
(_patches/diffusers_kvo_patch.py) adds kvo_cache support to the eager PyTorch
UNet, but feature injection is TensorRT-engine-only — the patched forward()
has no fio_cache/fi_strength/fi_threshold parameters. Every non-TRT SD1.5/2.1
run (e.g. acceleration: none) crashed on the first call:

  UNet2DConditionModel.forward() got an unexpected keyword argument 'fio_cache'

Mirrors the SDXL branch's existing _check_unet_tensorrt() gate: kvo_cache is
always passed (both backends support it), the FI trio only when TRT is active.

Adds tests/unit/test_unet_call_backend_gate.py, which reproduces the crash via
a real (patched) tiny UNet2DConditionModel at the actual unet_step() call site
and locks in that the TensorRT path keeps receiving all four cache kwargs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant