A Python script now runs MiniMax-H3 video and audio generation without opening the graphical ComfyUI interface. The workflow handles GPU memory, disk space, model precision, resolution, duration, and sampling strategy, choosing a weight profile based on available hardware. It installs ComfyUI programmatically, pulls diffusion, text-encoder, video-VAE, and audio-VAE weights from Hugging Face, and talks to the server via HTTP and WebSocket APIs. The code builds the execution graph in Python, checks node schemas against the live /object_info endpoint, and supports text-to-video, first- and last-frame-conditioned generation, and reference-image-conditioned generation. This creates a reproducible pipeline for testing MiniMax-H3 without using the graphical interface.
Setup and configuration
The script defines the core MiniMax-H3 configuration, model profiles, generation parameters, and shared utility functions. It calculates valid frame counts and canvas dimensions while checking GPU capability, available VRAM, BF16 support, and disk space before inference begins. It also selects the most appropriate model profile so the pipeline matches the hardware available in the Colab runtime.
The code includes a prompt for a realistic live-action cinematic look featuring a lighthouse keeper on a storm-lashed cliff at dusk. The prompt specifies anamorphic lens, shallow depth of field, and film grain. It breaks the scene into three shots: a wide shot of waves against black rock, a medium shot of the keeper bracing against the wind, and a close-up where he says “She’s holding.” The camera instructions call for hard cuts, slight handheld jitter, and no dissolves. Audio requires roaring surf, howling wind, a low cello drone, and heavy wave impacts on each cut. The output must contain no text, subtitles, logos, or watermarks.
Configuration variables set the aspect ratio to 16:9, megapixels to 0.4, duration to 5.0 seconds, and seed to 556589502035082. Steps are set to 20 with a res_multistep sampler and simple scheduler. First frame, last frame, and reference images are left empty for this run. Sigma shift and turbo LoRA are disabled. Turbo steps are set to 8 with an euler sampler and beta scheduler. The ComfyUI directory is /content/ComfyUI, outputs go to /content/outputs, and models live in /content/models. The server runs on port 8188. The Hugging Face token is pulled from the environment variable HF_TOKEN. Skip install is set to False.
Three model profiles exist for different hardware tiers. The quality profile needs 70 GB VRAM and uses bf16 safetensors for the UNET and text encoder with –normalvram flags. The balanced profile needs 38 GB VRAM and uses pruned int8 convrot weights with –normalvram and –cache-none flags. The squeeze profile needs 20 GB VRAM and uses pruned fp8 scaled weights with –lowvram, –cache-none, and –disable-smart-memory flags. The video VAE is minimax_h3_video_vae_fp16.safetensors and the audio VAE is minimax_h3_audio_vae_fp32.safetensors.
A shell command function runs a command, streaming output. A JSON function sends a request to the API path with a payload if provided, defaulting to a 30 second timeout. A frame alignment function snaps the frame count upward to the 17k+5 grid required by H3. A canvas function mirrors ComfyUI’s ResolutionSelector and the H3 768*1344 area cap, scaling dimensions down if they exceed the cap and rounding to a multiple of 32.
A preflight function imports torch and exits if missing, requiring a Colab GPU runtime. It checks for a CUDA device and exits if none is found, instructing the user to change the runtime type to GPU A100. It prints the GPU name, VRAM in GB, and whether bf16 is supported. It prints free disk space in GB. If bf16 is not supported, the script exits because MiniMax-H3 will not run on T4 or K80 cards, requiring an A100, L4, or H100 instead. It finds the profile matching the available VRAM and exits if the VRAM is below 20 GB. It warns if free disk is less than 45 GB. It prints the selected profile name and the UNET and text encoder filenames.
Installation and downloads
The script installs and configures ComfyUI, prepares the external model directory structure, and enables MiniMax-H3 support inside the Colab environment. It downloads the required diffusion model, text encoder, video VAE, and audio VAE weights from Hugging Face while reusing cached files whenever possible. It also optionally retrieves the Turbo LoRA configuration.
If SKIP_INSTALL is True and the ComfyUI directory exists, the script skips the install. Otherwise, it installs huggingface_hub with hf_xet and hf_transfer, plus websocket-client. It clones the ComfyUI repository with a depth of 1. It installs requirements from the ComfyUI requirements.txt file. It prints the ComfyUI version if the version file exists. It exits if the ComfyUI checkout lacks native MiniMax-H3 nodes, requiring an update. It creates directories for diffusion_models, text_encoders, vae, and loras inside the models root. It writes an extra_model_paths.yaml file pointing to these directories. It creates the output directory.
A fetch function downloads a file from Hugging Face. It sets the HF_HUB_ENABLE_HF_TRANSFER environment variable to 1. It checks if the target file exists and is larger than 1 MB, printing a cache message if so. It attempts to download the file using the HF_TOKEN if provided. If the download fails with a 401, 403, or gated error, it exits with a message to accept the MiniMax-H3 community license on the model page, create a read token, and set the HF_TOKEN. It moves the downloaded file to the target location if the paths differ.
The download_weights function selects the UNET file based on the mode, using the reference UNET for r2v mode and the forward UNET otherwise. It fetches the diffusion model, text encoder, video VAE, and audio VAE. It handles the Turbo LoRA if CFG[“TURBO_LORA”] is True. It lists repo files from drbaph/MiniMax-H3-Turbo-Lora-ComfyUI looking for safetensors files containing pruned. If no files match, it lists all safetensors files. If files exist, it fetches the last sorted file and prints the turbo LoRA name.




