bgls


Namebgls JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/asciineuron/bgls
SummaryImplementation of the gate-by-gate sampling algorithm.
upload_time2023-09-26 22:09:00
maintainer
docs_urlNone
authorAlex Shapiro
requires_python>=3.9.0
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # BGLS

[![build](https://github.com/asciineuron/bgls/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/asciineuron/bgls/actions)
[![doctest](https://github.com/asciineuron/bgls/actions/workflows/doctest.yml/badge.svg?branch=main)](https://github.com/asciineuron/bgls/actions)
[![pages-build-deployment](https://github.com/asciineuron/bgls/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/asciineuron/bgls/actions/workflows/pages/pages-build-deployment)
[![Documentation](https://img.shields.io/badge/Documentation-GH_Pages-blue)](https://asciineuron.github.io/bgls/)
[![Repository](https://img.shields.io/badge/GitHub-5C5C5C.svg?logo=github)](https://github.com/asciineuron/bgls)
[![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg?style=for-the-badge)](https://unitary.fund)


BGLS is a Python package that implements the **B**ravyi, **G**osset, and **L**iu **S**ampling algorithm presented in *How to simulate quantum measurement without computing marginals ([Phys. Rev. Lett.](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.128.220503)) ([arXiv](https://arxiv.org/abs/2112.08499))* for [Cirq](https://quantumai.google/cirq) circuits.

## Quickstart

### Installation

```bash
pip install bgls
```

### Example

```python
import cirq
import bgls

# Example circuit to run.
qubits = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
    cirq.H.on(qubits[0]),
    cirq.CNOT.on(*qubits),
    cirq.measure(*qubits, key="z")
)

# Run the circuit with BGLS.
simulator = bgls.Simulator(
    initial_state=cirq.StateVectorSimulationState(qubits=qubits, initial_state=0),
    apply_op=cirq.protocols.act_on,
    compute_probability=bgls.born.compute_probability_state_vector,
)
results = simulator.run(circuit, repetitions=10)
print(results.histogram(key="z"))
```

Sample output:

```text
Counter({0: 6, 3: 4})
```

## Documentation

See more details and examples in the [Documentation for BGLS](https://asciineuron.github.io/bgls/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asciineuron/bgls",
    "name": "bgls",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alex Shapiro",
    "author_email": "alexander.shapiro@epfl.ch",
    "download_url": "https://files.pythonhosted.org/packages/09/ce/686abb156b6712b97787ccf1406017444785b60f641d8de5328ee5ba01af/bgls-0.2.0.tar.gz",
    "platform": null,
    "description": "# BGLS\n\n[![build](https://github.com/asciineuron/bgls/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/asciineuron/bgls/actions)\n[![doctest](https://github.com/asciineuron/bgls/actions/workflows/doctest.yml/badge.svg?branch=main)](https://github.com/asciineuron/bgls/actions)\n[![pages-build-deployment](https://github.com/asciineuron/bgls/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/asciineuron/bgls/actions/workflows/pages/pages-build-deployment)\n[![Documentation](https://img.shields.io/badge/Documentation-GH_Pages-blue)](https://asciineuron.github.io/bgls/)\n[![Repository](https://img.shields.io/badge/GitHub-5C5C5C.svg?logo=github)](https://github.com/asciineuron/bgls)\n[![Unitary Fund](https://img.shields.io/badge/Supported%20By-UNITARY%20FUND-brightgreen.svg?style=for-the-badge)](https://unitary.fund)\n\n\nBGLS is a Python package that implements the **B**ravyi, **G**osset, and **L**iu **S**ampling algorithm presented in *How to simulate quantum measurement without computing marginals ([Phys. Rev. Lett.](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.128.220503)) ([arXiv](https://arxiv.org/abs/2112.08499))* for [Cirq](https://quantumai.google/cirq) circuits.\n\n## Quickstart\n\n### Installation\n\n```bash\npip install bgls\n```\n\n### Example\n\n```python\nimport cirq\nimport bgls\n\n# Example circuit to run.\nqubits = cirq.LineQubit.range(2)\ncircuit = cirq.Circuit(\n    cirq.H.on(qubits[0]),\n    cirq.CNOT.on(*qubits),\n    cirq.measure(*qubits, key=\"z\")\n)\n\n# Run the circuit with BGLS.\nsimulator = bgls.Simulator(\n    initial_state=cirq.StateVectorSimulationState(qubits=qubits, initial_state=0),\n    apply_op=cirq.protocols.act_on,\n    compute_probability=bgls.born.compute_probability_state_vector,\n)\nresults = simulator.run(circuit, repetitions=10)\nprint(results.histogram(key=\"z\"))\n```\n\nSample output:\n\n```text\nCounter({0: 6, 3: 4})\n```\n\n## Documentation\n\nSee more details and examples in the [Documentation for BGLS](https://asciineuron.github.io/bgls/).\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Implementation of the gate-by-gate sampling algorithm.",
    "version": "0.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/asciineuron/bgls/issues/",
        "Documentation": "https://github.com/asciineuron/bgls",
        "Homepage": "https://github.com/asciineuron/bgls",
        "Source": "https://github.com/asciineuron/bgls"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcd7f2f19c5d33fd742ab0703a2eaf72e97af28aea23acb40a660ebfb3f84f13",
                "md5": "fbbe6fdf5e2e86e23e99b5921b18c8ad",
                "sha256": "535087493af4fd6c95fd5b89aea6c3e98b8c68d2262be50fb08e0976c16e4fb1"
            },
            "downloads": -1,
            "filename": "bgls-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fbbe6fdf5e2e86e23e99b5921b18c8ad",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.0",
            "size": 25379,
            "upload_time": "2023-09-26T22:08:58",
            "upload_time_iso_8601": "2023-09-26T22:08:58.518294Z",
            "url": "https://files.pythonhosted.org/packages/bc/d7/f2f19c5d33fd742ab0703a2eaf72e97af28aea23acb40a660ebfb3f84f13/bgls-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09ce686abb156b6712b97787ccf1406017444785b60f641d8de5328ee5ba01af",
                "md5": "2eb1a9baa6274b7ba66d7bb3489686a5",
                "sha256": "488235be47e9b733c52d57207b18ad6cae5c3ec1ce797da96eb87ea589b4d859"
            },
            "downloads": -1,
            "filename": "bgls-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2eb1a9baa6274b7ba66d7bb3489686a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 19018,
            "upload_time": "2023-09-26T22:09:00",
            "upload_time_iso_8601": "2023-09-26T22:09:00.319477Z",
            "url": "https://files.pythonhosted.org/packages/09/ce/686abb156b6712b97787ccf1406017444785b60f641d8de5328ee5ba01af/bgls-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-26 22:09:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "asciineuron",
    "github_project": "bgls",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "bgls"
}
        
Elapsed time: 0.12647s