Repository navigation
Fix higher derivatives of Lambert W at zero - #2038
Open
DiadkoShmek wants to merge 2 commits into
Open
DiadkoShmek wants to merge 2 commits into
DiadkoShmek wants to merge 2 commits into
Conversation
Signed-off-by: DiadkoShmek <207617272+DiadkoShmek@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tfp.math.lambertwis smooth at zero, but its maskedW / (z * (1 + W))derivative gives incorrect higher derivatives there. On the JAX substrate, reverse-modeW''(0)is NaN and forward-modeW''(0)is zero, although the correct value is -2. The Hessian at zero of0.5 * (W(z) - 1)**2is consequently 1 instead of 3.Use the equivalent
exp(-W) / (1 + W)expression in both derivative rules so differentiation remains smooth through zero. Add float32/float64 regressions for derivatives through fourth order and batched second derivatives containing zeros.Validation:
superfluous-parensdiagnostics; no new diagnostics.git diff --checkpasses.Tested with JAX/jaxlib 0.7.0 on CPU. TensorFlow custom-VJP registration, GPU execution and Bazel were not exercised. The original owner files are modified; generated substrate files are used for validation and are not included in this patch.
I directed this work and take responsibility for the contribution and its follow-up. AI assistance was used in producing the change.
CI follow-up
The current Python 3.12 changed-file lint workflow installs unpinned Pylint. Its 4.0.5 check flagged seven pre-existing redundant-parenthesis assignments in this already changed source file. Those seven pairs are removed; the full implementation AST (including type comments) and test bytes are unchanged. Both affected files now pass the unmodified project Pylint command. The same three pre-existing configuration UserWarnings remain; no checks or configuration were disabled. Numerical testing was not repeated for this syntax-only amendment; the original numerical evidence and stated residual limits above are retained.