Nodes/Ollama-ImageList/Llama.cpp Gemma 4 Runtime Preset
ComfyUI Node

Llama.cpp Gemma 4 Runtime Preset

Three runtime presets and the numbers behind them

By craftingmod·Created about a month ago·Updated 12 days ago· 2
Llama.cpp Gemma 4 Runtime Preset
    • runtime
    • n_ctx
    • max_tokens
    presetVision Standard

    Gemma 4 vision has a quirk that will bite you if you hit it blind: the number of tokens a single image consumes isn't fixed, and when you connect images to a llama.cpp Generate node, your context window and batch sizes have to cover that image-token count or the run fails before the model even loads. Llama.cpp Gemma 4 Runtime Preset exists to make that painless - it's a dropdown of three pre-measured runtime configurations for Gemma 4, tuned for the way that model budgets tokens.

    The preset combo has three options, and the tooltip is unusually candid about the tradeoffs:

    • Vision Standard (default) - the safe starting point.
    • Long / Thinking - reserves more output context without enabling thinking. The distinction matters: this is about room for reasoning text, not turning thinking on.
    • High Detail / OCR - uses 1120 image tokens and may require more VRAM or backend-specific tuning. This is the preset for reading small text or fine detail, where an image token ceiling of ~1120 is the price of fidelity.

    The node outputs three things, and the third one is the detail people miss. runtime is a typed bundle you connect to the legacy Llama.cpp Generate's runtime input, which overrides the advanced n_batch, n_ubatch, image_max_tokens, and both override switches. But the preset also emits n_ctx and max_tokens as plain INTs - and the tooltip is explicit: the runtime bundle does not set Generate's visible n_ctx and max_tokens. You have to connect those two outputs to the node's corresponding inputs yourself, or the preset's context and output-length choices never take effect. That's the trap. Vision Standard gives you context and token numbers that work with the image-token budget; if you ignore the two INTs, you're running the runtime tuning with default context, which defeats the purpose.

    The rest of the mechanism is inherited from the Generate node it feeds: images become PNG data URIs in one multimodal message, the model loads, runs, and closes per request. The runtime preset just decides the batch/token geometry so the geometry never becomes the reason a request fails.

    Install is the pack standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/craftingmod/ComfyUI-Ollama-ImageList
    

    Restart ComfyUI. JamePeng llama-cpp-python wheel and ComfyUI 0.19.3+ apply, as with every llama.cpp node in the pack.

    If you're on the compact flow, you don't need this node - its Generate keeps image budgets visible as image_max_tokens/image_min_tokens and pairs Gemma 4 with the Model Profile's Gemma 4 Vision setting instead. For the legacy detailed Generate, this is the friendly path: pick Vision Standard, wire all three outputs, and let the pre-measured numbers do the arithmetic you'd otherwise have to reverse-engineer from a crash log.

    CategoryOllama/llama_cpp/legacy

    Inputs (1)

    NameTypeDefaultDescription
    presetCOMBOVision StandardVision Standard is the safe starting point. Long / Thinking reserves more output context without enabling thinking. High Detail / OCR uses 1120 image tokens and may require more VRAM or backend-specific tuning.

    Outputs (3)

    NameTypeDescription
    runtimeOLLAMA_IMAGE_LIST_LLAMA_CPP_GEMMA4_RUNTIME
    n_ctxINT
    max_tokensINT