ComfyUI Node

CXH_Phi_load

The node that drags a ~9GB vision model into ComfyUI (first run included)

By StartHua·Created 2 years ago·Updated 2 years ago· 18
CXH_Phi_load
    • phi_mode
    model
    num_crops4
    attentioneager

    This is the "please wait, downloading ~9GB" node. CXH_Phi_load is the loader half of the vision pipeline in StartHua's little pack, and it earns its keep by doing the two things nobody wants to do by hand: pulling Microsoft's Phi-3.5-vision-instruct model off HuggingFace and loading it onto your GPU inside ComfyUI. Pair it with CXH_Phi_Run and you can point at any image in a workflow - a render, a reference, a loaded PNG - and ask it a question in plain language. "What color is the hair" and getting an actual answer back is the party trick.

    How it works

    First run is the expensive one. The node calls snapshot_download and drops the whole model into ComfyUI/models/LLM/microsoft/Phi-3.5-vision-instruct - roughly 9GB, so go make a coffee. It then loads it with AutoModelForCausalLM plus the model's AutoProcessor, both with trust_remote_code=True, pinned to CUDA (device_map="cuda", torch_dtype="auto"). No HF token needed - I checked the repo, it's not gated, and it's MIT licensed on top.

    Two things make this loader friendlier than it looks. The download is one-time; the load is cached by ComfyUI, so once it's in VRAM you can tweak the prompt in the Run node as many times as you like without touching the model again. And because the processor is built into the model handle, everything downstream - the cropping, the <|image_1|> placeholders, the chat template - is handled for you.

    Inputs that matter

    There are only three, and you can ignore two of them:

    • model - a dropdown with exactly one entry, Phi-3.5-vision-instruct. It's there for symmetry with the pack's text loader, not choice.
    • num_crops - 4 or 16, default 4. The source comment says it plainly: 4 for multi-frame (or multi-image), 16 for a single image where you want the model to actually look closely. The 16-crop mode is slower and eats more VRAM, but it's noticeably better at detail questions about one image.
    • attention - eager (default), sdpa, or flash_attention_2. See the gotcha below.

    The single output, phi_mode (type CXH_PHI_PIP), is the loaded model + processor bundle. Wire it into the phi_mode input of CXH_Phi_Run. That's the whole graph so far.

    Install

    The pack README is, charitably, a stub - two screenshots and the words "Fast, Fast, Fast!" - so do what the rest of the ecosystem does: ComfyUI Manager, search for Comfyui_CXH_Phi_3.5, install, restart. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StartHua/Comfyui_CXH_Phi_3.5
    # then restart ComfyUI
    

    Where people get burned

    • The flash_attn==2.5.8 pin in requirements.txt. flash-attn is a compiled extension - it needs a matching CUDA build or a long source compile, and it's the classic ComfyUI dependency fight. The kicker: with the default eager attention (or sdpa), you don't need flash-attn at all. If the pack's install chokes on it, comment that line out of requirements.txt and leave attention on eager/sdpa.
    • It's CUDA-only, no ifs. device_map="cuda" is hardcoded, so a plain CPU Mac or an AMD-only box is out.
    • VRAM contention. A 4.2B vision model and a diffusion model in the same graph compete for the same card. On an 8GB GPU you'll get offloading stutter; 12GB+ is comfortable.

    One more honest note: if your actual goal is bulk-captioning, this is a heavy hammer. The community has largely settled on lightweight options like Florence-2 or JoyCaption for that job. Phi-3.5-vision shines at open-ended questions about images, not at captioning a thousand files.

    CategoryCXH/LLM

    Inputs (3)

    NameTypeDefaultDescription
    modelCOMBO1 options: Phi-3.5-vision-instruct
    num_cropsCOMBO42 options: 4, 16
    attentionCOMBOeager3 options: flash_attention_2, sdpa, eager

    Outputs (1)

    NameTypeDescription
    phi_modeCXH_PHI_PIP