Comfy-Org / Comfy-Org/ComfyUI

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

Open
#8,515 1 comment 1 reaction 0 assignees View on GitHub
Important Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [ ] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

Floating-point values should retain their original precision during export.

Nodes should not rely on value != 1.0 logic for float comparison.

Suggested Fix:

Use round() or string formatting with limited precision when serializing to JSON.

Avoid strict float comparisons in node code; use an epsilon-based comparison instead, e.g.:
`abs(strength - 1.0) > 1e-6`

### Actual Behavior

Description:
When exporting a workflow to the API format (.json), we observed a bug related to floating-point precision. Specifically, numeric parameters with seemingly simple values (e.g., 1.0) are converted into inaccurate representations such as 1.0000000000000002.

For example, in the StyleModelApply node, the strength parameter originally set to 1 is changed to 1.0000000000000002 after export. This causes a critical issue because the node's internal code performs a strict check using strength != 1.0, which fails due to this tiny floating-point discrepancy.

This results in incorrect behavior for models or nodes that rely on exact value matching, which is a fragile and incorrect pattern in floating-point handling.

### Steps to Reproduce

Create a workflow containing a StyleModelApply node with strength set to 1.
Export the workflow as API format (.json).
Inspect the JSON — strength will be 1.0000000000000002 instead of 1.0.
Load the workflow and observe the incorrect behavior of the node due to failed equality check.

### Debug Logs

```powershell
No logs.
```

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.