Skip to main content

A frontend library for hybrid CV-DV computation based on Pennylane.

Project description

hybridlane

PyPI - Version Docs Build Status License

hybridlane is a frontend library for expressing and manipulating hybrid continuous-variable (CV) and discrete-variable (DV) quantum circuits within the PennyLane ecosystem. It implements the concepts introduced in the paper Y. Liu et al, 2024 (arXiv:2407.10381).


✨ Why hybridlane?

Quantum computing research is increasingly exploring hybrid (heterogenous) models. hybridlane empowers researchers and developers to:

  • Design complex hybrid circuits effortlessly: Mix and match qubits and qumodes in the same circuit without workaround.
  • Scale to large circuits: Define hybrid gate semantics independent of simulation, enabling fast circuit description (we tried up to 10k qumodes).
  • Integrate with PennyLane: Leverage existing PennyLane tools for transformations, resource estimation, and device integration.

🚀 Features

hybridlane offers functionality designed for hybrid quantum circuit development:

  • 📃 Hybrid Gate Semantics: The library precisely defines hybrid gates as presented in the reference paper, along with their operational semantics. Crucially, these definitions are entirely independent of their truncated matrix representations, allowing for rapid description of large circuits.

  • ⚛️ Native Qumode Support: Unlike other libraries that might interpret lists of qubits as a "qumode," hybridlane provides native support for qumodes as fundamental wire types. The types of wires (qubit or qumode) are automatically inferred through static analysis of the circuit structure, eliminating the need for manual type annotation and making circuit construction highly intuitive.

  • 🤝 PennyLane Compatibility: hybridlane is built to be compatible with PennyLane. Existing PennyLane users will find the interface familiar, allowing them to utilize PennyLane gates and operators, define custom devices for hybrid CV-DV computation (for simulators or hardware), write decomposition passes (transforms) to transpile hybrid circuits, and perform resource estimation. A key differentiator is the ability to freely mix qubits and qumodes within the same circuit, a capability not natively found in PennyLane or StrawberryFields alone.

  • 💻 Classical Simulation Device: We provide a classical simulation device that dispatches computations to Bosonic Qiskit. This device is ideal for testing small circuits or serving as a reference for building your own custom hybrid devices.

  • 💾 OpenQASM-based Intermediate Representation (IR): hybridlane includes an intermediate representation based on OpenQASM, extended with modifications to handle the more complex semantics inherent in CV-DV quantum computation. This enables interoperability and advanced circuit manipulation.


⚙️ Installation

hybridlane is currently in early preview. We highly value your feedback on GitHub Issues to help us improve!

The package can be installed from PyPI with

pip install hybridlane[extras]

Available Extra Flags:

  • [all]: Installs all extra flags.
  • [bq]: Installs support for the hybrid.bosonicqiskit simulation device.

For more detailed installation instructions and environment setup, please refer to the Getting Started Guide in our Documentation.


⚡ Quick Start

Get started with hybridlane in just a few lines of code:

import numpy as np
import pennylane as qml
import hybridlane as hqml

# Create the bosonic qiskit simulator with custom Fock truncation
dev = qml.device(
    "hybrid.bosonicqiskit",
    wires=[0, "m0"],
    qumodes=["m0"],
    max_fock_level=8
)

# Define a hybrid circuit with familiar Pennylane syntax
@qml.qnode(dev)
def circuit(n):
    # Python control flow allowed
    for j in range(n):
        # You can use existing Pennylane gates.
        qml.X(0) # wire `0` inferred to be a qubit

        # Or use the hybrid CV-DV gates in Hybridlane
        # (!) Qubits come before qumodes, allowing m0 to be inferred as a qumode
        hqml.JaynesCummings(np.pi / (2 * np.sqrt(j + 1)), np.pi / 2, [0, "m0"])

    # Freely mix qubit and qumode observables
    # (!) We use `hqml` for measurements and for CV observables
    return hqml.expval(hqml.NumberOperator("m0") @ qml.Z(0))

# Execute the circuit
expval = circuit(5)
# array(5.)

# Or analyze its structure
import hybridlane.sa as sa
res = sa.analyze(circuit._tape)
# StaticAnalysisResult(qumodes=Wires(['m0']), qubits=Wires([0]), schemas=[<hybridlane.sa.base.BasisSchema object at 0x7f504673a090>], wire_order=Wires([0, 'm0']))

For more examples and detailed usage, explore the Documentation.


🚧 Limitations & Future Work

While hybridlane provides a powerful framework for hybrid quantum circuits, it's currently under active development and has some known limitations:

  • ❌ Quantum Error Correction (QEC): While QEC circuits can be described using this package, hybridlane is not designed to handle fault-tolerant programs or extensive resource estimation like specialized libraries such as Qualtran. Our focus remains on the circuit model of quantum computing.

  • ❌ Catalyst/JIT Compilation Support: Currently, hybridlane does not support PennyLane's Catalyst and qjit capabilities. This would require developing a custom MLIR dialect for hybrid operations, which is a significant undertaking. While not on the immediate roadmap, this could be a potential feature in the future.

  • ❌ Automatic Differentiation (Autodiff): While our gate definitions are fundamentally compatible with PennyLane's differentiability paradigm, we do not yet provide a differentiable simulator device, nor are gradient recipes fully defined for all hybrid operations. For now, the hybrid.bosonicqiskit device will typically require finite differences for gradient computation. We plan to integrate more robust autodiff capabilities in future releases.


📚 Documentation

For comprehensive information on hybridlane's API, detailed usage examples, theoretical background, and contributing guidelines, please visit our official Documentation.


❓ Support & Feedback

Having trouble? Found a bug? Have a great idea for a new feature?

  • For technical questions, bug reports, or feature requests, please open an issue on our GitHub Issues page.

📜 License

This project is licensed under a permissive open-source license - see the LICENSE.txt file for details.


🙏 Acknowledgements

This project was supported by the U.S. Department of Energy, Office of Science, Advanced Scientific Computing Research program under contract number DE-FOA-0003265.

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

hybridlane-0.2.0a1.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

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

hybridlane-0.2.0a1-py3-none-any.whl (60.8 kB view details)

Uploaded Python 3

File details

Details for the file hybridlane-0.2.0a1.tar.gz.

File metadata

  • Download URL: hybridlane-0.2.0a1.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.17

File hashes

Hashes for hybridlane-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 5be6046ef0ba31018a359a4084fc9af63c1c83f683c6ca5131832e7d32837f12
MD5 6183354c33b9bde486894e1550165b2e
BLAKE2b-256 6c6de01458762d1cdd62319e9042d56318e3da3251c93e2f819cf444dd98712c

See more details on using hashes here.

File details

Details for the file hybridlane-0.2.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for hybridlane-0.2.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea662b82a5f97d37103a58ddfd963a4e1f664731421bbe2ff7e6288873b24ade
MD5 608b731b014c135ba53a230469afe1e2
BLAKE2b-256 02dd95da08bd0826b7c9f14f256b05929c452c3a209b519c817092261f7abc32

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