Skip to main content

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.

QBridge-Agent CLI compiling a QBridge DSL file locally

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

qbridge_agent-0.3.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qbridge_agent-0.3.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

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

Hashes for qbridge_agent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d6db166fc02ba0034b6caa032b5f6ccda1dd4c5b3ec347764bd1d2902a655981
MD5 a6d14f598ac007083b6e5a89ce339a7a
BLAKE2b-256 1e06e1a10b72a8d0d008f1540260986e349b849b03851da83234dbfbf3caf4d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qbridge_agent-0.3.0.tar.gz:

Publisher: publish.yml on ProfessionalQwerty/qbridge-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for qbridge_agent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0015d9de3e9ba1e79a09509dcb336a3f1b2f2d9cf21d9ad4155a0bace8d26489
MD5 e393a1f40b205b469f30809f37a67499
BLAKE2b-256 4fe92efbe26011a072cfbe9d8a17d3df2c467e72a6de3848ae8446f69eb32f90

See more details on using hashes here.

Provenance

The following attestation bundles were made for qbridge_agent-0.3.0-py3-none-any.whl:

Publisher: publish.yml on ProfessionalQwerty/qbridge-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page