Commit Graph

5554 Commits

Author SHA1 Message Date
Scott Yewell 55760cdeb5 attention_pytorch: skip the chunk buffer/copy when steps==1
Addresses CodeRabbit feedback on #14838: the chunking loop always
allocated a temporary output buffer and copied SDPA's result into it,
even in the common case (any non-MPS device, or MPS below the size
threshold) where steps==1 and the loop only ever runs once. Adds a
fast path that calls scaled_dot_product_attention directly and
reshapes its result, matching the original pre-fix code for that case
-- no extra allocation or copy. The chunked path (steps>1) is
unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HAMqHgFBD6e9wjU8k8U6uW
2026-07-08 16:31:12 -04:00
Scott Yewell 7b7d48faa2 Remove diagnostic logging scaffolding from the MPS attention fix
Keep the fix itself (size-based chunking/capping) but drop the
_diag_log_attn_size helper, the debug-level [MPS-ATTN-FIX:...]
messages, and the now-unused tag parameters that only existed to
support that logging -- a minimal correctness fix without added
observability scaffolding.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HAMqHgFBD6e9wjU8k8U6uW
2026-07-08 16:23:23 -04:00
Scott Yewell 7be129913f Fix MPS attention corruption for large sequences (Wan2.2 long-video)
MPS uses 32-bit indexing internally for many ops; a single attention
matrix (b*heads*seq_q*seq_k) at or above ~2^31 elements silently
corrupts output instead of raising, regardless of free unified memory.
A 61-frame/832x640 Wan2.2 case measured 7.68B elements, 3.6x over the
limit.

Fixes all four MPS-reachable attention implementations in
comfy/ldm/modules/attention.py, not just the ones a given launch
config happens to select:

- model_management.py: add bf16 to FORCE_UPCAST_ATTENTION_DTYPE
  (was fp16-only).
- attention_split: extend fp32 upcast to the second (weights x V)
  matmul, not just Q.Kt; add size-based diagnostic logging
  (_diag_log_attn_size); force chunking via a new shared
  _mps_forced_attn_chunk_steps() helper once the attention matrix
  exceeds 2^30 elements, independent of the existing memory-pressure
  based steps calculation (which never triggers on a 512GB unified
  memory machine); fix a slice_size divisibility bug that silently
  fell back to computing the whole unchunked sequence.
- attention_pytorch: port the same MPS chunking guard to the native
  SDPA path (previously unguarded and unsafe for large sequences on
  MPS), chunking over seq_q with a preallocated output buffer; zero
  behavior change when chunking doesn't engage. Also add
  attn_precision handling (get_attn_precision + float32 upcast of
  q/k/v/mask), which this path previously ignored entirely.
- attention_basic: reached via optimized_attention_for_device's
  small_input=True path whenever pytorch attention isn't enabled --
  a live path on MPS for text/image encoder attention (CLIP, T5,
  Llama, Gemma, Qwen-VL, DINO, BiRefNet, RT-DETR, etc). Had zero
  chunking of any kind; introduces a chunking loop using the same
  shared helper, preserving both bool-mask (masked_fill_) and
  float-mask (additive) handling.
- attention_sub_quad: the actual default MPS attention path (selected
  whenever no --use-*-attention flag is passed at all). Its
  free-memory-based query_chunk_size/kv_chunk_size selection has the
  same class of gap attention_split had -- on a 512GB unified-memory
  machine it always picks the largest candidate and disables
  kv-chunking entirely. Adds a new _mps_cap_subquad_chunk_sizes()
  helper that caps both values against the same MPS ceiling, entirely
  in the caller so the third-party MIT-licensed
  sub_quadratic_attention.py delegate stays untouched.
- Quiet the MPS-ATTN-FIX log to debug level (fires on every call once
  a guard engages, not deduplicated like the diagnostic logging).

Verified: standalone numerical tests confirm chunked/capped output
matches unchunked baseline (fp16-rounding-level max abs diff) for all
four functions, across no-mask/float-mask/bool-mask and fp32-upcast
variants, including the attention_sub_quad boundary case that forces
the delegate's real kv-chunked branch instead of its fast path. Shape
parity confirmed against the real 61-frame/832x640 repro case: all
four functions independently compute consistent forced chunk sizes
for the identical b*heads=40, seq=13860 shape.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HAMqHgFBD6e9wjU8k8U6uW
2026-07-08 16:23:23 -04:00
Silver 091b70edda
add models-directory launch argument (#9113) 2026-07-08 22:20:47 +08:00
comfyanonymous ffbecfffb9
Fix crash when using UNetSelfAttentionMultiply (#14823) 2026-07-07 21:17:31 -07:00
comfyanonymous b481bc15af
Support gqa on all attention backends, drop support for pytorch 2.4 (#14772) 2026-07-07 22:57:52 -04:00
comfyanonymous 6880614319
Update AGENTS.md (#14819) 2026-07-07 18:36:13 -07:00
Barish Ozbay 51bf508a0b
feat: Implement basic text overlay node (CORE-137) (#14610) 2026-07-07 21:26:52 +08:00
Alexander Piskun a3020f107e
fix(Video): don't crash on videos with undecodable audio streams (#14746)
* fix(Video): don't crash on videos with undecodable audio streams

Signed-off-by: bigcat88 <bigcat88@icloud.com>

* Update comfy_api_nodes/util/upload_helpers.py

---------

Signed-off-by: bigcat88 <bigcat88@icloud.com>
Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com>
2026-07-07 15:59:49 +03:00
comfyanonymous 7cf4e78335
Delete symlink that breaks our updates. (#14803) 2026-07-06 22:24:05 -04:00
Alexis Rolland 7747c342d4
ci: add CLA Assistant workflow (#14582) 2026-07-07 06:44:19 +08:00
comfyanonymous 439bd807f8
Skip unloading dynamic model patchers in current workflow. (#14799) 2026-07-06 14:35:12 -07:00
Daxiong (Lin) b08debceca
chore: update embedded docs to v0.5.7 (#14783) 2026-07-06 09:56:09 +08:00
comfyanonymous 000c6b784e
Small speedup for text model sampling. (#14773) 2026-07-05 18:39:24 -07:00
Alexander Piskun 985fb9d6ad
[Partner Nodes] fix(logs-auth): mask authorization headers in logs (#14774)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
2026-07-05 13:55:29 +03:00
Alexis Rolland 7f287b705e
fix: Bug when setting transparency in color picker (#14764) 2026-07-04 19:13:38 -04:00
comfyanonymous b7ba504e06
Try to make coderabbit enforce AGENTS.md (#14759) 2026-07-04 14:25:24 -04:00
Silver 6c62ca0b6b
fix: error when embedding is loaded with models using llama_template (#14744) 2026-07-04 17:06:09 +08:00
Robin Huang 3fe9f5fecb
Add CLAUDE.md as symlink to AGENTS.md (#14757) 2026-07-04 13:12:47 +08:00
Alexander Piskun 1073a74976
[Partner Nodes] chore(ByteDance): adjust category name (#14752)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
2026-07-04 00:01:05 +03:00
comfyanonymous de1b8f3e8d
Update AGENTS.md (#14738) 2026-07-03 13:08:24 -07:00
Alexander Piskun 77917ed3a6
[Partner Nodes] chore(StabilityAI): remove StabilityAI nodes (#14737)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
2026-07-03 14:24:21 +03:00
Daxiong (Lin) a04ebe05c2
chore: update workflow templates to v0.11.2 (#14741) 2026-07-03 19:08:11 +08:00
Alexander Piskun 9764381998
[Partner Nodes] feat(ByteDance): add support for Seed Audio 1.0 (#14731)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
2026-07-03 14:00:10 +03:00
comfyanonymous 1e04ced089
Update AGENTS.md (#14733) 2026-07-03 02:08:47 -04:00
Matt Miller 96e0e3585b
security: fix four vulnerabilities (GHSA-779p-m5rp-r4h4) (#14734)
* security: fix five vulnerabilities (GHSA-779p-m5rp-r4h4)

- CVE-2026-56670: force download of SVG/XML responses on /view to prevent stored XSS
- CVE-2026-56671: contain /experiment/models/preview reads within the model folder
- CVE-2026-56672: stop inline rendering of uploaded /userdata/{file} content
- CVE-2026-56673: prevent path traversal in get_annotated_filepath (LoadImage /prompt input)
- CVE-2026-56674: reject opaque/null Origin to close the CSRF middleware bypass

Adds regression tests under tests-unit/security_test/ covering all five.

* security: address review feedback on GHSA-779p fixes

- Fix Windows CI failure in test_get_annotated_filepath: compare against
  os.path.abspath(...) to match the intentional abspath normalization added
  by the traversal hardening (abspath prepends the drive letter on Windows).
- origin_check: narrow the bare `except:` in is_loopback() to ValueError so
  genuine interrupts aren't swallowed (review nit).
- origin_check: guard .port access in is_cross_origin_forbidden() so a
  malformed/out-of-range port (e.g. Origin: http://127.0.0.1:99999) fails
  closed with a 403 instead of surfacing an uncaught 500 in the middleware.
- server /view: escape backslash/quote in the Content-Disposition filename
  (RFC 6266 quoted-string) so a filename containing a double quote can't
  malform the response header.

* security: address CodeRabbit review feedback on GHSA-779p tests

- test #3: guard the symlink-escape test with a try/except skip so it no
  longer errors on Windows CI where os.symlink needs elevated privileges /
  Developer Mode (mirrors the guard in the sibling test #2).
- test #5: refresh the stale module docstring to describe the actual /view
  gating (view_image closure calling folder_paths.is_dangerous_content_type,
  the normalising check) instead of the bypassable raw set-membership test.

* revert(security): drop CVE-2026-56674 Origin: null CSRF change

Per maintainer review, the reported CSRF is already mitigated by the pre-existing
Sec-Fetch-Site: cross-site check for current browsers, and the null-origin
rejection risked breaking legitimate sandboxed-iframe embeds. Restores
origin_only_middleware and is_loopback in server.py to their prior state
(the Sec-Fetch-Site check is retained) and removes utils/origin_check.py and its
regression test. The other four GHSA-779p fixes are unaffected.
2026-07-02 20:44:54 -07:00
comfyanonymous 35c1470935
Update AGENTS.md (#14726) 2026-07-02 15:05:55 -04:00
Alexander Piskun 694815f498
[Partner Nodes] chore(Ideogram): remove IdeogramV1 and IdeogramV2 nodes (#14712)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com>
2026-07-02 08:35:11 +03:00
comfyanonymous 92594ca84c
Update AGENTS.md with more stuff. (#14725) 2026-07-01 21:55:13 -04:00
Silver 2c935de1b1
Fix Qwen3-VL tokenizer crash with custom embeddings (#14713) 2026-07-01 21:15:07 +03:00
comfyanonymous dd17debce5
Add some more stuff to AGENTS.md (#14704) 2026-07-01 01:51:51 -04:00
comfyanonymous 50e5270b86
Add AGENTS.md (#14696) 2026-06-30 17:40:33 -04:00
comfyanonymous bb131be9e8 ComfyUI v0.27.0 2026-06-30 17:36:02 -04:00
Daxiong (Lin) 6fca64780c
chore: update workflow templates to v0.11.1 (#14698) 2026-06-30 14:28:09 -07:00
Alexis Rolland 6e11828d10
chore: Update nodes categories (#14674) 2026-07-01 05:20:20 +08:00
Alexander Piskun b70944e710
[Partner Nodes] feat(Google): add Gemini Video Omni node (#14695) 2026-06-30 17:17:53 -04:00
Matt Miller 1c59659a2f
feat: make asset hashing opt-in via --enable-asset-hashing, off by default (#14663)
Add a --enable-asset-hashing CLI flag (action=store_true, default False)
and plumb it into the two asset-seeder call sites in main.py that
previously hardcoded compute_hashes=True (the startup scan and the
post-job output enqueue). Local runs now skip blake3 hashing unless the
user opts in, avoiding the startup/per-output cost on large models
directories while keeping hashing available for asset-portability
features.

Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com>
2026-06-30 14:13:20 -07:00
comfyanonymous d395813bcd
Fix memory leak related to int8. (#14697) 2026-06-30 14:08:59 -07:00
Alexander Piskun 8fe0243d97
[Partner Nodes] feat(Google): add Nano Banana 2 Lite model (#14693)
Signed-off-by: bigcat88 <bigcat88@icloud.com>
2026-06-30 11:17:23 -07:00
Silver ba3f697dbb
Add ConditioningMultiply node to nodes.py as an addition to other adj… (#14686) 2026-06-30 16:27:09 +08:00
Comfy Org PR Bot 510ed5c384
Bump comfyui-frontend-package to 1.45.20 (#14684) 2026-06-30 16:25:03 +08:00
comfyanonymous 7851410511
Better and faster int8 lora applying. (#14685) 2026-06-29 21:52:08 -04:00
Daxiong (Lin) a58473fd9b
chore: update embedded docs to v0.5.6 (#14668)
Co-authored-by: Alexis Rolland <alexisrolland@hotmail.com>
2026-06-29 17:08:06 +08:00
comfyanonymous 79c555ce6b
Fix int8 mm being skipped on offloaded lora weights. (#14669) 2026-06-28 23:52:36 -04:00
Matt Miller f19735759e
ci: add team-gated Cursor review (thin caller for github-workflows) (#14527) 2026-06-27 23:34:30 -07:00
comfyanonymous a95e461916
int8 support on turing GPUs. (#14662) 2026-06-27 15:53:11 -07:00
pythongosssss 603d891eaf
Update GLSL node to use ANGLE library (CORE-162) (#13195) 2026-06-27 08:40:31 +08:00
comfyanonymous 470ac36a0a
Fix int8 loras causing lower quality requant with wrong settings. (#14650)
* Update comfy-kitchen

* Support requantizing with same settings as orig quant.
2026-06-26 16:41:29 -07:00
comfyanonymous 7cb784e0f4
Faster int8. (#14641) 2026-06-25 15:25:47 -07:00
comfyanonymous 1a510f0423
Support int8 models. (#14636) 2026-06-25 11:23:58 -07:00