Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

unitary_generator.py : tensor_gates() tries to call numpy array #18

Closed
astrophys opened this issue Aug 8, 2018 · 9 comments
Closed

Comments

@astrophys
Copy link

I have a minimal working example:

from pyquil.quil import Program
from pyquil.gates import *
from pyquil.parameters import Parameter, quil_sin, quil_cos
from pyquil.quilbase import DefGate
from pyquil.api import QVMConnection
#from referenceqvm.api import QVMConnection
import numpy as np
theta = Parameter('theta')
cry = np.array([[1.0,0.0,0.0,0.0],[0.0,1.0,0.0,0.0],[0.0,0.0,quil_cos(theta / 2), -1 * quil_sin(theta / 2)],[0.0,0.0,quil_sin(theta / 2), quil_cos(theta / 2)]]) 
dg = DefGate('CRY', cry, [theta])
CRY = dg.get_constructor()
p = Program()
p.inst(dg)
p.inst (X(0))
p.inst (X(1))
p.inst (CRY(4.304)(0,2))
qvm = QVMConnection()
wf = qvm.wavefunction(p)
print(wf)

When I run this I get the output :

(-0.5490303672+0j)|011> + (0.8358024024+0j)|111>

If I switch from the Rigetti server to a local installation of reference-qvm (i.e. comment from pyquil.api import QVMConnection and uncomment #from referenceqvm.api import QVMConnection) and try to run it I get the error :

Traceback (most recent call last):
  File "minimal_broken_example.py", line 22, in <module>
    wf = qvm.wavefunction(p)
  File "/gpfs0/export/opt/python/3.6.5/additional_packages/src/reference-qvm/referenceqvm/qvm_wavefunction.py", line 378, in wavefunction
    self.kernel()
  File "/gpfs0/export/opt/python/3.6.5/additional_packages/src/reference-qvm/referenceqvm/qam.py", line 167, in kernel
    halted = self.transition(self.current_instruction())
  File "/gpfs0/export/opt/python/3.6.5/additional_packages/src/reference-qvm/referenceqvm/qvm_wavefunction.py", line 268, in transition
    self._transition(instruction)
  File "/gpfs0/export/opt/python/3.6.5/additional_packages/src/reference-qvm/referenceqvm/qvm_wavefunction.py", line 180, in _transition
    unitary = tensor_gates(self.gate_set, self.defgate_set, instruction, self.num_qubits)
  File "/gpfs0/export/opt/python/3.6.5/additional_packages/src/reference-qvm/referenceqvm/unitary_generator.py", line 352, in tensor_gates
    (*[value_get(p) for p in pyquil_gate.params]),
TypeError: 'numpy.ndarray' object is not callable

It seems to me that the in the function tensor_gates() that it is expecting something other than a numpy array to be returned by dict_check[pyquil_gate.name].

QUESTIONS:

  1. How do I fix this?
  2. Also, is the expected behavior of the local installation of reference-qvm supposed to exactly replicate the behavior of the Rigetti server version?

Thanks

@vtomole
Copy link

vtomole commented Aug 9, 2018

Could be a bug in the reference QVM. What do you think? @ncrubin

@ncrubin
Copy link
Contributor

ncrubin commented Aug 13, 2018

Checking in detail this week

@euler16
Copy link

euler16 commented Oct 14, 2018

is this issue still open?

@vtomole
Copy link

vtomole commented Oct 14, 2018

@euler16 Yes.

@euler16
Copy link

euler16 commented Oct 14, 2018

@vtomole I want to start contributing to Open Source and specially PyQuil. Could you give me some pointers to solve the issue?

@vtomole
Copy link

vtomole commented Oct 14, 2018

@euler16 This is not a good isue for first timers. I sugget you work on any of https://github.com/rigetticomputing/pyquil/issues?q=label%3A"good+first+issue"+is%3Aissue+is%3Aopen instead.

@mpharrigan
Copy link
Contributor

you can also try using / contributing to rigetti/pyquil#552

@euler16
Copy link

euler16 commented Oct 15, 2018

Thank you @vtomole and @mpharrigan :)

@mpharrigan
Copy link
Contributor

reference_qvm is now cleaned up and in pyquil

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants