-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support differentiability through Torch tensors (#703)
* Defining pulser.math and AbstractArray * POC: Differentiable constant pulse amp Typing is still failing * Fix typing in waveforms * Fix all typing errors in POC * Pass all existing UTs * Pass all UTs without array support * Fix typing * All tests pass with torch installed * Add support for pulser-diff backend (#686) * works with basic features of pulser-diff * Fixed phase attribute setting; removed debugging code; reverted unnecessary changes * Modified register creation code to work with AbstractArray; register coordinates are differentiable with pulser-diff * Fixed type hints * Minor fixes and refactoring * Modified ParamObj code to work with quantum model training in pulser-diff * Minor refactoring; add possibility to ensure 0D AbstractArray is reshaped into 1D * Force array only for scalars * Fix UTs after pulser-diff changes * Avoid using AbstractArrayLike outside of pulser.math * Preserve gradient in EOM mode * Add torch as an optional requirement * Support waveform multiplication with abstract array * Explicitly marking the differentiable parameters * Remove __array_wrap__ * Pass relevant UTs without array support * Support new features * Using pm.Differentiable whenever possible * Simplifying Waveform.__getitem__() type hint * UTs for new features outside of pulser.math * Write torch UTs for registers * Write UTs for waveforms * UTs for pulse * UTs for EOM * UTs on internal functionality * UTs for Sequence with autograd * Implicitly cover math functions * Removing AbstractArray.__hash__() and differentiable phase shifts * Finish unit tests * Update CI to run tests with and without torch * Fix CI errors * Fix failing no-torch UT * Minor corrections * Include pulser[torch] installation in the README * Fix warning in UT after merge * Incorporating the latest changes * Fix typing * Addressing review comments * Including `detach()` in Differentiable protocol * Differentiable -> TensorLike * Tentatively allow waveform division by array * Full coverage --------- Co-authored-by: Vytautas Abramavicius <[email protected]>
- Loading branch information
1 parent
6c12156
commit e21d3a8
Showing
49 changed files
with
2,224 additions
and
563 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.