Skip to content

[tmva][sofie] Enhance Softplus stability in ROperator_BasicUnary#21092

Open
AdityaDRathore wants to merge 1 commit intoroot-project:masterfrom
AdityaDRathore:feature/sofie-softplus
Open

[tmva][sofie] Enhance Softplus stability in ROperator_BasicUnary#21092
AdityaDRathore wants to merge 1 commit intoroot-project:masterfrom
AdityaDRathore:feature/sofie-softplus

Conversation

@AdityaDRathore
Copy link

Description

This PR implements numerical stability improvements for the Softplus operator, addressing overflow issues identified in Issue #21071.

It supersedes PR #21023 (which was closed due to branch history alignment).

Changes

  • Hexfloat Thresholding: Implements a hard threshold check using 0x1.4p+4f (20.0f) to prevent exp() overflow for large inputs.
  • Precision Logic: Replaces the naive log(exp(x)+1) with std::log1p(std::exp(x)) to preserve precision for negative inputs.
  • Validation: Adds a dedicated unit test suite TestSofieSoftplus.cxx verifying bit-exact hexfloat emission and overflow protection.

Technical Context

Fixes #21071

cc: @sanjibansg @lmoneta @bellenot

This commit specializes the `UnaryOpTraits` for `kSoftplus` within
`ROperator_BasicUnary` to address numerical instability issues (Issue root-project#21071).

Changes:
- Implemented exact hexfloat thresholding (0x1.4p+4f) to prevent
  overflow for inputs > 20.0.
- Replaced `std::log(std::exp(x)+1)` with `std::log1p(std::exp(x))`
  to preserve precision for negative inputs.
- Validated via dedicated `TestSofieSoftplus` suite unit testing overflow
  and bit-exact generation.

Fixes root-project#21071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tmva][sofie] Improve numerical stability and overflow protection for Softplus operator

3 participants