Skip to main content

IBM Quantum Qiskit Connector For Backend RuntimeService

Project description

qiskit-connector

Qiskit Python Version Compatibility - v3.8, v3.9, v3.10, v3.11 Qiskit Connector Quality Check

⚛️IBM Quantum Qiskit Connector For Backend RuntimeService

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 application code in realtime. This package performs the following:

  • Loads environment variables from config file (e.g. .env) to configure your IBM Quantum account plan and make the backend object available within your quantum application code for reuse in real-time.
  • Detects your active plan (Open, Standard, Premium, Dedicated) and sets up the correct channel/instance.
  • It has functions to save your account using its (qiskit_smart), to verify QPU resources using (qpu_verify, is_verified), and retrieve a ready-to-use backend using (connector()). Presents you with the least-busy backend to run your quantum application code in realtime instead of you using simulators.
🐍 Software 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
)
  • qiskit_smart(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 querying QiskitRuntimeService.backends() or falling back to paid_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 an IBMBackend instance ready for circuit execution.

  • plan_type() -> str
    Returns either "Open Plan" or "Paid Plan" depending on your .env toggles.


🔧 Installation

pip install qiskit-connector

This will also pull in functionalities powered by:

  • qiskit>=2.0.0

and any other Qiskit dependencies. (Qiskit 1.x is not supported).


🗂️ Environment Variable Setup

🔐 Security Practice: Do not check-in .env or any environment variable files 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.Use the template below as the content of your .env file or variable config file.

# @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, or DEDICATED_PLAN may be set to "on" at a time.


📖 Usage

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

[] Quantum environment variables loaded successfully!

--------------------------------------------------------------------------------
[] Connected [Open Plan] -> Realtime Least Busy QPU: ibm_torino
--------------------------------------------------------------------------------

Available QPUs (Open Plan):
  - ibm_brisbane
  - ibm_sherbrooke
  - ibm_torino

Default QPU:     ibm_torino
Qubit Version:   2
Number Qubits:   133

--------------------------------------------------------------------------------

Your Plan:       Open Plan
Least Busy QPU:  ibm_torino
This is a real & live QPU device

#-------- remaining code below ------

IBM Quantum


📜 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 Computer Scientist
IBM Quantum Ambassador & Research Scientist
IEEE Senior Member (Computational Intelligence)


📜 License

This project uses the MIT License

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

qiskit_connector-2.0.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.

qiskit_connector-2.0.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file qiskit_connector-2.0.0.tar.gz.

File metadata

  • Download URL: qiskit_connector-2.0.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for qiskit_connector-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1289c7dd0d54d5d6c3a4c2ba1dbbeb2d9c613859d27b9377b6b9ea8b73397747
MD5 507095267ed7a81beecfc54009e5e376
BLAKE2b-256 c94bfff48dd646897c0ee1f8a52548ea31a764d7777f2b3bac80d1211b308baf

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_connector-2.0.0.tar.gz:

Publisher: workflow.yml on schijioke-uche/qiskit-connector

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

File details

Details for the file qiskit_connector-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for qiskit_connector-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4fa6da3cbd986922cdc42566d9a88bb2fd24a98e48608128474e4966cd1d14a1
MD5 2a4314187e9cd4b2cfb158be6011cfa3
BLAKE2b-256 bd194db0f1aee0f49ae1f185fc6cc96505dcfab530f2271ba5ea69367c09a938

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_connector-2.0.0-py3-none-any.whl:

Publisher: workflow.yml on schijioke-uche/qiskit-connector

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