-
Notifications
You must be signed in to change notification settings - Fork 59
add random Clifford circuit codes #298
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
25450ce
add random Clifford circuit codes
royess 29b8b1b
fix a bug in parity checks
royess 3cf3c88
add test cases
royess 9ebb2cf
add rng API for random circuits
royess e34704b
Merge branch 'master' into randomcircuit
royess b0be6ec
enlarge random circuit code sizes in testing
royess 56e08e2
update documents and references
royess 1ea0ec1
change the API of random circuit codes; move random circuits to rando…
royess 89ab652
remove redundant fields of `CircuitCode` and some stylistic changes
royess b2ee210
Merge remote-tracking branch 'origin/master' into randomcircuit
royess 05b6d1b
improve docstring
royess f05d897
stylistic changes
royess e97a207
fix cross references
royess 2469e9a
update changelog and project.toml
Krastanov 2fc7cda
typo
Krastanov 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
using Random: AbstractRNG, GLOBAL_RNG | ||
|
||
|
||
""" | ||
`CircuitCode` is defined by a given encoding circuit `circ`. | ||
|
||
- `arrange`: the spatial arrangement of qubits | ||
- `connect`: the gate connectivity, can be `alltoall` or `brickwork` | ||
- `circ`: the encoding circuit | ||
- `encode_qubits`: the qubits to be encoded | ||
|
||
Qubit arrangement for different connectivity types: | ||
|
||
- For `all-to-all` connectivity, `arrange` is a one-element tuple containing the number of qubits. | ||
- For `brickwork` connectivity, the qubits are arranged as a lattice, and `arrange` contains side length in each dimension. | ||
For example, a 5×5 lattice will have `arrange = (5, 5)`. | ||
|
||
TODO it would be nicer if we can use CartesianIndex for `encode_qubits` in brickworks, | ||
but its conversion to LinearIndex is limited, not supporting non-one step. | ||
royess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
struct CircuitCode <: AbstractECC | ||
arrange::NTuple{N,Int} where {N} | ||
connect::Union{Val{:alltoall},Val{:brickwork}} | ||
circ::Vector{QuantumClifford.AbstractOperation} | ||
encode_qubits::AbstractArray | ||
end | ||
|
||
iscss(::Type{CircuitCode}) = nothing | ||
|
||
code_n(c::CircuitCode) = prod(c.arrange) | ||
|
||
code_k(c::CircuitCode) = length(c.encode_qubits) | ||
|
||
function parity_checks(c::CircuitCode) | ||
n = code_n(c) | ||
checks = one(Stabilizer, n)[setdiff(1:n, c.encode_qubits)] | ||
for op in c.circ | ||
apply!(checks, op) | ||
end | ||
checks | ||
end | ||
|
||
""" | ||
Random Clifford circuit code. | ||
|
||
The code is generated by a random Clifford circuit `circ` that encode a subset of qubits `encode_qubits` into logical qubits. | ||
The connectivity of the random circuit can be either all-to-all [brown2013short](@cite) or brickwork in some dimensions [gullans2021quantum](@cite). | ||
Each gate in the random circuit is a random 2-qubit Clifford gate. | ||
""" | ||
royess marked this conversation as resolved.
Show resolved
Hide resolved
|
||
function random_circuit_code end | ||
|
||
function random_circuit_code(rng::AbstractRNG, n::Int, connect::Val{:alltoall}, ngates::Int, k::Int) | ||
CircuitCode((n,), connect, random_all_to_all_clifford_circuit(rng, n, ngates), collect(1:k)) | ||
end | ||
|
||
function random_circuit_code(n::Int, connect::Val{:alltoall}, ngates::Int, k::Int) | ||
CircuitCode((n,), connect, random_all_to_all_clifford_circuit(n, ngates), collect(1:k)) | ||
end | ||
|
||
function random_circuit_code(rng::AbstractRNG, n::Int, connect::Val{:alltoall}, ngates::Int, encode_qubits::AbstractArray) | ||
CircuitCode((n,), connect, random_all_to_all_clifford_circuit(rng, n, ngates), encode_qubits) | ||
end | ||
|
||
function random_circuit_code(n::Int, connect::Val{:alltoall}, ngates::Int, encode_qubits::AbstractArray) | ||
CircuitCode((n,), connect, random_all_to_all_clifford_circuit(n, ngates), encode_qubits) | ||
end | ||
|
||
function random_circuit_code(rng::AbstractRNG, arrange::NTuple{N,Int} where {N}, connect::Val{:brickwork}, nlayers::Int, encode_qubits::AbstractArray) | ||
CircuitCode(arrange, connect, random_brickwork_clifford_circuit(rng, arrange, nlayers), encode_qubits) | ||
end | ||
|
||
function random_circuit_code(arrange::NTuple{N,Int} where {N}, connect::Val{:brickwork}, nlayers::Int, encode_qubits::AbstractArray) | ||
CircuitCode(arrange, connect, random_brickwork_clifford_circuit(arrange, nlayers), encode_qubits) | ||
end |
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.