-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix/ld runtime #19
Open
maolinml
wants to merge
5
commits into
main
Choose a base branch
from
fix/ld_runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix/ld runtime #19
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
96c4fc2
add gitignore
maolinml 1b73069
-m modify a typo in README
maolinml d3ff8d8
modify parse_protocol so that programs without local detuning can be run
maolinml 8964834
deprecate tau and use n-tau-steps and the time max in the program to …
maolinml 71bb6e7
modify the test file
maolinml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,36 +46,45 @@ function piecewise_protocol(x, points, values) | |
return y | ||
end | ||
|
||
function parse_protocol(ahs_program, τ::Float64, n_τ_steps::Int) | ||
function parse_protocol(ahs_program, n_τ_steps::Int) | ||
# Define piecewise functions (protocols) | ||
time_steps = collect(0:(n_τ_steps-1)) ./ n_τ_steps | ||
total_time = n_τ_steps * τ | ||
time_points_Δ = ahs_program["hamiltonian"]["drivingFields"][1]["detuning"]["time_series"]["times"] | ||
values_Δ = ahs_program["hamiltonian"]["drivingFields"][1]["detuning"]["time_series"]["values"] | ||
|
||
time_points_Ω = ahs_program["hamiltonian"]["drivingFields"][1]["amplitude"]["time_series"]["times"] | ||
values_Ω = ahs_program["hamiltonian"]["drivingFields"][1]["amplitude"]["time_series"]["values"] | ||
|
||
pattern = ahs_program["hamiltonian"]["shiftingFields"][1]["magnitude"]["pattern"] | ||
time_points_shift = ahs_program["hamiltonian"]["shiftingFields"][1]["magnitude"]["time_series"]["times"] | ||
values_shift = ahs_program["hamiltonian"]["shiftingFields"][1]["magnitude"]["time_series"]["values"] | ||
if "localDetuning" ∉ keys(ahs_program["hamiltonian"]) || length(ahs_program["hamiltonian"]["localDetuning"]) == 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be pre-empted by @ykharkov's new PR |
||
# Define an empty local detuning with zero pattern and zero values | ||
filling = ahs_json["setup"]["ahs_register"]["filling"] | ||
pattern = ["0" for _ in filling] | ||
time_points_local_detuning = ["0.0", time_points_Ω[end]] | ||
values_local_detuning = ["0.0", "0.0"] | ||
else | ||
pattern = ahs_program["hamiltonian"]["localDetuning"][1]["magnitude"]["pattern"] | ||
time_points_local_detuning = ahs_program["hamiltonian"]["localDetuning"][1]["magnitude"]["time_series"]["times"] | ||
values_local_detuning = ahs_program["hamiltonian"]["localDetuning"][1]["magnitude"]["time_series"]["values"] | ||
end | ||
|
||
# Convert strings to floats [parsing Braket AHS program] | ||
time_points_Δ = parse.(Float64, time_points_Δ) | ||
values_Δ = parse.(Float64, values_Δ) | ||
time_points_Ω = parse.(Float64, time_points_Ω) | ||
values_Ω = parse.(Float64, values_Ω) | ||
|
||
|
||
pattern = parse.(Float64, pattern) | ||
time_points_shift = parse.(Float64, time_points_shift) | ||
values_shift = parse.(Float64, values_shift) | ||
time_points_local_detuning = parse.(Float64, time_points_local_detuning) | ||
values_local_detuning = parse.(Float64, values_local_detuning) | ||
|
||
# Define piecewise protocols | ||
total_time = time_points_Δ[end] | ||
t_vals = [i/n_τ_steps*total_time for i in 1:n_τ_steps] | ||
# Global detuning time series | ||
Δ_glob_ts = [piecewise_protocol(t, time_points_Δ, values_Δ) for t in t_vals] | ||
# Local detuning time series | ||
Δ_loc_ts = [piecewise_protocol(t, time_points_shift, values_shift) for t in t_vals] | ||
Δ_loc_ts = [piecewise_protocol(t, time_points_local_detuning, values_local_detuning) for t in t_vals] | ||
# Rabi driving field | ||
Ω_ts = [piecewise_protocol(t, time_points_Ω, values_Ω) for t in t_vals] | ||
|
||
|
@@ -88,7 +97,9 @@ function parse_protocol(ahs_program, τ::Float64, n_τ_steps::Int) | |
rabi_driving=Ω_ts, | ||
global_detuning=Δ_glob_ts, | ||
local_detuning=Δ_loc_ts, | ||
pattern=pattern) | ||
pattern=pattern, | ||
τ=total_time/n_τ_steps | ||
) | ||
end | ||
|
||
function compute_energies(samples, Vij::Matrix{Float64}, Δ_glob_ts, Δ_loc_ts, pattern) | ||
|
@@ -107,14 +118,15 @@ function compute_energies(samples, Vij::Matrix{Float64}, Δ_glob_ts, Δ_loc_ts, | |
end | ||
|
||
""" | ||
get_trotterized_circuit_2d(sites, τ, n_steps, N, Vij::Matrix{Float64}) | ||
get_trotterized_circuit_2d(sites, n_steps, N, Vij::Matrix{Float64}) | ||
|
||
Second order Trotterization circuit for a time-dependent Hamiltonian, | ||
for a time step `τ` and `n_steps` total time steps, on `N` total atoms. | ||
for a time step `n_steps` total time steps, on `N` total atoms. | ||
`sites` defines the site indices in the MPS used to build the circuit. | ||
Returns a `Vector{Vector{iTensor}}` list of gates at each time step. | ||
""" | ||
function get_trotterized_circuit_2d(sites, τ::Float64, n_steps::Int, N::Int, Vij::Matrix{Float64}, protocol) | ||
function get_trotterized_circuit_2d(sites, n_steps::Int, N::Int, Vij::Matrix{Float64}, protocol) | ||
τ = protocol[:τ] | ||
circuit = Vector{Vector{ITensor}}(undef, n_steps) | ||
for i_τ in 1:n_steps | ||
two_site_gates = ITensor[] | ||
|
@@ -172,7 +184,6 @@ Returns prepared experiment protocol `protocol` as a `NamedTuple` with keys | |
function parse_ahs_program(ahs_json, args::Dict{String, Any}) | ||
program_path = args["program-path"] | ||
experiment_path = args["experiment-path"] | ||
τ = args["tau"] | ||
n_τ_steps = args["n-tau-steps"] | ||
interaction_R = args["interaction-radius"] | ||
C6 = args["C6"] | ||
|
@@ -202,7 +213,7 @@ function parse_ahs_program(ahs_json, args::Dict{String, Any}) | |
@debug "Atoms in atom array: $atom_coordinates" | ||
|
||
Vij = get_Vij(atom_coordinates, N, interaction_R, C6) | ||
protocol = parse_protocol(ahs_json, τ, n_τ_steps) | ||
protocol = parse_protocol(ahs_json, n_τ_steps) | ||
return Vij, protocol, N | ||
end | ||
|
||
|
@@ -255,7 +266,6 @@ end | |
function run(ahs_json, args) | ||
|
||
experiment_path = args["experiment-path"] | ||
τ = args["tau"] | ||
n_τ_steps = args["n-tau-steps"] | ||
C6 = args["C6"] | ||
interaction_R = args["interaction-radius"] | ||
|
@@ -268,7 +278,7 @@ function run(ahs_json, args) | |
# Initialize ψ to be a product state: Down state (Ground state) | ||
ψ = MPS(s, n -> "Dn") | ||
@info "Generating Trotterized circuit" | ||
circuit = get_trotterized_circuit_2d(s, τ, n_τ_steps, N, Vij, protocol) | ||
circuit = get_trotterized_circuit_2d(s, n_τ_steps, N, Vij, protocol) | ||
|
||
max_bond_dim = args["max-bond-dim"] | ||
cutoff = args["cutoff"] | ||
|
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.
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.
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.
If tau is not used, should it instead be "supported" here but print that it is deprecated?