Go to file
Matthew Treinish 247f44ef87
Reverse argument order on qpy_serialization.dump and fix warning (#6449)
* Reverse argument order on qpy_serialization.dump and fix warning

This commit reverses the argument order on the dump() function in the
qiskit.circuit.qpy_serialization module. The equivalent function in
pickle uses the argument order 'dump(obj, file)'. [1] So to ensure
consistency with the equivalent stdlib function and avoid surprises for
users this commit swaps the argument order before we release and are
locked into the api.

The other minor fix as part of this PR is the warning message about
loading qpy generated by newer qiskit was not correctly generating the
version string from the qpy data. It needed to cast the version parts
into a string prior to calling join(). This has been fixed so in case
someone tries to load a qpy generated with a qiskit version newer than
the one loading it the warning about it maybe not working actually
prints (and it loads instead of raising an exception).

[1] https://docs.python.org/3/library/pickle.html#pickle.dump

* Run black

* Update tests

Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
2021-06-22 16:18:42 +00:00
.github Fix codeowners matching rule for utils (#5626) 2021-01-14 16:49:59 +00:00
docs Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00
examples Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00
qiskit Reverse argument order on qpy_serialization.dump and fix warning (#6449) 2021-06-22 16:18:42 +00:00
releasenotes Fix oracle_evaluation for PhaseOracle (#6365) 2021-06-18 14:51:12 +00:00
test Reverse argument order on qpy_serialization.dump and fix warning (#6449) 2021-06-22 16:18:42 +00:00
tools Fix lint in subunit to junit tools script (#6614) 2021-06-21 16:35:51 +00:00
.git-blame-ignore-revs Add git blame ignore file (#6362) 2021-05-05 16:43:47 +00:00
.gitignore Fix density matrix expval cython function (#5984) 2021-03-11 15:49:23 +00:00
.local-spellings speeling fixes (#5858) 2021-02-19 00:54:19 +00:00
.mailmap Update mailmap (#6561) 2021-06-12 18:19:49 +00:00
.mergify.yml Pivot mergify config to use a merge queue (#6211) 2021-05-07 17:41:08 -04:00
.pylintrc Lint tweaks (#6037) 2021-06-13 20:55:47 -04:00
.stestr.conf Removes stestr's grouping configuration. (#6399) 2021-05-12 19:06:06 +00:00
.travis.yml Prepare for renaming default branch to main (#6221) 2021-04-20 12:30:16 -04:00
CODE_OF_CONDUCT.md Pointing all Qiskit projects to main CoC file moving forward. (#5412) 2020-11-18 13:24:17 -05:00
CONTRIBUTING.md deprecation warnings as error while testing (#6392) 2021-05-27 20:16:24 +00:00
LICENSE.txt Consistent license across all the project (#550) 2018-06-08 15:00:58 +02:00
MANIFEST.in Modify linux 3.7 CI job to install from sdist (#6175) 2021-04-10 14:37:26 +00:00
Make.bat Fix typo under qiskit directory (#3659) 2020-01-09 17:23:54 -05:00
Makefile Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00
README.md Skip badges on pypi (#6034) 2021-04-06 22:07:36 +00:00
azure-pipelines.yml Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00
constraints.txt remove docplex in constraints.txt (#6613) 2021-06-21 23:21:41 +00:00
postBuild Make all mpl styles json loads and update visualization code and docs (#5223) 2020-10-29 22:26:39 +00:00
pyproject.toml Switch to using black for code formatting (#6361) 2021-05-05 09:53:39 -04:00
requirements-dev.txt Pin sphinx-panels version for docs builds (#6511) 2021-06-04 15:10:48 -04:00
requirements.txt Performance improvements for collect_2q_blocks (#6433) 2021-06-08 18:42:11 +00:00
setup.py Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00
tox.ini Blacken stragglers (#6611) 2021-06-21 21:49:31 +00:00

README.md

Qiskit Terra

LicenseBuild StatusReleaseDownloadsCoverage Status

Qiskit is an open-source framework for working with noisy quantum computers at the level of pulses, circuits, and algorithms.

Qiskit is made up of elements that work together to enable quantum computing. This element is Terra and is the foundation on which the rest of Qiskit is built.

Installation

We encourage installing Qiskit via the pip tool (a python package manager), which installs all Qiskit elements, including Terra.

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.

Creating Your First Quantum Program in Qiskit Terra

Now that Qiskit is installed, it's time to begin working with Terra.

We are ready to try out a quantum circuit example, which is simulated locally using the Qiskit BasicAer element. This is a simple example that makes an entangled state.

$ python
>>> from qiskit import QuantumCircuit, transpile
>>> from qiskit.providers.basicaer import QasmSimulatorPy
>>> qc = QuantumCircuit(2, 2)
>>> qc.h(0)
>>> qc.cx(0, 1)
>>> qc.measure([0,1], [0,1])
>>> backend_sim = QasmSimulatorPy()
>>> transpiled_qc = transpile(qc, backend_sim)
>>> result = backend_sim.run(transpiled_qc).result()
>>> print(result.get_counts(qc))

In this case, the output will be:

{'00': 513, '11': 511}

A script is available here, where we also show how to run the same program on a real quantum computer via IBMQ.

Executing your code on a real quantum chip

You can also use Qiskit to execute your code on a real quantum chip. In order to do so, you need to configure Qiskit for using the credentials in your IBM Q account:

Configure your IBMQ credentials

  1. Create an IBM Q > Account if you haven't already done so.

  2. Get an API token from the IBM Q website under My Account > API Token and the URL for the account.

  3. Take your token and url from step 2, here called MY_API_TOKEN, MY_URL, and run:

    >>> from qiskit import IBMQ
    >>> IBMQ.save_account('MY_API_TOKEN', 'MY_URL')
    

After calling IBMQ.save_account(), your credentials will be stored on disk. Once they are stored, at any point in the future you can load and use them in your program simply via:

>>> from qiskit import IBMQ
>>> IBMQ.load_account()

Those who do not want to save their credentials to disk should use instead:

>>> from qiskit import IBMQ
>>> IBMQ.enable_account('MY_API_TOKEN')

and the token will only be active for the session. For examples using Terra with real devices we have provided a set of examples in examples/python and we suggest starting with using_qiskit_terra_level_0.py and working up in the levels.

Contribution Guidelines

If you'd like to contribute to Qiskit Terra, please take a look at our contribution guidelines. This project adheres to Qiskit's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please join the Qiskit Slack community and use our Qiskit Slack channel for discussion and simple questions. For questions that are more suited for a forum we use the Qiskit tag in the Stack Exchange.

Next Steps

Now you're set up and ready to check out some of the other examples from our Qiskit Tutorials repository.

Authors and Citation

Qiskit Terra is the work of many people who contribute to the project at different levels. If you use Qiskit, please cite as per the included BibTeX file.

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 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

License

Apache License 2.0