Skip to content

Fix ldexp grad for negative exponents - #91

Open
laifenxiawucha wants to merge 1 commit into
mainfrom
agent/fix-ldexp-negative-exponent-grad
Open

laifenxiawucha wants to merge 1 commit into
mainfrom
agent/fix-ldexp-negative-exponent-grad

Conversation

@laifenxiawucha

Copy link
Copy Markdown
Owner

Fixes https://github.com/intel-sandbox/torch-xpu-ops-exp/issues/1929

The ldexp autograd formula used at::pow(2, other), which follows integer pow semantics when other is an integer tensor. For negative exponents this evaluates to zero, so gradients with respect to self are incorrect. Use the floating overload, at::pow(2.0, ...), for both backward and forward AD formulas, and add a regression test for negative exponents.

Test: python3 -m py_compile test/test_binary_ufuncs.py; python3 test/test_binary_ufuncs.py TestBinaryUfuncs.test_ldexp_backward_negative_exponent (blocked: missing expecttest in local environment)

@laifenxiawucha
laifenxiawucha force-pushed the agent/fix-ldexp-negative-exponent-grad branch from 0f0c493 to c6e75ed Compare July 7, 2026 19:55
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