[MiniMax-H3] Block-level group offloading of the Qwen3-VL text encoder fails: the encoder step bypasses its top-level forward

Offen
#15,399 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Shan2L arbeitet bereits daran.

Seit 25.11.2026.

  • #15395 von @Shan2L — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
18/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
python, pytorch
Bereich
ai-infra-agents

Rechercherichtung

Start with get_qwen3vl_prompt_embeds in the MiniMax-H3 and Pika-H3-Flex pipeline modules, where text_encoder.model(...) and the manual _hf_hook.pre_forward call bypass the top-level forward. Reproduce with block_level group offloading on the text encoder to see the device mismatch on the token embedding. Done means encoding succeeds under block_level offloading and matches the existing output; the linked pull request #15395 already proposes the change, so this is not open for a fresh attempt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

get_qwen3vl_prompt_embeds (MiniMax-H3, MiniMax-H3-Image, and its copy in Pika-H3-Flex) calls text_encoder.model(...) and fires accelerate's _hf_hook.pre_forward by hand; the code carries a TODO about it. Hooks that wrap only the top-level forward therefore never fire. With offload_type="block_level" group offloading on the text encoder, the modules outside the decoder blocks (the token embedding) are never onloaded and encoding fails:

RuntimeError: Expected all tensors to be on the same device, but got index is on cuda:0, different from other tensors on cpu
Reproduction
import torch
from diffusers import ModularPipeline
from diffusers.hooks import apply_group_offloading

pipe = ModularPipeline.from_pretrained("<MiniMax-H3-Image diffusers checkpoint>")
pipe.load_components(dtype=torch.bfloat16)
dev = torch.device("cuda")
pipe.transformer.enable_group_offload(dev, offload_device=torch.device("cpu"), offload_type="block_level", num_blocks_per_group=1, use_stream=True)
apply_group_offloading(pipe.text_encoder, dev, offload_device=torch.device("cpu"), offload_type="block_level", num_blocks_per_group=1, use_stream=True)
pipe.vae.to(dev)
pipe(prompt="a garden", height=1024, width=1024, output="images")  # fails in the text encoder step

leaf_level on the text encoder works, because it hooks every leaf module.

Context

Offloading is the only way to run MiniMax-H3-Image on one 32 GB GPU: the documented ComponentsManager auto offload moves the ~62 GB text encoder as a whole and does not fit.

System Info

diffusers main (e3f8451), torch 2.14 (ROCm 10.1), Radeon AI PRO R9600D / R9700 (gfx1201).

Fix

#15395 calls text_encoder(...) with logits_to_keep=1 instead, so the top-level hooks fire; hidden_states[50] is bitwise identical to the current call.

Vorherrschende Sprache
Python
Sterne
35k
Forks
7.5k
Ø Merge
2 T. 22 Std.
Gemergte PRs (30 T.)
58

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus huggingface/diffusers

Alle Issues in huggingface/diffusers

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.