hdh


Namehdh JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryHybrid Dependency Hypergraphs for quantum computation: translation, visualization, and partitioning.
upload_time2025-08-06 14:51:27
maintainerNone
docs_urlNone
authorMaria Gragera Garces
requires_python<4.0,>=3.10
licenseMIT
keywords quantum compiler partitioning hdh hypergraph
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
![HDH Logo](https://raw.githubusercontent.com/grageragarces/hdh/main/docs/img/logo.png)

# Hybrid Dependency Hypergraphs for Quantum Computation

<p style="text-align:center">
  <a href="https://pypi.org/project/hdh/">
    <img src="https://badge.fury.io/py/hdh.svg" alt="PyPI version">
  </a>
  · MIT Licensed ·
  <a href="https://unitary.foundation">
    <img src="https://img.shields.io/badge/Supported%20By-UNITARY%20FOUNDATION-brightgreen.svg?style=for-the-badge" alt="Unitary Foundation">
  </a>
  · Author: Maria Gragera Garces
  <br><br>
  <em>Work in Progress - Preparing for 1.0</em>
</p>

---

## What is HDH?

**HDH (Hybrid Dependency Hypergraph)** is an intermediate representation designed to describe quantum computations in a model-agnostic way.
It provides a unified structure that makes it easier to:

- Translate quantum programs (e.g., from Qiskit or QASM) into a common hypergraph format
- Analyze and visualize the logical and temporal dependencies within a computation
- Partition workloads across devices using tools like METIS or KaHyPar, taking into account hardware and network constraints

---

## Current Capabilities

- Qiskit circuit translation  
- OpenQASM 2.0 file parsing  
- Graph-based printing and canonical formatting  
- Partitioning with METIS using custom HDH-to-graph translation  
- Model-specific abstractions for:
  - Quantum Circuits
  - Measurement-Based Quantum Computing (MBQC)
  - Quantum Walks
  - Quantum Cellular Automata (QCA)

Includes test examples for:

- Circuit translation (`test_convert_from_qiskit.py`)
- QASM import (`test_convert_from_qasm.py`)
- MBQC (`mbqc_test.py`)
- Quantum Walks (`qw_test.py`)
- Quantum Cellular Automata (`qca_test.py`)
- Protocol demos (`teleportation_protocol_logo.py`)

---

## Installation

```bash
pip install hdh
```

---

## Quickstart

### From Qiskit

```python
from qiskit import QuantumCircuit
from hdh.converters.convert_from_qiskit import from_qiskit
from hdh.visualize import plot_hdh

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

hdh = from_qiskit(qc)

plot_hdh(hdh)
```

### From QASM file

```python
from hdh.converters.convert_from_qasm import from_qasm
from hdh.visualize import plot_hdh

qasm_path = os.path.join(os.path.dirname(__file__), 'test_qasm_file.qasm')
hdh = from_qasm('file', qasm_path)

plot_hdh(hdh)
```

---

## Example Use Cases

- Visualize quantum protocols (e.g., teleportation)  
- Analyze dependencies in quantum walk evolutions  
- Explore entanglement flow in MBQC patterns  

---

## Coming Soon

- Compatibility with Cirq, Braket, and Pennylane  
- Full graphical UI for HDH visualization  
- Native noise-aware binning strategies  
- Analysis tools for:
  - Cut cost estimation across partitions
  - Partition size reporting
  - Parallelism tracking by time step
  
  ```python
  from hdh.passes.cut import compute_cut, cost, partition_sizes, compute_parallelism_by_time

  num_parts = 3
  partitions = compute_cut(hdh, num_parts)

  print(f"\nMETIS partition into {num_parts} parts:")
  for i, part in enumerate(partitions):
      print(f"Partition {i}: {sorted(part)}")
      
  # plot_hdh(hdh)
  cut_cost = cost(hdh, partitions)
  sizes = partition_sizes(partitions)
  global_parallelism = compute_parallelism_by_time(hdh, partitions, mode="global")
  parallelism_at_t3 = compute_parallelism_by_time(hdh, partitions, mode="local", time_step=3)

  print("\n--- QW Metrics ---")
  print(f"\nCut cost: {cut_cost}")
  print(f"Partition sizes: {sizes}")
  print(f"Parallelism over time: {global_parallelism}")
  print(f"Parallelism at time t=3: {parallelism_at_t3}")

  ```

---

## Tests and Demos

All tests are under `tests/` and can be run with:

```bash
pytest
```

If you're interested in the HDH of a specific model, see in manual_tests:

- `mbqc_test.py` for MBQC circuits  
- `qca_test.py` for Cellular Automata  
- `qw_test.py` for Quantum Walks  
- `teleportation_protocol_logo.py` for a protocol-specific demo  

---

## Contributing

Pull requests welcome. Please open an issue or get in touch if you're interested in:

- SDK compatibility  
- Optimization strategies  
- Frontend tools (visualization, benchmarking)  

---

## Citation

More formal citation and paper preprint coming soon. Stay tuned for updates.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hdh",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "quantum, compiler, partitioning, hdh, hypergraph",
    "author": "Maria Gragera Garces",
    "author_email": "m.gragera.gaces@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/fe/01a4526727e754845d144adcdb961c754435396ff8b23b2fb2e563128610/hdh-0.1.3.tar.gz",
    "platform": null,
    "description": "\n![HDH Logo](https://raw.githubusercontent.com/grageragarces/hdh/main/docs/img/logo.png)\n\n# Hybrid Dependency Hypergraphs for Quantum Computation\n\n<p style=\"text-align:center\">\n  <a href=\"https://pypi.org/project/hdh/\">\n    <img src=\"https://badge.fury.io/py/hdh.svg\" alt=\"PyPI version\">\n  </a>\n  \u00b7 MIT Licensed \u00b7\n  <a href=\"https://unitary.foundation\">\n    <img src=\"https://img.shields.io/badge/Supported%20By-UNITARY%20FOUNDATION-brightgreen.svg?style=for-the-badge\" alt=\"Unitary Foundation\">\n  </a>\n  \u00b7 Author: Maria Gragera Garces\n  <br><br>\n  <em>Work in Progress - Preparing for 1.0</em>\n</p>\n\n---\n\n## What is HDH?\n\n**HDH (Hybrid Dependency Hypergraph)** is an intermediate representation designed to describe quantum computations in a model-agnostic way.\nIt provides a unified structure that makes it easier to:\n\n- Translate quantum programs (e.g., from Qiskit or QASM) into a common hypergraph format\n- Analyze and visualize the logical and temporal dependencies within a computation\n- Partition workloads across devices using tools like METIS or KaHyPar, taking into account hardware and network constraints\n\n---\n\n## Current Capabilities\n\n- Qiskit circuit translation  \n- OpenQASM 2.0 file parsing  \n- Graph-based printing and canonical formatting  \n- Partitioning with METIS using custom HDH-to-graph translation  \n- Model-specific abstractions for:\n  - Quantum Circuits\n  - Measurement-Based Quantum Computing (MBQC)\n  - Quantum Walks\n  - Quantum Cellular Automata (QCA)\n\nIncludes test examples for:\n\n- Circuit translation (`test_convert_from_qiskit.py`)\n- QASM import (`test_convert_from_qasm.py`)\n- MBQC (`mbqc_test.py`)\n- Quantum Walks (`qw_test.py`)\n- Quantum Cellular Automata (`qca_test.py`)\n- Protocol demos (`teleportation_protocol_logo.py`)\n\n---\n\n## Installation\n\n```bash\npip install hdh\n```\n\n---\n\n## Quickstart\n\n### From Qiskit\n\n```python\nfrom qiskit import QuantumCircuit\nfrom hdh.converters.convert_from_qiskit import from_qiskit\nfrom hdh.visualize import plot_hdh\n\nqc = QuantumCircuit(2)\nqc.h(0)\nqc.cx(0, 1)\n\nhdh = from_qiskit(qc)\n\nplot_hdh(hdh)\n```\n\n### From QASM file\n\n```python\nfrom hdh.converters.convert_from_qasm import from_qasm\nfrom hdh.visualize import plot_hdh\n\nqasm_path = os.path.join(os.path.dirname(__file__), 'test_qasm_file.qasm')\nhdh = from_qasm('file', qasm_path)\n\nplot_hdh(hdh)\n```\n\n---\n\n## Example Use Cases\n\n- Visualize quantum protocols (e.g., teleportation)  \n- Analyze dependencies in quantum walk evolutions  \n- Explore entanglement flow in MBQC patterns  \n\n---\n\n## Coming Soon\n\n- Compatibility with Cirq, Braket, and Pennylane  \n- Full graphical UI for HDH visualization  \n- Native noise-aware binning strategies  \n- Analysis tools for:\n  - Cut cost estimation across partitions\n  - Partition size reporting\n  - Parallelism tracking by time step\n  \n  ```python\n  from hdh.passes.cut import compute_cut, cost, partition_sizes, compute_parallelism_by_time\n\n  num_parts = 3\n  partitions = compute_cut(hdh, num_parts)\n\n  print(f\"\\nMETIS partition into {num_parts} parts:\")\n  for i, part in enumerate(partitions):\n      print(f\"Partition {i}: {sorted(part)}\")\n      \n  # plot_hdh(hdh)\n  cut_cost = cost(hdh, partitions)\n  sizes = partition_sizes(partitions)\n  global_parallelism = compute_parallelism_by_time(hdh, partitions, mode=\"global\")\n  parallelism_at_t3 = compute_parallelism_by_time(hdh, partitions, mode=\"local\", time_step=3)\n\n  print(\"\\n--- QW Metrics ---\")\n  print(f\"\\nCut cost: {cut_cost}\")\n  print(f\"Partition sizes: {sizes}\")\n  print(f\"Parallelism over time: {global_parallelism}\")\n  print(f\"Parallelism at time t=3: {parallelism_at_t3}\")\n\n  ```\n\n---\n\n## Tests and Demos\n\nAll tests are under `tests/` and can be run with:\n\n```bash\npytest\n```\n\nIf you're interested in the HDH of a specific model, see in manual_tests:\n\n- `mbqc_test.py` for MBQC circuits  \n- `qca_test.py` for Cellular Automata  \n- `qw_test.py` for Quantum Walks  \n- `teleportation_protocol_logo.py` for a protocol-specific demo  \n\n---\n\n## Contributing\n\nPull requests welcome. Please open an issue or get in touch if you're interested in:\n\n- SDK compatibility  \n- Optimization strategies  \n- Frontend tools (visualization, benchmarking)  \n\n---\n\n## Citation\n\nMore formal citation and paper preprint coming soon. Stay tuned for updates.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Hybrid Dependency Hypergraphs for quantum computation: translation, visualization, and partitioning.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://pypi.org/project/hdh/",
        "Repository": "https://github.com/grageragarces/hdh"
    },
    "split_keywords": [
        "quantum",
        " compiler",
        " partitioning",
        " hdh",
        " hypergraph"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0ddea9f21268a6d62305c27aa324101ff2664e53711fbb87d84c2e6f5fed5e73",
                "md5": "6e9979b459ec6b6a5b60684cb57ce0c5",
                "sha256": "f5a4a38c674141b6324323ad8199da330392c15c186ef6a89bdce6793a771b40"
            },
            "downloads": -1,
            "filename": "hdh-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e9979b459ec6b6a5b60684cb57ce0c5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 20974,
            "upload_time": "2025-08-06T14:51:26",
            "upload_time_iso_8601": "2025-08-06T14:51:26.397029Z",
            "url": "https://files.pythonhosted.org/packages/0d/de/a9f21268a6d62305c27aa324101ff2664e53711fbb87d84c2e6f5fed5e73/hdh-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e7fe01a4526727e754845d144adcdb961c754435396ff8b23b2fb2e563128610",
                "md5": "fa4933de0bcb8ce62b068bbc525c9a09",
                "sha256": "81daebe698d5bfd21132baa27fdd2a76b068536c18d546d854e3171d27189c3a"
            },
            "downloads": -1,
            "filename": "hdh-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "fa4933de0bcb8ce62b068bbc525c9a09",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 17663,
            "upload_time": "2025-08-06T14:51:27",
            "upload_time_iso_8601": "2025-08-06T14:51:27.597991Z",
            "url": "https://files.pythonhosted.org/packages/e7/fe/01a4526727e754845d144adcdb961c754435396ff8b23b2fb2e563128610/hdh-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-06 14:51:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "grageragarces",
    "github_project": "hdh",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hdh"
}
        
Elapsed time: 1.92117s