Nodes/ComfyUI-BerniniR/BerniniR · Load Model (native, safe fp8)
ComfyUI Node

BerniniR · Load Model (native, safe fp8)

Loads fp8 Wan experts without crashing Windows on torch 2.8

By neuregex·Created 3 months ago·Updated 3 months ago· 24
BerniniR · Load Model (native, safe fp8)
    • model
    unet_name

    BerniniR · Load Model (native, safe fp8) loads a Wan expert as a stock ComfyUI MODEL - but does it in a way that dodges a genuinely nasty crash. ComfyUI's standard load_torch_file calls safetensors.torch.load_file, which segfaults with an "access violation" when it materializes fp8 e4m3 tensors under torch 2.8 on Windows. This node reads the safetensors by hand (mmap + a byte copy, never a view into the file), builds the model skeleton in meta device, and assigns the real weights onto it with zero fp8 allocation. The crash can't happen because the crashy code path never runs.

    This is the entry point to the pack's native path - the one that plays nice with UnetLoaderGGUF and ComfyUI's own sampling machinery, as opposed to the diffusers-based Load Model node.

    What you set

    One input: unet_name, a dropdown of everything in ComfyUI/models/diffusion_models. The file needs to be a Wan expert converted to native ComfyUI keys - the pack ships the converter:

    python tools/convert_bernini_to_comfy.py --repo Bernini-R-Diffusers --out-dir comfy_out --dtype bf16
    

    The converter's key mapping is verified against diffusers' official convert_wan_to_diffusers.py. (The GGUF path skips this entirely - the pre-quantized GGUFs from neuregex/Bernini-R-GGUF are already native keys, which is why the README's GGUF graphs just use UnetLoaderGGUF.)

    What it does, mechanically

    It reads the checkpoint without safetensors.torch.load_file, detects the model from the keys, sets inference dtype (float8_e4m3fn if the checkpoint has fp8, bfloat16 otherwise) with a bf16 manual cast so mixed checkpoints don't blow up with "Input type (float) vs bias (BFloat16)", builds the skeleton on meta device (0 RAM, and critically no real torch.empty(fp8) that segfaults), assigns your tensors with strict=False, assign=True, and wraps it in a ModelPatcher - after which ComfyUI manages it like any other model. It then applies the Bernini patches (source-id RoPE + stream-concat) so the model is ready for editing streams; if patching fails, it runs as native Wan rather than dying.

    Output

    model (MODEL) - into a KSampler/SamplerCustom for plain t2v, or into BerniniR · Source Stream + BerniniR · Guider for editing.

    Honest note: for pure t2v/t2i you may not need this node at all. With a single stream at source_id=0, the forward is numerically identical to standard Wan2.2, so a plain UnetLoaderGGUF → sampler just works. This node (and its native siblings) is the path for editing, and for anyone whose environment trips the fp8 crash on the standard loader.

    Install & troubleshooting

    Shared pack install: ComfyUI Manager, or clone into custom_nodes + pip install -r requirements.txt.

    • "ComfyUI no detectó un modelo de difusión" - the file isn't a converted Wan expert (or wasn't converted with this pack's tool). Run the converter, or use the GGUF repo.
    • Weights were pre-quantized fp8 and Windows crashes anyway? This node is the fix - that's literally why it exists. If you still crash, check torch version; the bug is torch 2.8/Windows-specific.
    • Warning about missing patches? The model still loads as native Wan (fine for t2v); editing streams just won't work.
    • Loading into VRAM for real? The meta+assign trick keeps load RAM low; the experts still need their ~14 GB (fp8) each at sampling. That's what the Guider's dual-expert and GGUF paths are designed around.
    CategoryBerniniR

    Inputs (1)

    NameTypeDefaultDescription
    unet_nameCOMBOExperto Wan en models/diffusion_models (convertido con convert_bernini_to_comfy.py).

    Outputs (1)

    NameTypeDescription
    modelMODEL