geqie
Core quantum image encoding library. Full documentation: https://merqlab.github.io/geqie.
Table of contents
API
Quick start
import numpy as np
from PIL import Image
import geqie
from geqie.encodings import frqi
image = np.asarray(Image.open("assets/test_images/grayscale/test_image_4x4.png"))
circuit = geqie.encode(frqi.init_function, frqi.data_function, frqi.map_function, image)
counts = geqie.simulate(circuit, n_shots=1024)
reconstructed = geqie.retrieve(frqi.retrieve_function, counts)
Encodings
Each encoding lives in geqie.encodings.<name> (e.g., frqi, neqr, mcqi) and exposes:
| Function | Signature | Returns | Description |
|---|---|---|---|
init_function |
(n_qubits, **encoding_params) |
Statevector |
Initial state of the circuit |
data_function |
(*coords, R, image, **encoding_params) |
Statevector |
Data (pixel position) state for the given pixel |
map_function |
(*coords, R, image, **encoding_params) |
Operator |
Map (pixel value) operator for the given pixel |
retrieve_function |
(results, **encoding_params) |
np.ndarray |
Reconstructs the image from measurement counts |
coords are pixel indices (e.g., u, v for 2D images) and R = ceil(log2(max(image.shape))). Custom encodings can be created by providing your own functions with the same signatures.
geqie.encode
Builds a quantum circuit encoding the image using the provided encoding functions.
geqie.encode(
init_function, data_function, map_function, image,
image_dimensionality=2,
perform_measurement=True,
logging_level=None,
encoding_params={},
) -> QuantumCircuit
| Parameter | Description |
|---|---|
init_function |
Function returning the initial Statevector |
data_function |
Function returning the data Statevector for a pixel |
map_function |
Function returning the map Operator for a pixel |
image |
Image as a NumPy array |
image_dimensionality |
Number of leading image axes treated as spatial coordinates (rest are e.g. channels) |
perform_measurement |
Append measurement of all qubits to the circuit |
logging_level |
Logging level (see geqie.logging_utils.levels) |
encoding_params |
Extra keyword arguments passed to the encoding functions (e.g., {"bitrate": 4}) |
geqie.simulate
Simulates the circuit locally with Qiskit Aer.
geqie.simulate(
circuit, n_shots,
return_qiskit_result=False,
return_padded_counts=False,
device="CPU",
method="automatic",
noise_model=None,
logging_level=None,
) -> dict[str, int] | qiskit.result.Result
| Parameter | Description |
|---|---|
circuit |
Circuit returned by geqie.encode |
n_shots |
Number of simulation shots |
return_qiskit_result |
Return the raw Qiskit Result instead of counts |
return_padded_counts |
Include zero-count states in the returned counts |
device |
Aer simulator device ("CPU" or "GPU") |
method |
Aer simulation method (e.g., "automatic", "statevector") |
noise_model |
Optional qiskit_aer.noise.NoiseModel |
logging_level |
Logging level |
geqie.execute
Executes the circuit on real hardware via IBM Quantum Platform (Qiskit Runtime SamplerV2).
geqie.execute(
circuit, n_shots,
circuit_param_values={},
return_qiskit_result=False,
return_padded_counts=False,
dry_run=False,
api_token="",
instance_crn="",
credentials_name="",
backend="",
channel="ibm_quantum_platform",
ibm_qp_runtime_args={},
transpiler_args={},
logging_level=None,
) -> dict[str, int] | PrimitiveResult | None
| Parameter | Description |
|---|---|
circuit |
Circuit returned by geqie.encode |
n_shots |
Number of shots |
circuit_param_values |
Values for parametrized circuits |
return_qiskit_result |
Return the raw Qiskit Runtime result instead of counts |
return_padded_counts |
Include zero-count states in the returned counts |
dry_run |
Set up the backend and transpile, but don't submit the job (returns None) |
api_token |
IBM Quantum API token (used with instance_crn) |
instance_crn |
IBM Quantum instance CRN |
credentials_name |
Name of saved QiskitRuntimeService credentials (alternative to api_token); if neither is given, the default saved account is used |
backend |
Backend name; if empty, the least busy backend with enough qubits is selected |
channel |
Qiskit Runtime channel |
ibm_qp_runtime_args |
Extra keyword arguments for QiskitRuntimeService |
transpiler_args |
Extra keyword arguments for qiskit.transpile |
logging_level |
Logging level |
Example
counts = geqie.execute(circuit, n_shots=1024, credentials_name="my-ibm-credentials")
geqie.retrieve
Reconstructs the image from measurement counts using the encoding's retrieve function.
geqie.retrieve(
retrieve_function, results,
image_dimensionality=2,
encoding_params={},
) -> np.ndarray
| Parameter | Description |
|---|---|
retrieve_function |
Encoding's retrieve_function (e.g., frqi.retrieve_function) |
results |
Measurement counts returned by geqie.simulate or geqie.execute |
image_dimensionality |
Number of spatial image dimensions (used by encodings that support it, e.g. mfrqi) |
encoding_params |
Extra keyword arguments passed to the retrieve function (e.g., {"bitrate": 4}) |
Examples
See the examples/ directory for notebooks covering individual encodings and CLI workflows.
CLI
geqie list-encodings
geqie list-encodings
geqie simulate
Usage: geqie simulate [OPTIONS]
Options:
--encoding TEXT Name of the encoding from 'encodings'
directory [required]
--image-path TEXT Path to the image file [required]
--image-dimensionality INTEGER Number of image dimensions to consider
[default: 2]
--bitrate INTEGER Number of color bits for encodings that
support it [default: 8]
--verbosity-level TEXT Set verbosity level, 0-6 (higher means more
verbose)
--n-shots INTEGER Number of simulation shots
--return-qiskit-result BOOLEAN Return results directly from qiskit
[default: False]
--return-padded-counts BOOLEAN Return state counts including zero-count
states [default: False]
--output-path TEXT Path to where the results will be written
-e, --encoding-params KEY=VALUE
Arbitrary extra parameters as key=value
pairs. May be repeated, e.g.,
-e bitrate=4 -e custom_flag=true
--help Show this message and exit.
Example
geqie simulate --encoding frqi --image-path assets/test_image.png --n-shots 1024 --return-padded-counts true
geqie execute
Usage: geqie execute [OPTIONS]
Options:
--encoding TEXT Name of the encoding from 'encodings'
directory [required]
--image-path TEXT Path to the image file [required]
--image-dimensionality INTEGER Number of image dimensions to consider
[default: 2]
--bitrate INTEGER Number of color bits for encodings that
support it [default: 8]
--verbosity-level TEXT Set verbosity level, 0-6 (higher means more
verbose)
--n-shots INTEGER Number of simulation shots
--return-qiskit-result BOOLEAN Return results directly from qiskit
[default: False]
--return-padded-counts BOOLEAN Return state counts including zero-count
states [default: False]
--output-path TEXT Path to where the results will be written
--credentials-name TEXT Name of saved IBM Quantum credentials; if no
credentials are given, the default saved
account is used
--api-token TEXT IBM Quantum API token (used with --instance-
crn)
--instance-crn TEXT IBM Quantum instance CRN
--channel TEXT Qiskit Runtime channel [default:
ibm_quantum_platform]
-e, --encoding-params KEY=VALUE
Arbitrary extra parameters as key=value
pairs. May be repeated, e.g.,
-e bitrate=4 -e custom_flag=true
--help Show this message and exit.
Example
geqie execute --encoding frqi --image-path assets/test_image.png --n-shots 1024
Metadata
Release files for geqie 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| geqie-1.0.1.tar.gz | 23.1 kB | With provenance | Details for geqie-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geqie-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for geqie-1.0.1-py3-none-any.whl |
Total release size: 58.3 kB
Release files / geqie-1.0.1.tar.gz
| Download URL | geqie-1.0.1.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc88d95d99a18d2903147f3739a7af6dd37bd25e734ce640c926782f98099ef6
|
|
BLAKE2b-256 checksum How to use checksums |
36453b61a7bdfae92cdd34778af75ef92803779348756d75f351640f94b84cf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / geqie-1.0.1-py3-none-any.whl
| Download URL | geqie-1.0.1-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c254e9e3e72d99d0f026cdf723db7c6fb5d7ec07fe92613323f465a146cfa12a
|
|
BLAKE2b-256 checksum How to use checksums |
e56b10a7db06654810f45f891ff384482b4f574b14025546d8deb1cf4e35c64a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for geqie 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for geqie-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.