I guess that comfy provides other ways to control how frequencies are handled. Upfront, with sampler/scheduler mostly. It's not really a post-processing tool, though it can be used as such.
It is for very specific use cases, very precise edits. You probably don't need it. Most people don't use it.
It splits the signal so you can alter either high frequencies or low frequencies without altering the other. Then the same node can recombine the signals.
u/Greedy_Cow9889
Well, I had time to read your comment before it got deleted (no idea why BTW).
Here is the answer I planned to send:
Great answer comrade, thanx a lot. I have so many questions right now, but I'll keep that for later. For now I'm gonna benchmark it on my Linux + 3090 + 64GB DDR5. I will post the results.
I'm very interested yet curious about how it works and the process that led you to build it.
I've had a chat with chatGPT, to explain the optimization techniques used and the trade-offs. It was a bit long but interesting. Did chatGPT get it right?
Here is the summary, for those interested:
NoiraDEVILNodes is an experimental acceleration suite for running the original 66.28 GB BF16 MiniMax H3 diffusion model in ComfyUI on consumer GPUs.
It combines four main optimization techniques:
These techniques target different bottlenecks: redundant computation, CPU-to-GPU weight transfers, repeated modulation calculations and expensive attention operations.
## 1. Guarded Residual Caching
**Purpose:** Avoid repeatedly executing the expensive diffusion transformer.
Normally, every diffusion step evaluates the transformer using the current latent and timestep to calculate a new prediction.
Residual caching reuses a previously calculated prediction instead of running the entire transformer again.
Importantly, a cache hit does NOT mean the diffusion step becomes a no-op. The sampler still advances the latent using the current timestep and the cached prediction.
In simplified form:
- Normal sampling: calculate a new prediction at every step.
- Cached sampling: reuse a previous prediction for selected steps.
- The latent continues evolving throughout the process.
The implementation uses safeguards such as residual thresholds, temporal guards, restrictions on consecutive cache hits and schedule boundaries.
**Benefits:**
- Potentially the largest reduction in computation.
- Avoids complete transformer evaluations.
- Also avoids transferring weights for skipped transformer blocks.
- Particularly attractive for very large models.
**Trade-offs:**
- Reused predictions are approximations of the current predictions.
- Errors can accumulate across successive diffusion steps.
- Potential degradation of fine details, character identity, motion and temporal consistency.
- A cache threshold does not guarantee perceptual equivalence.
- The resulting video may differ from ordinary dense sampling.
**Assessment:** Potentially very effective, but one of the riskiest optimizations for output fidelity. Conservative caching should be preferred initially.
## 2. Adaptive Weight Read-Ahead
**Purpose:** Reduce GPU waiting time caused by transferring model weights from system RAM to VRAM.
The complete BF16 model is approximately 66.28 GB, considerably larger than the VRAM of consumer GPUs.
Consequently, model weights must be streamed between system RAM and GPU memory.
A naive implementation loads each layer only when it is needed, potentially leaving the GPU waiting for transfers.
Adaptive read-ahead anticipates which transformer blocks will be required and stages their weights in advance.
It uses mechanisms such as:
- Pinned host memory.
- Prefetch queues.
- GPU memory budgets.
- Overlapping weight transfers with GPU computation.
- Memory reserves to prevent allocation failures.
**Benefits:**
- Reduces transfer-related waiting time.
- Improves GPU utilization.
- Does not inherently alter model calculations or output quality.
- Particularly valuable when running models larger than available VRAM.
**Trade-offs:**
- Consumes additional system RAM.
- Pinned memory reduces the flexibility of the operating system's memory manager.
- Requires sufficient PCIe bandwidth.
- Poorly configured prefetching can cause RAM or VRAM exhaustion.
- Introduces synchronization and memory-management complexity.
**Assessment:** One of the safest optimizations from a quality perspective. Particularly interesting for GPUs with limited VRAM, provided sufficient system RAM and PCIe bandwidth are available.
AdaLN (Adaptive Layer Normalization) uses modulation parameters to control how transformer blocks process their inputs.
Some of these calculations depend on the timestep and model parameters rather than the changing video latent.
For a known sampling schedule, the required modulation tensors can therefore be precomputed and reused.
The implementation calculates these values ahead of sampling and stores them for subsequent retrieval.
The important distinction is that this is intended to be an exact optimization, not an approximation.
The implementation checks bitwise parity between the native computation and the precomputed results before enabling the optimization.
**Benefits:**
- Avoids repeated projection calculations.
- Reduces unnecessary computation during sampling.
- Reduces the need to repeatedly load associated projection weights.
- Should not degrade output quality when exact parity is maintained.
**Trade-offs:**
- Requires additional CPU memory.
- Introduces initialization overhead.
- Depends on the sampling schedule.
- Requires compatibility with the expected model architecture and execution path.
- Changes to upstream model internals can invalidate implementation assumptions.
**Assessment:** Probably the most attractive optimization. It removes redundant work without intentionally sacrificing numerical accuracy.
## 4. Sparse Attention
**Purpose:** Reduce the computational cost of attention.
Attention allows video tokens to exchange information with other tokens, establishing spatial and temporal relationships.
Dense attention calculates all relevant token interactions. Its computational and memory costs increase substantially with sequence length.
Sparse attention deliberately reduces the number of interactions.
The Noira implementation uses a reduced video-attention budget during selected portions of the sampling schedule, while retaining denser attention for certain conditioning and boundary operations.
The reported configuration uses a 15% video-attention budget during the middle of sampling, with denser attention at the beginning and end.
**Benefits:**
- Reduces attention computation.
- Can significantly improve performance on long video sequences.
- Particularly useful when attention becomes a major computational bottleneck.
**Trade-offs:**
- Some token interactions are no longer calculated.
- May reduce prompt adherence.
- Can affect character identity and appearance.
- May degrade motion coherence and interactions between characters.
- Can introduce spatial or temporal inconsistencies.
- The optimal attention budget may depend on the prompt and scene.
**Assessment:** Potentially useful, but quality-sensitive. Aggressive sparsity should be avoided until its effects have been evaluated on representative videos.
Their combined effect can be greater than their individual contributions because they reinforce one another.
For example, residual caching avoids executing transformer blocks and consequently avoids transferring their weights. Adaptive read-ahead then focuses on the smaller number of executions that remain.
However, their speed gains cannot simply be added together. As one bottleneck is reduced, another may become dominant.
Combining multiple optimizations also makes quality problems more difficult to diagnose.
## 6. Overall Assessment
Technique
Quality risk
Main cost
Exact AdaLN
Very low, when parity is verified
CPU memory and initialization
Adaptive weight read-ahead
Very low, when implemented correctly
System RAM and PCIe bandwidth
Guarded residual caching
Medium to high
Numerical approximation
Sparse attention
Medium to high
Reduced information exchange
### Preferred approach
Prioritize optimizations that eliminate redundant work without changing the model's mathematical behaviour:
Exact AdaLN.
Adaptive weight read-ahead.
Conservative guarded residual caching.
Sparse attention only if additional acceleration is necessary.
The ideal outcome would be to obtain substantial performance improvements through exact computation reuse and better memory management, while minimizing approximations that could compromise video quality.
**The key distinction:**
A faster generation is not necessarily an equivalent generation. The real objective should be to maximize speed while preserving the visual quality, character consistency and temporal coherence of the original MiniMax H3 model.
Actually, that is totally part of "getting the hang" 😜 .
You seem eager to learn. Generative AI in general and ComfyUI in particular are full of micro and macro concepts. It's a rabbit-hole elephant-hole. Start with the basics, Pixaroma is the usually recommended tuto maker to follow (for good reasons) but there are others around (foxfuressence for example).
Illustrious is a good starting point. Understand the classic workflow pattern (model / clip / VAE -> lora -> CLIP encode -> sampler -> decode -> output) and what each node is there for.
(And you're not prepared for the esoteric language people in this subreddit use)
You can stick to this, which is powerful enough. But nothing prevents you from adding features if they are worth it (easy to use / well documented or intuitive), or if they are for your personal use.
Since you code nodes, adding those features to nodes makes more sense most of the time.
Spot on 👍 - Use 'preview image' first. Save image when you're happy with the result. Or save them all and sort later.
This node takes width and height as input
There are other nodes which upscale by a factor or to a total number of pixels. Double click the canvas and type 'upscale'. Pick what you prefer.
Thanx for taking the time.
For me it is still a bijection when dequantizing, no new data.
We effectively convert INT8 to FP32, but the FP32 precision is lost. Only specific values of the FP32 are allowed, with unreachable intervals in between.
My IT and maths degrees are long gone, and friday nights don't help, so hit me (or ignore me) if I'm nitpicking.
But where does the retrieved data comes from? It has to be "guessed" somehow by the dequantizer, or am I missing something?
The quality gap you see might be the normal error expected from the quantization (despite 0.4% being very low - well I dunno I've never looked at the actual numbers)
It seems OK. I misunderstood your issue, I thought every model was failing. If only 3 fail, it may be because they are turbo models (turbo lora merged into it). Try 8 steps and CFG 1 and see if that fixes it.
Other option is that the model download failed, but it had to happen 3 times. Unlikely but possible.
Even without Turbo, CFG 6 is high (but fine) and 34 steps can be lowered to 20-ish without quality loss.
There is no gain that I can see in doing it within comfyUI.
Of course we could, but
- comfy's big disadvantage is that the settings are scattered all throughout the graph
- comfy's strength of finely adjusting workflows is kinda irrelevant there - a monolithic program is better suited.
Or maybe I'm totally wrong and it's just that the community took the habit of using other programs.
There a trick you can try: set the CFG to 0, it should generate an image based on your negative prompt only.
Important, use the base checkpoint, not a distilled.
Quick explanation: CW is the conditioning weight, NEG is the negative cond (prompt), POS is the positive cond (prompt)
CW = NEG + CFG x (POS - NEG)
With CFG = 1:
CW = NEG + POS - NEG = POS <-- only POS in the result
With CFG = 0:
CW = NEG + 0 x (POS - NEG) = NEG <-- only NEG in the result
Je ne sais pas, je n'ai pas vraiment creusé la question. C'est sûr que c'est pas un cas d'usage ultra répandu, mais si c'est possible, quelqu'un l'a peut-etre déjà fait. A mon avis, il ne faut pas s'attendre a des résultats incroyables du premier coup.
Une façon d'aborder les choses serait de générer en 180° directement plutôt que de passer par une conversion.
Je jetterai un coup d'oeil sur le sujet un de ces jours.
😝
There was a discussion about it 3 weeks ago (don't mind the AR passthrough stuff). Some infos are scattered around. Basically some have tried with different techniques with different success.
For real VR180 from a flat screen-size picture, you need to extend (outpaint) + add depth. Both can be achieved through AI in theory.
I guess that comfy provides other ways to control how frequencies are handled. Upfront, with sampler/scheduler mostly. It's not really a post-processing tool, though it can be used as such.
I can't help you more but others have gone that path.
https://www.adobe.com/products/photoshop/frequency-separation.html
https://www.affinity.studio/blog/frequency-separation-explained
I've never seen this node used anywhere in a comfy workflow though.
It is for very specific use cases, very precise edits. You probably don't need it. Most people don't use it.
It splits the signal so you can alter either high frequencies or low frequencies without altering the other. Then the same node can recombine the signals.
You can check your model with
head -c 4 Qwen-Image-2.1-Turbo-Uncensored-AD-Q6_K.ggufThe output should be GGUF
The error points to a faulty model or outdated loader node.
Several people have developped apps to connect to comfyUI via API, network hook, or even use comfyUI natively on mobile phone.
Search this subreddit with the keyword "mobile" or similar, sort by NEW.
u/Greedy_Cow9889
Well, I had time to read your comment before it got deleted (no idea why BTW).
Here is the answer I planned to send:
Great answer comrade, thanx a lot. I have so many questions right now, but I'll keep that for later. For now I'm gonna benchmark it on my Linux + 3090 + 64GB DDR5. I will post the results.
Keep it on 👍
I'm very interested yet curious about how it works and the process that led you to build it.
I've had a chat with chatGPT, to explain the optimization techniques used and the trade-offs. It was a bit long but interesting. Did chatGPT get it right?
Here is the summary, for those interested:
These techniques target different bottlenecks: redundant computation, CPU-to-GPU weight transfers, repeated modulation calculations and expensive attention operations.
## 1. Guarded Residual Caching
**Purpose:** Avoid repeatedly executing the expensive diffusion transformer.
Normally, every diffusion step evaluates the transformer using the current latent and timestep to calculate a new prediction.
Residual caching reuses a previously calculated prediction instead of running the entire transformer again.
Importantly, a cache hit does NOT mean the diffusion step becomes a no-op. The sampler still advances the latent using the current timestep and the cached prediction.
In simplified form:
- Normal sampling: calculate a new prediction at every step.
- Cached sampling: reuse a previous prediction for selected steps.
- The latent continues evolving throughout the process.
The implementation uses safeguards such as residual thresholds, temporal guards, restrictions on consecutive cache hits and schedule boundaries.
**Benefits:**
- Potentially the largest reduction in computation.
- Avoids complete transformer evaluations.
- Also avoids transferring weights for skipped transformer blocks.
- Particularly attractive for very large models.
**Trade-offs:**
- Reused predictions are approximations of the current predictions.
- Errors can accumulate across successive diffusion steps.
- Potential degradation of fine details, character identity, motion and temporal consistency.
- A cache threshold does not guarantee perceptual equivalence.
- The resulting video may differ from ordinary dense sampling.
**Assessment:** Potentially very effective, but one of the riskiest optimizations for output fidelity. Conservative caching should be preferred initially.
## 2. Adaptive Weight Read-Ahead
**Purpose:** Reduce GPU waiting time caused by transferring model weights from system RAM to VRAM.
The complete BF16 model is approximately 66.28 GB, considerably larger than the VRAM of consumer GPUs.
Consequently, model weights must be streamed between system RAM and GPU memory.
A naive implementation loads each layer only when it is needed, potentially leaving the GPU waiting for transfers.
Adaptive read-ahead anticipates which transformer blocks will be required and stages their weights in advance.
It uses mechanisms such as:
- Pinned host memory.
- Prefetch queues.
- GPU memory budgets.
- Overlapping weight transfers with GPU computation.
- Memory reserves to prevent allocation failures.
**Benefits:**
- Reduces transfer-related waiting time.
- Improves GPU utilization.
- Does not inherently alter model calculations or output quality.
- Particularly valuable when running models larger than available VRAM.
**Trade-offs:**
- Consumes additional system RAM.
- Pinned memory reduces the flexibility of the operating system's memory manager.
- Requires sufficient PCIe bandwidth.
- Poorly configured prefetching can cause RAM or VRAM exhaustion.
- Introduces synchronization and memory-management complexity.
**Assessment:** One of the safest optimizations from a quality perspective. Particularly interesting for GPUs with limited VRAM, provided sufficient system RAM and PCIe bandwidth are available.
## 3. Exact AdaLN Optimization
**Purpose:** Eliminate redundant timestep-dependent calculations.
AdaLN (Adaptive Layer Normalization) uses modulation parameters to control how transformer blocks process their inputs.
Some of these calculations depend on the timestep and model parameters rather than the changing video latent.
For a known sampling schedule, the required modulation tensors can therefore be precomputed and reused.
The implementation calculates these values ahead of sampling and stores them for subsequent retrieval.
The important distinction is that this is intended to be an exact optimization, not an approximation.
The implementation checks bitwise parity between the native computation and the precomputed results before enabling the optimization.
**Benefits:**
- Avoids repeated projection calculations.
- Reduces unnecessary computation during sampling.
- Reduces the need to repeatedly load associated projection weights.
- Should not degrade output quality when exact parity is maintained.
**Trade-offs:**
- Requires additional CPU memory.
- Introduces initialization overhead.
- Depends on the sampling schedule.
- Requires compatibility with the expected model architecture and execution path.
- Changes to upstream model internals can invalidate implementation assumptions.
**Assessment:** Probably the most attractive optimization. It removes redundant work without intentionally sacrificing numerical accuracy.
## 4. Sparse Attention
**Purpose:** Reduce the computational cost of attention.
Attention allows video tokens to exchange information with other tokens, establishing spatial and temporal relationships.
Dense attention calculates all relevant token interactions. Its computational and memory costs increase substantially with sequence length.
Sparse attention deliberately reduces the number of interactions.
The Noira implementation uses a reduced video-attention budget during selected portions of the sampling schedule, while retaining denser attention for certain conditioning and boundary operations.
The reported configuration uses a 15% video-attention budget during the middle of sampling, with denser attention at the beginning and end.
**Benefits:**
- Reduces attention computation.
- Can significantly improve performance on long video sequences.
- Particularly useful when attention becomes a major computational bottleneck.
**Trade-offs:**
- Some token interactions are no longer calculated.
- May reduce prompt adherence.
- Can affect character identity and appearance.
- May degrade motion coherence and interactions between characters.
- Can introduce spatial or temporal inconsistencies.
- The optimal attention budget may depend on the prompt and scene.
**Assessment:** Potentially useful, but quality-sensitive. Aggressive sparsity should be avoided until its effects have been evaluated on representative videos.
## 5. How the Optimizations Complement Each Other
The four techniques attack different bottlenecks:
| Optimization | Primary target |
| -------------------------- | --------------------------------- |
| Guarded residual caching | Redundant transformer execution |
| Adaptive weight read-ahead | CPU-to-GPU transfer latency |
| Exact AdaLN | Redundant modulation calculations |
| Sparse attention | Attention computation |
Their combined effect can be greater than their individual contributions because they reinforce one another.
For example, residual caching avoids executing transformer blocks and consequently avoids transferring their weights. Adaptive read-ahead then focuses on the smaller number of executions that remain.
However, their speed gains cannot simply be added together. As one bottleneck is reduced, another may become dominant.
Combining multiple optimizations also makes quality problems more difficult to diagnose.
## 6. Overall Assessment
### Preferred approach
Prioritize optimizations that eliminate redundant work without changing the model's mathematical behaviour:
Exact AdaLN.
Adaptive weight read-ahead.
Conservative guarded residual caching.
Sparse attention only if additional acceleration is necessary.
The ideal outcome would be to obtain substantial performance improvements through exact computation reuse and better memory management, while minimizing approximations that could compromise video quality.
**The key distinction:**
A faster generation is not necessarily an equivalent generation. The real objective should be to maximize speed while preserving the visual quality, character consistency and temporal coherence of the original MiniMax H3 model.
Actually, that is totally part of "getting the hang" 😜 .
You seem eager to learn. Generative AI in general and ComfyUI in particular are full of micro and macro concepts. It's a
rabbit-holeelephant-hole. Start with the basics, Pixaroma is the usually recommended tuto maker to follow (for good reasons) but there are others around (foxfuressence for example).Illustrious is a good starting point. Understand the classic workflow pattern (model / clip / VAE -> lora -> CLIP encode -> sampler -> decode -> output) and what each node is there for.
(And you're not prepared for the esoteric language people in this subreddit use)
Dynamic Prompting Quickstart Guide
You could call that the "standard".
You can stick to this, which is powerful enough. But nothing prevents you from adding features if they are worth it (easy to use / well documented or intuitive), or if they are for your personal use.
Since you code nodes, adding those features to nodes makes more sense most of the time.
Spot on 👍 - Use 'preview image' first. Save image when you're happy with the result. Or save them all and sort later.
This node takes width and height as input
There are other nodes which upscale by a factor or to a total number of pixels. Double click the canvas and type 'upscale'. Pick what you prefer.
https://i.redd.it/g6f6vynmh84i1.png
https://i.redd.it/7y04d3be984i1.png
Nearest-exact should give the more faithful output.
If the edges are too sharp, try area.
And also, while you're at it, try the other 3, who knows, maybe you'll fancy the results more.
I couldn't find any mention of ComfyUI in the ProArt website.
Check the startup log
Compare with the full path here:
https://i.redd.it/5y5pvev4xx2i1.png
Thanx for taking the time.
For me it is still a bijection when dequantizing, no new data.
We effectively convert INT8 to FP32, but the FP32 precision is lost. Only specific values of the FP32 are allowed, with unreachable intervals in between.
My IT and maths degrees are long gone, and friday nights don't help, so hit me (or ignore me) if I'm nitpicking.
But where does the retrieved data comes from? It has to be "guessed" somehow by the dequantizer, or am I missing something?
The quality gap you see might be the normal error expected from the quantization (despite 0.4% being very low - well I dunno I've never looked at the actual numbers)
Comfy doesn't eat VRAM by itself. The loaded model used to train the LoRA is gonna eat the VRAM, so it's fine.
It seems OK. I misunderstood your issue, I thought every model was failing. If only 3 fail, it may be because they are turbo models (turbo lora merged into it). Try 8 steps and CFG 1 and see if that fixes it.
Other option is that the model download failed, but it had to happen 3 times. Unlikely but possible.
Even without Turbo, CFG 6 is high (but fine) and 34 steps can be lowered to 20-ish without quality loss.
Template workflow? If not, share a screenshot or the .json of the workflow.
There is no gain that I can see in doing it within comfyUI.
Of course we could, but
- comfy's big disadvantage is that the settings are scattered all throughout the graph
- comfy's strength of finely adjusting workflows is kinda irrelevant there - a monolithic program is better suited.
Or maybe I'm totally wrong and it's just that the community took the habit of using other programs.
EDIT: and because fizgig is great.
Yep, CFG is an interesting concept overall.
MOSS also has a Skip Layer Guidance (SLG) mechanism on top of that, but I have no idea what's the effect on NEG. I haven't tried myself (yet).
There a trick you can try: set the CFG to 0, it should generate an image based on your negative prompt only.
Important, use the base checkpoint, not a distilled.
Quick explanation:
CW is the conditioning weight, NEG is the negative cond (prompt), POS is the positive cond (prompt)
With CFG = 1:
CW = NEG + POS - NEG = POS <-- only POS in the result
With CFG = 0:
CW = NEG + 0 x (POS - NEG) = NEG <-- only NEG in the result
Custom nodes. Search this sub for "queue control" or something.
Delete this file
comfyui/user/comfyui.logStart comfyUI, then provide the file ⬆️ (comfyui.log) on pastebin, google drive, anything convenient for you. This will give some context.
Je ne sais pas, je n'ai pas vraiment creusé la question. C'est sûr que c'est pas un cas d'usage ultra répandu, mais si c'est possible, quelqu'un l'a peut-etre déjà fait. A mon avis, il ne faut pas s'attendre a des résultats incroyables du premier coup.
Une façon d'aborder les choses serait de générer en 180° directement plutôt que de passer par une conversion.
Je jetterai un coup d'oeil sur le sujet un de ces jours.
😝
There was a discussion about it 3 weeks ago (don't mind the AR passthrough stuff). Some infos are scattered around. Basically some have tried with different techniques with different success.
For real VR180 from a flat screen-size picture, you need to extend (outpaint) + add depth. Both can be achieved through AI in theory.