Repository navigation
Estimate the Adahessian trace on both complex components - #556
Open
shaneraphel wants to merge 1 commit into
Open
shaneraphel wants to merge 1 commit into
shaneraphel wants to merge 1 commit into
Conversation
randint_like rejects a complex parameter, so Adahessian raised RuntimeError before the Hutchinson vector existed (issue 458). Signs are drawn on the real and imaginary parts and packed back into a complex vector. The trace and the moments stay on those two components, and a real parameter still follows the old update.
This branch has not been deployed
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.
Summary
The Adahessian half of #458.
torch.randint_likerejects a complex parameter, soget_traceraisedRuntimeError: check_random_bounds handles only integral, floating-point and boolean typesand the step never ran. AdaBound's complex failure in the same issue is a different call and is handled separately.The Hutchinson vector is now a Rademacher draw on
view_as_realof the parameter, packed back withview_as_complexso it still matches the complex gradient that autograd produced. The absolute value that removes the ±1 sign is taken per component. A complex conv kernel still averages its spatial dimensions, as the real 4D path does; the component axis is not one of those dimensions. Moments are stored on the two components and the write-back goes throughview_as_real, so neither part is dropped.A real parameter does not take this branch. Two steps on
[0.5, -0.2, 0.3]still finish at[0.43060994148254395, -0.17224396765232086, 0.2583659589290619].Complex rank 3 and 5 are still rejected. The real implementation has no branch for those ranks either, and a complex conv1d or conv3d would need the same spatial reduction the real kernels are still missing.
Test plan
pytest tests/test_adahessian_complex.py[0.5+0.1j, -0.2+0.3j]matches Adahessian onview_as_realof the same values, bitwise, including the random signs.