Nodes/CMK Flow/CMK Boundary Cache
ComfyUI Node

CMK Boundary Cache

The boundary around an InstantID rebuild, on disk as well as in memory

By CMKFlow·Created 3 months ago·Updated 2 days ago· 6
CMK Boundary Cache
  • MODEL
  • IMAGE
  • LOG
  • diagnostic
  • MODEL
  • IMAGE
  • LOG
  • diagnostic

An InstantID FaceRebuild pass is the most expensive optional thing you can put in an SDXL workflow: InsightFace embeddings, a control adapter, a secondary sampler, a paste-back. CMK Boundary Cache for FaceRebuild is the fence around that module, and it's the one boundary in the pack that checks the disk as well as the session before it decides to skip work.

What it is

Four lazy inputs - MODEL (CMK_MODEL_PIPE), IMAGE, LOG (CMK_LOG_PIPE) and diagnostic (CMK_DIAGNOSTIC) - and the same four back out. Category CMK/Developer/Boundary & Cache, DEV_ONLY flag set, so it's part of the pack's shipped FaceRebuild workflows rather than something you add by hand.

It shares its display name with the detailer and face-process boundaries. They're distinct classes with distinct cache scopes; this one lives in face_rebuild_boundary.

How it works

The lazy-input mechanism is the same as its siblings, and it's the reason it's worth having: all four inputs are declared lazy, so ComfyUI calls check_lazy_status before evaluating the upstream graph at all. When the node can satisfy the request from cache, it returns an empty list - "request nothing" - and the entire FaceRebuild chain, detector and sampler and paste-back included, never runs.

Two facts decide whether it can. A fingerprint of the node itself plus a schema version (cmk_face_rebuild_boundary_v1), and - unlike the face-process boundary, which relies on session state - a check that the cache entry actually exists on disk as well as in the in-memory session. That's this boundary's distinguishing feature, and it's a sensible one for a module this heavy: an entry that survived in the process but lost its backing file isn't trusted.

There's also a static short-circuit. Before any of that, the node inspects the graph to see whether the whole FaceRebuild module is statically disabled - reading the enable booleans off the relevant nodes and nothing more - and if it is, reports DISABLED_PASSTHROUGH_READY and passes the four inputs straight through. The disabled path requires all four to be wired, and raises a specific error naming the missing ones if they aren't, rather than inventing a placeholder diagnostic out of nothing.

Status is written to ComfyUI/temp/cmk/face_rebuild_boundary/last_status.json, and the status file is the honest way to answer "did that run actually skip, or does my image just look small?"

Why it's here

Because InstantID is the branch you keep wanting to A/B. Identity weight, start/end percent, face selection, which of two rebuild variants you're running - every one of those is a re-run of the whole rebuild. With the boundary in place, the first run pays (MISS → STORED) and the siblings you didn't touch come back as hits.

The caveat is the pack's standard one, and it's real: these caches live in ComfyUI/temp/cmk/ and a ComfyUI restart empties them. No cross-session continuation except on the video path. Treat the boundary as a within-session accelerator; the manual is explicit that caches are not a portable project format.

Install

Ships with the pack. Manager: search CMK Flow, install the CMKFlow entry, restart. Manual, from the directory containing main.py:

git clone https://github.com/CMKFlow/cmk_nodes.git custom_nodes/cmk_nodes
python3 custom_nodes/cmk_nodes/scripts/install_cmk_requirements.py

CMK dependency check: OK before you restart. The dependency list matters more for this node's neighbourhood than for the node itself: insightface and onnxruntime are both installed by requirements.txt, and FaceRebuild doesn't work without them plus the InsightFace buffalo_l model pack and the InstantID adapter/ControlNet files. The resource checker knows the exact filenames and can pull the ones with public sources:

python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --models-root "/path/to/shared/models"
python3 custom_nodes/cmk_nodes/scripts/check_cmk_resources.py --install instantid-adapter --target-root "/path/to/shared/models"

ComfyUI's Vue Nodes / Nodes 2.0 setting needs to be enabled; CMK's dynamic nodes rely on it. The pack is verified against ComfyUI 0.38.2 and frontend 1.53.6.

Issues worth knowing

This boundary does not accept a partial graph. If the module is disabled and one of the four inputs is unwired, you get a RuntimeError listing what's missing - "disabled passthrough requires MODEL, LOG" and so on. That's intentional: a passthrough that silently fabricates a diagnostic would poison the log chain downstream.

If a rebuild branch keeps re-executing despite no changes, suspect the dependency manifest and check that status file before you start debugging the FaceRebuild node itself. And remember that InsightFace licensing runs through this whole path: the library is MIT, the pretrained ONNX models are not, which is worth knowing before you ship anything commercial built on it.

CategoryCMK/Internal/Boundary & Cache

Inputs (4)

NameTypeDefaultDescription
MODELCMK_MODEL_PIPE—
IMAGEIMAGE—
LOGCMK_LOG_PIPE—
diagnosticCMK_DIAGNOSTIC—

Outputs (4)

NameTypeDescription
MODELCMK_MODEL_PIPE—
IMAGEIMAGE—
LOGCMK_LOG_PIPE—
diagnosticCMK_DIAGNOSTIC—