DGX Spark Safetensors Loader
The Load Diffusion Model that doesn't spike to 2x RAM on a DGX Spark
- model
The name is basically the pitch. If you don't own an NVIDIA DGX Spark, stop reading now - this node does nothing for you. If you do, it's a drop-in replacement for ComfyUI's built-in Load Diffusion Model that swaps the Hugging Face safetensors loader for NVIDIA's fastsafetensors, which does a zero-copy read from storage straight into VRAM.
Why that matters: the Spark is a GB10 box with 128GB of unified memory shared between CPU and GPU. The HF safetensors loader reads a model into system memory and then copies it over to the GPU, and on this architecture that means you can briefly hold two copies of the same weights - a 60GB FLUX.2-dev BF16 can balloon past your RAM ceiling and fail even though it should fit in half the machine. This is not a theoretical complaint. DGX Spark owners on r/comfyui describe the exact symptom set the README is aimed at: double memory usage during load, huge spikes, and OOMs that "brick it and force a hard reboot" (thread 1syh2oa). Loading big models on this box is the pain, and this node is one author's attempt to kill it.
How it works
Under the hood it's small and fairly clean. The node takes your model filename, hands it to SafeTensorsFileLoader (targeting cuda:0), calls copy_files_to_device(), then walks the file's keys into a state dict. From there it's the standard ComfyUI path - model_config_from_unet detects the architecture, and weights go into the module with load_state_dict(..., assign=True), which assigns tensors in place rather than copying them again. Zero-copy is the whole point, and it's why load times stay fast and memory stays flat.
The catch is sitting right there in the source, as a comment: #fb.close() # No! and #loader.close() # No!. fastsafetensors manages memory outside ComfyUI's allocator, and there's no way to hand it back. Every model you load with this node stays pinned in memory until you restart ComfyUI. The author says so outright: memory management is broken, the workaround is to quit and restart.
The inputs that matter
There are exactly two, both on the required list:
- model_name - a dropdown of the
.safetensorsfiles in yourmodels/diffusion_modelsfolder. Same folder as the built-in loader, so drop FLUX.2-dev BF16 in there and it shows up. - device - an enum that only contains
cuda:0. On a Spark there's one device, so you'll never touch it.
The single output is model (type MODEL), which wires straight into your KSampler's model input. That's the whole graph change: swap this node in for Load Diffusion Model, keep everything downstream identical.
Install
ComfyUI Manager can find it by the pack name, or:
cd ComfyUI/custom_nodes
git clone https://github.com/phaserblast/ComfyUI-DGXSparkSafetensorsLoader.git
source venv/bin/activate # your venv, if you use one
pip install fastsafetensors
Restart ComfyUI and search for "DGX Spark Safetensors Loader" under the loaders category. The only real dependency is fastsafetensors - it's an NVIDIA foundation-model-stack package, so it installs cleanly on the Spark's CUDA setup.
Where people get burned
Three things, straight from the README, all real:
- Quantized models don't work. GGUF, fp8, any of it - this loader expects plain FP16/BF16 tensors. If you need a quant, keep using the built-in Load Diffusion Model.
- VRAM never frees. Load three models in one session and all three stay resident. Restart to clear.
- It's experimental. The README's own framing is "may destroy the universe, don't use it in production," and it's only been minimally tested on discrete GPUs - which are not the architecture this targets anyway.
So treat it as what it is: a fix for a specific machine's specific problem, written by someone who got tired of his Spark falling over loading FLUX.2. On a DGX Spark running BF16 models it's genuinely worth a try - on anything else, skip it entirely.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | The filename of the .safetensors model to load. | |
| device | COMBO | cuda:0 | The device to which the model will be copied. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |