Skip to content

Treat near-neutral style strengths as neutral - #15744

Open
yzxcj797 wants to merge 1 commit into
Comfy-Org:masterfrom
yzxcj797:fix/style-model-neutral-strength
Open

Treat near-neutral style strengths as neutral#15744
yzxcj797 wants to merge 1 commit into
Comfy-Org:masterfrom
yzxcj797:fix/style-model-neutral-strength

Conversation

@yzxcj797

Copy link
Copy Markdown

Summary

  • Compare attn-bias style strength with 1.0 using a floating-point tolerance.
  • Prevent serialized round-trip drift from creating an unnecessary attention mask.
  • Add regression coverage for neutral, near-neutral, and non-neutral strengths.

Fixes #8515

Testing

  • pytest tests-unit/comfy_extras_test/style_model_apply_test.py -q — 3 passed
  • ruff check nodes.py tests-unit/comfy_extras_test/style_model_apply_test.py
  • git diff --check

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e80eff13-62b1-4626-901c-8e46b739f2cf

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab2f7a and 177fe43.

📒 Files selected for processing (2)
  • nodes.py
  • tests-unit/comfy_extras_test/style_model_apply_test.py

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Keep changes small, direct, and limited to the narrowest necessary code path and smallest number of files.
Prefer practical fixes, minimal dependencies, and existing repository patterns; remove obsolete, dead, unreachable, or unused code.
Preserve existing APIs, node names, model-loading behavior, file layout, and workflow compatibility unless replacement is explicitly intended.
Core ComfyUI must not add outbound internet requests, telemetry, tracking, reporting, remote configuration, or background network activity. User-authorized model downloads are limited to the requested artifact and must exclude telemetry and unrelated metadata.

Files:

  • tests-unit/comfy_extras_test/style_model_apply_test.py
  • nodes.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Keep state and capability flags on the object that owns the behavior. Prefer explicit parent-owned attributes over probing child objects with getattr; use child checks only when the child owns the delegated behavior.
Preserve shared method signatures, argument order, return shapes, side effects, and error behavior unless every affected caller and interface is intentionally updated.
Do not add unused compatibility parameters, flags, attributes, constructor options, or model-specific options to shared helpers; keep one-off behavior at the integration boundary.
Normalize third-party return conventions at integration boundaries so core code receives the expected type and shape; avoid undocumented caller-side unwrapping.
Do not add torch.no_grad, torch.inference_mode, or inference-mode wrappers. Do not add model freeze/unfreeze toggles; only disable globally enabled inference mode when a training path requires gradients.
Remove inference-only training behavior such as dropout while preserving checkpoint and state-dict compatibility; use nn.Identity when deleting a module would alter keys or ordering.
Keep imports at module scope except established optional-backend probes or imports required to avoid cycles; avoid unnecessary try/except blocks and use specific exceptions with useful fallbacks.
Do not add workarounds for unsupported library versions, especially PyTorch exception-and-float-cast retries, unless a comment names the exact versions still requiring them.
Let unsupported model formats, invalid quantization metadata, and bad states fail with clear errors instead of silently degrading output.
Match local style, keep comments sparse and useful, and remove comments that merely restate obvious code.
Treat dtype, device placement, VRAM use, and offloading as correctness concerns across CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low-VRAM environments.
Prefer existing ComfyUI and Comfy Kitchen operations, quantization helpers, cast/offload helpe...

Files:

  • tests-unit/comfy_extras_test/style_model_apply_test.py
  • nodes.py
**/*.{py,json}

📄 CodeRabbit inference engine (AGENTS.md)

Treat legacy combo, io.Combo, and io.DynamicCombo values affecting filesystem access as untrusted; revalidate them at load/save boundaries with folder_paths, containment checks, or fixed allowlists.

Files:

  • tests-unit/comfy_extras_test/style_model_apply_test.py
  • nodes.py
**/*.{py,md,txt,json}

📄 CodeRabbit inference engine (AGENTS.md)

Keep warning and info messages short and actionable, remove noisy or misleading logging, and make documentation edits concise, factual, and tied to changed behavior.

Files:

  • tests-unit/comfy_extras_test/style_model_apply_test.py
  • nodes.py
**

⚙️ CodeRabbit configuration file

**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a with: block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.

Files:

  • tests-unit/comfy_extras_test/style_model_apply_test.py
  • nodes.py
nodes.py

⚙️ CodeRabbit configuration file

nodes.py: Core node definitions (2500+ lines). Focus on:

  • Backward compatibility of NODE_CLASS_MAPPINGS
  • Consistency of INPUT_TYPES return format

Files:

  • nodes.py
🔇 Additional comments (2)
nodes.py (1)

1143-1143: LGTM!

tests-unit/comfy_extras_test/style_model_apply_test.py (1)

1-39: LGTM!


📝 Walkthrough

Walkthrough

StyleModelApply.apply_stylemodel now uses math.isclose to compare attn_bias strength with 1.0. Near-unit values do not trigger additional attention-mask processing. Materially different values still trigger that processing. Unit tests cover neutral, near-equivalent, and non-neutral strengths.

Merge Risk: ⚪ Minimal · up to 177fe

This localized change treats floating-point-near-neutral style strengths as neutral and adds regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: treating floating-point values near 1.0 as neutral style strengths.
Description check ✅ Passed The description directly explains the tolerance-based comparison, regression tests, and prevention of unnecessary attention masks.
Linked Issues check ✅ Passed The changes satisfy issue #8515 by replacing strict float comparison behavior and adding coverage for near-neutral and non-neutral strengths.
Out of Scope Changes check ✅ Passed All changes support issue #8515 and the stated objective; no unrelated code or tests are included.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Exporting workflow to API format introduces floating point precision issues And bug about StyleModelApply node

1 participant