Nynxz/ComfyUI-PlatoKeys
Closed-form encoder remapping for ComfyUI diffusion conditioning
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
PlatoKeys is a Python custom-node extension for ComfyUI V3 that separates encoder calibration from inference. The calibration CLI loads the source and target encoders sequentially and accumulates weighted first- and second-order statistics in float64. Memory for those statistics does not grow with the number of token pairs, but the matrices still grow with feature width. A thin SVD yields the semi-orthogonal Procrustes map; closed-form Ridge provides a regularized fit that can adjust individual channel scales.
At inference, Load Plato Key supplies a safetensors projection and metadata to the graph. Plato Key Encode handles prompt encoding directly, while Patch CLIP clones the CLIP object and wraps tokenization and encoding for downstream consumers. Both use the key’s layer, normalization, chat-template, and prefix-strip settings; temporary overrides of SDClipModel defaults are restored in a finally block without modifying ComfyUI core. The manifest declares safetensors as its only direct dependency; node execution relies on the ComfyUI host.
Key Capabilities & Differentiators
The extension handles both single-layer targets and stacked hidden states. For Krea 2, it aligns calibration pairs across different tokenizers using UTF-8 byte spans, projects into the 12 Qwen3-VL-4B layer taps, then flattens [B, 12, seq, 2560] into [B, seq, 30720]. Patch CLIP can also project visual tokens from a compatible source encoder, as in the Qwen3-VL-4B → Z-Image route.
The MOSS-Image Qwen3.5-2B → Qwen3.5-9B Ridge key is 16.8 MB, with held-out token cosine of 0.8978 and R² of 0.7486. The Krea 2 Qwen3.5-2B and 9B routes use 121 MB and 241 MB keys, with R² values of 0.7412 and 0.7723, respectively. Compare Conditioning can check mapped tensors against native ones; Compose Plato Keys can combine compatible routes through a hub into a single inference projection.
Trade-offs & Limitations
The native encoder is the baseline when conditioning fidelity and minimal integration work take priority. PlatoKeys is useful when a different source encoder is worth the extra compatibility checks: the target encoder can stay out of the mapped inference branch, but the source checkpoint, extraction layer, normalization, template, and prefix handling must match the key. A smaller source can reduce encoder cost; a larger source or a wide multi-layer projection can instead add overhead. Key file size is not a measurement of runtime VRAM.
Compared with training a learned adapter, a closed-form fit removes the gradient-training loop but limits the mapping to what can be recovered linearly from the source representations. Calibration fit scores characterize hidden states, not image quality, prompt adherence, or end-to-end speed. Before replacing the native path, run an A/B comparison on representative prompts and any visual inputs, and measure memory and runtime on the full graph.
Hardware & Deployment Guide
Install the source checkout under ComfyUI/custom_nodes and restart ComfyUI. Put a matching pre-calibrated key in ComfyUI/models/plato_keys/ or register an alternate location through extra_model_paths.yaml. Once the models and key are local, inference does not require a hosted API. The manifest identifies package version 0.1.0, but no GitHub release is listed, so record the working plugin and ComfyUI revisions alongside the encoder checkpoints and key file.
For a custom route, scripts/calibrate_comfy.py consumes local ComfyUI checkpoints and supports quantized int8/fp8 inputs and multi-layer extraction. scripts/calibrate.py provides the Hugging Face path and has a companion Colab notebook. Its --target-8bit and --target-4bit flags are options for fitting Qwen3.5-9B calibration on a 16 GB GPU. Use --save-stats and --from-stats to refit on CPU without rerunning the encoder passes.
Local ComfyUI teams that want to reuse a smaller or vision-capable encoder, have a matching key or can calibrate one, and can compare outputs against the native path.
You need native conditioning fidelity, cannot maintain checkpoint-to-key compatibility, or need proven image-quality and speed gains without running your own evaluation.
Quick Start & Installation
cd ComfyUI/custom_nodes git clone https://github.com/Nynxz/ComfyUI-PlatoKeys
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/Nynxz/ComfyUI-PlatoKeys.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about ComfyUI-PlatoKeys
Which node should I use to integrate an alternate encoder?
Will it reduce VRAM, and what hardware does calibration need?
Can I self-host it for commercial workloads?
When should I use this instead of the native encoder or a trained adapter?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy