Model Clone
A copy of a model that shares nothing — deepcopy, done properly
- model
- clone
CdlModelClone takes a cdlModel - any PyTorch model object built elsewhere in ComfyDL - and hands you an independent copy of it. The implementation is literally copy.deepcopy(model), and that's the whole point: the clone has the same architecture and the same weights, but no shared parameters with the original. Change one, the other stays untouched.
Why would you want that in a graph? The classic reason is experimentation hygiene. You train a LeNet or an RNN until it's decent, clone it, and then wreck the clone with a different learning rate or a destructive experiment while the original stays pristine for comparison. The pack's Model Utils family is built around exactly this pattern: clone to branch, Model Forward to run, Model Save to keep, Model Load to restore. Cloning is the "git branch" of the model toolkit.
How it works
Deepcopy means the copy is fully recursive: every submodule, every tensor, every optimizer state that lives on the model gets duplicated in memory. There's no copy-on-write trickery - you pay the memory cost immediately. A 10-million-parameter model cloned is a second 10-million-parameter model in RAM. For the small textbook nets this pack builds (LeNet is ~61k parameters), that's a rounding error. For anything you've let grow big, it's a real consideration.
The output is a cdlModel with the same type and weights. You can verify the independence yourself by running Model Params on both - or by training the clone and watching the original's numbers sit perfectly still.
Inputs and output
model- the only input, anycdlModel.
The single output is clone, a cdlModel. Wire it anywhere the original would go - forward, save, mode, info.
Installing ComfyDL
It ships with the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ComfyDL/requirements.txt
Restart ComfyUI. The only extra dependency is matplotlib; torch comes with ComfyUI. ComfyUI Manager users: search "ComfyDL", and if it's not in the built-in list (the pack isn't published to the official Comfy Registry yet), use Install via Git URL with the repo link.
Common issues
The realistic failures are conceptual rather than mechanical. Don't reach for this node when you want a reference to the same model - if you just want the same network in two places without independence, wire the original to both and skip the copy. And mind the memory: in a long-running session where you clone repeatedly (say, inside an iterative loop), each clone can pile up and eat RAM. For everything else, it's a one-input node that does one thing correctly - which is more than some utilities in this ecosystem can claim.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model | cdlModel | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| clone | cdlModel | — |