gtorlai / pastaq.jl Goto Github PK
View Code? Open in Web Editor NEWPackage for Simulation, Tomography and Analysis of Quantum Computers
License: Apache License 2.0
Package for Simulation, Tomography and Analysis of Quantum Computers
License: Apache License 2.0
Use unsplit (N-tensors) Choi matrix, and transform it to split (2N-tensor) at the beginning of the tomography
function.
Here is a TODO list for improving initializetomography
:
randomMPS
function for initializing state tomography.randomstate(N; mixed = true, lpdo = false)
randomprocess(N; mixed = true, lpdo = false)
Change dictionary to return arrays given parameters, then quantumgate function build the actual ITensor
Switch the order of the indices when creating ITensor, and keep the traditional definition of the 2-qubit gates
There are many functions that do similar things, like:
hadamardlayer
hadamardlayer!
randomrotationlayer
randomrotationlayer!
twoqubitlayer
twoqubitlayer!
It seems like we could compress this into a unified interface, for example:
N = 10 # N sites
# Same as hadamardlayer
g = gatelayer("H", N)
and
# Same as hadamardlayer!
appendlayer!(gates, "H", N)
randomrotation
could be implemented through the gate
interface with a special GateName
, for example gate("randrot", s)
. Then, randomrotation[!]
could be replaced by:
gatelayer("randU", N)
appendlayer!(gates, "randU", N)
Also, the two-qubit layer could be determined automatically internally, or be specified with a keyword argument. I think a keyword argument may be best, such as:
appendlayer!(gates, "CX", N; nqubit = 2) # Every other site, starting at site 1 (on odd sites)
appendlayer!(gates, "CX", N; nqubit = 2, start = 2) # Every other site, starting at site 2 (so on even sites)
Also, we could probably just simplify:
randomquantumcircuit
-> randomcircuit
We can change gate and projection measurement definitions to look like:
function gate_I(T::Type{Number} = ComplexF64)
return T[1 0;
0 1]
end
Proposal to replace initializetomography
with more specific functions randomstate
and randomprocess
. The interface could be something like:
randomstate(MPS, N)
# Make a random qubit wavefunction for pure state tomographyrandomstate(LPDO, N)
# Make a random mixed state as an LPDOrandomstate(MPO, N)
# Make a random mixed state as an MPOrandomprocess(MPO, N)
# Make a random unitary circuit as an MPOrandomprocess(Choi, N)
# Make a random Choi matrix, defaults to Choi{LPDO}
randomprocess(Choi{MPO}, N)
# Make a random Choi matrix in MPO formAdditionally, these options could be chosen with flags, like:
randomstate(N) = randomstate(MPS, N)
randomstate(N; mixed = true) = randomstate(LPDO, N)
randomstate(N; mixed = true, lpdo = false) = randomstate(MPO, N)
randomprocess(N) = randomprocess(MPO, N)
randomprocess(N; mixed = true) = randomprocess(Choi{LPDO}, N)
randomprocess(N; mixed = true, lpdo = false) = randomprocess(Choi{MPO}, N)
Here I'm assuming lpdo = true
is the default, since it is probably most common, but could be chosen the other way.
Change all contractions to in-place operations (for example outer product).
Implement an n-qubit "randU" gate that is a random unitary picked from a certain distribution. At first we can implement it with a positive QR decomposition of random matrices (where the elements are picked from a normal distribution).
This would be to clarify it is a Boolean flag, not actually a set of local normalizations.
Couldn't we define this as site::Int
and avoid the type check in the function?
The file tomography.jl
is getting pretty long, it would be nice to move things related to distance measures (like frobenius_distance
, fidelity
, fidelity_bound
, and future inner
definitions) to a new file distances.jl
.
Update the gradnll for LPDO ansatz with all optimizations done for the MPS case
Reexport ITensors.jl with Reexport.jl.
Before the release, we should go through exports.jl
and remove anything that we don't want to be public functions, such as:
choi
choimatrix
readouterror!
projectchoi
convertdatapoint
gradlogZ
nll
gradnll
gradients
fullfidelity
It is best to keep this list as short as possible, especially at the beginning.
Pre-release:
run
functionruncircuit
gradnll
for LPDOImplement the standard VQE:
Measurement dictionary containing eigenstates of the rotation gates, similar syntax of the quantumgate case
Include the possibility to use customized preparation states and measurement bases. The user should provide the IDs and the corresponding quantum gates.
Add a readout error to each measurement, where an outcome 0 is flipped to 1 with probability p(1|0)
and an outcome 1 is flipped to 0 with probability p(0|1)
.
In randomcircuit
, there is a line:
cycle = twoqubit_bonds[(d-1)%2+1]
that chooses which layering of bonds to use (either odd or even) for the 2-qubit gates. However, in the 2D version, there are 4 unique layers of bonds (odd and even, layered in different directions). Perhaps the line should be something like:
cycle = twoqubit_bonds[(d-1)%length(twoqubit_bonds)+1]
I find the name generatedata
a little opaque. Could we just call it sample
, or something related like samples
or getsamples
? I think this is an appropriate name, since the data is always generated by sampling in some way.
Include new optimization routines:
Add an LPDO type, which represents an MPO of the form X*X^\dagger
(and only stores the MPO X
).
Update: This was added in #67. I'll leave this issue open to keep track of where it should be incorporated into the code. Here are functions where the LPDO should be used:
lognormalize!(::LPDO)
(but rename normalize!(::LPDO)
with options about how the normalization will happen)fullmatrix(::LPDO)
statetomography
/processtomography
gradients
initializetomography
gradlogZ
gradnll
nll
getdensityoperator
with MPO(::LPDO)
tr(::LPDO)
logtr(::LPDO)
fidelity(::LPDO, ::MPS)
and related functions.frobenius_distance(::LPDO, ::LPDO)
Also, change statetomography!
-> statetomography
.
The bond dimension of the Choi matrix, after splitting N
tensors with physical dimension d=4
into 2N
tensors with physical dimension d=2
, grows too large.
First, we consider the case of a unitary circuit
Random.seed!(1234)
N = 4
gates = randomcircuit(N,4)
U = runcircuit(N,gates;process=true)
@show linkdims(U)
# linkdims(U) = [4,4,4]
Λ = choimatrix(N,gates)
@show linkdims(Λ)
# linkdims(Λ) = [2, 4, 4, 4, 8, 4, 2]
In the above example, the SVD introduced new bonds with dimensions [2,4,8,2]
, with a factor 2 increase with respect to the alternative representation.
The idea is to use the un-split version instead, both in the quantum circuit simulator and in quantum tomography
The new function (quantumcircuit.jj line 30)
function applygate!(M::MPS,gate::ITensor)
for 1-qubit gates conflicts with the one for 2q gates (quantumcircuit.jl line 74)
function applygate!(M::MPS, gate::ITensor; cutoff = 1e-10)
Investigate the presence of zero gradients
Perform state tomography with LPDO for the density matrix of a quantum spin chain at finite temperature.
Optimize the LPDO gradnll function similar to the gradnll function for MPS
fullfidelity
is not my favorite name. Instead, we could define fidelity(::ITensor, ::ITensor)
, and then tell people to use fidelity(prod(rho), prod(sigma))
. We can also define fidelity(::MPO, ::MPO)
and just make it throw an error, telling people to use fidelity(::ITensor, ::ITensor)
instead.
Ideally we would like to have an automated way to generate the various gates for preparation and measurement rotations.
Preparation gates
Given a set of specified single-qubit states (ψ1,…ψK), we generate a set of gates (g1,…,gK) generating each state.
Measurement bases
For each measurement basis (given as input as a hermitian 2x2 matrix), we generate the gate for the corresponding rotation.
Also, clean up the code for frobenius_distance
and fidelity_bound
by combining the different versions into one generic version.
Implement non-negative matrix factorizations (like those used in https://arxiv.org/abs/1703.00365) to do non-negative MPS/MPO evolution and tomography.
Introduce swap operation to realize long-range quantum gates
MPO
(2-siteinds tensors) unitary quantum circuit and the MPO
(4-siteinds tensors) Choi matrix for the case of unitary and noisy channels respectively.choi
flag to build_process
in generatedata
initializetomography
interface.splitchoi
to take an unsplit Choi MPO / Unitary MPO as inputunsplit(Λ::{MPS,MPO})
: take a 2N-sites Choi MPS/MPO, and returns the unsplit version with N
tensors.choimatrix
and generatedata
: create the Choi matrix as a MPO with N
4-siteinds tensors. In tomography
, the Choi MPO needs to be split into an 2N
-sites MPS at the beginning of the function. This will be changed at a later time. After the tomography, return the learned circuit MPO (compress back to N
tensors).optimizers
to avoid model inputrandomstates
hilbertspace
,replacehilbertspace!
choimatrix
splitchoi
, splitunitary
,unsplitchoi
,unsplitunitary
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.