Skip to content

Reimplement angle interpolation#55

Merged
eggerdj merged 8 commits intoqiskit-community:mainfrom
yishaishimoni:reimplement_angle_interpolation
Jan 27, 2026
Merged

Reimplement angle interpolation#55
eggerdj merged 8 commits intoqiskit-community:mainfrom
yishaishimoni:reimplement_angle_interpolation

Conversation

@yishaishimoni
Copy link
Copy Markdown
Contributor

Summary

Refactor qaoa_training_pipeline.training.parameter_extenders.interpolate to make it more readable
(no change in logic).

Details and comments

The method, as described in Zhou et al. in PRX 10, 021067 (2020), takes each of the vectors for beta and gamma
(of length reps) and assumes its values are at integer position in the range 1..reps.
The method then constructs a new vector
of length reps + 1 whose entries are evenly spaced over the same interval [1, reps].
Each new entry is obtained by linear interpolation between adjacent parameters of the original vector.

The original implementation is correct, but the logic of the loop is difficult to understand.
Explicitly defining a new grid and using np.interpolate makes the logic explicit and clear,
while also making the implementation shorted and cleaner.

To ensure that the implementation provides the exact same results I ran the following code

from qaoa_training_pipeline.training.parameter_extenders import interpolate
for n in range(1, 4):
    gamma = np.random.uniform(0, np.pi/2, n)
    beta = np.random.uniform(0, np.pi/2, n)
    params = beta.tolist() + gamma.tolist() 
    assert np.allclose(interpolate(params), my_interpolate(params))

where my_interpolate is the new version in this pull request and interpolate is the original one.
This code completed successfully, indicating that both function return the exact same output.

No additional tests are added since this is not new functionality and older tests should cover this code.

Version updated

Version is not updated since this does not change any functionality

  • [ ]

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Copy Markdown
Collaborator

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks a lot. Can you add version number in param_result and the README? Also their is a conflict with the NB in main.

@yishaishimoni yishaishimoni marked this pull request as ready for review January 22, 2026 13:53
@yishaishimoni
Copy link
Copy Markdown
Contributor Author

oops, sorry about the nb getting messed up, I guess I started this branch from the fixed-angles-notebook branch before it was approved and a few things changed afterwards. I also bumped the version and updated the readme and params.

Copy link
Copy Markdown
Collaborator

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@eggerdj eggerdj merged commit fc866dc into qiskit-community:main Jan 27, 2026
8 checks passed
@yishaishimoni yishaishimoni deleted the reimplement_angle_interpolation branch January 27, 2026 12:00
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.

2 participants