From 54b7c5b0e6598669e3d73e9316188775d657d1a7 Mon Sep 17 00:00:00 2001 From: John Pollock Date: Sun, 31 Aug 2025 01:45:13 -0500 Subject: [PATCH] Advanced Checkpoint and Advanced DisTorch2 Checkpoint loaders (https://github.com/pollockjj/ComfyUI-MultiGPU/issues/95), Fix CLiP loading device when MultGPU or DisTorch2 is invoked. Advanced Checkpoint Loaders allow users to map each of the elements of the checkpoint to a different device, or in the case of DisTorch2, shard the UNet and CLiP .safetensors arbitrarily whilst ensuring actual computation remains on selected `compute` device. Added example workflow for standard and DisTorch2 MultGPU checkpoint loaders. --- .../distorch2/default_advanced_DisTorch2.json | 396 ++++++++++ ...ch2.json => default_simple_DisTorch2.json} | 0 examples/multiGPU/sd15_2gpu_advanced.json | 737 ++++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 1134 insertions(+), 1 deletion(-) create mode 100755 examples/distorch2/default_advanced_DisTorch2.json rename examples/distorch2/{default_DisTorch2.json => default_simple_DisTorch2.json} (100%) create mode 100755 examples/multiGPU/sd15_2gpu_advanced.json diff --git a/examples/distorch2/default_advanced_DisTorch2.json b/examples/distorch2/default_advanced_DisTorch2.json new file mode 100755 index 0000000..1993039 --- /dev/null +++ b/examples/distorch2/default_advanced_DisTorch2.json @@ -0,0 +1,396 @@ +{ + "id": "d21a2457-c2bf-4733-b2e9-42352b1dd20d", + "revision": 0, + "last_node_id": 11, + "last_link_id": 17, + "nodes": [ + { + "id": 7, + "type": "CLIPTextEncode", + "pos": [ + 413, + 389 + ], + "size": [ + 425.27801513671875, + 180.6060791015625 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 16 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 6 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "text, watermark" + ] + }, + { + "id": 3, + "type": "KSampler", + "pos": [ + 863, + 186 + ], + "size": [ + 315, + 474 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 14 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 4 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 6 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 2 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 7 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 262971817904402, + "randomize", + 20, + 8, + "euler", + "normal", + 1 + ] + }, + { + "id": 8, + "type": "VAEDecode", + "pos": [ + 1209, + 188 + ], + "size": [ + 210, + 46 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 7 + }, + { + "name": "vae", + "type": "VAE", + "link": 17 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "slot_index": 0, + "links": [ + 9 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + }, + "widgets_values": [] + }, + { + "id": 9, + "type": "SaveImage", + "pos": [ + 1451, + 189 + ], + "size": [ + 797.607666015625, + 781.645263671875 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 9 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "SaveImage" + }, + "widgets_values": [ + "ComfyUI" + ] + }, + { + "id": 5, + "type": "EmptyLatentImage", + "pos": [ + 473, + 609 + ], + "size": [ + 315, + 106 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 2 + ] + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 1024, + 1024, + 1 + ] + }, + { + "id": 6, + "type": "CLIPTextEncode", + "pos": [ + 415, + 186 + ], + "size": [ + 422.84503173828125, + 164.31304931640625 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 15 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 4 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "A towering technological monolith in a cyberpunk cityscape at night, with \"DisTorch 2\" emblazoned across its surface in massive neon blue-green mixed with purple letters that illuminate the surrounding buildings. The text occupies the central third of the frame, crafted from glowing plasma tubes and crackling energy. Rain-slicked streets below reflect the brilliant signage, while holographic advertisements and flying vehicles populate the background. Moody atmospheric lighting, heavy contrast, photorealistic textures, cinematic color grading. \"Now for .safetensors!\" in same stying but smaller font as a splash overlay in the right-hand corner of the image " + ] + }, + { + "id": 11, + "type": "CheckpointLoaderAdvancedDisTorch2MultiGPU", + "pos": [ + -135.86851501464844, + 203.48403930664062 + ], + "size": [ + 397.9400329589844, + 338 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 14 + ] + }, + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 15, + 16 + ] + }, + { + "name": "VAE", + "type": "VAE", + "links": [ + 17 + ] + } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderAdvancedDisTorch2MultiGPU" + }, + "widgets_values": [ + "Juggernaut-XL_v9_RunDiffusionPhoto_v2.safetensors", + "cuda:0", + 1.1, + "cpu", + "cuda:1", + 2, + "cpu", + "cuda:1", + "", + "", + true + ], + "color": "#233", + "bgcolor": "#355" + } + ], + "links": [ + [ + 2, + 5, + 0, + 3, + 3, + "LATENT" + ], + [ + 4, + 6, + 0, + 3, + 1, + "CONDITIONING" + ], + [ + 6, + 7, + 0, + 3, + 2, + "CONDITIONING" + ], + [ + 7, + 3, + 0, + 8, + 0, + "LATENT" + ], + [ + 9, + 8, + 0, + 9, + 0, + "IMAGE" + ], + [ + 14, + 11, + 0, + 3, + 0, + "MODEL" + ], + [ + 15, + 11, + 1, + 6, + 0, + "CLIP" + ], + [ + 16, + 11, + 1, + 7, + 0, + "CLIP" + ], + [ + 17, + 11, + 2, + 8, + 1, + "VAE" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 0.6593771753936349, + "offset": [ + 1007.5875606954307, + 245.85267454738732 + ] + }, + "frontendVersion": "1.25.11", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/examples/distorch2/default_DisTorch2.json b/examples/distorch2/default_simple_DisTorch2.json similarity index 100% rename from examples/distorch2/default_DisTorch2.json rename to examples/distorch2/default_simple_DisTorch2.json diff --git a/examples/multiGPU/sd15_2gpu_advanced.json b/examples/multiGPU/sd15_2gpu_advanced.json new file mode 100755 index 0000000..a3727f8 --- /dev/null +++ b/examples/multiGPU/sd15_2gpu_advanced.json @@ -0,0 +1,737 @@ +{ + "id": "a6ee03c8-e601-4b33-87dc-64e9ed484de8", + "revision": 0, + "last_node_id": 26, + "last_link_id": 63, + "nodes": [ + { + "id": 2, + "type": "KSampler", + "pos": [ + 1235.140380859375, + -287.8480529785156 + ], + "size": [ + 295.7660217285156, + 474 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 35 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 46 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 59 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 9 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 6, + 52 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 5770521, + "fixed", + 20, + 8, + "dpmpp_2m_sde_gpu", + "karras", + 1 + ] + }, + { + "id": 21, + "type": "CLIPTextEncode", + "pos": [ + 937.1891479492188, + -240.19276428222656 + ], + "size": [ + 285.6000061035156, + 88 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 54 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 46 + ] + } + ], + "title": "CLIP Text Encode (Positive Prompt)", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "realistic photograph of a glass of wine, depth of field, bokeh" + ], + "color": "#232", + "bgcolor": "#353" + }, + { + "id": 24, + "type": "CLIPTextEncode", + "pos": [ + 946.2571411132812, + 271.57373046875 + ], + "size": [ + 285.6000061035156, + 88 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 61 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 56 + ] + } + ], + "title": "CLIP Text Encode (Positive Prompt)", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "realistic photograph of a glass of wine, depth of field, bokeh" + ], + "color": "#232", + "bgcolor": "#353" + }, + { + "id": 15, + "type": "VAEDecode", + "pos": [ + 1556.0386962890625, + 268.0700988769531 + ], + "size": [ + 210, + 46 + ], + "flags": { + "collapsed": false + }, + "order": 11, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 22 + }, + { + "name": "vae", + "type": "VAE", + "link": 63 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "slot_index": 0, + "links": [ + 53 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + }, + "widgets_values": [] + }, + { + "id": 23, + "type": "SaveImage", + "pos": [ + 1796.7874755859375, + 243.16427612304688 + ], + "size": [ + 473.8890686035156, + 484.4914245605469 + ], + "flags": {}, + "order": 12, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 53 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "SaveImage" + }, + "widgets_values": [ + "ComfyUI" + ] + }, + { + "id": 6, + "type": "PreviewImage", + "pos": [ + 1805.782958984375, + -291.3573303222656 + ], + "size": [ + 491.1799011230469, + 494.12640380859375 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 7 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "PreviewImage" + }, + "widgets_values": [] + }, + { + "id": 5, + "type": "VAEDecode", + "pos": [ + 1592.0411376953125, + -260.3390808105469 + ], + "size": [ + 140, + 46 + ], + "flags": { + "collapsed": false + }, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 6 + }, + { + "name": "vae", + "type": "VAE", + "link": 36 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "slot_index": 0, + "links": [ + 7 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + }, + "widgets_values": [] + }, + { + "id": 12, + "type": "KSampler", + "pos": [ + 1255.6590576171875, + 244.5147705078125 + ], + "size": [ + 274.0234375, + 474.0000305175781 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 60 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 56 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 57 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 52 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "slot_index": 0, + "links": [ + 22 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 5770521, + "fixed", + 20, + 4, + "dpmpp_2m_sde_gpu", + "karras", + 0.5 + ] + }, + { + "id": 25, + "type": "CLIPTextEncode", + "pos": [ + 944.7369384765625, + -117.6661605834961 + ], + "size": [ + 285.6000061035156, + 76 + ], + "flags": { + "collapsed": false + }, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 58 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 59 + ] + } + ], + "title": "CLIP Text Encode (Negative Prompt)", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "" + ], + "color": "#322", + "bgcolor": "#533" + }, + { + "id": 19, + "type": "CheckpointLoaderSimpleMultiGPU", + "pos": [ + 549.6911010742188, + -220.0397186279297 + ], + "size": [ + 378, + 122 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "slot_index": 0, + "links": [ + 35 + ] + }, + { + "name": "CLIP", + "type": "CLIP", + "slot_index": 1, + "links": [ + 54, + 58 + ] + }, + { + "name": "VAE", + "type": "VAE", + "slot_index": 2, + "links": [ + 36 + ] + } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimpleMultiGPU" + }, + "widgets_values": [ + "safetensor_testing/realDream_15SD15.safetensors", + "cuda:0" + ], + "color": "#233", + "bgcolor": "#355" + }, + { + "id": 26, + "type": "CheckpointLoaderAdvancedMultiGPU", + "pos": [ + 558.9177856445312, + 261.31072998046875 + ], + "size": [ + 335.6988220214844, + 170 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 60 + ] + }, + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 61, + 62 + ] + }, + { + "name": "VAE", + "type": "VAE", + "links": [ + 63 + ] + } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderAdvancedMultiGPU" + }, + "widgets_values": [ + "safetensor_testing/realisticVisionV60B1_v51VAE.safetensors", + "cuda:0", + "cuda:1", + "cpu" + ], + "color": "#233", + "bgcolor": "#355" + }, + { + "id": 8, + "type": "EmptyLatentImage", + "pos": [ + 991.2929077148438, + -435.2230224609375 + ], + "size": [ + 210, + 106 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 9 + ] + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 1024, + 1024, + 1 + ] + }, + { + "id": 22, + "type": "CLIPTextEncode", + "pos": [ + 942.2822875976562, + 408.21136474609375 + ], + "size": [ + 285.6000061035156, + 98.24866485595703 + ], + "flags": { + "collapsed": false + }, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 62 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "slot_index": 0, + "links": [ + 57 + ] + } + ], + "title": "CLIP Text Encode (Negative Prompt)", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "" + ], + "color": "#322", + "bgcolor": "#533" + } + ], + "links": [ + [ + 6, + 2, + 0, + 5, + 0, + "LATENT" + ], + [ + 7, + 5, + 0, + 6, + 0, + "IMAGE" + ], + [ + 9, + 8, + 0, + 2, + 3, + "LATENT" + ], + [ + 22, + 12, + 0, + 15, + 0, + "LATENT" + ], + [ + 35, + 19, + 0, + 2, + 0, + "MODEL" + ], + [ + 36, + 19, + 2, + 5, + 1, + "VAE" + ], + [ + 46, + 21, + 0, + 2, + 1, + "CONDITIONING" + ], + [ + 52, + 2, + 0, + 12, + 3, + "LATENT" + ], + [ + 53, + 15, + 0, + 23, + 0, + "IMAGE" + ], + [ + 54, + 19, + 1, + 21, + 0, + "CLIP" + ], + [ + 56, + 24, + 0, + 12, + 1, + "CONDITIONING" + ], + [ + 57, + 22, + 0, + 12, + 2, + "CONDITIONING" + ], + [ + 58, + 19, + 1, + 25, + 0, + "CLIP" + ], + [ + 59, + 25, + 0, + 2, + 2, + "CONDITIONING" + ], + [ + 60, + 26, + 0, + 12, + 0, + "MODEL" + ], + [ + 61, + 26, + 1, + 24, + 0, + "CLIP" + ], + [ + 62, + 26, + 1, + 22, + 0, + "CLIP" + ], + [ + 63, + 26, + 2, + 15, + 1, + "VAE" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 0.8769226950001169, + "offset": [ + -155.61337164905575, + 501.2042499363116 + ] + }, + "ue_links": [], + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "frontendVersion": "1.25.11", + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ebe5432..2d75c79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-multigpu" description = "Provides a suite of custom nodes to manage multiple GPUs for ComfyUI, including advanced model offloading for both GGUF and Safetensor formats with DisTorch, and bespoke MultiGPU support for WanVideoWrapper and other custom nodes." -version = "2.3.0" +version = "2.4.0" license = {file = "LICENSE"} [project.urls]