Code Monkey home page Code Monkey logo

Comments (8)

willzeng avatar willzeng commented on June 14, 2024 2

The representation is as a binary fraction listed from the right. This means that
0001 represents 1/2
0010 represents 1/4
0011 represents 1/4 + 1/2 = 3/4
1000 represents 1/16

Each index to the left is 1/2^i

Does that makes sense @peterwittek ?

from grove.

kmckiern avatar kmckiern commented on June 14, 2024 1

I think there are two issues here, one is related to #44 and the other is some change to pyquil between late November and now. I'm trying to find the pyquil commit causing the problem.

from grove.

willzeng avatar willzeng commented on June 14, 2024 1

Thanks @kmckiern ! This appears to be fixed.

from grove.

ncrubin avatar ncrubin commented on June 14, 2024

@JansenZhao thanks for raising the issue. That is concerning. I wonder if this is related to issue #44?

from grove.

JansenZhao avatar JansenZhao commented on June 14, 2024

@ncrubin Thanks. Most likely, but I am not so clear what was meant by "What phase convention did we choose so the QFT is correct?" in #44.

from grove.

willzeng avatar willzeng commented on June 14, 2024

I've taken a bit of a look into this and also think that we need to confirm the convention.
When I run the following:

import numpy as np
import scipy.linalg
from grove.alpha.phaseestimation.phase_estimation import phase_estimation
import pyquil.api as api

qvm = api.QVMConnection()

phase = 3/4
Z = np.asarray([[1.0, 0.0], [0.0, -1.0]])
Rz = scipy.linalg.expm(1j*Z*2*np.pi*phase)
p = phase_estimation(Rz, 8)
print(qvm.run(p, range(8), 1))
print(qvm.wavefunction(p))

I get this output:

[[0, 0, 0, 0, 0, 0, 1, 0]]
(1+0j)|001000000>

I would expect

[[0, 0, 0, 0, 0, 0, 1, 1]]
(1+0j)|110000000>

In general if I run with phase of x then I seem to get a bit representation of 1-x and the wavefunction is shifted to the right by one qubit from what i would expect
e.g. for phase=1/16 I get:

[[0, 0, 0, 0, 1, 1, 1, 1]]
(1+0j)|011110000>

from grove.

willzeng avatar willzeng commented on June 14, 2024

I'm also getting non-deterministic results for phase=1/8. I would expect that because 1/8 can be exactly represented as a binary fraction then it should give exact and deterministic results? @ncrubin ?

from grove.

peterwittek avatar peterwittek commented on June 14, 2024

Thanks, it works fine! What's the convention for the binary encoding of the phase?

from grove.

Related Issues (20)

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.