Python client for the Qly quantum computing platform — submit circuits to real quantum hardware and poll for results.
Project description
qly-sdk
Python client for Qly, a quantum computing platform. Write a circuit in OpenQASM or Qiskit, submit it to real quantum hardware (IBM, IonQ, AWS Braket, Quantinuum, Azure) or a simulator, and pull the results back.
pip install qly-sdk
The PyPI name is qly-sdk; everything else is just qly — you import qly
and the CLI command is qly.
Getting a key
Sign in at qly.app, open API Keys (/settings/api-keys),
and create one. You'll see the secret once — it looks like qly_live_…. Jobs you
run with the key are billed to your account's prepaid balance, which you top up
on the billing page.
Quickstart
from qly import Qly
client = Qly(api_key="qly_live_...") # or set QLY_API_KEY in your environment
bell = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
"""
job = client.run(bell, provider="ibm", device="ibm_kingston", shots=1024)
print(job.counts) # {'00': 503, '11': 521}
run() submits and blocks until the job finishes. If you'd rather not block,
use submit() and poll yourself.
Command line
The package installs a qly command, so you can work from a shell without
writing any Python:
qly configure # paste your key once; stored in ~/.config/qly/
qly devices # what can I run on?
qly balance
qly submit bell.qasm --provider ionq --device simulator --shots 1024 --wait
qly jobs --limit 10 # recent jobs
qly job <job-id> # status + measurement histogram
submit --wait polls until the job finishes and prints the counts. Every
command takes --json for machine-readable output, and --api-key /
QLY_API_KEY override the stored key (useful in CI).
Submitting and polling separately
job = client.submit(bell, provider="ibm", device="ibm_kingston", shots=1024)
print(job.id, job.status) # 'd4a…', 'PENDING'
job = client.wait(job) # blocks until terminal, raises on failure
print(job.counts)
# or poll by hand:
job = client.get_job(job.id)
if job.done:
print(job.results)
From a Qiskit circuit
Install the extra (pip install "qly-sdk[qiskit]") and pass the circuit directly:
from qiskit import QuantumCircuit
from qly import Qly
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
client = Qly()
job = client.run(circuit=qc, provider="ionq", device="simulator", shots=512)
print(job.counts)
Listing devices and checking balance
for d in client.devices():
print(d.provider, d.id, d.qubits, "sim" if d.is_simulator else "qpu")
print(client.balance().formatted) # '$12.40'
Estimator (expectation values)
For IBM, you can ask for Pauli expectation values instead of shot counts:
job = client.run(
ansatz_qasm,
provider="ibm",
device="ibm_kingston",
primitive="estimator",
observables=["ZZ", "IZ", "ZI"],
shots=4096,
)
print(job.results) # {'evs': [...], 'stds': [...]}
Errors
| Exception | When |
|---|---|
AuthenticationError |
missing / invalid / revoked key |
InsufficientBalanceError |
not enough credit; .estimated_cents, .balance_cents |
RateLimitError |
too many submissions; .retry_after |
JobFailedError |
job ended FAILED/ERROR/CANCELLED; .job for detail |
JobTimeoutError |
run()/wait() timed out |
APIError |
anything else; .status_code, .payload |
from qly import InsufficientBalanceError
try:
client.run(circuit, provider="ibm", device="ibm_kingston")
except InsufficientBalanceError as e:
print(f"Need ~{e.estimated_cents}¢, have {e.balance_cents}¢")
Configuration
| Argument | Env var | Default |
|---|---|---|
api_key |
QLY_API_KEY |
— (required) |
base_url |
QLY_BASE_URL |
https://qly.app |
License
MIT
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 qly_sdk-0.2.0.tar.gz.
File metadata
- Download URL: qly_sdk-0.2.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c00d1c74cd7a21db982981ae91063f13039dcf0659907df1263279fe297c54c
|
|
| MD5 |
eb9d1e28ac594623a59b5a8941f65949
|
|
| BLAKE2b-256 |
7f7c419b4d3c1218c93a79e7d68c9226861ad7398ab78906b677d6a3255a5d93
|
File details
Details for the file qly_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: qly_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8163cd70aa3966f99b9b5285449a2e2b11cfdfc83f4ef224d34e948ac9f63a20
|
|
| MD5 |
04885baff42e842ad7c69394a6d37b39
|
|
| BLAKE2b-256 |
81f54f7b62bd9cac4a60b11bf38f3bf3a59064b1c6a5df88c2d92707c21375b7
|