Skip to content

Comments

Don't crash right away if op is uninitialized.#12615

Merged
comfyanonymous merged 1 commit intomasterfrom
comfyanonymous-patch-1
Feb 24, 2026
Merged

Don't crash right away if op is uninitialized.#12615
comfyanonymous merged 1 commit intomasterfrom
comfyanonymous-patch-1

Conversation

@comfyanonymous
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

The change adds defensive error handling to the state_dict method of the MixedPrecisionOps class. When the weight attribute is not present, the method now logs a warning and returns the current state dictionary rather than attempting to access the missing weight, which would cause an AttributeError. This handles the case where a state dictionary is requested before the operation is fully initialized.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to evaluate relevance to the changeset. Add a description explaining why the guard is needed and how it prevents crashes for uninitialized ops.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a guard to prevent crashes when an op is uninitialized, which aligns with the changeset that adds error handling in MixedPrecisionOps.state_dict.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
comfy/ops.py (1)

831-831: Redundant "Warning:" prefix in the log message.

logging.warning(...) already marks the record as WARNING level — prepending the literal string "Warning:" is noise in both the log output and log aggregators.

🔧 Suggested fix
-                    logging.warning("Warning: state dict on uninitialized op {}".format(prefix))
+                    logging.warning("state dict on uninitialized op {}".format(prefix))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy/ops.py` at line 831, Remove the redundant literal "Warning:" prefix
from the logging call and log the message directly; locate the logging.warning
call that currently builds "Warning: state dict on uninitialized op
{}".format(prefix) and change it to log "state dict on uninitialized op" with
the prefix supplied as a parameter (use logging.warning with format-style args
or an f-string) so the record level isn't duplicated and the message stays
structured and concise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@comfy/ops.py`:
- Line 831: Remove the redundant literal "Warning:" prefix from the logging call
and log the message directly; locate the logging.warning call that currently
builds "Warning: state dict on uninitialized op {}".format(prefix) and change it
to log "state dict on uninitialized op" with the prefix supplied as a parameter
(use logging.warning with format-style args or an f-string) so the record level
isn't duplicated and the message stays structured and concise.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11fefa5 and c19d9ae.

📒 Files selected for processing (1)
  • comfy/ops.py

@comfyanonymous comfyanonymous merged commit 599f9c5 into master Feb 24, 2026
15 checks passed
@comfyanonymous comfyanonymous deleted the comfyanonymous-patch-1 branch February 24, 2026 17:28
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.

1 participant