Local, compiler-backed CUDA-Q optimization agent
Project description
QBridge-Agent
Local, compiler-backed CUDA-Q optimization agent. QBridge-Agent translates constrained binary optimization problems into QBridge DSL, compiles them with the installed QBridge CUDA-Q compiler, and runs on your local NVIDIA CUDA-Q target.
Example: qbridge-agent examples/knapsack_n5.py --workspace ./qbridge-output
Install and run locally
Prerequisites
- Python 3.9+
qbridge[quantum]with CUDA-Q and an NVIDIA GPU target- For natural-language mode: an
OPENROUTER_API_KEY
From PyPI
pip install "qbridge[quantum]" qbridge-agent
From a source checkout
cd QbridgeAgentV2
pip install -e ".[dev]"
DSL file mode (no API key)
Compile and solve a QBridge DSL file:
qbridge-agent examples/knapsack_n5.py --workspace ./qbridge-output
Compile only (emit CUDA-Q kernel without running the GPU):
qbridge-agent examples/knapsack_n5.py --workspace ./qbridge-output --no-solve
examples/knapsack_n5.py must be a supported QBridge Python DSL optimization
model (import qbridge as qb, declared variables, objective, constraints), not
arbitrary Python.
Natural-language mode (uses OpenRouter)
export OPENROUTER_API_KEY=sk-or-...
qbridge-agent --prompt "Knapsack with 5 items, values [6,5,8,9,6], weights [2,3,4,5,3], capacity 8" \
--workspace ./qbridge-output
Optional model override:
qbridge-agent --prompt "MaxCut on a 4-node cycle with edge weights 1,2,3,4" \
--model openai/gpt-4o-mini \
--workspace ./qbridge-output
Layout
QBridge-Agent/
├── agent/
│ ├── cli.py # public CLI (DSL or --prompt)
│ ├── cudaq_entry.py # programmatic NL agent entry
│ ├── planner/ # intent-to-DSL prompt policy
│ ├── tools/ # independent benchmark verification
│ └── compiler_interface/ # DSL extraction, local compiler and CUDA-Q execution
├── docs/
│ └── cli-screenshot.png # terminal screenshot
├── examples/
├── evaluations/
│ ├── benchmark_tasks.json # frozen T1/T2 task set
│ ├── results/ # raw reproducible run artifacts
│ └── README.md
└── README.md
Evaluation results
Frozen six-task T1/T2 CUDA-Q benchmark (three trials per system, NVIDIA
cusvsim_fp32, openai/gpt-4o-mini via OpenRouter):
| Metric | QBridge-Agent | Aider |
|---|---|---|
| VERIFIED (of 18 trials) | 16 | 0 |
| Mean total tokens | 1,241 | 3,331 |
| Mean wall time | 3.8 s | 12.6 s |
| Relative cost | 1× | 2.68× tokens, ~3.36× wall time |
QBridge-Agent reached 16/18 verified independent constraint/objective checks; Aider reached 0/18. On the same task set, Aider used 2.68× more tokens and ~3.36× more wall-clock time per trial.
Run benchmarks in WSL Ubuntu with the CUDA-Q virtualenv (not Windows
python):
wsl -d Ubuntu -- bash -c "cd /mnt/c/Users/Dilip/Documents/ProjectQ/QbridgeAgentV2 && \
export PYTHONPATH=/mnt/c/Users/Dilip/Documents/ProjectQ/QbridgeAgentV2 && \
export OPENROUTER_API_KEY=\$OPENROUTER_API_KEY && \
/home/dilip/qbridge-env/bin/python3 evaluations/run_benchmark.py \
--trials 3 --results evaluations/results/my_run"
The runner forces cudaq.set_target("nvidia"), performs a CUDA-Q sample GPU
probe before work begins, stores the actual target description for each V2
result, and checks both systems with the same classical feasibility/objective
verifier. It never converts an execution error into a successful result.
Token usage is captured for both systems: QBridge-Agent reads OpenRouter API
usage fields; Aider writes structured rows to AIDER_USAGE_LOG inside each
trial directory. Per-trial result.json files include usage, usage_totals,
and timings (llm_s / aider_llm_s, driver_s / compile_solve_s,
wall_s).
Raw artifacts for the 20 July 2026 runs are under
evaluations/results/20260720_t1_t2_gpu_fixed (verification) and
evaluations/results/20260720_token_tracking_fixed (token/timing capture).
OPENROUTER_API_KEY is required only for this external-model comparison; the
normal DSL compile/solve path is local. See evaluations/README.md for full
methodology and tables.
For maintainer release steps, see RELEASE.md.
Scope
Supported: small constrained binary optimization problems expressible in the current QBridge DSL. Unsupported quantum algorithms and arbitrary Python are errors, not guessed translations.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qbridge_agent-0.3.0.tar.gz.
File metadata
- Download URL: qbridge_agent-0.3.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6db166fc02ba0034b6caa032b5f6ccda1dd4c5b3ec347764bd1d2902a655981
|
|
| MD5 |
a6d14f598ac007083b6e5a89ce339a7a
|
|
| BLAKE2b-256 |
1e06e1a10b72a8d0d008f1540260986e349b849b03851da83234dbfbf3caf4d3
|
Provenance
The following attestation bundles were made for qbridge_agent-0.3.0.tar.gz:
Publisher:
publish.yml on ProfessionalQwerty/qbridge-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qbridge_agent-0.3.0.tar.gz -
Subject digest:
d6db166fc02ba0034b6caa032b5f6ccda1dd4c5b3ec347764bd1d2902a655981 - Sigstore transparency entry: 2206351769
- Sigstore integration time:
-
Permalink:
ProfessionalQwerty/qbridge-agent@d5dc23fb71fb4563dc576a73b56a0ea842aaeb4e -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ProfessionalQwerty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5dc23fb71fb4563dc576a73b56a0ea842aaeb4e -
Trigger Event:
push
-
Statement type:
File details
Details for the file qbridge_agent-0.3.0-py3-none-any.whl.
File metadata
- Download URL: qbridge_agent-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0015d9de3e9ba1e79a09509dcb336a3f1b2f2d9cf21d9ad4155a0bace8d26489
|
|
| MD5 |
e393a1f40b205b469f30809f37a67499
|
|
| BLAKE2b-256 |
4fe92efbe26011a072cfbe9d8a17d3df2c467e72a6de3848ae8446f69eb32f90
|
Provenance
The following attestation bundles were made for qbridge_agent-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on ProfessionalQwerty/qbridge-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qbridge_agent-0.3.0-py3-none-any.whl -
Subject digest:
0015d9de3e9ba1e79a09509dcb336a3f1b2f2d9cf21d9ad4155a0bace8d26489 - Sigstore transparency entry: 2206351787
- Sigstore integration time:
-
Permalink:
ProfessionalQwerty/qbridge-agent@d5dc23fb71fb4563dc576a73b56a0ea842aaeb4e -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/ProfessionalQwerty
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5dc23fb71fb4563dc576a73b56a0ea842aaeb4e -
Trigger Event:
push
-
Statement type: