
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
[!IMPORTANT]
This package is obsolete. It was vendored into Qiskit itself as of
qiskit==0.43.0
(viaqiskit-terra==0.24.0
at the time), at version0.5.3
of this package. There is no longer any need to install this package; simply useqiskit.qasm2.load
orqiskit.qasm2.loads
. The Qiskit version is actively developed, and this package is not being updated any more.All references to Qiskit in the README and in the package itself mean Qiskit versions
<0.43
, before this package was vendored into Qiskit.
This repository provides the Python package qiskit_qasm2
, which provides a
fast parser of OpenQASM 2 into Qiskit's QuantumCircuit
. It is often 10x or
more faster than Qiskit's native parser. The API is simple:
qiskit_qasm2.load
takes a filename, and returns QuantumCircuit
;qiskit_qasm2.loads
takes an OpenQASM 2 program in a string, and returns
QuantumCircuit
.The full documentation is published to https://jakelishman.github.io/qiskit-qasm2.
A simple parsing example:
import qiskit_qasm2
program = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
"""
qiskit_qasm2.loads(program).draw()
┌───┐ ┌─┐
q_0: ┤ H ├──■──┤M├───
└───┘┌─┴─┐└╥┘┌─┐
q_1: ─────┤ X ├─╫─┤M├
└───┘ ║ └╥┘
c: 2/═══════════╩══╩═
0 1
The parser supports all of the OpenQASM 2 specification, including:
qreg
and creg
);qelib1.inc
as a special builtin include, precisely as described in the
paper;gate
and opaque
declarations;In addition, the parser also includes options to:
include
statements in OpenQASM 2;Qiskit's builtin parser makes some extra-spec additions by default, with no
option to disable them. This mostly takes the form of custom gate overrides,
and various additional gates in Terra's vendored version of qelib1.inc
compared to the description in the paper. This parser is more type-safe than
Qiskit's, but does include a compatibility mode
to ease the transition from using Qiskit's parser.
Install the latest release of the qiskit_qasm2
package from pip:
pip install qiskit_qasm2
If you're looking to contribute to this project, please first read our contributing guidelines.
Set up your development environment by installing the development requirements with pip:
pip install -r requirements-dev.txt tox
This installs a few more packages than the dependencies of the package at
runtime, because there are some tools we use for testing also included, such as
tox
and pytest
.
You will also need a working Rust toolchain. The easiest way to install one is by using rustup on Linux, macOS or Windows.
After the development requirements are installed, you can install an editable version of the package with
pip install -e .
After this, any changes you make to the library code will immediately be present when you open a new Python interpreter session.
This package was mostly an excuse for me to learn a bit more about how lexers are written at a low level. This is why the Rust crate doesn't use any lexer-generation libraries. You can read a bit more about the architecture and some of the design decisions in the developer section of the documentation.
After the development requirements have been installed, the command
tox -e docs
will build the HTML documentation, and place it in docs/_build/html
. The
documentation state of the main
branch of this repository is published to
https://jakelishman.github.io/qiskit-qasm2.
The Python components of this repository are formatted using black
, and the
Rust components with rustfmt
. You can run these on the required files by
running
tox -e style
The full lint suite can be run with
tox -e lint
This project is licensed under version 2.0 of the Apache License.
FAQs
Importer for parsing OpenQASM 2 strings into Qiskit circuits
We found that qiskit-qasm2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.