2025-10-03 21:43:54 +03:00
|
|
|
from typing_extensions import override
|
|
|
|
|
from comfy_api.latest import ComfyExtension, io
|
2025-05-21 01:56:56 -07:00
|
|
|
from comfy_api.torch_helpers import set_torch_compile_wrapper
|
|
|
|
|
|
2025-12-15 13:49:29 -08:00
|
|
|
def skip_torch_compile_dict(guard_entries):
|
|
|
|
|
return [("transformer_options" not in entry.name) for entry in guard_entries]
|
2024-09-12 05:23:32 -04:00
|
|
|
|
2025-10-03 21:43:54 +03:00
|
|
|
class TorchCompileModel(io.ComfyNode):
|
2024-09-12 05:23:32 -04:00
|
|
|
@classmethod
|
2025-10-03 21:43:54 +03:00
|
|
|
def define_schema(cls) -> io.Schema:
|
|
|
|
|
return io.Schema(
|
|
|
|
|
node_id="TorchCompileModel",
|
2026-05-08 13:02:55 +08:00
|
|
|
category="experimental",
|
2025-10-03 21:43:54 +03:00
|
|
|
inputs=[
|
|
|
|
|
io.Model.Input("model"),
|
|
|
|
|
io.Combo.Input(
|
|
|
|
|
"backend",
|
|
|
|
|
options=["inductor", "cudagraphs"],
|
feat: mark 429 widgets as advanced for collapsible UI (#12197)
* feat: mark 429 widgets as advanced for collapsible UI
Mark widgets as advanced across core, comfy_extras, and comfy_api_nodes
to support the new collapsible advanced inputs section in the frontend.
Changes:
- 267 advanced markers in comfy_extras/
- 162 advanced markers in comfy_api_nodes/
- All files pass python3 -m py_compile verification
Widgets marked advanced (hidden by default):
- Scheduler internals: sigma_max, sigma_min, rho, mu, beta, alpha
- Sampler internals: eta, s_noise, order, rtol, atol, h_init, pcoeff, etc.
- Memory optimization: tile_size, overlap, temporal_size, temporal_overlap
- Pipeline controls: add_noise, start_at_step, end_at_step
- Timing controls: start_percent, end_percent
- Layer selection: stop_at_clip_layer, layers, block_number
- Video encoding: codec, crf, format
- Device/dtype: device, noise_device, dtype, weight_dtype
Widgets kept basic (always visible):
- Core params: strength, steps, cfg, denoise, seed, width, height
- Model selectors: ckpt_name, lora_name, vae_name, sampler_name
- Common controls: upscale_method, crop, batch_size, fps, opacity
Related: frontend PR #11939
Amp-Thread-ID: https://ampcode.com/threads/T-019c1734-6b61-702e-b333-f02c399963fc
* fix: remove advanced=True from DynamicCombo.Input (unsupported)
Amp-Thread-ID: https://ampcode.com/threads/T-019c1734-6b61-702e-b333-f02c399963fc
* fix: address review - un-mark model merge, video, image, and training node widgets as advanced
Per comfyanonymous review:
- Model merge arguments should not be advanced (all 14 model-specific merge classes)
- SaveAnimatedWEBP lossless/quality/method should not be advanced
- SaveWEBM/SaveVideo codec/crf/format should not be advanced
- TrainLoraNode options should not be advanced (7 inputs)
Amp-Thread-ID: https://ampcode.com/threads/T-019c322b-a3a8-71b7-9962-d44573ca6352
* fix: un-mark batch_size and webcam width/height as advanced (should stay basic)
Amp-Thread-ID: https://ampcode.com/threads/T-019c3236-1417-74aa-82a3-bcb365fbe9d1
---------
Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
2026-02-19 19:20:02 -08:00
|
|
|
advanced=True,
|
2025-10-03 21:43:54 +03:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
outputs=[io.Model.Output()],
|
|
|
|
|
is_experimental=True,
|
|
|
|
|
)
|
2024-09-12 05:23:32 -04:00
|
|
|
|
2025-10-03 21:43:54 +03:00
|
|
|
@classmethod
|
|
|
|
|
def execute(cls, model, backend) -> io.NodeOutput:
|
2026-02-24 16:13:46 -08:00
|
|
|
m = model.clone(disable_dynamic=True)
|
2025-12-15 13:49:29 -08:00
|
|
|
set_torch_compile_wrapper(model=m, backend=backend, options={"guard_filter_fn": skip_torch_compile_dict})
|
2025-10-03 21:43:54 +03:00
|
|
|
return io.NodeOutput(m)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TorchCompileExtension(ComfyExtension):
|
|
|
|
|
@override
|
|
|
|
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
|
|
|
|
return [
|
|
|
|
|
TorchCompileModel,
|
|
|
|
|
]
|
|
|
|
|
|
2024-09-12 05:23:32 -04:00
|
|
|
|
2025-10-03 21:43:54 +03:00
|
|
|
async def comfy_entrypoint() -> TorchCompileExtension:
|
|
|
|
|
return TorchCompileExtension()
|