qiskit-symb
Symbolic evaluation of parameterized quantum circuits in Qiskit
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.6%) to scientific vocabulary
Keywords
Repository
Symbolic evaluation of parameterized quantum circuits in Qiskit
Basic Info
- Host: GitHub
- Owner: SimoneGasperini
- License: apache-2.0
- Language: Python
- Default Branch: master
- Homepage: https://pypi.org/project/qiskit-symb/
- Size: 479 KB
Statistics
- Stars: 37
- Watchers: 1
- Forks: 4
- Open Issues: 2
- Releases: 10
Topics
Metadata Files
README.md

Table of contents
Introduction
The qiskit-symb package is meant to be a Python tool to enable the symbolic evaluation of parametric quantum states defined by Qiskit by parameterized quantum circuits.
A Parameterized Quantum Circuit (PQC) is a quantum circuit where we have at least one free parameter (e.g. a rotation angle $\theta$). PQCs are particularly relevant in Quantum Machine Learning (QML) models, where the values of these parameters can be learned during training to reach the desired output.
In particular, qiskit-symb can be used to create a symbolic representation of a parametric quantum state directly from the Qiskit quantum circuit. This has been achieved through the re-implementation of some basic classes defined in the qiskit/quantum_info/ module by using sympy as a backend for symbolic expressions manipulation.
Installation
User-mode
pip install qiskit-symb
:warning: The package requires qiskit==1.x. It doesn't support qiskit==2.x yet.
Dev-mode
git clone https://github.com/SimoneGasperini/qiskit-symb.git
cd qiskit-symb
pip install requirements-dev.txt
pip install -e .
Usage examples
Sympify a Qiskit circuit
Let's get started on how to use qiskit-symb to get the symbolic representation of a given Qiskit circuit. In particular, in this first basic example, we consider the following quantum circuit:
```python
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter, ParameterVector
y = Parameter('y') p = ParameterVector('p', length=2)
pqc = QuantumCircuit(2) pqc.ry(y, 0) pqc.cx(0, 1) pqc.u(p[0], 0, p[1], 1)
pqc.draw('mpl')
```

To get the sympy representation of the unit-norm complex vector prepared by the parameterized circuit, we just have to create the symbolic Statevector instance and call the to_sympy() method:
```python
from qiskitsymb.quantuminfo import Statevector
psi = Statevector(pqc)
psi.to_sympy()
math
\left[\begin{matrix}\cos{\left(\frac{p[0]}{2} \right)} \cos{\left(\frac{y}{2} \right)} & - e^{1.0 i p[1]} \sin{\left(\frac{p[0]}{2} \right)} \sin{\left(\frac{y}{2} \right)} & \sin{\left(\frac{p[0]}{2} \right)} \cos{\left(\frac{y}{2} \right)} & e^{1.0 i p[1]} \sin{\left(\frac{y}{2} \right)} \cos{\left(\frac{p[0]}{2} \right)}\end{matrix}\right]
```
If you want then to assign a value to some specific parameter, you can use the subs(<dict>) method passing a dictionary that maps each parameter to the desired corresponding value:
python
new_psi = psi.subs({p: [-1, 2]})
new_psi.to_sympy()
math
\left[\begin{matrix}\cos{\left(\frac{1}{2} \right)} \cos{\left(\frac{y}{2} \right)} & e^{2.0 i} \sin{\left(\frac{1}{2} \right)} \sin{\left(\frac{y}{2} \right)} & - \sin{\left(\frac{1}{2} \right)} \cos{\left(\frac{y}{2} \right)} & e^{2.0 i} \sin{\left(\frac{y}{2} \right)} \cos{\left(\frac{1}{2} \right)}\end{matrix}\right]
Lambdify a Qiskit circuit
Given a Qiskit circuit, qiskit-symb also allows to generate a Python lambda function with actual arguments matching the Qiskit unbound parameters.
Let's consider the following example starting from a ZZFeatureMap circuit, commonly used as a data embedding ansatz in QML applications:
```python
from qiskit.circuit.library import ZZFeatureMap
pqc = ZZFeatureMap(feature_dimension=3, reps=1)
pqc.draw('mpl')
```

To get the Python function representing the final parametric statevector, we just have to create the symbolic Statevector instance and call the to_lambda() method:
```python
from qiskitsymb.quantuminfo import Statevector
pqc = pqc.decompose() statevec = Statevector(pqc).to_lambda() ```
We can now call the lambda-generated function statevec passing the x values we want to assign to each parameter. The returned object will be a numpy 2D-array (with shape=(8,1) in this case) representing the final output statevector psi.
python
x = [1.24, 2.27, 0.29]
psi = statevec(*x)
This feature can be useful when, given a Qiskit PQC, we want to run it multiple times with different parameters values. Indeed, we can perform a single symbolic evaluation and then call the lambda generated function as many times as needed, passing different values of the parameters at each iteration.
Qiskit Medium
Read my blog post introducing to qiskit-symb published on the official Qiskit Medium blog.

Contributors
Simone Gasperini |
Sebastian Brandhofer |
Owner
- Name: Simone Gasperini
- Login: SimoneGasperini
- Kind: user
- Location: Bologna, Italy
- Company: UniBo & INFN
- Repositories: 3
- Profile: https://github.com/SimoneGasperini
PhD student in Data Science and Computation | MSc in Applied Physics
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Gasperini"
given-names: "Simone"
orcid: "https://orcid.org/0000-0003-4454-7131"
title: "qiskit-symb"
version: 0.5.0
date-released: 2025-07-23
url: "https://github.com/SimoneGasperini/qiskit-symb"
GitHub Events
Total
- Create event: 3
- Release event: 2
- Issues event: 3
- Watch event: 6
- Delete event: 1
- Issue comment event: 2
- Push event: 11
- Pull request event: 1
- Fork event: 2
Last Year
- Create event: 3
- Release event: 2
- Issues event: 3
- Watch event: 6
- Delete event: 1
- Issue comment event: 2
- Push event: 11
- Pull request event: 1
- Fork event: 2
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 2
- Total pull requests: 1
- Average time to close issues: 8 months
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 5.5
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 1
- Average time to close issues: about 2 months
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- gcattan (2)
- awinick (1)
- SimoneGasperini (1)
Pull Request Authors
- q-inho (1)
- sbrandhsn (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 123 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 10
- Total maintainers: 1
pypi.org: qiskit-symb
Symbolic evaluation of parameterized quantum circuits in Qiskit
- Documentation: https://qiskit-symb.readthedocs.io/
- License: Apache-2.0
-
Latest release: 0.5.0
published 7 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- coveralls *
- hypothesis *
- pylint *
- pytest *
- pytest-cov *
- qiskit-terra *