Nodes/CFG Megapack/CFG Mix: Pentachoron
ComfyUI Node

CFG Mix: Pentachoron

Guidance as a geometry problem, and the weirdest node here

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
CFG Mix: Pentachoron
  • model
  • MODEL
◄k1.00►
◄scale-1.0►
◄spacenoise (eps)►

Most of this pack is other people's papers, faithfully reimplemented. This node isn't. CFG Mix: Pentachoron is the pack author's own research, carried over from his AlephLLM work, and it approaches guidance as a shape problem: constrain the push, don't just scale it.

I'll be honest about the shape of this article: the mechanism is unusual enough to be worth understanding, and the practical effect is subtle. If you want one combine node that just works, read the Direction Rules page instead.

What it does

Plain CFG's push past the conditional prediction is (w - 1)(c - u). Take each pixel's push in every group of four latent channels and read it as coordinates on the five vertices of a regular pentachoron - the 4-dimensional analogue of a tetrahedron, whose vertices all sit at cosine −1/4 to each other. Now each pixel has five signed amplitudes, one per vertex.

Those amplitudes are put through sinh(z) / Σcosh(z): a smooth, signed weighting rather than a selector, scaled by a tau taken from the overall RMS of the amplitudes. Then the push is rebuilt from the weighted vertices.

Three properties fall out of that, and they're the point:

  • Small pushes come back as plain CFG. The limit is continuous, so gentle guidance is untouched.
  • A pixel's push in a group stays bounded - it can't exceed 4·tau.
  • A pixel pushing hard along one vertex damps its other four. Local extremes get reined in.

The maths runs in float64 whatever your model's dtype. That's not decoration: as the amplitudes approach zero the numerator cancels, and in float32 the node would lose the plain-CFG limit entirely.

The inputs

  • k - the temperature, default 1. Larger values are closer to plain CFG, 1000000 is exactly plain CFG (a handy sanity check), and smaller values clamp each pixel's push more firmly.
  • scale - the guidance scale for the rule; -1 (default) inherits the KSampler's cfg.
  • space - fixed to noise by default, and there's no auto option here, unlike the rest of the pack. That's because the rule is deliberately nonlinear: the space you run it in changes the image.

Output: one MODEL.

The catch worth knowing first

The method needs a channel count divisible by 4. SDXL and SD 1.5 have four latent channels, which is one pentachoron; Anima and other 16-channel Cosmos-style transformers have four. Load something with a latent channel count that doesn't divide by four and the node raises rather than guessing - the error message tells you the count it saw, which is more than most packs manage.

There's no extra cost: no extra model evaluation, no extra buffers beyond the maths itself.

Install

ComfyUI Manager: search CFG Megapack in the Custom Nodes Manager, install, restart. comfy-cli: comfy node install comfy-cfg-megapack. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack

Restart. No requirements.txt because there's nothing to install - torch and the Python standard library on ComfyUI's newer comfy_api.latest node API, which is also why this pack's source has no NODE_CLASS_MAPPINGS dictionary. If you go looking for that dict and don't find it, the pack isn't broken; it's written for current ComfyUI. Tested on ComfyUI 0.38.0 with torch 2.11, GPU and CPU-only. CFG_MEGAPACK_VRAM_FRACTION=0.6 before launch caps the pack's VRAM share.

The pentachoron comparison graph is one of the shipped examples - Workflow → Browse Templates → Custom Nodes → comfy-cfg-megapack.

Traps

  • It's a combine-stage node, and combine is exclusive. Chain it after Direction Rules or Scale Rules (or any combine paper node, APG and CFG-Zero* included) and you've replaced it; chain it before and you get replaced. One combine rule per plan.
  • You cannot tune your way to a big visible change. The node damps extreme per-pixel pushes and mostly matches plain CFG elsewhere, so if your images look identical that's the expected result at the default k of 1 - not a broken install.
  • space is not cosmetic here. The rule is nonlinear, so noise (eps) and denoised (x0) are genuinely different images, and unlike most nodes in this pack there's no auto to fall back on.
  • Other packs' CFG-function nodes still share ComfyUI's one slot. RescaleCFG, Mahiro or RenormCFG chained after this node takes it.

If you want to see what it's actually doing rather than guess, chain CFG Measure: Per-Step Probe and watch the guidance-size and std-ratio columns against a plain-CFG run. This is a node where the numbers are more informative than eyeballing two renders.

CategoryCFG Megapack/3 mix

Inputs (4)

NameTypeDefaultDescription
modelMODEL—
kFLOAT1.000.01–1000000Temperature: larger is closer to plain CFG (1000000 is plain CFG), smaller a firmer limit on each pixel's push.
scaleFLOAT-1.0-1–100The guidance scale w for this rule. -1 uses the sampler's cfg value.
spaceCOMBOnoise (eps)Where the rule is computed; the rule is nonlinear, so the space changes the image. Noise is its own space (on flow models, the noise itself).

Outputs (1)

NameTypeDescription
MODELMODEL—