artur-qiskit-terra


Nameartur-qiskit-terra JSON
Version 0.45.2 PyPI version JSON
download
home_pagehttps://github.com/Qiskit/qiskit
SummarySoftware for developing quantum computing programs
upload_time2024-01-19 16:55:00
maintainer
docs_urlNone
authorQiskit Development Team
requires_python>=3.8
licenseApache 2.0
keywords qiskit sdk quantum
VCS
bugtrack_url
requirements rustworkx numpy psutil scipy sympy dill python-dateutil stevedore typing-extensions symengine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Qiskit
[![License](https://img.shields.io/github/license/Qiskit/qiskit-terra.svg?)](https://opensource.org/licenses/Apache-2.0) 
[![DOI](https://zenodo.org/badge/161550823.svg)](https://zenodo.org/badge/latestdoi/161550823)

**Qiskit**  is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

This library is the core component of Qiskit, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator).
It also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators. 

For more details on how to use Qiskit, refer to the documentation located here:

<https://qiskit.org/documentation/>


## Installation

We encourage installing Qiskit via ``pip``:

```bash
pip install qiskit
```

Pip will handle all dependencies automatically and you will always install the latest (and well-tested) version.

To install from source, follow the instructions in the [documentation](https://qiskit.org/documentation/contributing_to_qiskit.html#install-install-from-source-label).

## Create your first quantum program in Qiskit

Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are:
1. Define and build a quantum circuit that represents the quantum state
2. Define the classical output by measurements or a set of observable operators
3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimator` to estimate values.

Create an example quantum circuit using the `QuantumCircuit` class:

```python
import numpy as np
from qiskit import QuantumCircuit

# 1. A quantum circuit for preparing the quantum state |000> + i |111>
qc_example = QuantumCircuit(3)
qc_example.h(0)          # generate superpostion
qc_example.p(np.pi/2,0)  # add quantum phase
qc_example.cx(0,1)       # 0th-qubit-Controlled-NOT gate on 1st qubit
qc_example.cx(0,2)       # 0th-qubit-Controlled-NOT gate on 2nd qubit
```

This simple example makes an entangled state known as a [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) $(|000\rangle + i|111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). 

Once you've made your first quantum circuit, choose which primitive function you will use. Starting with `sampler`,
we use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured:

```python
# 2. Add the classical output in the form of measurement of all qubits
qc_measured = qc_example.measure_all(inplace=False)

# 3. Execute using the Sampler primitive
from qiskit.primitives.sampler import Sampler
sampler = Sampler()
job = sampler.run(qc_measured, shots=1000)
result = job.result()
print(f" > Quasi probability distribution: {result.quasi_dists}")
```
Running this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations.  
To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXX-YYY$ and pass it to the `run()` function, along with our quantum circuit. Note the Estimator requires a circuit _**without**_ measurement, so we use the `qc_example` circuit we created earlier.

```python
# 2. define the observable to be measured 
from qiskit.quantum_info import SparsePauliOp
operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)])

# 3. Execute using the Estimator primitive
from qiskit.primitives import Estimator
estimator = Estimator()
job = estimator.run(qc_example, operator, shots=1000)
result = job.result()
print(f" > Expectation values: {result.values}")
```

Running this will give the outcome `4`. For fun, try to assign a value of +/- 1 to each single-qubit operator X and Y 
and see if you can achieve this outcome. (Spoiler alert: this is not possible!)

Using the Qiskit-provided `qiskit.primitives.Sampler` and `qiskit.primitives.Estimator` will not take you very far. The power of quantum computing cannot be simulated 
on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum 
circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware.
The tool that does this is the [transpiler](https://qiskit.org/documentation/apidoc/transpiler.html) 
and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a
default compiler which works very well in most examples. The following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits $0 \rightarrow 1 \rightarrow 2$ with the `coupling_map =[[0, 1], [1, 2]]`.

```python
from qiskit import transpile
qc_transpiled = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3)
```

For further examples of using Qiskit you can look at the tutorials in the documentation here:

<https://qiskit.org/documentation/tutorials.html>

### Executing your code on real quantum hardware

Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. 
The best way to use Qiskit is with a runtime environment that provides optimized implementations of `sampler` and `estimator` for a given hardware platform. This runtime may involve using pre- and post-processing, such as optimized transpiler passes with error suppression, error mitigation, and, eventually, error correction built in. A runtime implements `qiskit.primitives.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. For example,
some packages that provide implementations of a runtime primitive implementation are:

* https://github.com/Qiskit/qiskit-ibm-runtime

Qiskit also provides a lower-level abstract interface for describing quantum backends. This interface, located in
``qiskit.providers``, defines an abstract `BackendV2` class that providers can implement to represent their
hardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface with real hardware are:

* https://github.com/Qiskit/qiskit-ibm-provider
* https://github.com/qiskit-community/qiskit-ionq
* https://github.com/qiskit-community/qiskit-aqt-provider
* https://github.com/qiskit-community/qiskit-braket-provider
* https://github.com/qiskit-community/qiskit-quantinuum-provider
* https://github.com/rigetti/qiskit-rigetti

<!-- This is not an exhaustive list, and if you maintain a provider package please feel free to open a PR to add new providers -->

You can refer to the documentation of these packages for further instructions
on how to get access and use these systems.

## Contribution Guidelines

If you'd like to contribute to Qiskit, please take a look at our
[contribution guidelines](CONTRIBUTING.md). By participating, you are expected to uphold our [code of conduct](CODE_OF_CONDUCT.md).

We use [GitHub issues](https://github.com/Qiskit/qiskit-terra/issues) for tracking requests and bugs. Please
[join the Qiskit Slack community](https://qisk.it/join-slack) for discussion, comments, and questions.
For questions related to running or using Qiskit, [Stack Overflow has a `qiskit`](https://stackoverflow.com/questions/tagged/qiskit).
For questions on quantum computing with Qiskit, use the `qiskit` tag in the [Quantum Computing Stack Exchange](https://quantumcomputing.stackexchange.com/questions/tagged/qiskit) (please, read first the [guidelines on how to ask](https://quantumcomputing.stackexchange.com/help/how-to-ask) in that forum).


## Authors and Citation

Qiskit is the work of [many people](https://github.com/Qiskit/qiskit-terra/graphs/contributors) who contribute
to the project at different levels. If you use Qiskit, please cite as per the included [BibTeX file](CITATION.bib).

## Changelog and Release Notes

The changelog for a particular release is dynamically generated and gets
written to the release page on Github for each release. For example, you can
find the page for the `0.9.0` release here:

<https://github.com/Qiskit/qiskit-terra/releases/tag/0.9.0>

The changelog for the current release can be found in the releases tab:
[![Releases](https://img.shields.io/github/release/Qiskit/qiskit-terra.svg?style=flat&label=)](https://github.com/Qiskit/qiskit-terra/releases)
The changelog provides a quick overview of notable changes for a given
release.

Additionally, as part of each release detailed release notes are written to
document in detail what has changed as part of a release. This includes any
documentation on potential breaking changes on upgrade and new features.
For example, you can find the release notes for the `0.9.0` release in the
Qiskit documentation here:

https://qiskit.org/documentation/release_notes.html#terra-0-9

## Acknowledgements

We acknowledge partial support for Qiskit development from the DOE Office of Science National Quantum Information Science Research Centers, Co-design Center for Quantum Advantage (C2QA) under contract number DE-SC0012704.

## License

[Apache License 2.0](LICENSE.txt)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Qiskit/qiskit",
    "name": "artur-qiskit-terra",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "qiskit sdk quantum",
    "author": "Qiskit Development Team",
    "author_email": "hello@qiskit.org",
    "download_url": "",
    "platform": null,
    "description": "# Qiskit\r\n[![License](https://img.shields.io/github/license/Qiskit/qiskit-terra.svg?)](https://opensource.org/licenses/Apache-2.0) \r\n[![DOI](https://zenodo.org/badge/161550823.svg)](https://zenodo.org/badge/latestdoi/161550823)\r\n\r\n**Qiskit**  is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.\r\n\r\nThis library is the core component of Qiskit, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator).\r\nIt also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators. \r\n\r\nFor more details on how to use Qiskit, refer to the documentation located here:\r\n\r\n<https://qiskit.org/documentation/>\r\n\r\n\r\n## Installation\r\n\r\nWe encourage installing Qiskit via ``pip``:\r\n\r\n```bash\r\npip install qiskit\r\n```\r\n\r\nPip will handle all dependencies automatically and you will always install the latest (and well-tested) version.\r\n\r\nTo install from source, follow the instructions in the [documentation](https://qiskit.org/documentation/contributing_to_qiskit.html#install-install-from-source-label).\r\n\r\n## Create your first quantum program in Qiskit\r\n\r\nNow that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are:\r\n1. Define and build a quantum circuit that represents the quantum state\r\n2. Define the classical output by measurements or a set of observable operators\r\n3. Depending on the output, use the primitive function `sampler` to sample outcomes or the `estimator` to estimate values.\r\n\r\nCreate an example quantum circuit using the `QuantumCircuit` class:\r\n\r\n```python\r\nimport numpy as np\r\nfrom qiskit import QuantumCircuit\r\n\r\n# 1. A quantum circuit for preparing the quantum state |000> + i |111>\r\nqc_example = QuantumCircuit(3)\r\nqc_example.h(0)          # generate superpostion\r\nqc_example.p(np.pi/2,0)  # add quantum phase\r\nqc_example.cx(0,1)       # 0th-qubit-Controlled-NOT gate on 1st qubit\r\nqc_example.cx(0,2)       # 0th-qubit-Controlled-NOT gate on 2nd qubit\r\n```\r\n\r\nThis simple example makes an entangled state known as a [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) $(|000\\rangle + i|111\\rangle)/\\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (`h`), Phase gate (`p`), and CNOT gate (`cx`). \r\n\r\nOnce you've made your first quantum circuit, choose which primitive function you will use. Starting with `sampler`,\r\nwe use `measure_all(inplace=False)` to get a copy of the circuit in which all the qubits are measured:\r\n\r\n```python\r\n# 2. Add the classical output in the form of measurement of all qubits\r\nqc_measured = qc_example.measure_all(inplace=False)\r\n\r\n# 3. Execute using the Sampler primitive\r\nfrom qiskit.primitives.sampler import Sampler\r\nsampler = Sampler()\r\njob = sampler.run(qc_measured, shots=1000)\r\nresult = job.result()\r\nprint(f\" > Quasi probability distribution: {result.quasi_dists}\")\r\n```\r\nRunning this will give an outcome similar to `{0: 0.497, 7: 0.503}` which is `000` 50% of the time and `111` 50% of the time up to statistical fluctuations.  \r\nTo illustrate the power of Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXX-YYY$ and pass it to the `run()` function, along with our quantum circuit. Note the Estimator requires a circuit _**without**_ measurement, so we use the `qc_example` circuit we created earlier.\r\n\r\n```python\r\n# 2. define the observable to be measured \r\nfrom qiskit.quantum_info import SparsePauliOp\r\noperator = SparsePauliOp.from_list([(\"XXY\", 1), (\"XYX\", 1), (\"YXX\", 1), (\"YYY\", -1)])\r\n\r\n# 3. Execute using the Estimator primitive\r\nfrom qiskit.primitives import Estimator\r\nestimator = Estimator()\r\njob = estimator.run(qc_example, operator, shots=1000)\r\nresult = job.result()\r\nprint(f\" > Expectation values: {result.values}\")\r\n```\r\n\r\nRunning this will give the outcome `4`. For fun, try to assign a value of +/- 1 to each single-qubit operator X and Y \r\nand see if you can achieve this outcome. (Spoiler alert: this is not possible!)\r\n\r\nUsing the Qiskit-provided `qiskit.primitives.Sampler` and `qiskit.primitives.Estimator` will not take you very far. The power of quantum computing cannot be simulated \r\non classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum \r\ncircuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware.\r\nThe tool that does this is the [transpiler](https://qiskit.org/documentation/apidoc/transpiler.html) \r\nand Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a\r\ndefault compiler which works very well in most examples. The following code will map the example circuit to the `basis_gates = ['cz', 'sx', 'rz']` and a linear chain of qubits $0 \\rightarrow 1 \\rightarrow 2$ with the `coupling_map =[[0, 1], [1, 2]]`.\r\n\r\n```python\r\nfrom qiskit import transpile\r\nqc_transpiled = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3)\r\n```\r\n\r\nFor further examples of using Qiskit you can look at the tutorials in the documentation here:\r\n\r\n<https://qiskit.org/documentation/tutorials.html>\r\n\r\n### Executing your code on real quantum hardware\r\n\r\nQiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface. \r\nThe best way to use Qiskit is with a runtime environment that provides optimized implementations of `sampler` and `estimator` for a given hardware platform. This runtime may involve using pre- and post-processing, such as optimized transpiler passes with error suppression, error mitigation, and, eventually, error correction built in. A runtime implements `qiskit.primitives.BaseSampler` and `qiskit.primitives.BaseEstimator` interfaces. For example,\r\nsome packages that provide implementations of a runtime primitive implementation are:\r\n\r\n* https://github.com/Qiskit/qiskit-ibm-runtime\r\n\r\nQiskit also provides a lower-level abstract interface for describing quantum backends. This interface, located in\r\n``qiskit.providers``, defines an abstract `BackendV2` class that providers can implement to represent their\r\nhardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre- and post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface with real hardware are:\r\n\r\n* https://github.com/Qiskit/qiskit-ibm-provider\r\n* https://github.com/qiskit-community/qiskit-ionq\r\n* https://github.com/qiskit-community/qiskit-aqt-provider\r\n* https://github.com/qiskit-community/qiskit-braket-provider\r\n* https://github.com/qiskit-community/qiskit-quantinuum-provider\r\n* https://github.com/rigetti/qiskit-rigetti\r\n\r\n<!-- This is not an exhaustive list, and if you maintain a provider package please feel free to open a PR to add new providers -->\r\n\r\nYou can refer to the documentation of these packages for further instructions\r\non how to get access and use these systems.\r\n\r\n## Contribution Guidelines\r\n\r\nIf you'd like to contribute to Qiskit, please take a look at our\r\n[contribution guidelines](CONTRIBUTING.md). By participating, you are expected to uphold our [code of conduct](CODE_OF_CONDUCT.md).\r\n\r\nWe use [GitHub issues](https://github.com/Qiskit/qiskit-terra/issues) for tracking requests and bugs. Please\r\n[join the Qiskit Slack community](https://qisk.it/join-slack) for discussion, comments, and questions.\r\nFor questions related to running or using Qiskit, [Stack Overflow has a `qiskit`](https://stackoverflow.com/questions/tagged/qiskit).\r\nFor questions on quantum computing with Qiskit, use the `qiskit` tag in the [Quantum Computing Stack Exchange](https://quantumcomputing.stackexchange.com/questions/tagged/qiskit) (please, read first the [guidelines on how to ask](https://quantumcomputing.stackexchange.com/help/how-to-ask) in that forum).\r\n\r\n\r\n## Authors and Citation\r\n\r\nQiskit is the work of [many people](https://github.com/Qiskit/qiskit-terra/graphs/contributors) who contribute\r\nto the project at different levels. If you use Qiskit, please cite as per the included [BibTeX file](CITATION.bib).\r\n\r\n## Changelog and Release Notes\r\n\r\nThe changelog for a particular release is dynamically generated and gets\r\nwritten to the release page on Github for each release. For example, you can\r\nfind the page for the `0.9.0` release here:\r\n\r\n<https://github.com/Qiskit/qiskit-terra/releases/tag/0.9.0>\r\n\r\nThe changelog for the current release can be found in the releases tab:\r\n[![Releases](https://img.shields.io/github/release/Qiskit/qiskit-terra.svg?style=flat&label=)](https://github.com/Qiskit/qiskit-terra/releases)\r\nThe changelog provides a quick overview of notable changes for a given\r\nrelease.\r\n\r\nAdditionally, as part of each release detailed release notes are written to\r\ndocument in detail what has changed as part of a release. This includes any\r\ndocumentation on potential breaking changes on upgrade and new features.\r\nFor example, you can find the release notes for the `0.9.0` release in the\r\nQiskit documentation here:\r\n\r\nhttps://qiskit.org/documentation/release_notes.html#terra-0-9\r\n\r\n## Acknowledgements\r\n\r\nWe acknowledge partial support for Qiskit development from the DOE Office of Science National Quantum Information Science Research Centers, Co-design Center for Quantum Advantage (C2QA) under contract number DE-SC0012704.\r\n\r\n## License\r\n\r\n[Apache License 2.0](LICENSE.txt)\r\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Software for developing quantum computing programs",
    "version": "0.45.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/Qiskit/qiskit-terra/issues",
        "Documentation": "https://qiskit.org/documentation/",
        "Homepage": "https://github.com/Qiskit/qiskit",
        "Source Code": "https://github.com/Qiskit/qiskit-terra"
    },
    "split_keywords": [
        "qiskit",
        "sdk",
        "quantum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d418a5d973ed139105b336ee29cc65e60a093491e686ba81c9e0d110105d91a",
                "md5": "09f089ee16653d4904a4888af9d53486",
                "sha256": "6f14b7c6b691b6cfba792cc7ef68c9c4177b8907a681b061f3e08451ce26d4d8"
            },
            "downloads": -1,
            "filename": "artur_qiskit_terra-0.45.2-cp38-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "09f089ee16653d4904a4888af9d53486",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 5146808,
            "upload_time": "2024-01-19T16:55:00",
            "upload_time_iso_8601": "2024-01-19T16:55:00.423942Z",
            "url": "https://files.pythonhosted.org/packages/2d/41/8a5d973ed139105b336ee29cc65e60a093491e686ba81c9e0d110105d91a/artur_qiskit_terra-0.45.2-cp38-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-19 16:55:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Qiskit",
    "github_project": "qiskit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "rustworkx",
            "specs": [
                [
                    ">=",
                    "0.13.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.17"
                ],
                [
                    "<",
                    "2"
                ]
            ]
        },
        {
            "name": "psutil",
            "specs": [
                [
                    ">=",
                    "5"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.5"
                ]
            ]
        },
        {
            "name": "sympy",
            "specs": [
                [
                    ">=",
                    "1.3"
                ]
            ]
        },
        {
            "name": "dill",
            "specs": [
                [
                    ">=",
                    "0.3"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    ">=",
                    "2.8.0"
                ]
            ]
        },
        {
            "name": "stevedore",
            "specs": [
                [
                    ">=",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": []
        },
        {
            "name": "symengine",
            "specs": [
                [
                    "!=",
                    "0.10.0"
                ],
                [
                    ">=",
                    "0.9"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "artur-qiskit-terra"
}
        
Elapsed time: 0.19449s