Skip to main content

Cqlib adapter

Project description

Cqlib Adapter

Installation

Install the package using pip:

pip install cqlib-adapter

1. Qiskit Ext

This project provides a Qiskit adapter for the TianYan quantum computing platform. It includes custom quantum gates and integrates with the TianYan backend to enable seamless execution of quantum circuits.

Features

  • Custom Quantum Gates: Adds custom gates like X2P, X2M, Y2P, Y2M, XY2P, and XY2M to Qiskit.
  • TianYan Backend Integration: Supports execution of quantum circuits on TianYan quantum computers and simulators.
  • Transpilation: Automatically transpiles Qiskit circuits to be compatible with TianYan backends.

QCIS Gates

QCIS Instruction Manual

The following QCIS gates are added to Qiskit:

  • X2P: Positive X rotation by π/2.
  • X2M: Negative X rotation by π/2.
  • Y2P: Positive Y rotation by π/2.
  • Y2M: Negative Y rotation by π/2.
  • XY2P: Positive XY rotation by a parameterized angle.
  • XY2M: Negative XY rotation by a parameterized angle.

Usage Example

Log in to the TianYan Lab, retrieve your Connection Key from the Dashboard page, and replace your_token in the code below.

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit_ext import X2PGate

# Create a quantum circuit
qs = QuantumRegister(2)
cs = ClassicalRegister(2)
circuit = QuantumCircuit(qs, cs)
circuit.x(qs[1])
circuit.h(qs[0])
circuit.cx(qs[0], qs[1])
circuit.append(X2PGate(), [qs[0]])
circuit.barrier(qs)
circuit.measure(qs, cs)

circuit.draw()

Circuit Text Diagram:

      ┌───┐     ┌─────┐ ░ ┌─┐   
q0_0: ┤ H ├──■──┤ X2p ├─░─┤M├───
      ├───┤┌─┴─┐└─────┘ ░ └╥┘┌─┐
q0_1: ┤ X ├┤ X ├────────░──╫─┤M├
      └───┘└───┘        ░  ║ └╥┘
c0: 2/═════════════════════╩══╩═
                           0  1 

1. Backend mode

from cqlib_adapter.qiskit_ext import TianYanProvider

# Initialize the TianYan provider
provider = TianYanProvider(token='your_token')

# Retrieve a specific backend (e.g., 'tianyan176-2')
backend = provider.backend('tianyan176-2')

# Run the circuit on the backend
job = backend.run([circuit], shots=3000)

# Retrieve and print the results
print(f'Job ID: {job.job_id()}')
print(f'Job Result: {job.result().get_counts()}')

2. Sampler mode

from cqlib_adapter.qiskit_ext import TianYanProvider, TianYanSampler

# Initialize the TianYan provider
provider = TianYanProvider(token='your_token')

# Retrieve a specific backend (e.g., 'tianyan24')
backend = provider.backend('tianyan24')

# Run the circuit on the backend
job = TianYanSampler(backend=backend).run([circuit], shots=3000)

# Retrieve and print the results
print(f'Job ID: {job.job_id()}')
print(f'Job Result: {job.result()}')
# c0 is the default register name
# cs = ClassicalRegister(2)
print(f'Counts: {job.result()[0].data.c0.get_counts()}')

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

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

cqlib_adapter-0.2.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

cqlib_adapter-0.2.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file cqlib_adapter-0.2.0.tar.gz.

File metadata

  • Download URL: cqlib_adapter-0.2.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for cqlib_adapter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 344961539517016b7a2d22dbcb36eb581e981228665052cbe4910556eda0d476
MD5 47a52c6e831b04cef41b6641afc02976
BLAKE2b-256 ce332a6089bd56e90cf5291943152df0e13a9ce2bada9caa152023d9d214a785

See more details on using hashes here.

File details

Details for the file cqlib_adapter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cqlib_adapter-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for cqlib_adapter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8faa363c518eb046826e2d82504144c0b0d0cdb8378294826a8b4ef3fab3a2
MD5 07ae4f3ae576bdaae05e1975f92e2074
BLAKE2b-256 2cc85052f61b1d58ed79ab6269ec975fb881c007f535fef30c61f697ac1f9404

See more details on using hashes here.

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