Skip to content

Conversation

@NeuralFault
Copy link
Contributor

Adds a module to SM Inference's optional Steps listing. This, when toggled on, will add the CFZ Cudnn Toggle node in ComfyUI-Zluda to SM Inference's workflow disabling Cudnn before VAE Decode to prevent "RuntimeError: GET was unable to find an engine to execute this computation" when MIOpen kicks in.

Is only a simple toggle that needs to be placed above FaceDetailer (since it itself invokes a conv2d function) in Inference's parameters, but otherwise to be the last Step module at the bottom of the list.

@github-actions
Copy link

github-actions bot commented Oct 26, 2025

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
@NeuralFault
@neural Fault
Neural Fault seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @NeuralFault, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a new CUDNN toggle module into the StabilityMatrix inference system, specifically targeting ComfyUI-Zluda users. The primary goal is to resolve a RuntimeError that occurs when MIOpen conflicts with CUDNN during VAE decoding on certain hardware configurations, such as AMD cards. The module provides a user-facing toggle to control CUDNN enablement and benchmarking, ensuring smoother operation and preventing workflow interruptions.

Highlights

  • New CUDNN Toggle Module: Introduces a new module to manage CUDNN settings specifically for ComfyUI-Zluda within the inference workflow.
  • Error Prevention: Designed to prevent "RuntimeError: GET was unable to find an engine to execute this computation" by disabling CUDNN before VAE Decode, particularly for AMD cards using MIOpen.
  • Workflow Integration: The module adds a toggle node that should be positioned strategically in the inference steps, ideally before FaceDetailer and as the last step module.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@NeuralFault
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new inference module to toggle cuDNN settings, which is a useful workaround for users on specific hardware configurations (AMD with Zluda). The implementation is straightforward and adds the necessary UI, ViewModel, and module logic.

My review focuses on a few key areas:

  • Connecting UI to Logic: There's a disconnect between the UI controls in the new CfzCudnnToggleCard and the CfzCudnnToggleModule logic, which currently uses hardcoded values. I've suggested wiring them up to make the feature fully configurable as the UI implies.
  • Code Consistency: I've pointed out a minor naming inconsistency in the new ComfyUI node definition to align it with existing conventions in the codebase.
  • Maintainability: I've also made a few suggestions to improve code organization by sorting attribute and type lists alphabetically.

Overall, this is a good addition. Addressing these points will improve the code's correctness and maintainability.

Comment on lines +1 to +61
using System.Linq;
using Injectio.Attributes;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Api.Comfy.Nodes;
using StabilityMatrix.Core.Models.Api.Comfy.NodeTypes;
using StabilityMatrix.Core.Models.Inference;

namespace StabilityMatrix.Avalonia.ViewModels.Inference.Modules;

[ManagedService]
[RegisterTransient<CfzCudnnToggleModule>]
public class CfzCudnnToggleModule : ModuleBase
{
/// <inheritdoc />
public CfzCudnnToggleModule(IServiceManager<ViewModelBase> vmFactory)
: base(vmFactory)
{
Title = "Disable CUDNN (ComfyUI-Zluda)";
}

/// <summary>
/// Applies CUDNN Toggle node between sampler latent output and VAE decode
/// This prevents "GET was unable to find an engine" errors on AMD cards with Zluda
/// </summary>
protected override void OnApplyStep(ModuleApplyStepEventArgs e)
{
// Get the primary connection (can be latent or image)
var primary = e.Builder.Connections.Primary;
if (primary == null)
{
return; // No primary connection to process
}

// Check if primary is a latent (from sampler output)
if (primary.IsT0) // T0 is LatentNodeConnection
{
var latentConnection = primary.AsT0;

// Insert CUDNN toggle node between sampler and VAE decode
var cudnnToggleOutput = e.Nodes.AddTypedNode(
new ComfyNodeBuilder.CUDNNToggleAutoPassthrough
{
Name = e.Nodes.GetUniqueName("CUDNNToggle"),
Model = null,
Conditioning = null,
Latent = latentConnection, // Pass through the latent from sampler
enable_cudnn = false,
cudnn_benchmark = false,
}
);

// Update the primary connection to use the CUDNN toggle latent output (Output3)
// This ensures VAE decode receives latent from CUDNN toggle instead of directly from sampler
e.Builder.Connections.Primary = cudnnToggleOutput.Output3;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The module currently hardcodes enable_cudnn and cudnn_benchmark to false, which doesn't use the values from CfzCudnnToggleCardViewModel. This makes the UI controls for these settings ineffective.

To fix this, you should:

  1. In the CfzCudnnToggleModule constructor, add the CfzCudnnToggleCardViewModel as a card to the module.
  2. Update OnApplyStep to retrieve the view model and use its properties (EnableCudnn and CudnnBenchmark) when creating the CUDNNToggleAutoPassthrough node.
  3. Consider renaming the module Title to "CUDNN Toggle (ComfyUI-Zluda)" to better reflect that it can both enable and disable CUDNN settings.
  4. The using System.Linq; statement is not used and can be removed.

I've included a code suggestion that implements these changes. Note that it uses PascalCase property names (EnableCudnn, CudnnBenchmark) for the CUDNNToggleAutoPassthrough node, which corresponds to another suggestion I've made for ComfyNodeBuilder.cs.

using Injectio.Attributes;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Api.Comfy.Nodes;
using StabilityMatrix.Core.Models.Api.Comfy.NodeTypes;
using StabilityMatrix.Core.Models.Inference;

namespace StabilityMatrix.Avalonia.ViewModels.Inference.Modules;

[ManagedService]
[RegisterTransient<CfzCudnnToggleModule>]
public class CfzCudnnToggleModule : ModuleBase
{
    /// <inheritdoc />
    public CfzCudnnToggleModule(IServiceManager<ViewModelBase> vmFactory)
        : base(vmFactory)
    {
        Title = "CUDNN Toggle (ComfyUI-Zluda)";
        AddCards(vmFactory.Get<CfzCudnnToggleCardViewModel>());
    }

    private CfzCudnnToggleCardViewModel Card => GetCard<CfzCudnnToggleCardViewModel>();

    /// <summary>
    /// Applies CUDNN Toggle node between sampler latent output and VAE decode
    /// This prevents "GET was unable to find an engine" errors on AMD cards with Zluda
    /// </summary>
    protected override void OnApplyStep(ModuleApplyStepEventArgs e)
    {
        // Get the primary connection (can be latent or image)
        var primary = e.Builder.Connections.Primary;
        if (primary == null)
        {
            return; // No primary connection to process
        }

        // Check if primary is a latent (from sampler output)
        if (primary.IsT0) // T0 is LatentNodeConnection
        {
            var latentConnection = primary.AsT0;

            // Insert CUDNN toggle node between sampler and VAE decode
            var cudnnToggleOutput = e.Nodes.AddTypedNode(
                new ComfyNodeBuilder.CUDNNToggleAutoPassthrough
                {
                    Name = e.Nodes.GetUniqueName("CUDNNToggle"),
                    Model = null,
                    Conditioning = null,
                    Latent = latentConnection, // Pass through the latent from sampler
                    EnableCudnn = Card.EnableCudnn,
                    CudnnBenchmark = Card.CudnnBenchmark,
                }
            );

            // Update the primary connection to use the CUDNN toggle latent output (Output3)
            // This ensures VAE decode receives latent from CUDNN toggle instead of directly from sampler
            e.Builder.Connections.Primary = cudnnToggleOutput.Output3;
        }
    }
}

[JsonDerivedType(typeof(RescaleCfgCardViewModel), RescaleCfgCardViewModel.ModuleKey)]
[JsonDerivedType(typeof(PlasmaNoiseCardViewModel), PlasmaNoiseCardViewModel.ModuleKey)]
[JsonDerivedType(typeof(NrsCardViewModel), NrsCardViewModel.ModuleKey)]
[JsonDerivedType(typeof(CfzCudnnToggleCardViewModel), CfzCudnnToggleCardViewModel.ModuleKey)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve code organization and maintainability, please keep [JsonDerivedType] attributes sorted alphabetically by the type name. CfzCudnnToggleCardViewModel should be placed before ControlNetCardViewModel.

[JsonDerivedType(typeof(RescaleCfgModule))]
[JsonDerivedType(typeof(PlasmaNoiseModule))]
[JsonDerivedType(typeof(NRSModule))]
[JsonDerivedType(typeof(CfzCudnnToggleModule))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve code organization and maintainability, please keep [JsonDerivedType] attributes sorted alphabetically by the type name. CfzCudnnToggleModule should be placed before ControlNetModule.

Comment on lines 96 to 100
typeof(FluxHiresFixModule),
typeof(UpscalerModule),
typeof(CfzCudnnToggleModule),
typeof(SaveImageModule),
typeof(FaceDetailerModule)
typeof(FaceDetailerModule),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and maintainability, please keep the list of available modules sorted alphabetically.

                typeof(CfzCudnnToggleModule),
                typeof(FaceDetailerModule),
                typeof(FluxHiresFixModule),
                typeof(SaveImageModule),
                typeof(UpscalerModule),

Comment on lines 103 to 107
typeof(HiresFixModule),
typeof(UpscalerModule),
typeof(CfzCudnnToggleModule),
typeof(SaveImageModule),
typeof(FaceDetailerModule)
typeof(FaceDetailerModule),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and maintainability, please keep the list of available modules sorted alphabetically.

                typeof(CfzCudnnToggleModule),
                typeof(FaceDetailerModule),
                typeof(HiresFixModule),
                typeof(SaveImageModule),
                typeof(UpscalerModule),

@NeuralFault
Copy link
Contributor Author

recheck

@NeuralFault
Copy link
Contributor Author

closing as needed to rebase, fix author issues and pushed to a new branch.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2025
@NeuralFault NeuralFault deleted the comfyui-zluda-cudnnfix branch October 26, 2025 22:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants