Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zmorrell
Copy link
Collaborator

@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

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Merging #42 (b91e40a) into main (4574c4a) will increase coverage by 0.03%.
The diff coverage is 96.66%.

@@            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     
Impacted Files Coverage Δ
src/base.jl 96.72% <50.00%> (-1.62%) ⬇️
src/dwave.jl 97.34% <100.00%> (+0.11%) ⬆️
src/simulate.jl 90.71% <100.00%> (+0.27%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@ccoffrin ccoffrin left a 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)

Copy link
Member

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)

Comment on lines 101 to 111
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
Copy link
Member

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

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.

None yet

2 participants