IBM Quantum Qiskit Connector For Backend RuntimeService
Project description
qiskit-connector
⚛️Qiskit Connector for IBM Quantum Backends in Realtime
A Quantum helper package which streamlines authentication, plan detection, and backend selection for Qiskit RuntimeService. This connector prevents repeated writing of runtimeservice instead allows you to directly use the backend object all over your quantum code application in realtime. This package performs the following:
- Loads environment variables from config file (e.g.
.env) viapython-dotenvto configure your IBM Quantum account and make thebackendobject available in your quantum code for reuse in real-time. - Detects your active plan (Open, Standard, Premium, Dedicated) and sets up the correct channel/instance.
- Provides functions to save your account (
qiskit_save_connection), verify QPU resources (qpu_verify,is_verified), and retrieve a ready-to-use backend (connector()).
🐍 Package built and maintained by Dr. Jeffrey Chijioke-Uche, IBM Quantum Ambassador & Research Scientist.
📋 Features & API
All of the following functions are available after you import the module:
from qiskit_connector import (
connector,
plan_type,
qpu_verify,
is_verified
)
-
qiskit_save_connection(plan_type: str)
Saves your IBM Quantum account into QiskitRuntimeService using the environment variables for the given plan ("open","standard","premium", or"dedicated"). -
qpu_verify()
Lists available QPUs for your plan by queryingQiskitRuntimeService.backends()or falling back topaid_plans()for paid plans. -
is_verified()
Verifies real‐time least-busy QPU for the active plan and prints details (name, qubit count, online date). -
connector() -> IBMBackend
Main entry point: Loads your saved account, picks the least busy QPU (or first available for open or paid plans), prints diagnostics, and returns anIBMBackendinstance ready for circuit execution. -
plan_type() -> str
Returns either "Open Plan" or "Paid Plan" depending on your.envtoggles.
🔧 Installation
pip install qiskit-connector
This will also pull in:
qiskit>=2.0.0qiskit-ibm-runtime>=0.37.0python-dotenvrequests
and any other Qiskit dependencies.
🗂️ Environment (.env) Setup
⚠️ Security Practice: Do not CHECK-IN .env into version control. Add it to your .gitignore.
During development, create a file named .env at your project root. The connector will automatically load it:
# @author: Dr. Jeffrey Chijioke-Uche, IBM Quantum Ambassador & Researcher
# This file is used to store environment variables for the Qiskit installation wizard: Update it.
# The "ibm_quantum" channel option is deprecated and will be sunset on 1 July 2025.
# After this date, ibm_cloud will be the only valid channel.
# For information on migrating to the new IBM Quantum Platform on the "ibm_cloud" channel,
# review the migration guide https://quantum.cloud.ibm.com/docs/migration-guides/classic-iqp-to-cloud-iqp .
# GENERAL PURPOSE
#--------------------------------------------
IQP_API_TOKEN="<PROVIDE_YOUR_API_TOKEN>"
# Channels:
#------------------------------------------
OPEN_PLAN_CHANNEL="<PROVIDE_YOUR_CHANNEL>"
PAID_PLAN_CHANNEL="<PROVIDE PAID PLAN CHANNEL>" # After July 1, 2025, use ibm_cloud for Paid Plans.
# API Access:
#-------------------------------------
IQP_API_URL=<PROVIDE_YOUR_API_URL>
IQP_RUNTIME_API_URL=<PROVIDE_YOUR_RUNTIME_API_URL>
# Quantum Url:
# The API URL. Defaults to https://cloud.ibm.com (when channel=ibm_cloud)
# The API URL:Default to: https://auth.quantum.ibm.com/api (when channel=ibm_quantum)"
#-------------------------------------
CLOUD_API_URL=<PROVIDE_YOUR_CLOUD_API_URL>
QUANTUM_API_URL="<PROVIDE_YOUR_QUANTUM_API_URL>"
# Instance:
#-------------------------------------
OPEN_PLAN_INSTANCE="<PROVIDE_YOUR_OPEN_PLAN_INSTANCE>"
PAID_PLAN_INSTANCE="<PROVIDE_YOUR_PAID_PLAN_INSTANCE>"
# Default (Open plan) - free
#----------------------------------------
OPEN_PLAN_NAME="open"
# Optional (Upgrade) - Standard
#-----------------------------------------
STANDARD_PLAN_NAME="standard"
# Optional (Upgrade) - Premium
#-----------------------------------------
PREMIUM_PLAN_NAME="premium"
# Optional (Upgrade) - Dedicated
#-----------------------------------------
DEDICATED_PLAN_NAME="dedicated"
# Switch "on" one plan: Use one or the other at a time. You cannot switch both on at the same time.
#--------------------------------------------------------------------------------------------------
OPEN_PLAN="on" # [Default & switched on] This plan is free - Signup
STANDARD_PLAN="off" # This plan is paid. Switched "Off" by default - Turn it "on" after purchase.
PREMIUM_PLAN="off" # This plan is paid. Switched "Off" by default - Turn it "on" after purchase.
DEDICATED_PLAN="off" # This plan is paid. Switched "Off" by default - Turn it "on" after purchase.
⚠️ Only one of
OPEN_PLAN,STANDARD_PLAN,PREMIUM_PLAN, orDEDICATED_PLANmay be set to "on" at a time.
📖 Quickstart Examples
Open Plan (default free tier) and Paid Plan
from qiskit_connector import connector, plan_type
from qiskit_ibm_runtime import SamplerV2 as Sampler, Session
# QPU execution mode by plan: Use of 'backend' object.
current = plan_type()
backend = connector()
if current == "Open Plan": # session not supported
sampler = Sampler(mode=backend)
print("Your Plan",current)
print("Least Busy QPU:", backend.name)
if isinstance(backend, IBMBackend):
print("This is a real & live QPU device")
else:
print("This is a simulator")
print(f"\n")
elif current == "Paid Plan": # supports session
with Session(backend=backend.name) as session:
sampler = Sampler(mode=session)
print("Your Plan",current)
print("Least Busy QPU:", backend.name)
if isinstance(backend, IBMBackend):
print("This is a real & live QPU device")
else:
print("This is a simulator")
print(f"\n")
else:
raise ValueError(f"Unknown plan type: {current}")
# --- do other things below with backend, quantum circuit, sampler & transpilation ------
Sample Output
Authors and Citation
Qiskit Connector was inspired, authored and brought about by the research carried out by Dr. Jeffrey Chijioke-Uche(IBM Quantum Ambassador & Research Scientist). This software is expected to continues to grow with the help and work of existing research at different levels in the Information Technology industry. If you use Qiskit for Quantum, please cite as per the provided BibTeX file.
📜 Software Publisher
Dr. Jeffrey Chijioke-Uche, IBM Quantum Ambassador & Research Scientist (All Rights Reserved)
📜 License
This project uses the MIT License
Project details
Release history Release notifications | RSS feed
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 qiskit_connector-0.2.9.tar.gz.
File metadata
- Download URL: qiskit_connector-0.2.9.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7eab51e69e1e37485c7763004f7b6f99b64a7d1e8cf3252936c8d3d44e7a9d5
|
|
| MD5 |
9f68a736b3f21d2086f8b92c32252c97
|
|
| BLAKE2b-256 |
5c17f3d84c45b5604e5c2584d223c9dac0bd61594c6a7575e567ad63ba298a47
|
File details
Details for the file qiskit_connector-0.2.9-py3-none-any.whl.
File metadata
- Download URL: qiskit_connector-0.2.9-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae4ac747034e7cd3ac16432e9bc57229f0714fecdb678676847211f40991690
|
|
| MD5 |
e386a0855b81eb5e4101c4e242299943
|
|
| BLAKE2b-256 |
40403dfa9c5c9e71c4f73f2aca5bf3a0efa6e844b6a50f1487377064d02a5b91
|