-
Notifications
You must be signed in to change notification settings - Fork 4
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: Improvements to precompilation and adjustments to new Quasar api #61
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
=======================================
Coverage 98.26% 98.27%
=======================================
Files 21 21
Lines 2189 2197 +8
=======================================
+ Hits 2151 2159 +8
Misses 38 38 ☔ View full report in Codecov by Sentry. |
rx(1) q[0]; | ||
prx(0.1, 0.2) q[0]; | ||
x q[0]; | ||
ry(0.1) q[0]; | ||
ry(1) q[0]; | ||
y q[0]; | ||
rz(0.1) q[0]; | ||
rz(1) q[0]; |
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.
Why add these specific values?
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.
So that the precompilation for integer-typed argument values gets triggered
#pragma braket result expectation x(q[0]) @ x(q[1]) | ||
#pragma braket result expectation z(q[0]) @ z(q[1]) | ||
#pragma braket result expectation y(q[0]) @ y(q[1]) | ||
#pragma braket result expectation h(q[0]) @ h(q[1]) | ||
#pragma braket result expectation i(q[0]) @ i(q[1]) |
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.
Why do we need to handle expectations of tensor products specifically? I see we're already handling tensor products for variance
on the next line
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.
Because the tensor product type is parametrized by the underlying element type
matrix_rep_raw(g::Rz, ϕ) = (θ = ϕ/2.0; return SMatrix{2,2}(exp(-im*θ), 0.0, 0.0, exp(im*θ))) | ||
matrix_rep_raw(g::Rx, ϕ) = ((sθ, cθ) = sincos(ϕ/2.0); return SMatrix{2,2}(cθ, -im*sθ, -im*sθ, cθ)) | ||
matrix_rep_raw(g::Ry, ϕ) = ((sθ, cθ) = sincos(ϕ/2.0); return SMatrix{2,2}(complex(cθ), complex(sθ), -complex(sθ), complex(cθ))) | ||
matrix_rep_raw(g::Rz, ϕ)::SMatrix{2,2,ComplexF64} = ((sθ, cθ) = sincos(ϕ/2.0); return SMatrix{2,2}(cθ - im*sθ, 0.0, 0.0, cθ + im*sθ)) |
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.
Why switch to the trig expression?
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.
Mostly for consistency with the above methods and also sincos
can be more optimized than exp(im*phi)
in some cases
@@ -311,14 +312,11 @@ function apply_gate!( | |||
g_00, g_10, g_01, g_11 = g_matrix | |||
Threads.@threads for chunk_index = 0:n_chunks-1 | |||
# my_amps is the group of amplitude generators which this `Task` will process |
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.
Need new explanation here
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.
Yep will add in a future "lots o' explanatory comments" PR
@@ -95,12 +94,12 @@ function Quasar.visit_pragma(v, program_expr) | |||
end | |||
|
|||
function parse_matrix(tokens::Vector{Tuple{Int64, Int32, Quasar.Token}}, stack, start, qasm) | |||
inner = Quasar.extract_braced_block(tokens, stack, start, qasm) | |||
inner = Quasar.extract_expression(tokens, Quasar.lbracket, Quasar.rbracket, stack, start, qasm) |
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.
Why the switch from the more specific to the more general function? Are the delimiter-specific methods going away in the new Quasar.jl?
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.
Because extract_braced_block
and other delimiter specific methods no longer exist in Quasar 0.0.2
Issue #, if available: N/A
Description of changes:
TensorProduct
combinations.Testing done:
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.