Skip to content

[Bug] Unsloth Studio: a pipeline image load can never pick group offload, so Qwen-Image-2.1 falls to whole-module offload on a 40 GB A100 #11547

Closed

Description

@LeoBorcherding

Loading Qwen/Qwen-Image-2.1 on a Colab A100-SXM4-40GB puts every component on whole-module offload, which pages the transformer, the text encoders and the VAE per step and turns VAE tiling on as a side effect. Group offload would have fit with about 8 GB to spare. It is never considered, because the pipeline load path hands the planner None for the companion split and both group checks are written to fail on None.

diffusion engine: diffusers (non-GGUF load (pipeline) requires diffusers)
diffusion.loaded: repo=Qwen/Qwen-Image-2.1 base=Qwen/Qwen-Image-2.1 device=cuda
  offload=model tiling=True
  reasons=companions exceed budget; whole-module offload of every component

The chain

  1. kind == "pipeline", so _plan_memory takes the branch at studio/backend/core/inference/diffusion.py:6289 and sets companion_mib = None and text_encoder_mib = None. The comment is explicit that this is deliberate: "No companion total on this branch (the whole repo IS the model), so there is no split to hand the planner either."
  2. _sum_required returns None if any argument is None (diffusion_memory.py:718), so group_floor and group_floor_streamed_te are both None.
  3. _group_fits() and _group_fits_streamed_te() are ... is not None and ... (diffusion_memory.py:795), so both are False by construction, on any card of any size.
  4. Resident placement is correctly declined, so the plan falls into the final else: OFFLOAD_MODEL, "companions exceed budget" (diffusion_memory.py:860).
  5. tile = policy in (OFFLOAD_MODEL, OFFLOAD_SEQUENTIAL) (diffusion_memory.py:877), so vae_tiling comes on with it.

refine_memory_plan_for_components runs afterwards against the real tensor sizes (diffusion.py:5513), but it only ever makes whole-module offload more granular when a component will not fit. It cannot walk back to group, and it does not touch vae_tiling.

What the split would have given

_FAMILY_BF16_GB["qwen-image-2.1"] already carries it at diffusion_auto_policy.py:54: transformer 14.2, text encoders 17.5, VAE 1.4 GB.

MiB vs budget
resident (all three + 8192 headroom + 2048 overhead) 44,140 over, correctly declined
group floor (companions resident + headroom + overhead) 28,264 fits
group floor, text encoders streamed 11,575 fits

Group offload is also faster than whole-module, so this costs speed and image quality at once.

The budget those rows are compared against is derived, not measured: safe_device_budget_mib is computed into plan.estimates but never logged, so on a 40 GB card with an idle GPU it works out to roughly 36,400 MiB after the 10% reserve. Logging the estimates alongside diffusion.loaded would take the guesswork out of the next report like this one.

Second, smaller bug in the same place

The reason string is wrong in this case. Nothing exceeded any budget, the size was simply unknown. Anyone reading companions exceed budget on a 40 GB card reasonably concludes their card is too small.

Environment

  • Colab, A100-SXM4-40GB, CUDA, Python 3.13, studio/setup.sh --local off main
  • Qwen/Qwen-Image-2.1, diffusers engine, bf16 dense (diffusion.transformer_quant: skipped)
  • Code read at upstream/main 070f292

Independent of #11539: that PR shrinks the text encoder with a pre-cast fp8 checkpoint, which changes the numbers in the table above but not the control flow. With the split still None, group offload stays unreachable on a pipeline load however small the companions get.

What led here, not claimed as fixed by this

This came out of chasing visible streaking artifacts in Qwen-Image-2.1 output. Across 12 generations in one session tiling=True was set on every one, so the tiled decode has never actually been tested against on this path, and the artifact tracks image content rather than any setting. That makes it a plausible symptom of the placement decision above, not a proven one. The planner bug stands on its own terms either way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions