rigetti / pyquil

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

HTTP 500 error ... no applicable method ... #11

Closed rallim closed 7 years ago

rallim commented 7 years ago

Hi, I'm seeing the following HTTP 500 error:

There is no applicable method for the generic function
  #<STANDARD-GENERIC-FUNCTION CL-QUIL::PRINT-INSTRUCTION (24)>
when called with arguments
  (18 #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDOUT* {1000014153}>).
...
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://api.rigetti.com/qvm

Here's a repro:

import pyquil.forest as qvm
import pyquil.quil as pq

def prog_from_file(filepath):
    """Make a Program from a file
    """
    p = pq.Program()
    with open(filepath) as fp:
        for line in fp:
            p.inst(line.rstrip('\n'))
    return p

if __name__ == '__main__':
    p = prog_from_file('/path/to/repro.quil')  # cleaner way to get a Program from a file?
    print p
    print qvm.Connection().run_and_measure(p, [2,3], 1)
    #print qvm.Connection().run(p, [2,3], 1)  # note that run appears to work

repro.quil:

X 5
X 0
H 1
CNOT 1 2
H 3
CNOT 3 4
CNOT 3 2
CNOT 5 4
H 5
MEASURE 5 [5]
MEASURE 4 [4]
CNOT 0 1
H 0
MEASURE 0 [0]
MEASURE 1 [1]
CNOT 3 2
JUMP-WHEN @THEN1 [1]
JUMP @END2
LABEL @THEN1
X 2
LABEL @END2
JUMP-WHEN @THEN7 [4]
JUMP @END8
LABEL @THEN7
X 3
LABEL @END8
JUMP-WHEN @THEN3 [0]
JUMP @END4
LABEL @THEN3
Z 2
LABEL @END4
JUMP-WHEN @THEN5 [5]
JUMP @END6
LABEL @THEN5
Z 3
LABEL @END6
CNOT 2 3

@tarballs-are-good Any clarification on the error and what triggers it? Thanks!

stylewarning commented 7 years ago

@rallim, thanks very much for the bug report!

There is no problem with your code. The problem actually was that there was some stray debug code that accidentally found its way into production some time ago that wasn't caught. (Funny that debug code caused a bug.)

It's fixed now. I've tested your example and it should work fine. To verify, cxn.version() should now give 0.5.1.