rigetti / rigetti/pyquil

run_symmetrized_readout does not respect memory declarations

Open
#1,003 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :bug:
Dominant language
Python
Stars
1.5k
Forks
358
Avg merge
1d 58m
Merged PRs (30d)
4

Description

Pre-Report Checklist

  • I am running the latest versions of pyQuil and the Forest SDK
  • I checked to make sure that this bug has not already been reported

Issue Description

QuantumComputer.run_symmetrized_readout produces symmetrized programs which may contain duplicate memory references. Quil does not allow for duplicate memory references.

Example

>>> import pyquil
>>> from pyquil import Program, get_qc
>>> from pyquil.gates import H, MEASURE
>>> from pyquil.quilbase import Declare, MemoryReference
>>> qc = get_qc('3q-qvm')
>>> qc.run_symmetrized_readout(Program(Declare('ro', 'BIT'), H(0), MEASURE(0, MemoryReference('ro', 0))), 1000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/erik/src/pyquil/pyquil/api/_error_reporting.py", line 238, in wrapper
    val = func(*args, **kwargs)
  File "/Users/erik/src/pyquil/pyquil/api/_quantum_computer.py", line 210, in run_symmetrized_readout
    results = _measure_bitstrings(self, sym_programs, meas_qubits, num_shots_per_prog)
  File "/Users/erik/src/pyquil/pyquil/api/_quantum_computer.py", line 919, in _measure_bitstrings
    prog = qc.compiler.quil_to_native_quil(prog)
  File "/Users/erik/src/pyquil/pyquil/api/_error_reporting.py", line 238, in wrapper
    val = func(*args, **kwargs)
  File "/Users/erik/src/pyquil/pyquil/api/_compiler.py", line 340, in quil_to_native_quil
    response = self.client.call('quil_to_native_quil', request, protoquil=protoquil).asdict()  # type: Dict
  File "/Users/erik/miniconda3/envs/pyquil/lib/python3.7/site-packages/rpcq/_client.py", line 180, in call
    raise utils.RPCError(reply.error)
rpcq._utils.RPCError: At line 5: The name "ro" has been DECLAREd more than once.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pyquil/api/_quantum_computer.py at run_symmetrized_readout and follow its call to _measure_bitstrings, both named in the traceback. Reproduce the example with a declared ro memory region and verify that the generated symmetrized programs no longer contain duplicate memory declarations or trigger the compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, quantum-computing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.