-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial h_gain_schedule implementation #42
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #42 +/- ##
==========================================
+ Coverage 92.88% 92.91% +0.03%
==========================================
Files 5 5
Lines 604 621 +17
==========================================
+ Hits 561 577 +16
- Misses 43 44 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some preliminary suggestions in line.
As a first pass, before working on the optimized 4th order, lets update the generic model and see how it looks. Take a similar path as I suggest in line, define separate z_component
and zz_component
and follow these through to use both B1 and B2 functions.
If we like how everything turns out with updating the generic solver, then can looking into making the updates in the optimized one.
A short hand AnnealingSchedule constructor that uses the Base.one function for the | ||
annealing schedule, but allows for a different inital state. | ||
""" | ||
AnnealingSchedule(A,B,init_default) = AnnealingSchedule(A, B, init_default, one) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this I am thinking we should structure it like,
AnnealingSchedule(A1,B1,B2,initial_state_default)
Where the numbers 1/2 indicate the order of the operators for that function.
I would then add overloaded constructors,
AnnealingSchedule(A,B) = AnnealingSchedule(A, B, B, initial_state_default)
AnnealingSchedule(A,B,initial_state) = AnnealingSchedule(A, B, B, initial_state)
AnnealingSchedule(A,B1,B2) = AnnealingSchedule(A, B1, B2, initial_state_default)
x_component = _sum_X(n) | ||
z_component = SparseArrays.spzeros(2^n, 2^n) | ||
for (tup,w) in ising_model | ||
z_component += _kron_Z(n, tup, w) | ||
if length(tup) == 1 | ||
z_component += annealing_schedule.h_gain_schedule(s) * _kron_Z(n, tup, w) | ||
else | ||
z_component += _kron_Z(n, tup, w) | ||
end | ||
end | ||
|
||
return annealing_schedule.A(s) * x_component + annealing_schedule.B(s) * z_component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here add z_component
(single spin) and zz_component
(two spin) then the interpolated model will follow the pattern of repeated f(s)*matrix
@ccoffrin
This is an initial attempt at the h-gains schedule implementation. I still need to add tests and fully verify that it is working, but as it stands it does not break anything that already works. Because of the way that the unwrapped magnus expansion is currently implemented, it would be very difficult to break h and J terms into their own terms, so for each time step, I assume that the h_gain_schedule over the step is well approximated by the average of the starting and ending hgs values.
This approach may introduce some overhead because it reconstructs the z_component of the hamiltonian on every iteration, but since it is sparse, this overhead should be insignificant compared to the matrix exponentiation, so I don't expect that it will hamper performance too much.
Does this all seem like a reasonable way to implement this new feature