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

Aberta
#15,399 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Shan2L já está trabalhando nisso.

Desde 25/11/2026.

  • #15395 de @Shan2L — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
18/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
python, pytorch
Domínio
ai-infra-agents

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
35k
Forks
7.5k
Merge médio
2d 22h
PRs com merge (30d)
58

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de huggingface/diffusers

Todas as issues de huggingface/diffusers

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.