Dataset → Tensors
The splitter, and the empty tensor that pretends to be labels
- dataset
- X
- y
What it is
ComfyDL is Cynthia-lxx's pack for building deep-learning workflows as ComfyUI graphs - d2l-derived textbook nodes, from-scratch trainers, one universal DATASET type carrying features, labels and column names by reference.
Dataset → Tensors is the exit door. Where Tensors → Dataset bundles, this one splits: wire a DATASET in, and you get X and y back as plain TENSORs.
You need it more often than you'd think. The pack's TENSOR type is ComfyUI's own canonical tensor socket, so once you've split, you can send X anywhere a tensor goes - a core activation or normalization node, a plot, a scatter chart, a metric node - instead of being trapped inside the dataset-only half of the graph. It also matters when the reader and the consumer disagree: Linear Regression Train accepts either a dataset or raw X/y tensors, and sometimes it's cleaner to split and wire explicitly than to rely on the trainer's resolution order.
How it works
The node reads dataset.features and dataset.labels and returns them. X is always the 2-D feature matrix (n_samples, n_features) and y is the label tensor as it was stored - usually (n,) for a reader-built dataset, (n, 1) if it came through a trainer or another pack's tensor.
The behaviour to know about is the unlabelled case. If the dataset has no labels, the node doesn't fail and doesn't return nothing - it returns torch.empty(0), an empty tensor:
y = dataset.labels if dataset.labels is not None else torch.empty(0)
That's deliberate, so downstream nodes always receive a consistent pair of sockets, and it's the single most confusing thing about this node. An empty y is a perfectly valid tensor, so nothing complains at the socket. The error arrives later, as a shape mismatch or a weird batch tuple inside whatever you wired it into, and by then you're debugging the wrong node.
Inputs and outputs
Required: dataset (marked as a forced input socket, so you can't type one in - it must be wired). Optional: none.
Outputs: X (feature matrix) and y (labels, empty if the dataset is unlabelled).
Install
Manager → search ComfyDL, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart. Requirements are only matplotlib, IPython and matplotlib-inline; torch is ComfyUI's own and pandas is assumed to be in the environment (the readers and writers need it). If the node never shows up, check the console - the pack loads modules in a try/except and reports failures as [ComfyDL] Warning: Failed to load <module>, which looks annoyingly like a missing node.
The wiring pattern worth knowing
The canonical little ComfyDL graph is:
Read CSV → Dataset → Dataset → Tensors ── X ──┐
└─ y ──┤
▼
Linear Regression Train → w, b, loss_history, y_hat
And the fastest check that a dataset is labelled at all: put Dataset → Preview next to it. The preview shows the label column under its own header when it exists, and simply omits it when it doesn't. Ten seconds there beats ten minutes of shape-error archaeology in the trainer.
Where people get burned
The empty y. If you set target to "" in the reader (or read a headerless text file, where a name can never match), y comes through empty and the trainer will reject it. Fix the reader, not the trainer.
Shape drift. X from a reader is (n, f), y is (n,). Some nodes want y as (n, 1). This node doesn't reshape either, so if something downstream is strict about that, dump the tensors into a Plot or a scatter node and look at what you actually have.
It's the same storage, not a copy. The outputs point at the dataset's tensors. That's why it's free, and it's why in-place edits propagate - no surprise, just don't expect a snapshot.
Nothing is normalized. Whatever scale your CSV had is the scale of X. If your features span three orders of magnitude, a fixed learning rate will struggle; standardising is on you, and this node won't do it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | DATASET | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| X | TENSOR | — |
| y | TENSOR | — |