diff --git a/fastvideo/models/encoders/minimax_h3_qwen3_vl.py b/fastvideo/models/encoders/minimax_h3_qwen3_vl.py index 896717a7f..a67273195 100644 --- a/fastvideo/models/encoders/minimax_h3_qwen3_vl.py +++ b/fastvideo/models/encoders/minimax_h3_qwen3_vl.py @@ -622,7 +622,14 @@ class MiniMaxH3Qwen3VLConditioner(TextEncoder[torch.Tensor]): f"tokens={int(mask.sum())}, features={features.shape[0]}") return mask - @torch.inference_mode() + # no_grad, NOT inference_mode: with text_encoder_cpu_offload=True (the + # FastVideoArgs default) the loader FSDP2-shards this conditioner, and + # FSDP2's wait_for_unshard reads tensor._version via + # _unsafe_preserve_version_counter - inference tensors do not track + # version counters, so inference_mode crashes the first encode. no_grad + # frees the same activation memory and keeps prompt_embeds ordinary + # tensors (safe for any future backward through the conditioning). + @torch.no_grad() def encode_ids( self, input_ids: torch.Tensor,