ComfyUI Node

Core ML Sampler

A KSampler for your Mac — no model slot required

By aszc-dev·Created 3 years ago·Updated 2 months ago· 183
Core ML Sampler
  • coreml_model
  • positive
  • negative
  • latent_image
  • LATENT
seed0
steps20
cfg8.0
sampler_name
scheduler
denoise1.00

If you already know how ComfyUI's KSampler works, you know how this node works - because it's literally a subclass of it. The Core ML Sampler is the node that actually generates images in a Core ML workflow. Where a normal KSampler takes a MODEL from a checkpoint loader, this one takes a coreml_model from the Core ML UNet Loader (or a converter node) and runs the same denoising loop on your Mac's Neural Engine instead of the GPU.

The whole point is that everything else in your graph stays vanilla. The text encoding, the VAE decode, the upscaling, the whole normal ComfyUI stack - untouched. Only the UNet inference path (the slow, repeated part) gets handed to Core ML. That's why this suite fits into existing habits so well: swap the loader and sampler, keep everything else.

How it works

Under the hood it wraps your Core ML UNet in a standard ComfyUI model patcher and feeds it to the stock KSampler machinery. The node does a couple of smart things you don't have to think about:

  • No latent provided? It creates one sized to match the model's fixed input shape (512×512 by default). Hand it a latent instead and you get img2img.
  • LCM models get auto-patched. If the model exposes a timestep_cond input, the node drops negative conditioning (LCM doesn't use it), injects the guidance embedding, and applies ComfyUI's LCM sampling type. This is why an LCM Core ML model "just works" in here.
  • SDXL models get their pooled embeddings and time-ids assembled so the dual text encoders behave.

The inputs you'll actually touch

The full list mirrors KSampler: coreml_model, seed, steps, cfg, sampler_name, scheduler, positive, denoise, plus optional negative and latent_image. The ones that matter:

  • cfg - defaults to 8, which is fine for normal SD1.5/SDXL but wrong for distilled models. LCM wants a CFG around 1–2; crank it down when you switch to an LCM model.
  • sampler_name / scheduler - the same 44 samplers and 9 schedulers as stock ComfyUI. If you're running the LCM Dreamshaper conversion, the README is explicit: sampler lcm, scheduler sgm_uniform, and a low step count. That combo is non-negotiable; LCM output is garbage otherwise. (The distillation notes in the KB say the same thing for LCM in general - low CFG, few steps, dedicated sampler.)
  • denoise - 1.0 for txt2img; drop it when you're doing img2img with a supplied latent.

Output is a LATENT, which decodes through any VAE decoder like normal.

Setup and the usual suspects

The node ships with the Core ML Suite pack. Manager → search "Core ML" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/aszc-dev/ComfyUI-CoreMLSuite
cd ComfyUI-CoreMLSuite
pip install -r requirements.txt

Two things trip people up. First, the model is fixed to its conversion size - if the latent you feed it doesn't match, you get shape errors rather than a resized image; re-convert the model at your target resolution. Second, "faster" doesn't mean "instant": the ANE path is roughly 1.5–2× over plain MPS, which the author measured at ~2 it/s on an M2 Pro. And remember the attention-implementation rule - CPU_AND_NE only reaches the ANE if the model was converted with SPLIT_EINSUM, so a GPU-converted model gives you none of the speedup you were promised.

CategoryCore ML Suite

Inputs (10)

NameTypeDefaultDescription
coreml_modelCOREML_UNET
seedINT00–18446744073709550000The random seed used for creating the noise.
stepsINT201–10000The number of steps used in the denoising process.
cfgFLOAT8.00–100The Classifier-Free Guidance scale balances creativity and adherence to the prompt. Higher values result in images more closely matching the prompt however too high values will negatively impact quality.
sampler_nameCOMBOThe algorithm used when sampling, this can affect the quality, speed, and style of the generated output.
schedulerCOMBOThe scheduler controls how noise is gradually removed to form the image.
positiveCONDITIONINGThe conditioning describing the attributes you want to include in the image.
denoiseFLOAT1.000–1The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling.
negativeoptCONDITIONING
latent_imageoptLATENT

Outputs (1)

NameTypeDescription
LATENTLATENTThe denoised latent.