Skip to main content

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

Project description

hybridlane

PyPI - Version Docs PyPI Downloads 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 bosonicqiskit.hybrid 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("bosonicqiskit.hybrid", 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 bosonicqiskit.hybrid 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.4.0a1.tar.gz (57.8 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.4.0a1-py3-none-any.whl (86.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hybridlane-0.4.0a1.tar.gz
Algorithm Hash digest
SHA256 fb936547442cfef1843d1862d07789b558b78c80f3ec06415ff71e267318332a
MD5 4bba77bb63aa070e6bdaaf635140014e
BLAKE2b-256 b81423e59af7427f2212f0156a6d05950454a9c844852c193b4212988d769fee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hybridlane-0.4.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb3a80d0aaed06140687746ac14d610062d10efd44479d69a1b77de93cac8a9a
MD5 acccf207e31390f814529c5dd5bf77eb
BLAKE2b-256 5586a152117e75e246854f456ea49acdeae0879fbaa419a36366d864c846d9c1

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