rigetti / pyquil

A Python library for quantum programming using Quil.
http://docs.rigetti.com
Apache License 2.0
1.41k stars 342 forks source link

Wavefunction decoding for JobConnections isn't decoding properly #85

Closed willzeng closed 7 years ago

willzeng commented 7 years ago

Running a wavefunction command on a JobConnection object gets a result that looks like the byte information hasn't been properly decoded:

from pyquil.quil import Program
from pyquil.gates import *
import pyquil.api as api

cxn = api.JobConnection(endpoint="https://job.rigetti.com/beta")
res = cxn.wavefunction(Program(X(0)))
# wait for a bit
print res.get()
{u'result': u'AAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA=', u'jobId': u'HMYHUBMJPM'}

This is on pyquil's current master branch.

stevenheidel commented 7 years ago

@willzeng - with my rewrite of the server the encoding is working again. The way this is implemented in PyQuil though is as follows:

...
res = cxn.wavefunction(Program(X(0)))

# decode the wavefunction
(wfxn, classical) = res.decode()
print(wfxn.get_outcome_probs())
willzeng commented 7 years ago

Yep that is working. It is likely to be a bit of a confusion point for users that res.get() shows a different encoding and res.decode() needs to be run, but we can deal with that separately.