ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
fix(comfyui): turn cuDNN attention off on a GPU the PyTorch build lacks (#8253)
Mike Bradley0bb4cdaca1a9
diff --git a/.github/workflows/comfyui-image.yml b/.github/workflows/comfyui-image.ymlindex dee20bc78..db46c8d84 100644--- a/.github/workflows/comfyui-image.yml+++ b/.github/workflows/comfyui-image.yml@@ -11,7 +11,9 @@ on:- 'ods/extensions/services/comfyui/Dockerfile'- 'ods/extensions/services/comfyui/constraints.txt'- 'ods/extensions/services/comfyui/startup.sh'+ - 'ods/extensions/services/comfyui/ods_attention_guard/**'- 'ods/tests/test_comfyui_image.py'+ - 'ods/tests/test_comfyui_attention_guard.py'- '.github/workflows/comfyui-image.yml'push:branches: [main]@@ -19,7 +21,9 @@ on:- 'ods/extensions/services/comfyui/Dockerfile'- 'ods/extensions/services/comfyui/constraints.txt'- 'ods/extensions/services/comfyui/startup.sh'+ - 'ods/extensions/services/comfyui/ods_attention_guard/**'- 'ods/tests/test_comfyui_image.py'+ - 'ods/tests/test_comfyui_attention_guard.py'- '.github/workflows/comfyui-image.yml'schedule:- cron: '41 4 * * 1'@@ -54,6 +58,6 @@ jobs:env:ODS_TEST_COMFYUI_IMAGE: '1'ODS_TEST_COMFYUI_IIDFILE: ${{ runner.temp }}/comfyui-image-id- run: python -m pytest -q -s ods/tests/test_comfyui_image.py+ run: python -m pytest -q -s ods/tests/test_comfyui_attention_guard.py ods/tests/test_comfyui_image.py- name: Report image sizerun: docker image inspect --format 'image {{.Architecture}} {{.Size}} bytes' "$(cat "$RUNNER_TEMP/comfyui-image-id")"diff --git a/ods/extensions/services/comfyui/Dockerfile b/ods/extensions/services/comfyui/Dockerfileindex ddf175158..d92f5de3a 100644--- a/ods/extensions/services/comfyui/Dockerfile+++ b/ods/extensions/services/comfyui/Dockerfile@@ -7,6 +7,7 @@# 3. ComfyUI from source (pinned tag)# 4. Custom nodes (each = own RUN for granular caching, pinned commits)# 5. comfy-kitchen NVFP4 acceleration+# 5b. ODS attention guard (a GPU this PyTorch build lacks kernels for)# 6. Build checks: pinned torch kept, every custom node imports# 7. Startup script + non-root user (changes most often)#@@ -96,6 +97,16 @@ RUN cd "$COMFYUI_DIR/custom_nodes" \# ---------------------------------------------------------------------------RUN pip3 install --no-cache-dir "comfy-kitchen[cublas]"+# ---------------------------------------------------------------------------+# Layer 5b: ODS attention guard+#+# This PyTorch is built for sm_80, sm_90, sm_100 and sm_120. On a GPU missing+# from that list, such as the GB300 (sm_103), its cuDNN attention finds no+# execution plan and every generation fails; the node turns cuDNN attention+# off there so PyTorch uses its flash kernels. Loaded like any custom node.+# ---------------------------------------------------------------------------+COPY ods_attention_guard/ "$COMFYUI_DIR/custom_nodes/ods_attention_guard/"+# ---------------------------------------------------------------------------# Layer 6: Build checks#diff --git a/ods/extensions/services/comfyui/ods_attention_guard/__init__.py b/ods/extensions/services/comfyui/ods_attention_guard/__init__.pynew file mode 100644index 000000000..e813bec57--- /dev/null+++ b/ods/extensions/services/comfyui/ods_attention_guard/__init__.py@@ -0,0 +1,22 @@+"""ODS: keep PyTorch attention off cuDNN on a GPU this PyTorch build has no kernels for.++The image's PyTorch (2.11.0+cu128) is built for sm_80, sm_90, sm_100 and+sm_120. On a GB300 (sm_103) its cuDNN attention found no execution plan+("cuDNN Frontend error: No valid execution plans built") and every image+generation failed, while the flash, memory-efficient and math kernels all ran+(Workstation06, 2026-10-26). PyTorch prefers cuDNN attention on GPUs this new,+so it is turned off on a GPU missing from the build's architecture list and+nowhere else.+"""+import logging++import torch++NODE_CLASS_MAPPINGS = {}+NODE_DISPLAY_NAME_MAPPINGS = {}++if torch.cuda.is_available():+ major, minor = torch.cuda.get_device_capability()+ if f"sm_{major}{minor}" not in torch.cuda.get_arch_list():+ torch.backends.cuda.enable_cudnn_sdp(False)+ logging.warning("ODS: cuDNN attention is off: this PyTorch build has no sm_%d%d kernels.", major, minor)diff --git a/ods/tests/test_comfyui_attention_guard.py b/ods/tests/test_comfyui_attention_guard.pynew file mode 100644index 000000000..725f4f7a6--- /dev/null+++ b/ods/tests/test_comfyui_attention_guard.py@@ -0,0 +1,63 @@+"""The ComfyUI image's attention guard, with PyTorch replaced by a stand-in.++On Workstation06's GB300 (sm_103, 2026-10-26) the image's PyTorch 2.11.0+cu128+(built for sm_80, sm_90, sm_100 and sm_120) failed every generation in cuDNN+attention ("No valid execution plans built"); flash, memory-efficient and math+attention all ran. The guard turns cuDNN attention off on such a GPU only.+"""+import importlib.util+import sys+import types+import unittest+from pathlib import Path++GUARD = Path(__file__).resolve().parents[1] / "extensions/services/comfyui/ods_attention_guard/__init__.py"+CU128_ARCHES = ["sm_80", "sm_90", "sm_100", "sm_120"]+++def load_guard(available, capability=(0, 0), arches=CU128_ARCHES):+ calls = []+ torch = types.ModuleType("torch")+ torch.cuda = types.SimpleNamespace(is_available=lambda: available,+ get_device_capability=lambda: capability,+ get_arch_list=lambda: list(arches))+ torch.backends = types.SimpleNamespace(cuda=types.SimpleNamespace(enable_cudnn_sdp=calls.append))+ previous = sys.modules.get("torch")+ sys.modules["torch"] = torch+ try:+ spec = importlib.util.spec_from_file_location("ods_attention_guard_under_test", GUARD)+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ finally:+ if previous is None:+ sys.modules.pop("torch")+ else:+ sys.modules["torch"] = previous+ return module, calls+++class AttentionGuardTests(unittest.TestCase):+ def test_turns_cudnn_attention_off_on_a_gpu_the_build_lacks(self):+ for capability in ((10, 3), (12, 1)): # GB300, GB10+ with self.subTest(capability=capability):+ _, calls = load_guard(True, capability)+ self.assertEqual(calls, [False])++ def test_leaves_a_gpu_the_build_targets_alone(self):+ for capability in ((12, 0), (10, 0), (9, 0), (8, 0)):+ with self.subTest(capability=capability):+ _, calls = load_guard(True, capability)+ self.assertEqual(calls, [])++ def test_is_inert_without_a_gpu(self):+ # The image's build check loads every custom node on the CPU.+ _, calls = load_guard(False)+ self.assertEqual(calls, [])++ def test_loads_as_a_custom_node_without_nodes(self):+ module, _ = load_guard(False)+ self.assertEqual((module.NODE_CLASS_MAPPINGS, module.NODE_DISPLAY_NAME_MAPPINGS), ({}, {}))+++if __name__ == "__main__":+ unittest.main()diff --git a/ods/tests/test_comfyui_image.py b/ods/tests/test_comfyui_image.pyindex 444261f27..82eacd5e2 100644--- a/ods/tests/test_comfyui_image.py+++ b/ods/tests/test_comfyui_image.py@@ -11,7 +11,7 @@ import unittestfrom pathlib import PathCONTEXT = Path(__file__).resolve().parents[1] / "extensions/services/comfyui"-NODES = ("ComfyUI-GGUF", "ComfyUI-KJNodes", "ComfyUI-LTXVideo", "ComfyUI-VideoHelperSuite")+NODES = ("ComfyUI-GGUF", "ComfyUI-KJNodes", "ComfyUI-LTXVideo", "ComfyUI-VideoHelperSuite", "ods_attention_guard")@unittest.skipUnless(os.environ.get("ODS_TEST_COMFYUI_IMAGE") == "1",@@ -47,6 +47,12 @@ class ComfyUIImageTests(unittest.TestCase):self.assertIn(node, installed)self.assertNotIn("ComfyUI-Manager", installed)+ def test_attention_guard_loads_and_is_inert_without_a_gpu(self):+ # It turns cuDNN attention off only on a GPU the PyTorch build lacks (GB300).+ self.assertEqual(self.python(+ "import sys; sys.path.insert(0, '/opt/comfyui/custom_nodes'); import torch, ods_attention_guard; "+ "print(torch.backends.cuda.cudnn_sdp_enabled())"), "True")+def test_build_check_left_no_user_directory(self):# startup.sh migrates an image-side user/ into the owner's mount.self.assertEqual(self.python("import os; print(os.path.exists('/opt/comfyui/user'))"), "False")