You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Small-integer inputs produce incorrect regression metric values or runtime errors #9246
With pairs of uint8, int8, or int16 images, MONAI regression metrics can subtract in the integer dtype and overflow or underflow before any subsequent floating-point conversion. A later conversion cannot recover the correct difference. For example, 0 - 255 wraps to 1 with uint8 inputs, so MSE, RMSE, PSNR, and MAPE can return incorrect values. MAE can also fail when computing the mean of an integer tensor.
Small-integer images should be converted to a suitable floating-point calculation dtype before subtraction. Existing floating-point inputs, including float64, should keep their precision.
Environment
Reproduced on upstream dev commit 827fa24fef4f474f70ead141412a2a0675990684, using macOS CPU, Python 3.14.7, PyTorch 2.15.0, and NumPy 2.5.4. A separate unmodified checkout was used to check the failure before applying the local patch.
Additional context
The local patch handles pairs of uint8/int8/int16 inputs at the shared RegressionMetric entry point. It does not claim to solve all integer or mixed-dtype cases and does not change direct functional helper calls. Large int32/int64 values need separate care because an unconditional floating-point cast can erase small residuals.
No patient data are used. All examples and test inputs are synthetic.
Tool assistance
The submitter provided the explanation of the problem and proposed fix. OpenAI Codex assisted with the investigation, English translation, and preparation of this report. Codex performed the local investigation, implementation, and reported checks.
Activity