IBM Quantum load balancer for optimizing instance allocations
Project description
qauvern — IBM Quantum Load Balancer
A Python CLI tool for optimizing quantum instance allocations across projects to maximize utilization of IBM Quantum resources.
Overview
qauvern helps administrators manage quantum computing allocations efficiently by:
- Analyzing current instance usage and allocations
- Identifying underutilized instances
- Recommending optimal allocation adjustments
- Automatically applying optimizations to maximize resource utilization
Key Concepts
- QAU (Quantum Allocation Unit): 1 QAU = 1600 minutes of quantum computing time
- Rolling Window: 28-day backward-looking usage period
- Fairness: Ratio of consumed time to allocated time (lower fairness = higher priority)
- Allocation: Target consumption for an instance during the rolling window
- Limit: Hard cap on instance consumption
- Net Grant: Temporary time bonus above the base limit, active for a 28-day window. The effective limit decays as pre-grant usage rolls out of the window.
Installation
There are two ways to install qauvern:
- Pex — a single self-contained file you can download and run directly. No virtual environment or dependency management needed; just Python 3.10+ on your system. Best if you want to get running quickly or avoid modifying your Python environment. (What is Pex?)
- pip — a standard install from source into a virtual environment. Best if you want to pin a version in a requirements file or integrate with an existing Python workflow.
Option 1: Pex (single-file executable)
Download qauvern.pex from the GitHub Releases page. The Pex file only requires Python 3.10+ on your macOS or Linux system — no pip or virtual environment needed.
chmod +x qauvern.pex
./qauvern.pex --help
You can also build the Pex yourself if you have the repo cloned and Just installed (see CONTRIBUTING.md):
just pex
./dist/qauvern.pex --help
Option 2: pip install
Install "qauvern" into a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
pip install qauvern
The qauvern CLI is available while the virtual environment is active:
qauvern --help
Configuration
Create a YAML configuration file defining your account, projects, and instances:
# config.yaml
account_id: "your-ibm-cloud-account-id"
plan_id: "91b2c828-2952-4f05-aed8-bedf92c6c480" # Standard plan
# Minimum allocation to maintain for each instance (optional, default: 60 seconds)
minimum_allocation_seconds: 60
# Hold back a percentage of account allocation from rebalancing (optional, default: 0)
# allocation_reserve_percent: 20
balance_period:
start_date: "2026-01-01T00:00:00"
end_date: "2026-12-31T23:59:59"
projects:
- name: "Quantum Chemistry Research"
crn: "crn:v1:bluemix:public:quantum-computing:us-east:a/abc123:instance-1::"
target_usage_seconds: 108000 # 30 hours (0.625 QAU) — optional
# Optional: Hard limit applied on every optimize run
# project_limit_seconds: 216000
# Optional: Temporary time bonus above project_limit_seconds.
# end_date is optional; defaults to start_date + 28 days if omitted.
# net_grants:
# - start_date: "2026-05-01T00:00:00"
# net_grant_seconds: 360000 # 100 extra hours for a May sprint
# - start_date: "2026-06-15T00:00:00"
# end_date: "2026-07-31T00:00:00"
# net_grant_seconds: 180000
- name: "Quantum Machine Learning"
crn: "crn:v1:bluemix:public:quantum-computing:us-east:a/abc123:instance-2::"
# No target_usage_seconds — allocation optimized between minimum and limit
project_limit_seconds: 72000
See examples/config-example.yaml for a complete example.
Usage
Authentication
The tool uses IBM Cloud IAM for authentication. Set your IBM Cloud API key as an environment variable:
export IBMCLOUD_API_KEY="your-ibm-cloud-api-key"
Or pass it directly with the --api-key flag to any command.
Obtaining an IBM Cloud API Key
- Log in to IBM Cloud
- Go to Manage > Access (IAM) > API keys
- Click Create an IBM Cloud API key
- Give it a name and description
- Copy the API key (you won't be able to see it again)
Commands
Configure (Generate Configuration)
Generate a base configuration file from an existing IBM Cloud account:
qauvern configure --account-id your-account-id --output config.yaml
This command will:
- Connect to the IBM Quantum API
- List all instances in the specified account
- Generate a base YAML configuration file with one project per instance
- Display a summary of found instances
Options:
--account-id, -a: IBM Cloud account ID (required)--api-key, -k: IBM Cloud API key (or useIBMCLOUD_API_KEYenv var)--output, -o: Output file path (default:config.yaml)--balance-start: Balance period start date (ISO format)--balance-end: Balance period end date (ISO format)
After generating the configuration, edit the file to set appropriate project names. Optionally set target_usage_seconds to enable balance-period tracking and exhaustion behavior; when omitted, allocation is optimized between minimum_allocation_seconds and project_limit_seconds.
Show Current Allocations
Display a summary of account and instance allocations:
qauvern show --config config.yaml
Output includes:
- Account summary (total allocation, consumption, utilization)
- Instance details with fairness values
Instances (Non-Admin View)
Display instance usage summary without requiring admin privileges:
qauvern instances --config config.yaml
This command only queries instance-level data and does not require account admin privileges, unlike the show command which accesses account-level allocation information.
Analyze Allocations
Analyze current allocations and show optimization recommendations without making changes:
qauvern analyze --config config.yaml
This command identifies underutilized instances, calculates optimal reallocations, and shows what changes would be made. The output includes a Cur Limit column (the live API value) and a New Limit column (what the optimizer would set). A (+grant) annotation indicates an active net grant is boosting the limit; ! indicates the instance is in debt.
Optimize Allocations
Apply optimization recommendations to update instance allocations:
qauvern optimize --config config.yaml
qauvern optimize --config config.yaml --dry-run # preview only
qauvern optimize --config config.yaml --yes # skip confirmation (for automation)
This command will:
- Confirm you want to proceed (bypass with
--yes) - Calculate optimal allocations
- Display proposed changes
- Apply allocation and limit updates via API
Use --dry-run to compute and display changes without applying them.
Create Instance
Provision a new IBM Quantum service instance:
qauvern create my-instance \
--target us-east \
--resource-group your-resource-group-id \
--plan internal
Options:
NAME(positional, required): Name for the new instance--target, -t: Deployment region (required, e.g.,us-east,eu-de)--resource-group, -g: IBM Cloud resource group ID (required)--plan, -p: Plan name (internal,premium,paygo) or plan UUID (required)--allocation, -a: Initial allocation (e.g.,96000,10h,2.5d,1qau)--limit, -l: Instance limit, set after creation (e.g.,10h,1qau)--tag: Tags to apply (repeatable)
Staging Environment
To target the IBM Quantum staging environment (test.cloud.ibm.com) instead of production, use the --staging flag or set the IBMCLOUD_STAGING environment variable:
qauvern --staging analyze --config config-staging.yaml
# or
export IBMCLOUD_STAGING=True
The --staging flag is a global option and applies to all commands.
How It Works
Optimization Algorithm
- Classify instances as active or inactive based on recent consumption
- Reclaim allocation from inactive instances (down to the configured minimum)
- Redistribute freed allocation to active instances weighted by fairness
- Enforce limits using
project_limit_secondsand any activenet_grants
The optimizer targets low fairness values (< 0.5) to ensure instances receive scheduling priority from IBM Quantum's fair-share system. See the net_grants field in Configuration for details on how grant rolloff works.
Examples
Basic Workflow
# 1. Generate initial configuration from your account
qauvern configure --account-id your-account-id --output config.yaml
# 2. Edit config.yaml to organize instances into projects
# 3. Check current status
qauvern show --config config.yaml
# 4. Analyze and see recommendations
qauvern analyze --config config.yaml
# 5. Apply optimizations
qauvern optimize --config config.yaml
Continuous Optimization
Run the optimizer periodically (e.g., weekly) to maintain optimal allocations:
# Add to crontab for weekly optimization
0 0 * * 0 qauvern optimize --config /path/to/config.yaml --yes
Contributing
See CONTRIBUTING.md for development setup, running tests, and submitting changes.
For background on the IBM Quantum APIs that qauvern interacts with, see the IBM Quantum API docs.
For questions or bug reports, open an issue.
License
Apache License 2.0
Releasing
Releases are automated via GitHub Actions. To release a new version:
- Bump
versioninpyproject.toml(semver:X.Y.Z) - Add a
## [X.Y.Z]section toCHANGELOG.md - Merge to
main
The workflow validates the version, runs the test suite across Python 3.10–3.14, builds and publishes to PyPI, then creates a GitHub Release with a git tag.
Changelog
See CHANGELOG.md for version history and changes.
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 qauvern-0.2.3.tar.gz.
File metadata
- Download URL: qauvern-0.2.3.tar.gz
- Upload date:
- Size: 97.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209cd8fe81f96db6573a89444f273709025809ab1b23964cbc11889806155066
|
|
| MD5 |
b349e60766079c3570dbf784246a49c3
|
|
| BLAKE2b-256 |
4582c54aa0393dc24937c3a2b4ad4c47aa2dfec4d335801fefe2f5894f2d3817
|
Provenance
The following attestation bundles were made for qauvern-0.2.3.tar.gz:
Publisher:
release.yml on IBM/qauvern
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qauvern-0.2.3.tar.gz -
Subject digest:
209cd8fe81f96db6573a89444f273709025809ab1b23964cbc11889806155066 - Sigstore transparency entry: 1550142135
- Sigstore integration time:
-
Permalink:
IBM/qauvern@f37c3becc284a9b4f39b3a4b8a4a862a524ab03a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f37c3becc284a9b4f39b3a4b8a4a862a524ab03a -
Trigger Event:
push
-
Statement type:
File details
Details for the file qauvern-0.2.3-py3-none-any.whl.
File metadata
- Download URL: qauvern-0.2.3-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c47b50d3975cb102f93d1027964be0afe57f075addb1af41740699ac20535d0
|
|
| MD5 |
b41daf38c1323ec2ed61771bc9e93dd2
|
|
| BLAKE2b-256 |
7b079af0a1be4eed5e311502d5e374380f0117f0945a4028360f12de7442dd55
|
Provenance
The following attestation bundles were made for qauvern-0.2.3-py3-none-any.whl:
Publisher:
release.yml on IBM/qauvern
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qauvern-0.2.3-py3-none-any.whl -
Subject digest:
8c47b50d3975cb102f93d1027964be0afe57f075addb1af41740699ac20535d0 - Sigstore transparency entry: 1550142171
- Sigstore integration time:
-
Permalink:
IBM/qauvern@f37c3becc284a9b4f39b3a4b8a4a862a524ab03a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/IBM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f37c3becc284a9b4f39b3a4b8a4a862a524ab03a -
Trigger Event:
push
-
Statement type: