Skip to main content

dqpu

CI Status Contract CI Status PyPI - Version License: Apache 2.0 Downloads

A Web3-Powered (Near), Decentralized Quantum Simulator with Verifiable Computation.

DQPU (Decentralized Quantum Processing Unit) introduces a novel, decentralized approach to quantum computing that leverages the power of blockchain and smart contracts. It addresses the challenge of securely and reliably delegating the execution of quantum computations in a trustless and transparent manner, encouraging competition between independent quantum resource providers.

Workflow

The DQPU system is composed of 3 actors:

  • Clients: users who need to perform a quantum sampling paying a reward
  • Verifiers: delegates who check for data validity and detect cheating users; they receive a reward for checking quantum sampling result validity
  • Samplers: users who run quantum samplers (either simulator or real quantum computers) and receive a reward for doing sampling

The following process outlines how clients can submit quantum circuits for sampling using the DQPU contract:

  1. Client Submits Job: A Client sends a quantum circuit along with a reward to the DQPU smart contract. The circuit data is uploaded to a distributed file storage system like IPFS. The smart contract adds the job to a queue in a 'pending-validation' state with the associated reward.

  2. Verifier Validates Circuit: A Verifier1 validates the submitted circuit. This might involve checks for syntax errors or ensuring the circuit is within allowed parameters. The verifier also adds special verification elements (traps) into the circuit and add the new circuit to the contract2. Once validated, the job moves to a 'waiting' state, becomes 'invalid' otherwise.

  3. Simulation or Hardware Execution: A Sampler retrieves a job from the waiting list. It then either simulates the circuit on a software program or executes it on real quantum hardware, depending on the job requirements and available resources. The simulation or execution result is submitted back to the smart contract with a security deposit (a percentage of the reward). The job status changes to 'validating'.

  4. Verifier Checks Result: The same Verifier from step 2 examines the returned result. The Verifier specifically checks the traps inserted earlier to ensure the result hasn't been tampered with. If the trap verification succeeds, the job status is updated to 'executed' and the trap is disclosed by the Verifier. The Sampler account receives the reward, while the Verifier receives a percentage of this reward. If the trap verification fails, the job returns in 'waiting' state (and the Verifier receives the security deposit of the Sampler).

  5. Client Receives Result: Once the job is marked as 'executed', the Client can retrieve the final result from the smart contract.

Smart Contract Web UI

A web interface showing the smart contract status is available here: https://dqpu.io/app

Installation

pip install dqpu

Or install the latest development version:

git clone https://github.com/dakk/dqpu
cd dqpu
python setup.py install

Install IPFS:

Usage: simulating a quantum circuit

The workflow described before is hidden to the final user: DQPU can be used seamleassy as any other quantum backend as any other quantum sampler. Currently DQPU implements a qiskit wrapper, a low level library for accessing the system primitives and a cli tool.

Qiskit example

import time
import qiskit
from qiskit.providers.jobstatus import JobStatus 
from dqpu.backends.qiskit import DQPUBackend

# Create a quantum circuit
qc = qiskit.QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

# Inizialize the DQPU backend and load the account
backend = DQPUBackend()
backend.load_account("dqpu_alice.testnet")

# Run the sampling
circ = transpile(qc, backend)
job = backend.run(circ, shots=1024)

# Wait for the job
while job.status() is JobStatus.RUNNING:
    print(f'Job {job.job_id()} is still running, please wait')
    time.sleep(1)

# Get the result
counts = job.result().get_counts(circ)
print(counts)

Low-level example

import time
from dqpu.blockchain import NearBlockchain, IPFSGateway
from dqpu.backends.base import submit_job, job_status, job_result

# Load account and initialize ipfs
nb = NearBlockchain('dqpu_alice.testnet')
ipfs = IPFSGateway()  # noqa: F841

f = open('test.qasm', 'r')
qasm_data = f.read()
jid = submit_job(nb, ipfs, qasm_data)
  
while job_status(nb, jid) != 'executed':
  print(f'Job {job.job_id()} is still running, please wait')
  time.sleep(1)

counts = job_result(nb, ipfs, jid)
print(counts)

Cli tool usage

Read dqpu.io/docs/cli for details.

Usage: running a sampler / verifier node node

Read dqpu.io/nodes for details.

Contributing

Read CONTRIBUTING for details.

License

This software is licensed with Apache License 2.0.

Cite

@software{dqpu2024,
  author = {Davide Gessa},
  title = {dqpu: A Web3-Powered, Decentralized Quantum Simulator with Verifiable Computation },
  url = {https://github.com/dakk/dqpu},
  year = {2024},
}

About the author

Davide Gessa (dakk)

  1. In this first version of the contract, Verifiers are trusted entities designated by the smart contract creator. ↩

  2. This step will become private in future versions of the protocol. ↩

Metadata

Release files for dqpu 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dqpu 0.2.7
File Size Uploaded Provenance Actions
dqpu-0.2.7.tar.gz 28.9 kB Without provenance Details for dqpu-0.2.7.tar.gz

Release files / dqpu-0.2.7.tar.gz

Download URL dqpu-0.2.7.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
891306e05b8cfd5db4343856df80514ae014fe2b33f2662655e8785905afc67a
BLAKE2b-256 checksum
How to use checksums
aae272c88f23c8a0a0bc2d35c594be9e3d8acfbb0d1290f6640a7443ff5832e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.13

Security for dqpu 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.7 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page