Skip to content

Native NVFP4 (Blackwell) Loading Failure on RTX 5090 - Wan 2.2/Flux2Dev/LTX2 Workflow #11864

Description

@freddiefiasco

Custom Node Testing

Expected Behavior

Expected Behavior When loading the Wan_2.2_nvfp4_mixed checkpoint on an RTX 5090 with comfy-kitchen (CUDA backend) active, the Load Diffusion Model node should natively map the 4-bit weights to the TensorCoreNVFP4Layout without intermediate upcasting.

The expected VRAM footprint for the 14B model should be approximately 7.5 GB (reflecting 4-bit quantization). The console should confirm a direct load into the NVFP4 container, enabling the RTX 5090’s native FP4 Tensor Core acceleration, rather than falling back to torch.float16 (28GB) or torch.float8_e4m3fn (14GB) via a safety cast.

Actual Behavior

Actual Behavior When attempting to load the Wan_2.2_nvfp4_mixed or others e.g. ltx2, flux2dev nvfp4 checkpoint, the Load Diffusion Model node fails to preserve the native 4-bit quantization, resulting in one of two failure modes:

Default Configuration: When weight_dtype is set to default, the loader defaults to torch.float16. This triggers a massive ~28 GB memory allocation (standard 14B size), causing an immediate torch.OutOfMemoryError as it exceeds the available VRAM on a single RTX 5090 instance when loaded alongside the T5 encoder.

FP8 Configuration: When weight_dtype is set to fp8_e4m3fn, the system forcibly upcasts the 4-bit weights to 8-bit. The console log reports loaded completely; 14745.55 MB loaded, confirming an FP8 load (14GB) rather than the expected NVFP4 load (~7GB).

In all successful load attempts, the logs show manual cast: torch.float16 or similar casting warnings, indicating that the comfy-kitchen NVFP4 backend was bypassed. The model never enters the optimized TensorCoreNVFP4Layout, forcing the system to rely on slower, memory-intensive standard operations.

Steps to Reproduce

Steps to Reproduce

Environment Setup: Configure a Windows environment with an NVIDIA RTX 5090 (Blackwell), CUDA 13.0, and PyTorch Nightly (2.9.1+cu130). Ensure comfy-kitchen is installed and the CUDA backend is initialized (verified via startup logs).

Clean Installation: Use a standard ComfyUI installation with minimal custom nodes (removing ComfyUI-MultiGPU or other patchers to isolate the issue).

Workflow Construction:

Add a standard Load Diffusion Model node.

Select the Wan_2.2_nvfp4_mixed.safetensors checkpoint.

Test Case A (Default Behavior):

Set the loader's weight_dtype to default.

Queue a prompt.

Result: The console logs a manual cast: torch.float16 warning. Memory allocation spikes to ~28GB, triggering a torch.OutOfMemoryError on a single GPU instance (when loaded with T5).

Test Case B (Forced FP8):

Set the loader's weight_dtype to fp8_e4m3fn.

Queue a prompt.

Result: The console logs loaded completely with a size of ~14,700 MB. This indicates the 4-bit weights were read but upcasted to 8-bit to satisfy the dtype request, rather than utilizing the 7GB NVFP4 layout.

Debug Logs

[ComfyUI-Manager] All startup tasks have been completed.
got prompt
...
Requested to load WanTEModel
loaded completely; 6419.48 MB loaded, full load: True
Requested to load WanVAE
loaded completely; 392.62 MB loaded, full load: True
Found quantization metadata version 1
Detected mixed precision quantization
Using mixed precision operations
model weight dtype torch.float8_e4m3fn, manual cast: torch.float16  <-- CRITICAL FAILURE
model_type FLOW
Using sage attention mode: sageattn3
Requested to load WAN21
0 models unloaded.
loaded completely; 14745.55 MB loaded, full load: True  <-- PROOF OF UPCAST (Should be ~7500 MB)

File "\custom_nodes\ComfyUI_bnb_nf4_fp4_Loaders\__init__.py", line 12, in functional_linear_4bits
    out = bnb.matmul_4bit(x, weight.t(), bias=bias, quant_state=weight.quant_state)
File "site-packages\bitsandbytes\autograd\_functions.py", line 376, in matmul_4bit
    assert quant_state is not None
AssertionError

model weight dtype torch.float16, manual cast: torch.float16
model_type FLOW
Requested to load WAN21
Allocated memory 54580 MiB
torch.OutOfMemoryError: Allocation on device

Other

Detailed Environment Specification

System Hardware

GPU: 2x NVIDIA GeForce RTX 5090 (Blackwell SM_120)

CPU: AMD Ryzen Threadripper 9960X 24-Cores

RAM: ~128 GB (Total System RAM)

OS: Windows 11 (Platform Release 11)

Core Software Stack

NVIDIA Driver: 591.74

CUDA Toolkit: 13.0 (Targeted via PyTorch cu130 build)

Python: 3.12.10 (tags/v3.12.10:0cc8128) [MSC v.1943 64 bit (AMD64)]

PyTorch: 2.9.1+cu130 (Nightly Build)

ComfyUI Versioning

Backend Version: 0.9.1

Frontend Version: 1.38.1

Comfy-Kitchen Backend: cuda (Initialized: {'available': True, ... 'capabilities': ['quantize_nvfp4', 'scaled_mm_nvfp4']})

Critical Libraries & Dependencies

SageAttention: 2.2.0 (Custom wheel: sageattention-2.2.0+cu130.torch2.11-cp311... equivalent build for Py3.12)

BitsAndBytes: 0.49.1 (Verified via Manager log refusing downgrade)

Crystools: 1.27.4

Launch Arguments

Flags: --listen --normalvram (Tested with --gpu-only and --highvram with identical failures)

Environment Overrides:

CUDA_VISIBLE_DEVICES=0 (To isolate single GPU behavior)

COMFY_KITCHEN_BACKEND=cuda (To force non-eager execution)

PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True

Model File Under Test

Checkpoint: Wan_2.2_nvfp4_mixed.safetensors (GitMylo / Wan-AI)

Target Format: NVFP4 / E2M1 (Expected Load Size: ~7.5 GB)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Potential BugUser is reporting a bug. This should be tested.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions