Update AGENTS.md (#15096)
This commit is contained in:
parent
806e092ed4
commit
02c688429e
1 changed files with 20 additions and 2 deletions
22
AGENTS.md
22
AGENTS.md
|
|
@ -162,8 +162,26 @@
|
||||||
adding parallel code paths. Use `comfy.quant_ops`, `comfy.model_management`,
|
adding parallel code paths. Use `comfy.quant_ops`, `comfy.model_management`,
|
||||||
`comfy.memory_management`, `comfy.pinned_memory`, `comfy_aimdo`, and
|
`comfy.memory_management`, `comfy.pinned_memory`, `comfy_aimdo`, and
|
||||||
`comfy-kitchen` helpers where they already solve the problem.
|
`comfy-kitchen` helpers where they already solve the problem.
|
||||||
- Use optimized comfy-kitchen ops in places where they improve performance
|
- Model implementations must use an existing optimized Comfy Kitchen or
|
||||||
without changing the expected dtype, device, memory, or interface behavior.
|
ComfyUI operation whenever one supports the required math and tensor layout
|
||||||
|
without changing expected dtype, device, memory, or interface behavior. This
|
||||||
|
is the default implementation requirement, not an optional follow-up
|
||||||
|
optimization.
|
||||||
|
- Before implementing model math, inspect the operations already exposed by
|
||||||
|
Comfy Kitchen, `comfy.quant_ops`, and existing ComfyUI model helpers. Check
|
||||||
|
for optimized single, paired, fused, layout-specific, and quantized variants
|
||||||
|
before writing a local implementation or composing lower-level torch ops.
|
||||||
|
- Use the compatible optimized operation first and adapt the model's inputs to
|
||||||
|
its documented layout while preserving the model's exact math. If several
|
||||||
|
optimized variants apply, benchmark representative model shapes and select
|
||||||
|
the fastest valid path.
|
||||||
|
- Add or retain a local implementation only when no existing optimized
|
||||||
|
operation supports the required math, layout, dtype, device, autograd, or
|
||||||
|
patch contract. Keep differentiable or patch-compatible fallbacks when the
|
||||||
|
optimized inference operation does not provide those contracts.
|
||||||
|
- Use the existing ComfyUI cast, offload, and cleanup helpers for parameters
|
||||||
|
passed to optimized operations. Preserve model-specific epsilon, scaling,
|
||||||
|
layout, dtype, device, and output-shape behavior.
|
||||||
- Prefer ComfyUI's shared optimized kernels and backend dispatchers over
|
- Prefer ComfyUI's shared optimized kernels and backend dispatchers over
|
||||||
handwritten implementations of the same operation. Remove duplicate local
|
handwritten implementations of the same operation. Remove duplicate local
|
||||||
kernels and adapt inputs to the shared operation's documented layout while
|
kernels and adapt inputs to the shared operation's documented layout while
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue