-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add random Clifford circuit codes (#298)
--------- Co-authored-by: Stefan Krastanov <github.acc@krastanov.org>
- Loading branch information
Showing
10 changed files
with
184 additions
and
15 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Random: AbstractRNG, GLOBAL_RNG | ||
|
||
|
||
""" | ||
`CircuitCode` is defined by a given encoding circuit `circ`. | ||
- `n`: qubit number | ||
- `circ`: the encoding circuit | ||
- `encode_qubits`: the qubits to be encoded | ||
See also: [`random_all_to_all_circuit_code`](@ref), [`random_brickwork_circuit_code`](@ref) | ||
""" | ||
struct CircuitCode <: AbstractECC | ||
n::Int | ||
circ::Vector{QuantumClifford.AbstractOperation} | ||
encode_qubits::AbstractArray | ||
end | ||
|
||
iscss(::Type{CircuitCode}) = nothing | ||
|
||
code_n(c::CircuitCode) = c.n | ||
|
||
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 all-to-all Clifford circuit code [brown2013short](@cite). | ||
The code of `n` qubits is generated by an all-to-all random Clifford circuit of `ngates` gates that encodes a subset of qubits `encode_qubits` into logical qubits. | ||
Because of the random picking, the size of `encode_qubits` is the only thing that matters for the code, referred to as `k`. | ||
See also: [`random_all_to_all_clifford_circuit`](@ref), [`CircuitCode`](@ref) | ||
""" | ||
function random_all_to_all_circuit_code end | ||
|
||
function random_all_to_all_circuit_code(rng::AbstractRNG, n::Int, ngates::Int, k::Int) | ||
CircuitCode(n, random_all_to_all_clifford_circuit(rng, n, ngates), collect(1:k)) | ||
end | ||
|
||
function random_all_to_all_circuit_code(n::Int, ngates::Int, k::Int) | ||
CircuitCode(n, random_all_to_all_clifford_circuit(n, ngates), collect(1:k)) | ||
end | ||
|
||
function random_all_to_all_circuit_code(rng::AbstractRNG, n::Int, ngates::Int, encode_qubits::AbstractArray) | ||
CircuitCode(n, random_all_to_all_clifford_circuit(rng, n, ngates), encode_qubits) | ||
end | ||
|
||
function random_all_to_all_circuit_code(n::Int, ngates::Int, encode_qubits::AbstractArray) | ||
CircuitCode(n, random_all_to_all_clifford_circuit(n, ngates), encode_qubits) | ||
end | ||
|
||
|
||
""" | ||
Random brickwork Clifford circuit code [brown2013short](@cite). | ||
The code is generated by a brickwork random Clifford circuit of `nlayers` layers that encodes a subset of qubits `encode_qubits` into logical qubits. | ||
See also: [`random_brickwork_clifford_circuit`](@ref), [`CircuitCode`](@ref) | ||
""" | ||
function random_brickwork_circuit_code end | ||
|
||
# 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. | ||
function random_brickwork_circuit_code(rng::AbstractRNG, lattice_size::NTuple{N,Int} where {N}, nlayers::Int, encode_qubits::AbstractArray) | ||
CircuitCode(prod(lattice_size), random_brickwork_clifford_circuit(rng, lattice_size, nlayers), encode_qubits) | ||
end | ||
|
||
function random_brickwork_circuit_code(lattice_size::NTuple{N,Int} where {N}, nlayers::Int, encode_qubits::AbstractArray) | ||
CircuitCode(prod(lattice_size), random_brickwork_clifford_circuit(lattice_size, nlayers), encode_qubits) | ||
end |
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
59e399d
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.
@JuliaRegistrator register
59e399d
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.
Registration pull request created: JuliaRegistries/General/110470
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: