Skip to main content

Quantum Computing Qiskit Connector For Quantum Backend Use In Realtime

Project description

Qiskit Connector

Python Qiskit Connector Quality Check DOI Qiskit Connector Code Coverage Analysis Qiskit Connector Latest Release PyPI Downloads License Monthly Downloads

🖥️ Qiskit Connector® - Seamless Real-Time Connector for IBM Quantum Computing QPU

Qiskit Connector® is quantum computing open-source SDK extension. The Qiskit Connector® transforms how quantum developers connect to IBM Quantum backends by automating every step of the authentication, plan detection, and backend selection process. Instead of writing extensive boilerplate setup code for each project, developers can now seamlessly authenticate, dynamically detect whether they are using an Open or Paid plan, and instantly access the optimal backend QPUresource which is least-busy using a single intuitive keyword: backend. The connector intelligently manages quantum computing plan environment variables and Qiskit runtime service configuration for sticky reusability of QPU resources from the backend, allowing quantum developers to streamline connection workflows and immediately focus on building, testing, and scaling quantum applications.

By eliminating manual configurations and connection complexities, Qiskit Connector empowers developers to reduce onboarding time, minimize human error, and accelerate quantum solution delivery. The tool is especially valuable for production-grade quantum development where agility, repeatability, and secure backend access are critical. Whether working in research environments, building enterprise-grade quantum solutions, or designing novel quantum algorithms, developers can now concentrate on high-value tasks without being slowed down by infrastructure setup challenges.

⚛️This package performs the following:

  • Loads environment variables from config file (e.g. .env if you are local) or load it remotely(depending on detection) 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 (qiskit_smart) to establish connectivity, then to verify QPU resources using (qpu_verify), and retrieve a ready-to-use backend using (connector()). Presents you with the least-busy backend QPU to run your quantum application code in realtime.
🧩 Software built by ©2025 Dr. Jeffrey Chijioke-Uche, IBM Computer Scientist & Quantum Ambassador.

📋 Built-in classes & functions

These functions are available after you import the module:

from qiskit_connector import QConnectorV2 as connector
from qiskit_connector import QPlanV2 as plan
  • connector()
    Primary Integration Point: Seamlessly initializes your IBM Quantum account, selects the optimal QPU (or the first available device for open/paid plans), and emits a clear diagnostics summary. It returns a fully configured backend object that you can immediately pass to Qiskit’s sampler, estimator, transpiler, or any circuit execution API—so you can focus on your quantum workflows rather than connection boilerplate.

  • plan()
    Subscription Plan Resolver: Automatically evaluates your environment configuration (via .env or system variables) to identify whether you’re operating under the Open Plan or a Paid Plan. This guarantees that your code consistently targets the correct IBM Quantum service tier, eliminating manual plan management and minimizing configuration drift.


📌 Changelog

Version Description Updated Import Syntax
<= v2.2.2 Initial import approach using functional-style interface for all versions equal or below v2.2.2 from qiskit_connector import connector, plan_type
>= v2.2.3 Switched to class-based architecture with aliasing for enhanced flexibility and clarity for all versions equal or above 2.2.3 from qiskit_connector import QConnectorV2 as connector
from qiskit_connector import QPlanV2 as plan

🔧 Installation

It is recommended that you use pip for installation - a common best practice.
pip install qiskit-connector

This will also pull in functionalities powered by Qiskit SDK:

  • qiskit>=2.0.0

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


🗂️ Variable Setup

🔐 Security Practices: Do not check-in to version control any environment variable config file or any variable setup file. The best security practice is to add it to your .gitignore or to accessible vault. During local development, create a file named .env at your project root and ensure it is named on your .gitignore. The connector will automatically load it. Use the template below as the content of your .env file or variable setup config file. Copy and paste it then supply the values.

# General Purpose:                                            (Required)
#--------------------------------------------------------------------------------------
IQP_API_TOKEN="<PROVIDE_YOUR_API_TOKEN>"  


# Channels:                                                   (Required)
#--------------------------------------------------------------------------------------
OPEN_PLAN_CHANNEL="<PROVIDE_YOUR_CHANNEL>"  
PAID_PLAN_CHANNEL="<PROVIDE PAID PLAN CHANNEL>"  


# API Url:                                                    (Optional)
#--------------------------------------------------------------------------------------
IQP_API_URL=<PROVIDE_YOUR_API_URL>  
IQP_RUNTIME_API_URL=<PROVIDE_YOUR_RUNTIME_API_URL>  


# Quantum Url:                                                (Optional)
#---------------------------------------------------------------------------------------
CLOUD_API_URL="<PROVIDE_YOUR_CLOUD_API_URL>" 
QUANTUM_API_URL="<PROVIDE_YOUR_QUANTUM_API_URL>"  


# Instance:                                                  (Required)
#---------------------------------------------------------------------------------------
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) - Pay as you go                             
#----------------------------------------------------------------------------------------
PAYGO_PLAN_NAME="pay-as-you-go"


# Optional (Upgrade) - Flex                              
#----------------------------------------------------------------------------------------
FLEX_PLAN_NAME="flex"


# Optional (Upgrade) - Premium                                
#----------------------------------------------------------------------------------------
PREMIUM_PLAN_NAME="premium"


# Optional (Upgrade) - Dedicated                               
#----------------------------------------------------------------------------------------
DEDICATED_PLAN_NAME="dedicated"


# Switch "on" plan:                                       (Required)
#----------------------------------------------------------------------------------------
OPEN_PLAN="on"        # [Default & switched on] [Free] 
PAYGO_PLAN="off"
FLEX_PLAN="off"      
PREMIUM_PLAN="off"      
DEDICATED_PLAN="off"    

⚠️ Only one of the plans can be set to "on" at a time.


👤 Usage - With Qiskit 2.x Code Sample

📦 For Open or Paid Plans
# After Pip install, Import Qiskit Connector:
from qiskit_connector import QConnectorV2 as connector
from qiskit_connector import QPlanV2 as plan

# Initialize Qiskit Connector::
current = plan()
backend = connector()

# ------------------------------ QISKIT 2.x CODE SAMPLE ---------------------------------------
#     This code sample is using the Qiskit Connector to run with a real quantum backend.
###############################################################################################
# 🔍 This code sample demonstrates how to create a randomized circuit with depolarizing noise
# ✅ QuantumCircuit(2, 2) — matches 2-qubit base circuit
# ✅ Applies independent random Pauli gates per qubit before and after the base logic
# ✅ Uses remove_final_measurements() to cleanly insert logic into the composed circuit
# ✅ Re-applies measurements after twirling to preserve expected output
################################################################################################
import random
import numpy as np
from qiskit import QuantumCircuit, transpile
from qiskit_ibm_runtime import SamplerV2 as Sampler, Session
from datetime import datetime
import time
from collections import Counter
from qiskit.visualization import circuit_drawer
from IPython.display import display, Markdown
from PIL import Image

# Pauli gates
paulis = ['I', 'X', 'Y', 'Z']
pauli_gates = {
    'I': lambda qc, q: None,
    'X': lambda qc, q: qc.x(q),
    'Y': lambda qc, q: qc.y(q),
    'Z': lambda qc, q: qc.z(q)
}

# Check if running on Jupyter Notebook
def in_jupyter():
    try:
        from IPython import get_ipython
        shell = get_ipython().__class__.__name__
        return shell in ('ZMQInteractiveShell',)  
    except Exception:
        return False
       
# 2-qubit base circuit
def base_circuit():
    qc = QuantumCircuit(2, 2)
    for q in range(2):
        qc.h(q)
        qc.rx(0.5, q)
        qc.rz(1.0, q)
        qc.s(q)
        qc.t(q)
        qc.h(q)
        qc.measure(q, q)
    return qc

#[C] Define randomized Pauli-wrapped circuit for depolarizing:
def randomize_circuit(base_qc, p):
    qc = QuantumCircuit(2, 2)

    for q in range(2):
        # [1] Random Pauli before::
        pauli_before = random.choice(paulis[1:]) if np.random.rand() < p else 'I'
        pauli_gates[pauli_before](qc, q)

    # [2] Append core logic (excluding original measurement)
    qc.compose(base_qc.remove_final_measurements(inplace=False), inplace=True)

    for q in range(2):
        # [3] Random Pauli after::
        pauli_after = random.choice(paulis[1:]) if np.random.rand() < p else 'I'
        pauli_gates[pauli_after](qc, q)

        # [4] Final measurement
        qc.measure(q, q)

    return qc

##################################
# Shots & Probability settings::  
###################################
shots = 1024  
p = 0.1 
qc = base_circuit()
circuits = [randomize_circuit(qc, p) for _ in range(shots)]

# # Randomized circuit:
render = "\n🔧 Randomized Circuit with Depolarizing Noise"
def platform():
    if in_jupyter():
        cir = circuits[0].draw(output="mpl")
        display(Markdown(render))
        display(cir)
    else:
        title = render
        circ = circuits[0].draw(output="text")
        print(f"\n{title}\n")
        print(circ)

##########################################################################
# This is a single job execution with Qiskit Connector initialized objects
##########################################################################
if current == "Open Plan":
    platform()
    sampler = Sampler(mode=backend)  # Session not allowed in Open Plan
    # Transpile all circuits for the backend
    circuits_t = [transpile(circ, backend=backend, optimization_level=3) for circ in circuits]
    job = sampler.run(circuits_t, shots=1)  # each circuit is run per-shot in real backend, to match Qiskit 2.x 
    print("Your Plan:", current)
    print("Least Busy QPU:", backend.name)
elif current == "Paid Plan":
    with Session(backend=backend.name) as session:
        platform()
        sampler = Sampler(mode=session) # Session is allowed in Paid Plan
        # Transpile all circuits for the backend
        circuits_t = [transpile(circ, backend=backend, optimization_level=3) for circ in circuits]
        job = sampler.run(circuits_t, shots=1)  # each circuit is run per-shot in real backend, to match Qiskit 2.x 
        print("Your Plan:", current)
        print("Least Busy QPU:", backend.name)
else:
    raise ValueError(f"Unknown plan type: {current}")

# Submit the job::
elapsed = 0
print()
try:
    print(f"-- REAL BACKEND JOB INFORMATION --")
    print(f"Assigned Backend QPU: {backend.name}")
    print(f"Number of circuits submitted to backend job: {len(circuits)}")
    print(f"Backend Job ID: {job.job_id()}")
    while not job.done():
        print(f"\r⏳ Job running... {elapsed} sec", end="", flush=True)
        time.sleep(1)
        elapsed += 1
except KeyboardInterrupt:
    print("\n⛔ Interrupted while waiting.")
    exit(0)
print("\r", end="", flush=True)

# Retrieve and aggregate measurement counts across all circuits:
result = job.result()
counts_total = Counter()
for pub0 in result:
    counts = pub0.data.c.get_counts()
    counts_total.update(counts)
print("______________________________________________________________________________")
print(f"✅ Job Result:")
print(dict(counts_total))

Output Sample

==================================================================================

   ____   ______                                  __
  / __ \ / ____/____   ____   ____   ___   _____ / /_ ____   _____
 / / / // /    / __ \ / __ \ / __ \ / _ \ / ___// __// __ \ / ___/
/ /_/ // /___ / /_/ // / / // / / //  __// /__ / /_ / /_/ // /
\___\_\____/ \____//_/ /_//_/ /_/ \___/ \___/ \__/ \____//_/

🧠 Qiskit Connector® for Quantum Backend Realtime Connection

⚛️ Connecting (Open Plan) to least-busy QPU...
----------------------------------------------------------------------------------
⚛️ Connected [Open Plan]  Realtime Least Busy QPU:: [ibm_sherbrooke]
- ibm_brisbane
- ibm_sherbrooke
- ibm_torino

🖥️ Least Busy QPU Now: [ibm_sherbrooke]
🖥️ Version: 2
🖥️ Qubits Count: 127
🖥️ Backend [ibm_sherbrooke] ready for use: ✔️ Yes
🖥️ Operational: Open Plan
==================================================================================

⚛️ Getting (Open Plan) Least-busy QPU Processor Info...
----------------------------------------------------------------------------------

--- 🔳  Processor Details for QConnector Least Busy Backend QPU: ibm_sherbrooke ---
🦾 Processor Type: Eagle
🦾 Processor Revision: r3
🦾 Processor status: 🟢 Online
       ..
     :=-+
     +. :=:-:
     #. :*-.-=
     : .*.   ++
        :   :*+=
            +##++
           :*##*++.
          :.*###*++
           --*###*+*
           .+:####*+
           .+-:**#+
           -  .:**#
                -##
                 :=
       
       Eagle Quantum Processor
==================================================================================
🔧 Randomized Circuit with Depolarizing Noise

     ┌───┐┌─────────┐ ┌───────┐   ┌───┐  ┌───┐┌───┐     ┌─┐
q_0:  H ├┤ Rx(0.5) ├─┤ Rz(1) ├───┤ S ├──┤ T ├┤ H ├─────┤M├────────
     ├───┤└──┬───┬──┘┌┴───────┴┐┌─┴───┴─┐├───┤├───┤┌───┐└╥┘┌───┐┌─┐
q_1:  X ├───┤ H ├───┤ Rx(0.5) ├┤ Rz(1) ├┤ S ├┤ T ├┤ H ├─╫─┤ Y ├┤M
     └───┘   └───┘   └─────────┘└───────┘└───┘└───┘└───┘  └───┘└╥┘
c: 2/════════════════════════════════════════════════════╩═══════╩═
                                                         0       1
Your Plan: Open Plan
Least Busy QPU: ibm_sherbrooke

-- REAL BACKEND JOB INFORMATION --
Assigned Backend QPU: ibm_sherbrooke
Number of circuits submitted to backend job: 1024
Backend Job ID: d14vu4u1plcs739qs6ng
______________________________________________________________________________
Job Result:
{'11': 787, '00': 13, '01': 102, '10': 122}

📜 Citation

Qiskit Connector software invention was inspired by IBM Research on Quantum Computing Qiskit Software, which led the authoring, design, development of Qiskit Connector based on the persistent research studies and tests carried out by Dr. Jeffrey Chijioke-Uche(IBM Quantum Ambassador & Research Scientist) in the lab. This software is expected to continue to metamorphose with the help and work of existing quantum computing academic scholarly & peer reviewed research at different levels in the Information Technology industry. If you use Qiskit for Quantum computing, please cite this software as per the provided BibTeX file. Also, citation is available in the following formats: Harvard, APA, MLA, IEEE, Chicago, & Vancouver


📜 Software Author

Dr. Jeffrey Chijioke-Uche
IBM Computer Scientist
IBM Quantum Ambassador & Research Scientist
IEEE Senior Member (Computational Intelligence)


📜 Rights

The Quantum Computing Qiskit Connector is copyrighted and it is a proprietary software developed by Dr. Jeffrey Chijioke-Uche ©2025 - All Rights Reserved. The software is for enhancing development, usability, and workflows in IBM Quantum Computing systems by global users. This software is protected under copyright laws and applicable intellectual property statutes. Unauthorized reproduction, distribution, or derivative use of the software in part or whole is strictly prohibited without express written permission from the author. This software may be used under the terms outlined in the accompanying licenses by (Apache 2.0 and Creative Commons Attribution 4.0 international). Use of this software signifies your agreement to comply with the license terms and to attribute the original author when incorporating the package into your work or systems. For other question(s), please contact the maintainer directly through the official project repository or email channel provided on PyPI. All Rights Reserved.


📜 Acknowledgment

The development of the Qiskit Connector has been made possible through the support, inspiration, and technical contributions of several leading institutions and communities. The software author would like to express deep gratitude to IBM Research & IBM Quantum Ambassadors Group for the pioneering efforts in quantum computing and providing the infrastructure and ecosystem that fostered the development of this software. Their continued support has significantly accelerated progress in real-world quantum computing and quantum application development for cutting edge technology advancement.

Additional appreciation is extended to the IEEE Computational Intelligence Society for their thought leadership in intelligent systems, and to the Harvard Program for Research in Science and Engineering for its role in shaping early research directions. The author also acknowledges Walden University Research for providing a strong academic and methodological foundation throughout the software development lifecycle. These institutions have collectively influenced the innovation and rigor reflected in this project.


📜 Licenses

This software uses these licenses for distribution:

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.3.1.tar.gz (44.9 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.3.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qiskit_connector-2.3.1.tar.gz
  • Upload date:
  • Size: 44.9 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.3.1.tar.gz
Algorithm Hash digest
SHA256 74ce2c2d405e50b6a738c7fbe618a06cfe4f900a6048259df3cdce986a9e4907
MD5 e87a35788fd6ed7278ae4124af6a7bc0
BLAKE2b-256 56110003130ee2619a7d24617072161d47e545115f3f2b4f0603706cd797c62f

See more details on using hashes here.

Provenance

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

Publisher: workflow.yml on QComputingSoftware/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.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for qiskit_connector-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a813a1a1f15790f28479d42d536b892e62bcb8ca6e6ab3beea4b19f7079b1fb
MD5 ec5dfa2dbe211f5e007dd859679ae72b
BLAKE2b-256 8bebd0bba4b0812e6c7c2e65a2c6b7fe35cd89f8ebfe74f227d8ee0f742c4c80

See more details on using hashes here.

Provenance

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

Publisher: workflow.yml on QComputingSoftware/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