quil-lang / qvm

The high-performance and featureful Quil simulator.
Other
411 stars 57 forks source link

Handful of MAKE-INSTANCE calls still using old :AMPLITUDES initarg #220

Closed appleby closed 4 years ago

appleby commented 4 years ago

There appear to be a handful of places in qvm-app and dqvm that are still calling MAKE-INSTANCE directly to create QVMs and passing the old :AMPLITUDES initarg rather than using the new :STATE API.

To reproduce, run the pyquil tests against qvm built from master. An example of the pytest error output:

pyquil/api/_error_reporting.py:238: in wrapper
    val = func(*args, **kwargs)
pyquil/api/_qvm.py:518: in run
    random_seed=self.random_seed)
pyquil/api/_error_reporting.py:238: in wrapper
    val = func(*args, **kwargs)
pyquil/api/_base_connection.py:340: in _qvm_run
    response = post_json(self.session, self.sync_endpoint + "/qvm", payload)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

session = <requests.sessions.Session object at 0x12ac1ac88>, url = 'http://127.0.0.1:5000/qvm'
json = {'addresses': {'ro': [0]}, 'compiled-quil': 'DECLARE ro BIT[1]\nX 0\nMEASURE 0 ro[0]\n', 'gate-noise': [0.01, 0.01, 0.01], 'trials': 1000, ...}

    def post_json(session, url, json):
        """
        Post JSON to the Forest endpoint.
        """
        res = session.post(url, json=json)
        if res.status_code >= 400:
>           raise parse_error(res)
E           pyquil.api._errors.QVMError: Invalid initialization argument:
E             :AMPLITUDES
E           in call for class #<STANDARD-CLASS QVM:DEPOLARIZING-QVM>.
E           See also:
E             The ANSI Standard, Section 7.1.2
E
E           The QVM returned the above error. This could be due to a bug in the server or a
E           bug in your code. If you suspect this to be a bug in pyQuil or Rigetti Forest,
E           then please describe the problem in a GitHub issue at:
E               https://github.com/rigetti/pyquil/issues

pyquil/api/_base_connection.py:56: QVMError

For instance, in qvm/app/src/configure-qvm.lisp, there are several make-appropriate-qvm methods that wind up allocating the amplitudes themselves and passing them along to make-instance.

Likewise in the run-qvm function defined in qvm/dqvm/tests/program-tests.lisp.

appleby commented 4 years ago

Closed by #221