quil-lang / qvm

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

Homogenize the interface for QVM creation #223

Open appleby opened 4 years ago

appleby commented 4 years ago

Some QVM types include a MAKE-FOO-QVM convenience function to create a QVM of the given type, while others do not. It would be nice(tm) if the interface was consistent. Currently, the following QVM types include a MAKE- function:

QVM type exists?
make-qvm yes
make-density-qvm yes
make-stabilizer-qvm yes
make-mixed-state-qvm yes

While these do not:

QVM type exists?
make-base-qvm no
make-basic-noise-qvm no
make-channel-qvm no
make-depolarizing-qvm no
make-noisy-qvm no

The ultimate goal is just to have some consistent and convenient way to create QVMs. Given that dropping existing MAKE- functions is awkward for backwards compat, we might add MAKE- functions for the QVMs that are missing them. Alternatively, we might deprecate the MAKE-FOO-QVM interface and beef up the INITIALIZE-INSTANCE methods so that the MAKE- functions are no longer needed.

Additionally, we might consider homogenizing the MAKE-FOO lambda lists (to the extent possible). For example, currently MAKE-DENSITY-QVM and MAKE-MIXED-STATE-QVM allow the caller to pass in an ALLOCATION, whereas MAKE-QVM and MAKE-STABILIZER-QVM do not.

(defun make-qvm (num-qubits &key (classical-memory-model quil:**empty-memory-model**))
(defun make-stabilizer-qvm (num-qubits &key (classical-memory-model quil:**empty-memory-model**)))
(defun make-density-qvm (num-qubits &key (allocation nil) &allow-other-keys))
(defun make-mixed-state-qvm (num-qubits &key (allocation nil) &allow-other-keys))