io module, such as io.Image or io.Int. You declare
an input with its .Input(...) constructor and an output with .Output(...). See the
V3 Migration guide for the full mapping between the V1 type strings and the
io classes.
Datatypes are used on the client side to prevent a workflow from passing the wrong form of data into a
node - a bit like strong typing. The JavaScript client side code will generally not allow a node output to
be connected to an input of a different datatype, although a few exceptions are noted below.
Comfy datatypes
COMBO
io.Combo represents a dropdown menu widget. The value of the input is a str; the widget options are
provided with the options parameter.
COMBO inputs are often dynamically generated at run time. Because define_schema is a class method, the
options can be computed when the node is loaded. For instance, a checkpoint loader node might do:
io.MultiCombo for dropdowns where more than one option can be selected; its value is a
list[str].
Primitive and reroute
Primitive and reroute nodes only exist on the client side. They do not have an intrinsic datatype, but when connected they take on the datatype of the input or output to which they have been connected (which is why they can’t connect to a* input…)
Python datatypes
INT
io.Int is an integer widget input.
-
Parameters:
default,min,max,step(all optional) -
Python datatype:
int
FLOAT
io.Float is a float widget input.
-
Parameters:
default,min,max,step(all optional) -
Python datatype:
float
STRING
io.String is a text widget input.
-
Parameters:
default,multiline,placeholder,dynamic_prompts(all optional) -
Python datatype:
str
BOOLEAN
io.Boolean is a toggle widget input.
-
Parameters:
default,label_on,label_off(all optional) -
Python datatype:
bool
Tensor datatypes
IMAGE
-
Declared with
io.Image.Input(...) -
Python datatype:
torch.Tensorwith shape [B,H,W,C]
B images, height H, width W, with C channels (generally C=3 for RGB).
LATENT
-
Declared with
io.Latent.Input(...) -
Python datatype:
dict, containing atorch.Tensorwith shape [B,C,H,W]
dict passed contains the key samples, which is a torch.Tensor with shape [B,C,H,W] representing
a batch of B latents, with C channels (generally C=4 for existing stable diffusion models), height H, width W.
The height and width are 1/8 of the corresponding image size (which is the value you set in the Empty Latent Image node).
Other entries in the dictionary contain things like latent masks.
MASK
-
Declared with
io.Mask.Input(...) -
Python datatype:
torch.Tensorwith shape [H,W] or [B,C,H,W]
AUDIO
-
Declared with
io.Audio.Input(...) -
Python datatype:
dict, containing atorch.Tensorwith shape [B, C, T] and a sample rate.
dict passed contains the key waveform, which is a torch.Tensor with shape [B, C, T] representing a batch of B audio samples, with C channels (C=2 for stereo and C=1 for mono), and T time steps (i.e., the number of audio samples).
The dict contains another key sample_rate, which indicates the sampling rate of the audio.
Custom Sampling datatypes
Noise
TheNOISE datatype represents a source of noise (not the actual noise itself). It can be represented by any Python object
that provides a method to generate noise, with the signature generate_noise(self, input_latent:Tensor) -> Tensor, and a
property, seed:Optional[int].
When noise is to be added, the latent is passed into this method, which should return a Tensor of the same shape containing the noise.
See the noise mixing example
Sampler
TheSAMPLER datatype represents a sampler, which is represented as a Python object providing a sample method.
Stable diffusion sampling is beyond the scope of this guide; see comfy/samplers.py if you want to dig into this part of the code.
Sigmas
TheSIGMAS datatypes represents the values of sigma before and after each step in the sampling process, as produced by a scheduler.
This is represented as a one-dimensional tensor, of length steps+1, where each element represents the noise expected to be present
before the corresponding step, with the final value representing the noise present after the final step.
A normal scheduler, with 20 steps and denoise of 1, for an SDXL model, produces:
Guider
AGUIDER is a generalisation of the denoising process, as ‘guided’ by a prompt or any other form of conditioning. In Comfy the guider is
represented by a callable Python object providing a __call__(*args, **kwargs) method which is called by the sample.
The __call__ method takes (in args[0]) a batch of noisy latents (tensor [B,C,H,W]), and returns a prediction of the noise (a tensor of the same shape).
Model datatypes
There are a number of more technical datatypes for stable diffusion models. The most significant ones areio.Model, io.CLIP,
io.VAE and io.Conditioning.
Working with these is (for the time being) beyond the scope of this guide!
Additional Parameters
TheInput constructors of the widget datatypes accept a number of optional parameters that configure the
widget. Below is a list of the officially supported parameters. (The legacy V1 schema spelled these as keys
in the input options dictionary, e.g. forceInput and rawLink; in V3 they are snake_case parameters of
the Input constructors.)