rigetti / rigetti/pyquil

Simulation with noise results in QVMError: Encountered the invalid instruction NOISY-RX-PLUS-180 1

Open
#748 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I would like to simulate a circuit with the device noise model. I tried the following code

qvm = get_qc("Aspen-1-16Q-A", as_qvm=True, noisy=True)
ro = p.declare(name='ro', memory_type='BIT', memory_size=2)
gate_list = [CNOT(0, 1), X(0), MEASURE(0, ro[0]), MEASURE(1, ro[1])]
for gate in gate_list:
    p += gate
p.wrap_in_numshots_loop(10)
compiled_program = qvm.compile(p)
results = qvm.run(compiled_program)

I got the following error

---------------------------------------------------------------------------
QVMError                                  Traceback (most recent call last)
<ipython-input-23-cf1df12e085a> in <module>
      6 p.wrap_in_numshots_loop(10)
      7 compiled_program = qvm.compile(p)
----> 8 results = qvm.run(compiled_program)

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    236             global_error_context.log[key] = pre_entry
    237 
--> 238         val = func(*args, **kwargs)
    239 
    240         # poke the return value of that call in

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_quantum_computer.py in run(self, executable, memory_map)
    159                     # TODO gh-658: have write_memory take a list rather than value + offset
    160                     self.qam.write_memory(region_name=region_name, offset=offset, value=value)
--> 161         return self.qam.run() \
    162             .wait() \
    163             .read_memory(region_name='ro')

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    236             global_error_context.log[key] = pre_entry
    237 
--> 238         val = func(*args, **kwargs)
    239 
    240         # poke the return value of that call in

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_qvm.py in run(self)
    479                                                         measurement_noise=self.measurement_noise,
    480                                                         gate_noise=self.gate_noise,
--> 481                                                         random_seed=self.random_seed)['ro']
    482         except KeyError:
    483             warnings.warn("You are running a QVM program with no MEASURE instructions. "

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    236             global_error_context.log[key] = pre_entry
    237 
--> 238         val = func(*args, **kwargs)
    239 
    240         # poke the return value of that call in

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_base_connection.py in _qvm_run(self, quil_program, classical_addresses, trials, measurement_noise, gate_noise, random_seed)
    360         payload = qvm_run_payload(quil_program, classical_addresses, trials,
    361                                   measurement_noise, gate_noise, random_seed)
--> 362         response = post_json(self.session, self.sync_endpoint + "/qvm", payload)
    363 
    364         ram = response.json()

~/venv/quantum/lib/python3.6/site-packages/pyquil/api/_base_connection.py in post_json(session, url, json)
     56     res = session.post(url, json=json)
     57     if res.status_code >= 400:
---> 58         raise parse_error(res)
     59     return res
     60 

QVMError: Encountered the invalid instruction

    NOISY-RX-PLUS-180 1

which could not be executed because the operator NOISY-RX-PLUS-180 is not known

The QVM returned the above error. This could be due to a bug in the server or a
bug in your code. If you suspect this to be a bug in pyQuil or Rigetti Forest,
then please describe the problem in a GitHub issue at:
    https://github.com/rigetti/pyquil/issues

I tried the code on both the qcs and my local machine (with pyquil 2.1.1), and they gave the same error.

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 with the qvm.compile and qvm.run entry points shown in the traceback, then trace the related paths in _quantum_computer.py, _qvm.py, and _base_connection.py. Reproduce the supplied noisy Aspen-1-16Q-A program locally and against QCS, and establish whether NOISY-RX-PLUS-180 is expected to be accepted before verifying the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.