Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Python Quantum Control Architecture Simulator (PyQCAS)

A Python-based, functional eQASM simulator without modeling timing behavior.

PyQCAS was originally named as PyCACTUS.

Installation

pip install pyqcas

Usage

from pyqcas.quantum_coprocessor import Quantum_coprocessor
qcas = Quantum_coprocessor()
qcas.upload_program(<path-to-eqasm_file>)
qcas.execute()
result = qcas.read_result()

The result returned is a binary block, which is the data in the memory of qcas.

To inspect the progress of the simulation, you can use the following method:

qcas.set_verbose(True)

To inspect the execution trace, you can set the logging level:

qcas.set_log_level(log_level=logging.DEBUG)

Allowed logging levels include DEBUG, INFO, WARNING, ERROR, CRITICAL.

A brief introduction to eQASM:

PyQCAS supports the eQASM instruction set architecture with a floating-point extension. A formal definition of the eQASM architecture can be found at eQASM Specification.

The following rules applies to eQASM:

  • All characters are case insensitive, and extra blank is allowed between two identifiers.
  • hash mark (#) starts the line comment.

An overview of eQASM instructions is listed in the following table:

NOTE, being a functional simulator, PyQCAS does not model the timing of quantum instructions. All QWAIT(R) instructions and the pre-intervals of quantum bundles are omitted during the simulation.

For Q_Ops in the quantum bundle, PyQCAS also pre-defines a set of quantum operations as following:

Name Number of Target Qubits Description
H 1 Hadamard gate
X 1 $R_x(\pi)$
Y 1 $R_y(\pi)$
Z 1 $R_z(\pi)$
S 1 $R_z(\frac{\pi}{2})$
Sdg 1 $R_z(-\frac{\pi}{2})$
T 1 $R_z(\frac{\pi}{4})$
Tdg 1 $R_z(-\frac{\pi}{4})$
X$\theta$ 1 $R_x(\frac{\pi\theta}{180})$
Y$\theta$ 1 $R_y(\frac{\pi\theta}{180})$
Z$\theta$ 1 $R_z(\frac{\pi\theta}{180})$
Xm$\theta$ 1 $R_x(-\frac{\pi\theta}{180})$
Ym$\theta$ 1 $R_y(-\frac{\pi\theta}{180})$
Zm$\theta$ 1 $R_z(-\frac{\pi\theta}{180})$
RX$\theta$ 1 the same as X$\theta$
RY$\theta$ 1 the same as Y$\theta$
RZ$\theta$ 1 the same as Z$\theta$
CZ 2 Controlled Phase gate
measure 1 Measure

Note: $\theta$ is a floating point value in $[0, 180]$, of which the decimal point is replaced by _. For example, X175_5 represents $R_x(\frac{\pi\cdot 175.5}{180})$, Xm175_5 represents $R_x(-\frac{\pi\cdot 175.5}{180})$.

Since eQASM does not support floating point values, which might be required by the quantum program, PyQCAS also support an extension with the following FP instructions:

Format formal definition explanation
FCVT.W.S rd, fs R[rd](31:0) = integer(F[fs]) Convert the 32-bit FP number in fs into a 32-bit signed integer, and store it in rd.
FCVT.S.W fd, rs F[fd] = float(R[rs](31:0)) Convert a 32-bit signed integer in rs into a 32-bit FP number, and store it in fd.
FLW fd, imm(rs) F[fd] <- memory(R[rs] + imm) Load a 32-bit FP number from the memory address imm + rs and store it to the FPR fd.
FSW fs, imm(rs) F[fs] -> memory(R[rs] + imm) Store a 32-bit FP number from the FPR fs to the memory address imm + rs.
FADD.S fd, fs, ft F[fd] = F[fs] + F[ft] Floating point addition.
FSUB.S fd, fs, ft F[fd] = F[fs] - F[ft] Floating point subtraction.
FMUL.S fd, fs, ft F[fd] = F[fs] * F[ft] Floating point multiplication.
FDIV.S fd, fs, ft F[fd] = F[fs] / F[ft] Floating point division.
FEQ.S rd, fs, ft R[rd] = F[fs] > F[ft] Set rd when fs is equal to ft.
FLT.S rd, fs, ft R[rd] = F[fs] < F[ft] Set rd when fs is less than ft.
FLE.S rd, fs, ft R[rd] = F[fs] <= F[ft] Set rd when fs is less equal to ft.
FMV.X.W rd, fs R[rd] = F[fs] moves the single-precision value in FPR fs represented in IEEE 754-2008 encoding to the lower 32 bits of GPR rd. NOTE: this is a direct, bit-wise move.
FMV.W.X fd, rs F[fd] = R[rs] moves the single-precision value encoded in IEEE 754-2008 standard encoding from the lower 32 bits of GPR rs to the FPR fd. NOTE: this is a direct, bit-wise move.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqcas-0.1.0b0.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqcas-0.1.0b0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file pyqcas-0.1.0b0.tar.gz.

File metadata

  • Download URL: pyqcas-0.1.0b0.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for pyqcas-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 dd2adf3459e6382539024576cd4cc510ff1ee08e828d611cfefd5bf97eb4ea70
MD5 6b2d04749bcd5c8d624eca3c11e3a53a
BLAKE2b-256 c35d5ec16eb2848a62eb7833bd03f3303de717d5ee1b13ccafe90a8f642fd2ac

See more details on using hashes here.

File details

Details for the file pyqcas-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: pyqcas-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for pyqcas-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd75103f798a9f4c3950d8136401973ba6bbdc814d2f3b5943a55fe9bbc35b14
MD5 a4bd1027efaebb6625a92c11ea0e5ef1
BLAKE2b-256 d002927adf9223f438db1b1ab0c4ada0b0837ff2b55df8bd31fdec749f663c43

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0b0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page