Circuit Simulator
Initialization
PastaQ.qubits
— Functionqubits(N::Int; mixed::Bool=false)
qubits(sites::Vector{<:Index}; mixed::Bool=false)
Initialize qubits to:
- An MPS wavefunction
|ψ⟩
ifmixed=false
- An MPO density matrix
ρ
ifmixed=true
qubits(M::Union{MPS,MPO,LPDO}; mixed::Bool=false)
Initialize qubits on the Hilbert space of a reference state, given as MPS
, MPO
or LPDO
.
qubits(N::Int, states::Vector{String}; mixed::Bool=false)
qubits(sites::Vector{<:Index}, states::Vector{String};mixed::Bool = false)
Initialize the qubits to a given single-qubit product state.
PastaQ.resetqubits!
— Functionresetqubits!(M::Union{MPS,MPO})
Reset qubits to the initial state:
|ψ⟩=|0,0,…,0⟩
ifM = MPS
ρ = |0,0,…,0⟩⟨0,0,…,0|
ifM = MPO
Gates and circuits
PastaQ.gate
— Functiongate(M::Union{MPS,MPO}, gatename::String, site::Int; kwargs...)
Generate a gate tensor for a single-qubit gate identified by gatename
acting on site site
, with indices identical to a reference state M
.
gate(M::Union{MPS,MPO},gatename::String, site::Tuple; kwargs...)
Generate a gate tensor for a two-qubit gate identified by gatename
acting on sites (site[1],site[2])
, with indices identical to a reference state M
(MPS
or MPO
).
PastaQ.buildcircuit
— Functionbuildcircuit(M::Union{MPS,MPO}, gates::Vector{<:Tuple};
noise = nothing)
Generates a vector of (gate) ITensor
, from a vector of Tuple
associated with a list of quantum gates. If noise is nontrivial, the corresponding Kraus operators are added to each gate as a tensor with an extra (Kraus) index.
Running a quantum circuit
PastaQ.runcircuit
— Functionruncircuit(M::Union{MPS,MPO}, gate_tensors::Vector{<:ITensor};
kwargs...)
Apply the circuit to a state (wavefunction/densitymatrix) from a list of tensors.
runcircuit(M::Union{MPS,MPO}, gates::Vector{<:Tuple};
noise=nothing, apply_dag=nothing,
cutoff=1e-15, maxdim=10000,
svd_alg = "divide_and_conquer")
Apply the circuit to a state (wavefunction or density matrix) from a list of gates.
If an MPS |ψ⟩
is input, there are three possible modes:
- By default (
noise = nothing
andapply_dag = nothing
), the evolutionU|ψ⟩
is performed. - If
noise
is set to something nontrivial, the mixed evolutionε(|ψ⟩⟨ψ|)
is performed. Example:noise = ("amplitude_damping", (γ = 0.1,))
(amplitude damping channel with decay rateγ = 0.1
) - If
noise = nothing
andapply_dag = true
, the evolutionU|ψ⟩⟨ψ|U†
is performed.
If an MPO ρ
is input, there are three possible modes:
- By default (
noise = nothing
andapply_dag = nothing
), the evolutionU ρ U†
is performed. - If
noise
is set to something nontrivial, the evolutionε(ρ)
is performed. - If
noise = nothing
andapply_dag = false
, the evolutionUρ
is performed.
runcircuit(N::Int, gates::Vector{<:Tuple};
process = false,
noise = nothing,
cutoff = 1e-15,
maxdim = 10000,
svd_alg = "divide_and_conquer")
Run the circuit corresponding to a list of quantum gates on a system of N
qubits. The starting state is generated automatically based on the flags process
, noise
, and apply_dag
.
- By default (
noise = nothing
,apply_dag = nothing
, andprocess = false
), the evolutionU|ψ⟩
is performed where the starting state is set to|ψ⟩ = |000...⟩
. The MPSU|000...⟩
is returned. - If
noise
is set to something nontrivial, the mixed evolutionε(|ψ⟩⟨ψ|)
is performed, where the starting state is set to|ψ⟩ = |000...⟩
. The MPOε(|000...⟩⟨000...|)
is returned. - If
process = true
andnoise = nothing
, the evolutionU 1̂
is performed, where the starting state1̂ = (1⊗1⊗1⊗…⊗1)
. The MPO approximation for the unitary represented by the set of gates is returned. - If
process = true
andnoise
is set to something nontrivial, the function returns the Choi matrixΛ = ε⊗1̂(|ξ⟩⟨ξ|)
, where|ξ⟩= ⨂ⱼ |00⟩ⱼ+|11⟩ⱼ
, approximated by a MPO with 4 site indices, two for the input and two for the output Hilbert space of the quantum channel.
PastaQ.choimatrix
— Functionchoimatrix(N::Int, gates::Vector{<:Tuple};
noise = nothing, apply_dag = false,
cutoff = 1e-15, maxdim = 10000, kwargs...)
Compute the Choi matrix Λ = ε⊗1̂(|ξ⟩⟨ξ|)
, where |ξ⟩= ⨂ⱼ |00⟩ⱼ+|11⟩ⱼ
, where ε
is a quantum channel built out of a set of quantum gates and a local noise model. Returns a MPO with N
tensor having 4 sites indices.
Standard quantum circuits
PastaQ.randomcircuit
— Methodrandomcircuit(N::Int,depth::Int,twoqubit_bonds::Array;
twoqubitgate = "CX",
onequbitgates = ["Rn"])
Build a random quantum circuit with N
qubits and depth depth
. Each layer in the circuit is built with a layer of two-qubit gates constructed according to a list of bonds contained in twoqubit_bonds
, followed by a layer of single qubit gates. By default, the two-qubit gate is controlled-NOT, and the single-qubit gate is a rotation around a random axis.
PastaQ.qft
— Functionqft(N::Int)
Generate a list of gates for the quantum fourier transform circuit on N
sites.