Skip to main content

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

Project description

hybridlane

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
        # (!) Qumodes come before qubits, allowing m0 to be inferred as a qumode
        hqml.JaynesCummings(np.pi / (2 * np.sqrt(j + 1)), np.pi / 2, ["m0", 0])

    # 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

hybridlane is developed by PNNL with contributions from the open-source community.

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.1.0a1.tar.gz (36.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.1.0a1-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hybridlane-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 cd08493f6cb1ab21fc841b29b942398f6d0a9c29bdd376d6f9c99aec15d43eef
MD5 44d2577aecfcd05fcca24172ac528dea
BLAKE2b-256 e04d2c8e1739c1da3463a4dd8390fc160efcc78e5f5a5ec93716a96cd3964204

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hybridlane-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebdbd96670bf673124dd0b46a2c64aab8db84a82b5151b3fb262b874f5995c58
MD5 ee5f94137bff901b35b59a35a2a629c7
BLAKE2b-256 9f7ec0bce5af8aec4cbfd5010635708a71d682fd9f6f1a25af0b4407cae19be7

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