Skip to main content

ommx-qctrl-qaoa-adapter

This package provides an adapter that lets you solve OMMX problems with Q-CTRL’s Fire Opal QAOA solver hosted on IBM Quantum.

OMMX (Open Mathematical programming Modeling eXtension) is an open standard for representing mathematical optimisation problems. Modeling once in OMMX lets you evaluate both classical and quantum solvers. Besides this Fire Opal adapter there are adapters for PySCIPOpt, D-Wave, and more:

OMMX also provides utilities to turn constrained models into unconstrained QUBO/HUBO via Instance.to_qubo / Instance.to_hubo. Define your model once; convert only when needed. See the OMMX tutorial for details.

Prerequisites

Before using the adapter you need:

  • Q-CTRL account API key (used to authenticate fireopal)
  • Either:
    • IBM Quantum API token and IBM Quantum instance CRN (to build credentials locally), or
    • A Fire Opal credential bundle you already saved via Q-CTRL tooling

Warning: Running Q-CTRL’s QAOA solver on IBM Quantum hardware consumes credits or usage. Understand the pricing before launching jobs.

Installation

Install from PyPI:

pip install ommx-qctrl-qaoa-adapter

Fire Opal QAOA overview

Fire Opal’s QAOA solver handles unconstrained binary optimisation problems across many combinatorial classes. It supports polynomial cost functions with arbitrary-order terms but requires at least one non-linear term. For the purely linear objectives are rejected to avoid spending quantum resources on trivial cases. See the Fire Opal QAOA solver guide for the detailed criteria. Use Instance.to_qubo / to_hubo to eliminate constraints and ensure quadratic penalties when necessary.

Usage

0. Authenticate your Q-CTRL account using an API key

The link provide how to get the Q-CTRL account and API key. If you already have authenticated the account in the enviroument. you can skip this process.

import fireopal

fireopal.authenticate_qctrl_account(api_key="Q-CTRL API Key")

1. Define your OMMX problem

from ommx.v1 import DecisionVariable, Instance

x0 = DecisionVariable.binary(0)
x1 = DecisionVariable.binary(1)
x2 = DecisionVariable.binary(2)

#Example objective (must include quadratic or higher terms)
objective = x0 + x1 - 2 * x0 * x1 + x1 + x2 - 2 * x1 * x2

# Example constraint: select at most two vertices.
constraint = x0 + x1 + x2 <= 2

instance = Instance.from_components(
    decision_variables=[x0, x1, x2],
    objective=objective,
    constraints=[constraint],
    sense=Instance.MAXIMIZE,
)

# Convert the constrained model to an unconstrained QUBO with a penalty term.
qubo_instance = instance.to_qubo()

Use qubo_instance (or instance.to_hubo(...) if you prefer higher-order penalties) when calling the adapter so Fire Opal receives an unconstrained formulation.

2. Solve with Fire Opal

from ommx_qctrl_qaoa_adapter import OMMXQctrlQAOAAdapter
from fireopal.run_options import IbmRunOptions

IBM_TOKEN = "your_ibm_cloud_token"
IBM_INSTANCE = "crn:v1:..."
BACKEND_NAME = "ibm_device"

run_opts = IbmRunOptions(session_id=None, job_tags=["ommx-demo"])

solution = OMMXQctrlQAOAAdapter.solve(
    ommx_instance=qubo_instance,
    backend_name=BACKEND_NAME,
    ibm_token=IBM_TOKEN,
    ibm_instance=IBM_INSTANCE,
    run_options=run_opts,
)
print("Objective:", solution.objective)
print("Assignments:", solution.state.entries)

Decode previously solved jobs

If you already ran fireopal.solve_qaoa elsewhere, you can reconstruct the OMMX solution from the below:

from ommx_qctrl_qaoa_adapter import OMMXQctrlQAOAAdapter

adapter = OMMXQctrlQAOAAdapter(qubo_instance)

fire_opal_result = {
    "solution_bitstring": "101",
    "solution_bitstring_cost": -2.0,
    "variables_to_bitstring_index_map": {"x_0": 0, "x_1": 1, "x_2": 2},
}

solution = adapter.decode(fire_opal_result)
print("Objective:", solution.objective)

Environment variables example

Before running the OMMXQctrlQAOAAdapter you can set:

export IBM_QUANTUM_TOKEN=...
export IBM_QUANTUM_INSTANCE=...

Error handling

OMMXQctrlQAOAAdapterError is raised when:

  • No decision variables, or non-binary variables are present
  • Constraints remain (Fire Opal only supports unconstrained problems)
  • The objective contains only linear terms
  • Fire Opal job fails (check IBM Quantum dashboard)
  • Credentials are missing or invalid

Development

Install dev dependencies via uv:

uv sync --all-extras

Run tests:

uv run pytest

References

Metadata

Release files for ommx-qctrl-qaoa-adapter 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ommx-qctrl-qaoa-adapter 0.0.1
File Size Uploaded Provenance Actions
ommx_qctrl_qaoa_adapter-0.0.1.tar.gz 82.5 kB Without provenance Details for ommx_qctrl_qaoa_adapter-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ommx-qctrl-qaoa-adapter 0.0.1
File Interpreter ABI Platform Actions
ommx_qctrl_qaoa_adapter-0.0.1-py3-none-any.whl Python 3 none any Details for ommx_qctrl_qaoa_adapter-0.0.1-py3-none-any.whl

Total release size: 95.3 kB

Release files / ommx_qctrl_qaoa_adapter-0.0.1.tar.gz

Download URL ommx_qctrl_qaoa_adapter-0.0.1.tar.gz
Size 82.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1e6f46fc1f43b22e21595273a58d5be09bccd281e10f665bc4bd47ec10a844a4
BLAKE2b-256 checksum
How to use checksums
5319502d89b44c621552ecb45d7274191f1b966b521630524f613feb36cc5de0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ommx_qctrl_qaoa_adapter-0.0.1-py3-none-any.whl

Download URL ommx_qctrl_qaoa_adapter-0.0.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0aff6c9b12cf7da7c2a2b1486034e3f012c6f94b89b407b26ce64a7d72776e0e
BLAKE2b-256 checksum
How to use checksums
960d787601d9848e09e4bfa8adf2dcb26f1f83be6aad945746cf5123edc63059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ommx-qctrl-qaoa-adapter 0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page