Qciscirq


NameQciscirq JSON
Version 0.1b0 PyPI version JSON
download
home_page
SummaryAdaptor between QCIS and Cirq
upload_time2023-01-31 15:20:43
maintainer
docs_urlNone
authorYiming Zhang
requires_python>=3.8.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Qciscirq

> Current version: v0.1-beta

Adaptors for translating quantum circuits between `QCIS` and `cirq.Circuit`.

## What is `qciscirq`

`QCIS` is a quantum circuit instruction set used in
Xiaobo Zhu group at USTC. `QCIS` is designed deliberately to work on 
hardware. They are low-level instructions and can be hard to write from
scratch, which requires heavy string manipulation.

`cirq` is an open-source quantum computing framework proposed by Google. It provides
a high-level quantum circuit API and a simulator for simulating quantum circuits. Writing
quantum circuits in `cirq` is much easier than `QCIS`.

This package(`qciscirq`) provides an adaptor for translating quantum circuits between `QCIS` and
`cirq.Circuit`. The supported translation units are limited by the relatively small number of
`QCIS` instructions. Additionally, `qciscirq` defines some cirq extension gates for some operation
abstractions such as dynamical decoupling sequence.

## Installation

`qciscirq` can be installed with `pip`:
```shell
pip install qciscirq
```

## API Reference

### `qciscirq.cirq_to_qcis`

```
Convert cirq circuit to QCIS circuit.

Args:
    circuit: The cirq circuit to be converted.
    map_func: A function that maps cirq.GridQubit to a string.
    all_blockable_qagents: All qagents that can be blocked, used in 'B' operation.
    couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.
        Defaults to None. When the circuit contains CZ gates, this argument must be provided.
    ignored_gates_or_ops: Specify the gates or operations to ignore when converting from cirq to qcis.
        Defaults to None. When None, the default set of gates or operations to ignore will be used, including
        stimcirq extension operations and cirq noise channel gates. When not None, the ignored set used will be
        the union of the default set and the set specified by this argument.

Returns:
    The QCIS circuit.

Examples:
    >>> import cirq
    >>> import qciscirq
    >>> q1, q2 = cirq.GridQubit.rect(1, 2)
    >>> print(qciscirq.cirq_to_qcis(
    ...     cirq.Circuit(
    ...         cirq.Moment((cirq.Y ** 0.5)(q1), (cirq.Y ** -0.5)(q2)),
    ...         cirq.Moment(cirq.CZ(q1, q2)),
    ...         cirq.Moment((cirq.Y ** 0.5)(q2)),
    ...         cirq.Moment(cirq.measure(q1, q2)),
    ...     ),
    ...     map_func={q1: 'Q01', q2: 'Q02'}.get,
    ...     all_blockable_qagents = ['Q01', 'Q02', 'R01'],
    ...     couplers = {'G0201': ('Q01', 'Q02')}))
    Y2P Q01
    Y2M Q02
    B Q01 Q02 R01
    CZ G0201
    B Q01 Q02 R01
    Y2P Q02
    B Q01 Q02 R01
    M Q01 Q02
    B Q01 Q02 R01
```

### `qciscirq.qcis_to_cirq`

```
Convert QCIS circuit to cirq circuit.

Args:
    qcis: The QCIS circuit to be converted.
    map_func: A function that maps a string to cirq.GridQubit.
    couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.
        Defaults to None. When qcis contains CZ operations, couplers must be provided.
    ignored_instructions: Instructions to be ignored. Defaults to None. When not None, the instructions
        start with the strings in this set will be ignored.

Returns:
    The cirq circuit.

Examples:
    >>> import cirq
    >>> import qciscirq
    >>> q1, q2 = cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)
    >>> qcis_circuit = '''X2P Q01
    ... X2M Q02
    ... B Q01 Q02 R01
    ... CZ G0201
    ... B Q01 Q02 R01
    ... M Q01 Q02
    ... B Q01 Q02 R01
    ... '''
    >>> print(qciscirq.qcis_to_cirq(
    ...    qcis_circuit,
    ...    map_func={'Q01': q1, 'Q02': q2}.get,
    ...    couplers={'G0201': ('Q01', 'Q02')}))
    (0, 1): ───X^0.5────@───M('Q01,Q02')───
                        │   │
    (0, 2): ───X^-0.5───@───M──────────────
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "Qciscirq",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Yiming Zhang",
    "author_email": "zhangyiming21@mail.ustc.edu.cn",
    "download_url": "https://files.pythonhosted.org/packages/71/8b/f1130205ee33f039639162b42a3004f623fc28315a595d4130ecee17a24b/Qciscirq-0.1b0.tar.gz",
    "platform": null,
    "description": "# Qciscirq\n\n> Current version: v0.1-beta\n\nAdaptors for translating quantum circuits between `QCIS` and `cirq.Circuit`.\n\n## What is `qciscirq`\n\n`QCIS` is a quantum circuit instruction set used in\nXiaobo Zhu group at USTC. `QCIS` is designed deliberately to work on \nhardware. They are low-level instructions and can be hard to write from\nscratch, which requires heavy string manipulation.\n\n`cirq` is an open-source quantum computing framework proposed by Google. It provides\na high-level quantum circuit API and a simulator for simulating quantum circuits. Writing\nquantum circuits in `cirq` is much easier than `QCIS`.\n\nThis package(`qciscirq`) provides an adaptor for translating quantum circuits between `QCIS` and\n`cirq.Circuit`. The supported translation units are limited by the relatively small number of\n`QCIS` instructions. Additionally, `qciscirq` defines some cirq extension gates for some operation\nabstractions such as dynamical decoupling sequence.\n\n## Installation\n\n`qciscirq` can be installed with `pip`:\n```shell\npip install qciscirq\n```\n\n## API Reference\n\n### `qciscirq.cirq_to_qcis`\n\n```\nConvert cirq circuit to QCIS circuit.\n\nArgs:\n    circuit: The cirq circuit to be converted.\n    map_func: A function that maps cirq.GridQubit to a string.\n    all_blockable_qagents: All qagents that can be blocked, used in 'B' operation.\n    couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.\n        Defaults to None. When the circuit contains CZ gates, this argument must be provided.\n    ignored_gates_or_ops: Specify the gates or operations to ignore when converting from cirq to qcis.\n        Defaults to None. When None, the default set of gates or operations to ignore will be used, including\n        stimcirq extension operations and cirq noise channel gates. When not None, the ignored set used will be\n        the union of the default set and the set specified by this argument.\n\nReturns:\n    The QCIS circuit.\n\nExamples:\n    >>> import cirq\n    >>> import qciscirq\n    >>> q1, q2 = cirq.GridQubit.rect(1, 2)\n    >>> print(qciscirq.cirq_to_qcis(\n    ...     cirq.Circuit(\n    ...         cirq.Moment((cirq.Y ** 0.5)(q1), (cirq.Y ** -0.5)(q2)),\n    ...         cirq.Moment(cirq.CZ(q1, q2)),\n    ...         cirq.Moment((cirq.Y ** 0.5)(q2)),\n    ...         cirq.Moment(cirq.measure(q1, q2)),\n    ...     ),\n    ...     map_func={q1: 'Q01', q2: 'Q02'}.get,\n    ...     all_blockable_qagents = ['Q01', 'Q02', 'R01'],\n    ...     couplers = {'G0201': ('Q01', 'Q02')}))\n    Y2P Q01\n    Y2M Q02\n    B Q01 Q02 R01\n    CZ G0201\n    B Q01 Q02 R01\n    Y2P Q02\n    B Q01 Q02 R01\n    M Q01 Q02\n    B Q01 Q02 R01\n```\n\n### `qciscirq.qcis_to_cirq`\n\n```\nConvert QCIS circuit to cirq circuit.\n\nArgs:\n    qcis: The QCIS circuit to be converted.\n    map_func: A function that maps a string to cirq.GridQubit.\n    couplers: A dictionary mapping coupler names to qubit pairs, used in CZ operation conversion.\n        Defaults to None. When qcis contains CZ operations, couplers must be provided.\n    ignored_instructions: Instructions to be ignored. Defaults to None. When not None, the instructions\n        start with the strings in this set will be ignored.\n\nReturns:\n    The cirq circuit.\n\nExamples:\n    >>> import cirq\n    >>> import qciscirq\n    >>> q1, q2 = cirq.GridQubit(0, 1), cirq.GridQubit(0, 2)\n    >>> qcis_circuit = '''X2P Q01\n    ... X2M Q02\n    ... B Q01 Q02 R01\n    ... CZ G0201\n    ... B Q01 Q02 R01\n    ... M Q01 Q02\n    ... B Q01 Q02 R01\n    ... '''\n    >>> print(qciscirq.qcis_to_cirq(\n    ...    qcis_circuit,\n    ...    map_func={'Q01': q1, 'Q02': q2}.get,\n    ...    couplers={'G0201': ('Q01', 'Q02')}))\n    (0, 1): \u2500\u2500\u2500X^0.5\u2500\u2500\u2500\u2500@\u2500\u2500\u2500M('Q01,Q02')\u2500\u2500\u2500\n                        \u2502   \u2502\n    (0, 2): \u2500\u2500\u2500X^-0.5\u2500\u2500\u2500@\u2500\u2500\u2500M\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Adaptor between QCIS and Cirq",
    "version": "0.1b0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "718bf1130205ee33f039639162b42a3004f623fc28315a595d4130ecee17a24b",
                "md5": "9d8be094979a770bcd5a2fbf6f5f21a2",
                "sha256": "9cb31d65af75623512f4705a2227f0ba860a85d42fa5f27f11369a01dc8f011f"
            },
            "downloads": -1,
            "filename": "Qciscirq-0.1b0.tar.gz",
            "has_sig": false,
            "md5_digest": "9d8be094979a770bcd5a2fbf6f5f21a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 9376,
            "upload_time": "2023-01-31T15:20:43",
            "upload_time_iso_8601": "2023-01-31T15:20:43.962165Z",
            "url": "https://files.pythonhosted.org/packages/71/8b/f1130205ee33f039639162b42a3004f623fc28315a595d4130ecee17a24b/Qciscirq-0.1b0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-31 15:20:43",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "qciscirq"
}
        
Elapsed time: 0.04756s