Giter VIP home page Giter VIP logo

quantumpeps.jl's Introduction

PEPS inspired quantum circuit ansatz

CI

To make life easier, here is a simplified notebook version of MPS inspired qubit saving scheme for VQE. For a PEPS inpired ansatz solving the J1-J2 square lattice model, please checkout the following content.

To Install

Type ] in a Julia REPL to enter the pkg mode, then type

pkg> dev https://github.com/GiggleLiu/QuantumPEPS.jl.git

To Run

First, enter the directory ~/.julia/dev/QuantumPEPS/ (the default development directory of Julia) in a terminal.

To run a toy example of J1-J2 model of size 4 x 4 with J2 = 0.5, type

julia> using QuantumPEPS

julia> Demo.j1j2peps(4, 4)   # QPEPS

julia> Demo.j1j2mps(4, 4)    # QMPS

To get some help on input arguments, type ? in the REPL to enter the help mode, and then type

help?> Demo.j1j2peps
  j1j2peps(nx::Int=4, ny::Int=4; depth::Int=5, nvirtual::Int=1,
                  nbatch::Int=1024, maxiter::Int=200,
                  J2::Float64=0.5, lr::Float64=0.1,
                  periodic::Bool=false, use_cuda::Bool=false, write::Bool=false)

  Faithful QPEPS traning for solving the J1-J2 hamiltonian ground state. Returns a triple of (optimizer, history, params).

  Positional Arguments
  ======================

    •  nx and ny are the square lattice sizes.

  Keyword Arguments
  ===================

    •  depth is the circuit depth, decides how many entangle layers between two measurements.

    •  nvirtual is the number of virtual qubits.

    •  nbatch is the batch size, or the number of shots.

    •  maxiter is the number of optimization iterations.

    •  J2 is the strength of the second nearest neighbor coupling.

    •  lr is the learning rate of the ADAM optimizer.

    •  periodic specifies the boundary condition of the lattice.

    •  use_cuda is true means uploading the code on GPU for faster computation.

    •  write is true will write training results to the data folder.

Reference

@article{Liu_2019,
	doi = {10.1103/physrevresearch.1.023025},
	url = {https://doi.org/10.1103%2Fphysrevresearch.1.023025},
	year = 2019,
	month = {sep},
	publisher = {American Physical Society ({APS})},
	volume = {1},
	number = {2},
	author = {Jin-Guo Liu and Yi-Hong Zhang and Yuan Wan and Lei Wang},
	title = {Variational quantum eigensolver with fewer qubits},
	journal = {Physical Review Research}
}

Download paper

quantumpeps.jl's People

Contributors

giggleliu avatar

Stargazers

A. Barış Özgüler avatar Isa avatar GhostSec avatar Fermi chen avatar Tan Jun Liang avatar ultimatile avatar Rongyang Sun avatar Atithi Acharya avatar Gábor Nagymajtényi avatar S avatar ebigram avatar  avatar Ejaaz Merali avatar Matthew Beach avatar Shixin Zhang avatar Rugantio Costa avatar  avatar  avatar Tie-Cheng Guo avatar Tim Kersey avatar Lei Wang avatar

Watchers

James Cloos avatar  avatar paper2code - bot avatar

quantumpeps.jl's Issues

system_test.jl breaks for use_cuda=true

Hi @GiggleLiu, I managed to install successfully QuantumPEPS, In order to check that it is working as expected
I ran your test:

test$ julia  runtests.jl 
Test Summary: | Pass  Total
pswap gate    |    5      5
nqubits: 1
[⊞] ZTest Summary: | Pass  Total
bag           |    7      7
Test Summary: | Pass  Total
basis rotor   |    3      3
Test Summary: | Pass  Total
QPEPSConfig   |    8      8
Test Summary: | Pass  Total
measure       |   13     13
Test Summary: | Pass  Total
qpeps machine |   12     12
Test Summary: | Pass  Total
qmps machine  |   12     12
Test Summary: | Pass  Total
j1j2          |    5      5
Test Summary: | Pass  Total
train         |    1      1

To this point everything looks alright, I also ran the test for systems:

test$ julia system_test.jl 
E0 = -5.41796875
Number of parameters is 60
Iter 1, E = -5.61083984375
Iter 2, E = -5.98095703125
Iter 3, E = -6.021728515625
Iter 4, E = -5.898193359375
Iter 5, E = -6.05810546875
Iter 6, E = -6.138671875
Iter 7, E = -6.192626953125
Iter 8, E = -6.207275390625
Iter 9, E = -6.2021484375
Iter 10, E = -6.234130859375

The problem arises when I changed the last line of the file to trigger the computation on the GPU, it is changing ln18 of system_test.jl as follows:

qpeps, history = train(config, model; maxiter=maxiter, nbatch=nbatch, optimizer=optimizer, use_cuda=true)
when I ran the test, I got the following error:

test$ julia system_test.jl 
ERROR: LoadError: UndefVarError: cu not defined
Stacktrace:
 [1] #train#35(::Int64, ::ADAM, ::Int64, ::Bool, ::typeof(train), ::QMPSConfig, ::J1J2{2}) at /home/qcs/.julia/dev/QuantumPEPS/src/train.jl:19
 [2] (::QuantumPEPS.var"#kw##train")(::NamedTuple{(:maxiter, :nbatch, :optimizer, :use_cuda),Tuple{Int64,Int64,ADAM,Bool}}, ::typeof(train), ::QMPSConfig, ::J1J2{2}) at ./none:0
 [3] top-level scope at /home/qcs/.julia/dev/QuantumPEPS/test/system_test.jl:18
 [4] include at ./boot.jl:328 [inlined]
 [5] include_relative(::Module, ::String) at ./loading.jl:1105
 [6] include(::Module, ::String) at ./Base.jl:31
 [7] exec_options(::Base.JLOptions) at ./client.jl:287
 [8] _start() at ./client.jl:460
in expression starting at /home/qcs/.julia/dev/QuantumPEPS/test/system_test.jl:18

Measurement code error

Hi @GiggleLiu , when I run the notebook about QuantumPEPS, the measurement operation code Measure{nbit, 1, AbstractBlock}(Z, (loc,), 0, false) can not work, I notice that you have provided a basis rotation approach instead, however, I am not sure what should I do to replace the measurement code? Could you please provide a simple demo about it? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.