Commit Graph

45 Commits

Author SHA1 Message Date
Matthew Treinish b7fcc76afb
Document release note subsections and categorize 1.1 notes (#11926)
* Document release note subsections and categorize 1.1 notes

This commit adds contributor documentation about the release note
subsections. Now that we're using subsections on main we should
encourage contributors to use the appropriate subsection when adding new
release notes to reduce the release time effort needed to correctly
categorize the release notes. This also updates the new release note
template to list out all the subsections.

This also updates the current notes pending for the 1.1.0 release to
use subsections so that from this point forward we're using subsections
for all feature, deprecation, and upgrade notes.

* Update releasenotes/notes/classical-store-e64ee1286219a862.yaml
2024-03-20 14:47:58 +00:00
Eric Arellano de4d0157dd
Remove more qiskit.org links (#11778) 2024-02-13 11:59:06 +00:00
Daniel Choi f808fe5c0d
Documentation on building doc locally (#11073)
* Adding documentation on building doc locally using tox, sphinx and make.

* fix suggestions from ElePT

* resetting Sphinx's cache.

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

* Suggesting by Eric to open the html file

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

* Update CONTRIBUTING.md

* Leave tox as the only option

---------

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2023-12-19 14:09:47 +00:00
abbycross cc6fa8f147
Add pointer to qiskit/documentation issues for docs issues outside of API references (#11373)
* Create config.yml

* Update CONTRIBUTING.md

* Update contributing.md

* Update .github/ISSUE_TEMPLATE/config.yml

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

* code review

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

* code review

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

* add migration guide link, add "issues" to header

* add to toc at top, update anchor tag

* Update CONTRIBUTING.md

Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
2023-12-08 08:11:18 +00:00
TsafrirA 31c2089a1e
Fix deprecation policy link in `CONTRIBUTING.md` (#11276)
* Fix deprecation policy link

* Update CONTRIBUTING.md

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2023-11-24 20:36:25 +00:00
Abby Mitchell b3a422a9ba
Combined contribute_to_qiskit.rst with contributing.md (#11217)
* Combined contribut_to_qiskit.rst with contributing.md

* Update CONTRIBUTING.md

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jake@binhbar.com>

* applied review comments and removed old contributing guide

* fixed docs warning

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
2023-11-20 18:58:06 +00:00
John Lapeyre 901e3b8973
Add ruff to local tests and CI (#10116)
* Add ruff to local tests and CI

This adds linting using ruff to the relevant configuration files. Only
a few rules are enabled and none of them trigger an error in the current
state of the repo.

* Add comments on running black separately from tox

* Simplify and remove potentially bug causing instructions in CONTRIBUTING

* Update pyproject.toml

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2023-05-30 22:43:36 +00:00
Jake Lishman 4dfef13085
Drop support for Python 3.7 (#10009)
* Drop support for Python 3.7

This updates our documentation and build processes to set Python 3.8 as
the oldest support version of Python, consistent with our policy on
Python support.

This commit also removes remaining Python-version gating, since we were
principally using this to account for differences between 3.7 and 3.8.
Several backport packages are no longer required for any suppported
Python version, because of this change.

* Remove test for multiprocessing on Mac

With Python 3.7 support now dropped, there are no versions of Python on
macOS that we expect to support with multiprocessing again.  There's no
guarantee that the hypothetical Python 10.11 (???) that this test was
previously checking would be any more valid than existing versions.

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2023-05-05 15:28:34 +00:00
Eric Arellano 38da9a7959
Add `rust-toolchain.toml` for a consistent Rust development version (#9584)
* Add `rust-toolchain.toml` for a consistent Rust development version

* Add components

* Simplify CI to not set Rust version

It will now use the rust-toolchain.toml file. This is possible because Rustup is already on the PATH, evidenced by us previously running `rustup default`

* Build Azure wheels with stable toolchain

* Use Stable for the sdist test build

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-02-15 19:38:00 +00:00
Adrin Jalali 45776849ee
DOC add build dependency to contributing guides (#9510)
* DOC add build dependency to contributing guides

* add pip command

* move note and remove explicitly listed packages

* Fix typo

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-02-01 20:41:26 +00:00
Matthew Treinish 10c57a7ef3
Bump MSRV to 1.61 and all rust dependencies to latest releases (#9393)
This commit bumps the minimum supported rust version from 1.56.1 to
1.61.0 (which is the LCD for all our dependencies) which was released
on 2022-05-19. By doing this we're now able to bump all of our
upstream dependencies to use the latest releases.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-20 19:53:10 +00:00
Matthew Treinish 186c807877
Explicitly set MSRV for rust extension (#8196)
* Explicitly set MSRV for rust extension

This commit explicitly sets the MSRV (minimum supported rust version)
for Qiskit Terra to 1.56 which was released in October 2021 (with 1.56.1
which fixed two CVEs being released Nov. 1st 2021). Previously we had
avoided setting a hard MSRV and opted to try and just loosely support the
past 6 months of rust releases. However, managing it loosely has proven
tricky to manage in practice. This commit sets a hard version for MSRV
and modifies a test job to validate we're able to compile with the MSRV.
This should ensure we're able to avoid breaking compatibility for that
version.

* Explicitly set MSRV to 1.56.1 instead of loosely 1.56

* Explicitly set version as variable in CI config

* Assign MSRV to azure variable

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-17 19:20:42 +00:00
Matthew Treinish b2ddaeb873
Document modifications to the release process (#8042)
* Document modifications to the release process

This commit updates the CONTRIBUTING.md file to more clearly document
the current release process. Previously for the release cycle
documentation we just had a mechanical list of the steps done by the
core team and what the automation does but it didn't really contain any
details on the aspects of how contributions with releasing. This commit
updates this section to better describe the different phases of a
release and the expectations and order of operations a contributor will
need to know around releasing.

* Update CONTRIBUTING.md

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 11:21:55 +00:00
Omar Costa Hamido 44c45ad503
Improve CONTRIBUTING.md (#7693)
* Update CONTRIBUTING.md

- improve sentence articulation.

* Update CONTRIBUTING.md

- removing some extra ":" characters

* add more restruct text ex and updt desc

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-03-16 16:25:04 +00:00
Matthew Treinish ccc371f8ff
Implement multithreaded stochastic swap in rust (#7658)
* Implement multithreaded stochastic swap in rust

This commit is a rewrite of the core swap trials functionality in the
StochasticSwap transpiler pass. Previously this core routine was written
using Cython (see #1789) which had great performance, but that
implementation was single threaded. The core of the stochastic swap
algorithm by it's nature is well suited to be executed in parallel, it
attempts a number of random trials and then picks the best result
from all the trials and uses that for that layer. These trials can
easily be run in parallel as there is no data dependency between the
trials (there are shared inputs but read-only). As the algorithm
generally scales exponentially the speed up from running the trials in
parallel can offset this and improve the scaling of the pass. Running
the pass in parallel was previously tried in #4781 using Python
multiprocessing but the overhead of launching an additional process and
serializing the input arrays for each trial was significantly larger
than the speed gains. To run the algorithm efficiently in parallel
multithreading is needed to leverage shared memory on shared inputs.

This commit rewrites the cython routine using rust. This was done for
two reasons. The first is that rust's safety guarantees make dealing
with and writing parallel code much easier and safer. It's also
multiplatform because the rust language supports native threading
primatives in language. The second is while writing parallel cython
code using open-mp there are limitations with it, mainly on windows. In
practice it was also difficult to write and maintain parallel cython
code as it has very strict requirements on python and c code
interactions. It was much faster and easier to port it to rust and the
performance for each iteration (outside of parallelism) is the same (in
some cases marginally faster) in rust. The implementation here reuses
the data structures that the previous cython implementation introduced
(mainly flattening all the terra objects into 1d or 2d numpy arrays for
efficient access from C).

The speedups from this PR can be significant, calling transpile() on a
400 qubit (with a depth of 10) QV model circuit targetting a 409 heavy
hex coupling map goes from ~200 seconds with the single threaded cython
to ~60 seconds with this PR locally on a 32 core system, When transpiling
a 1000 qubit (also with a depth of 10) QV model circuit targetting a 1081
qubit heavy hex coupling map goes from taking ~6500 seconds to ~720
seconds.

The tradeoff with this PR is for local qiskit-terra development a rust
compiler needs to be installed. This is made trivial using rustup
(https://rustup.rs/), but it is an additional burden and one that we
might not want to make. If so we can look at turning this PR into a
separate repository/package that qiskit-terra can depend on. The
tradeoff here is that we'll be adding friction to the api boundary
between the pass and the core swap trials interface. But, it does ease
the dependency on development for qiskit-terra.

* Sanitize packaging to support future modules

This commit fixes how we package the compiled rust module in
qiskit-terra. As a single rust project only gives us a single compiled
binary output we can't use the same scheme we did previously with cython
with a separate dynamic lib file for each module. This shifts us to
making the rust code build a `qiskit._accelerate` module and in that we
have submodules for everything we need from compiled code. For this PR
there is only one submodule, `stochastic_swap`, so for example the
parallel swap_trials routine can be imported from
`qiskit._accelerate.stochastic_swap.swap_trials`. In the future we can
have additional submodules for other pieces of compiled code in qiskit.
For example, the likely next candidate is the pauli expectation value
cython module, which we'll likely port to rust and also make parallel
(for sufficiently large number of qubits). In that case we'd add a new
submodule for that functionality.

* Adjust random normal distribution to use correct mean

This commit corrects the use of the normal distribution to have the mean
set to 1.0. Previously we were doing this out of band for each value by
adding 1 to the random value which wasn't necessary because we could
just generate it with a mean of 1.0.

* Remove unecessary extra scope from locked read

This commit removes an unecessary extra scope around the locked read for
where we store the best solution. The scope was previously there to
release the lock after we check if there is a solution or not. However
this wasn't actually needed as we can just do the check inline and the
lock will release after the condition block.

* Remove unecessary explicit type from opt_edges variable

* Fix indices typo in NLayout constructor

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Remove explicit lifetime annotation from swap_trials

Previously the swap_trials() function had an explicit lifetime
annotation `'p` which wasn't necessary because the compiler can
determine this on it's own. Normally when dealing with numpy views and a
Python object (i.e. a GIL handle) we need a lifetime annotation to tell
the rust compiler the numpy view and the python gil handle will have the
same lifetime. But since swap_trials doesn't take a gil handle and
operates purely in rust we don't need this lifetime and the rust
compiler can deal with the lifetime of the numpy views on their own.

* Use sum() instead of fold()

* Fix lint and add rust style and lint checks to CI

This commit fixes the python lint failures and also updates the ci
configuration for the lint job to also run rust's style and lint
enforcement.

* Fix returned layout mapping from NLayout

This commit fixes the output list from the `layout_mapping()`
method of `NLayout`. Previously, it incorrectly would return the
wrong indices it should be a list of virtual -> physical to
qubit pairs. This commit corrects this error

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Tweak tox configuration to try and reliably build rust extension

* Make swap_trials parallelization configurable

This commit makes the parallelization of the swap_trials() configurable.
This is dones in two ways, first a new argument parallel_threshold is
added which takes an optional int which is the number of qubits to
switch between a parallel and serial version. The second is that it
takes into account the the state of the QISKIT_IN_PARALLEL environment
variable. This variable is set to TRUE by parallel_map() when we're
running in a multiprocessing context. In those cases also running
stochastic swap in parallel will likely just cause too much load as
we're potentially oversubscribing work to the number of available CPUs.
So, if QISKIT_IN_PARALLEL is set to True we run swap_trials serially.

* Revert "Make swap_trials parallelization configurable"

This reverts commit 57790c84b0. That
commit attempted to sovle some issues in test running, mainly around
multiple parallel dispatch causing exceess load. But in practice it was
broken and caused more issues than it fixed. We'll investigate and add
control for the parallelization in a future commit separately after all
the tests are passing so we have a good baseline.

* Add docs to swap_trials() and remove unecessary num_gates arg

* Fix race condition leading to non-deterministic behavior

Previously, in the case of circuits that had multiple best possible
depth == 1 solutions for a layer, there was a race condition in the fast
exit path between the threads which could lead to a non-deterministic
result even with a fixed seed. The output was always valid, but which
result was dependent on which parallel thread with an ideal solution
finished last and wrote to the locked best result last. This was causing
weird non-deterministic test failures for some tests because of #1794 as
the exact match result would change between runs. This could be a bigger
issue because user expectations are that with a fixed seed set on the
transpiler that the output circuit will be deterministically
reproducible.

To address this is issue this commit trades off some performance to
ensure we're always returning a deterministic result in this case. This
is accomplished by updating/checking if a depth==1 solution has been
found in another trial thread we only act (so either exit early or
update the already found depth == 1 solution) if that solution already
found has a trial number that is less than this thread's trial number.
This does limit the effectiveness of the fast exit, but in practice it
should hopefully not effect the speed too much.

As part of this commit some tests are updated because the new
deterministic behavior is slightly different from the previous results
from the cython serial implementation. I manually verified that the
new output circuits are still valid (it also looks like the quality
of the results in some of those cases improved, but this is strictly
anecdotal and shouldn't be taken as a general trend with this PR).

* Apply suggestions from code review

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Fix compiler errors in previous commit

* Revert accidental commit of parallel reduction in compute_cost

This was only a for local testing to prove it was a bad idea and was
accidently included in the branch. We should not nest the parallel
execution like this.

* Eliminate short circuit for depth == 1 swap_trial() result

This commit eliminates the short circuit fast return in swap_trial()
when another trial thread has found an ideal solution. Trying to do this
in a parallel context is tricky to make deterministic because in cases
of >1 depth == 1 solutions there is an inherent race condition between
the threads for writing out their depth == 1 result to the shared
location. Different strategies were tried to make this reliably
deterministic but there wa still a race condition. Since this was just a
performance optimization to avoid doing unnecessary work this commit
removes this step. Weighing improved performance against repeatability
in the output of the compiler, the reproducible results are more
important. After we've adopted a multithreaded stochastic swap we can
investigate adding this back as a potential future optimization.

* Add missing docstrings

* Add section to contributing on installing form source

* Make rust python classes pickleable

* Add rust compiler install to linux wheel jobs

* Try more tox changes to fix docs builds

* Revert "Eliminate short circuit for depth == 1 swap_trial() result"

This reverts commit c510764a77. The
removal there was premature and we had a fix for the non-determinism in
place, ignoring a typo which was preventing it from working.

Co-Authored-By: Georgios Tsilimigkounakis <45130028+georgios-ts@users.noreply.github.com>

* Fix submodule declaration and module attribute on rust classes

* Fix rust lint

* Fix docs job definition

* Disable multiprocessing parallelism in unit tests

This commit disables the multiprocessing based parallelism when running
unittest jobs in CI. We historically have defaulted the use of
multiprocessing in environments only where the "fork" start method is
available because this has the best performance and has no caveats
around how it is used by users (you don't need an
`if __name__ == "__main__"` guard). However, the use of the "fork"
method isn't always 100% reliable (see
https://bugs.python.org/issue40379), which we saw on Python 3.9 #6188.
In unittest CI (and tox) by default we use stestr which spawns (not using
fork) parallel workers to run tests in parallel. With this PR this means
in unittest we're now running multiple test runner subprocesses, which
are executing parallel dispatched code using multiprocessing's fork
start method, which is executing multithreaded rust code. This three layers
of nesting is fairly reliably hanging as Python's fork doesn't seem to
be able to handle this many layers of nested parallelism. There are 2
ways I've been able to fix this, the first is to change the start method
used by `parallel_map()` to either "spawn" or "forkserver" either of
these does not suffer from random hanging. However, doing this in the
unittest context causes significant overhead and slows down test
executing significantly. The other is to just disable the
multiprocessing which fixes the hanging and doesn't impact runtime
performance signifcantly (and might actually help in CI so we're not
oversubscribing the limited resources.

As I have not been able to reproduce `parallel_map()` hanging in
a standalone context with multithreaded stochastic swap this commit opts
for just disabling multiprocessing in CI and documenting the known issue
in the release notes as this is the simpler solution. It's unlikely that
users will nest parallel processes as it typically hurts performance
(and parallel_map() actively guards against it), we only did it in
testing previously because the tests which relied on it were a small
portion of the test suite (roughly 65 tests) and typically did not have
a significant impact on the total throughput of the test suite.

* Fix typo in azure pipelines config

* Remove unecessary extension compilation for image tests

* Add test script to explicitly verify parallel dispatch

In an earlier commit we disabled the use of parallel dispatch in
parallel_map() to avoid a bug in cpython associated with their fork()
based subprocess launch. Doing this works around the bug which was
reliably triggered by running multiprocessing in parallel subprocesses.
It also has the side benefit of providing a ~2x speed up for test suite
execution in CI. However, this meant we lost our test coverage in CI for
running parallel_map() with actual multiprocessing based parallel
dispatch. To ensure we don't inadvertandtly regress this code path
moving forward this commit adds a dedicated test script which runs a
simple transpilation in parallel and verifies that everything works as
expected with the default parallelism settings.

* Avoid multi-threading when run in a multiprocessing context

This commit adds a switch on running between a single threaded and a
multithreaded variant of the swap_trials loop based on whether the
QISKIT_IN_PARALLEL flag is set. If QISKIT_IN_PARALLEL is set to TRUE
this means the `parallel_map()` function is running in the outer python
context and we're running in multiprocessing already. This means we do
not want to be running in multiple threads generally as that will lead
to potential resource exhaustion by spawn n processes each potentially
running with m threads where `n` is `min(num_phys_cpus, num_tasks)` and
`m` is num_logical_cpus (although only
`min(num_logical_cpus, num_trials)` will be active) which on the typical
system there aren't enough cores to leverage both multiprocessing and
multithreading. However, in case a user does have such an environment
they can set the `QISKIT_FORCE_THREADS` env variable to `TRUE` which
will use threading regardless of the status of `QISKIT_IN_PARALLEL`.

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Minor fixes from review comments

This commits fixes some minor details found during code review. It
expands the section on building from source to explain how to build a
release optimized binary with editable mode, makes the QISKIT_PARALLEL
env variable usage consistent across all jobs, and adds a missing
shebang to the `install_rush.sh` script which is used to install rust in
the manylinux container environment.

* Simplify tox configuration

In earlier commits the tox configuration was changed to try and fix the
docs CI job by going to great effort to try and enforce that
setuptools-rust was installed in all situations, even before it was
actually needed. However, the problem with the docs ci job was unrelated
to the tox configuration and this reverts the configuration to something
that works with more versions of tox and setuptools-rust.

* Add missing pieces of cargo configuration

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-28 21:49:54 +00:00
Jake Lishman 531e62f3a3
Optimise `import qiskit` with lazy imports (#7525)
* Unify lazy handling of optional dependencies

This introduces new `HAS_X` variables for each of Qiskit's optional
dependencies, and provides a simple unified interface to them from
`qiskit.utils.optionals`.  These objects lazily test for their
dependency when evaluated in a Boolean context, and have two `require_`
methods to unify the exception handling.  `require_now` tests
immediately for the dependency and raises `MissingOptionalLibraryError`
if it is not present, and `require_in_call` is a decorator that lazily
tests for the dependencies when the function is called.

These remove the burden of raising nice exceptions from the usage
points; a function marked `HAS_MATPLOTLIB.require_in_call` can now
safely `import matplotlib` without special handling, for example.  This
also provides a unified way for consumers of `qiskit` (such as the test
suite) to query the presence of libraries.

All tests are now lazy, and imports are moved to the point of usage, not
the point of import of the module.  This means that `import qiskit` is
significantly faster for people who have many of the optional
dependencies installed; rather than them all being loaded at initial
import just to test their presence, they will now be loaded on demand.

* Optimise time taken for `import qiskit`

This makes several imports lazy, only being imported when they are
actually called and used.  In particular, no component of `scipy` is
imported during `import qiskit` now, nor is `pkg_resources` (which is
surprisingly heavy).

No changes were made to algorithms or opflow, since these are not
immediately imported during `import qiskit`, and likely require more
significant work than the rest of the library.

* Import missing to-be-deprecated names

* Convert straggler tests to require_now

* Correct requirements in test cases

* Add `require_in_instance` class decorator

Effectively this is just a wrapper around `__init__`, except that this
class-decorator form will do the right thing even if `__init__` isn't
explicitly defined on the given class.

The implementation of `wrap_method` is a replacement for the older
`test.decorators._wrap_method`, which didn't handle all the possible
special cases as well, and messed up the documentation of its wrapped
functions.  That wasn't so important when it was just a private
function, but now it has become public (so that
`test.decorators.enforce_subclasses_call` can still use it from
`qiskit.utils`), it needed reworking to be more polished.

* Privatise non-public names rather than del

* Add tests of `require_in_instance`

* Fix typos in documentation

* Add section on requirements to CONTRIBUTING

* Update documentation on HoareOptimizer error

* Remove UK localisation

* Mention more uses of PIL in documentation

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-02 12:31:34 +00:00
Abby Mitchell 8dbb7183c6
Add contents list and label descriptions to contributing docs (#7158)
* Update contributing docs

* fix typo

Co-authored-by: Jake Lishman <jake@binhbar.com>

* fix typo

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Swapped 'good for community' label with 'help wanted'

* tweaked wording

* Fix minor typos

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-26 15:29:51 +00:00
Lev Bishop 105cba366d
Add incremental pylint make target (#6597)
* Add incremental pylint make target

* add tox.ini and fetch/compare to origin/HEAD

* commands

* opportunistic caching

* Add small tool to avoid shell utils

* import pylint not sub-process. clean examples

* blacken few extra files

* just pylint

* update contributing.md

* tweak error msg, tox.ini

* fixup makefile, tox.ini

* command line tweaks

* add tools to lint-incr target

* Update tox.ini

* Revert "Update tox.ini"

Tox doesn't support globbing so this change wasn't valid that line was
commented on purpose. This reverts the previous tox.ini update and adds
a comment about the commented line to explain the intent.

This reverts commit c33c2745cf.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2021-07-23 00:06:55 +00:00
Luciano Bello bfc0eb59d0
deprecation warnings as error while testing (#6392)
* deprecation warnings as error while testing

* more allowlist

* more

* add pulses

* pulses

* quantuminfo

* QuantumCircuit.u

* CXDirection

* moving error

* more

* test.python.quantum_info.operators.test_scalar_op

* test.python.quantum_info.operators.channel

* test.python.quantum_info.operators.channel.est_stinespring

* more exception for windows

* Deprecating code doc

* new expception

* add example

* spacing

* Fixed grammar/typos in contributing.md

Co-authored-by: Abby-Mitchell <abby.mitchell@btinternet.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-05-27 20:16:24 +00:00
Ikko Hamamura 567db74822
Fix missing parenthesis in CONTRIBUTING.md (#6374)
In #6361 the CONTRIBUTING.md was updated to reflect the use of black for code formatting.
However, as part of that change a typo was made in the link to pylint. This commit corrects that
issue so the link to pylint works in the rendered markdown.
2021-05-07 12:19:38 -04:00
Matthew Treinish dc592ffd58
Add git blame ignore file (#6362)
This commit adds a new file with the SHA1 of commits to ignore when
running git blame. This is important because of the recent adoption of
black as our code formatting tool in #6361 we caused a large amount of
code churn to change the code formatting. However using the ignore file
is a local opt-in feature for git and not something we can enable
globally by default. To facilitate this a section is added to the bottom
of the contributing guide to document how this file can be used.
2021-05-05 16:43:47 +00:00
Matthew Treinish 2eee56616d
Switch to using black for code formatting (#6361)
* make compatible with pylint and pycodestyle

* black config

* flake8 compatible config

* Missing newline

* Add black check to CI and dev requirements

This commit updates the CI configuration and local tox configuration to
leverage black instead of pycodestyle. It adds a check job to ci and the
tox lint job so we can quickly check if black has been run. A tox job
named 'black' is added to run black on all the code in the repo.

* Run black on everything

This commit reformats all the code in the qiskit-terra repository to use
black. It changes no functionality in the project and just adjusts the
code formatting to be consistent and automated. If you are looking at
this commit in the git log you can likely safely ignore any diff from
this commit as it is just the result of running '`black' on the repo
and instead you should look at any commits before or after this for
functional changes.

Co-authored-by: Lev S. Bishop <18673315+levbishop@users.noreply.github.com>
2021-05-05 09:53:39 -04:00
Abby Mitchell e2ebf12324
Add documentation for running visualisation snapshot tests (#6088)
* Added test snapshot

* Removed example test

* Updated contributing docs with snapshot testing info

* Fixed image url

* Made changes according to PR requests

* Added note about not pushing metadata changes
2021-04-22 11:22:51 +00:00
Matthew Treinish 98130dd615
Prepare for renaming default branch to main (#6221)
With the pending support being added to qiskit-bot in
Qiskit/qiskit-bot#9 we're able to rename the default branch for the
repository to 'main'. However, when we do that several things will need
to be updated, most importantly the CI trigger was hardcoded to the
previous default branch 'master. This commit fixes these references and
should be merged after we rename the branch to re-enable CI.
2021-04-20 12:30:16 -04:00
Matthew Treinish 393f8fe8ef
Add more details on documentation to the PR checklist (#6218)
* Add more details on documentation to the PR checklist

This commit expands step 2 on updating documentation in the
CONTRIBUTING.md file's checklist for opening a PR. This was previously
missing an explanation about needing to update the autosummary
directives if a new class, function, or module is added otherwise it
won't be included in the documentation builds. In addition to fixing
this oversight a link is added to the contributing documentation's
section on the documentation structure to provide more details on how to
add/where to add new objects to the documentation build.

* Add note on new objects being user facing

* Update CONTRIBUTING.md

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Apply suggestions from code review

Co-authored-by: Abby Mitchell <abby.s.mitchell@gmail.com>

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Abby Mitchell <abby.s.mitchell@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-04-15 16:21:46 +00:00
Matthew Treinish 1b44513309
Clarify the CONTRIBUTING.md section on stream capture (#5761)
This commit expands on the stream capture section of the CONTRIBUTING.md
guide. The existing section was a bit confusing because it makes the
QISKIT_TEST_CAPTURE_STREAMS environment variable sound general but it
only works with stestr (or a similar test runner built on the same
stack). This clarifies that it only has the desired effect with stestr
and if you're using the stdlib runner this is the equivalent of running
--buffer.
2021-02-01 17:43:36 +00:00
Matthew Treinish 01ded73d1d
Add support for attachments to test execution (#3982)
* Add support for attachments to test execution

By default in CI and with tox locally we run all the tests in parallel.
However, this makes things like printing to stdout, warnings on stderr,
or logging during tests difficult to deal with. This is because we'll
have multiple writers to the output streams simultaneously and no way
to figure out which text goes to which test. Luckily stestr and the
subunit protocl it uses internally has a method for adding attachments
to test results to handle this kind of case. Using this each output
stream is associated with the test which generated it and will get
displayed as such. The only issue with this is that the stdlib unittest
doesn't know how to write attachments to it's result stream. There is a
unittest extension library testtools[1] that provides this functionality
in a strictly compatible manner with unittest, however the current state
of the library needs some work before it can work well with more modern
features of stdlib unittest from python>3.5 so we either have to change
the tests to not use these features or come up with an alternative
solution for test attachments.

This commit ports the necessary result streaming functionality from
testtools into the QiskitTestCase base test class and then sets up the
appropriate fixtures to attach output streams from each test. This works
around the current limitation with testtools (I'm slowly working on
fixing this in testtools) but still provides the functionality. When
testtools is at the point it can be a drop in replacement for unittest
as terra is using it we can drop this code.

As part of this change all the test classes that define a setUp have a
missing super() call added. This framework does not work without setUp
in the base class being defined since that's what is used to setup the
stream capture. Moving forward the base test class actually enforces
that super() is called, otherwise the tests will fail.

[1] https://github.com/testing-cabal/testtools

* Fix lint

* Update contributing doc

* Fix copy paste error

* Add missing super calls from new tests

* Add missing super() calls and fix skip message

* Fix lint

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
2020-09-09 23:01:54 +00:00
Aniruddha Sarkar b5285ccc5c
minor_spelling_mistakes (#4847)
Two misspelled word were edited
2020-08-01 12:40:17 -04:00
Matthew Treinish a87fe61992
Use FakeProvider for jupyter and monitor tests (#4296)
* Use FakeProvider for jupyter and monitor tests

Right now the jupyter widget tests and backend monitor tests are the
only place in the qiskit-terra unittests that require talking to IQX.
This commit removes that dependency by leveraging the FakeProvider and
FakeBackends which contain snapshots of the responses from the IBMQ api.

To accomplish mocking out the qiskit-ibmq-provider usage the
backend_overview module had to be renamed because it conflicted with the
backend_overview function and was not importable via an absolute import.

* Fix tests and lint

* Remove online tests from contributing documentation

There are no longer any online tests in the suite now that the provider
interactions have been mocked out. This commit removes the documentation
about how to configure the online tests.

* Fixes from review comments
2020-05-15 19:26:34 -04:00
Kazuaki Ishizaki 6789862ace Fix typo under qiskit directory (#3659)
* fix typo

* address review comment

* address review comment
2020-01-09 17:23:54 -05:00
Matthew Treinish f9d04bee6c Cleanup CONTRIBUTING.md file (#3550)
As part of the effort to standardize working between all the qiskit
elements and adopting the same workflow and common practices for each
element we recently added most of terra's contributing.md file into the
documentation (see Qiskit/qiskit#868). This commit updates the
contributing file to reference the hosted documentation and removes the
duplicated sections. At the same time this commit also adds some additional
details on referencing issues inside a release note.
2019-12-05 14:01:59 +00:00
Matthew Treinish b9f2de9700 Add overview of doc structure and process to contributing guide (#3389)
This commit expands the sections on documentation in the CONTRIBUTING.md
file to cover in more depth the new documentation structure and workflow
that is currently being adopted. [1][2] This strives to provide useful
information for so that patch authors and reviewers know how
documentation in terra is structured and how it gets built as part of
the larger qiskit documentation.

[1] https://github.com/Qiskit/qiskit-terra/pull/3325
[2] https://github.com/Qiskit/qiskit/pull/551
2019-11-08 06:30:00 +00:00
Matthew Treinish 8f70d2df44 Add deprecation policy to CONTRIBUTING.md (#3191)
* Add deprecation policy to CONTRIBUTING.md

As we've become better about stabilizing interfaces in terra we've
started deprecating features and APIs prior removal. This is necessary
step towards growing user trust that they can rely on terra moving
forward, so that code they write using it will continue to work in the
future. However it's not necessarily clear what the expectations are for
features and APIs when they become deprecated. This commit attempts to
address this by adding a deprecation policy to the CONTRIBUTING.md file
which clearly documents how deprecations are handled and establishes the
policy around their use. This way end users know what to expect when
dealing with deprecations and how long they have to adapt to changes.

* Apply suggestions from code review

Co-Authored-By: elfrocampeador <corey.mendell@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Add examples for deprecations

This commit adds additional sections to the deprecation policy with
examples on how to raise a warning, and write release notes for a
deprecation and a deprecation removal.

* Apply suggestions from code review

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update deprecation warning example

This updates the warning based on the review discussion for how to best
advertise the removal date. The example deprecation warning now
indicates which release a deprecation was added in and mentions the
policy of a minimum of 3 months between deprecation in a release and
removal.
2019-10-10 17:20:46 -04:00
Paul Nation 159ea77768 Move API docs for Terra into source (#3085)
* add api docs into terra

* docs to top level

* Add tox target to build documentation

* Add release notes to docs build

* Add docs build to azure

* Remove duplicate deps from docs tox job

* Update codeowners

* Update CONTRIBUTING.md for docs changes

* Remove depth limit from docs job checkout
2019-09-30 12:50:44 -04:00
Matthew Treinish effad1228e Remove changelog and document automated creation (#3109)
* Remove changelog and document automated creation

With the introduction of the qiskit-bot release automation for terra we
no longer need to manually maintain or keep a changelog in repo. The
github release pages (which we were manually copy and pasting the
changelog into already) take the place of this file. For all future
releases the creation of this page is completely automatic and handled
by the bot. This works by using the git log and PR tags to figure out
which commits belong in the changelog summary. The commit msg summary
(the first line) is used for the changelog based on the tags. If a
longer explanation is necessary that should be handled in the reno
release notes.

Fixes #3077

* Add README section on changelog

* Make tweaks to readme for clarity
2019-09-23 10:07:52 -04:00
Matthew Treinish 709baa8905
Add reno release notes for 0.9 release (#2919)
* Add reno release notes for 0.9 release

This commit starts the process of adding release notes using reno to
qiskit-terra. This notes for several of the user facing changes in the
0.9 release so far. We can continue to modify release notes after the fact
because they're tied to the git history for which release they're
associated with. New release notes can be added with: "reno new $name"
and you can generate rst output using "reno report"

Moving forward the expectation is that we'll require a PR to include
release documentation in the form of a reno release note before we merge
it, if it contains a user facing change. Release notes differ from
changelog in that they provide much more detail to end users on what has
changed, how they can adapt to it, and why it was changed (if
necessary). Accordingly the release notes are free form restructured text
that enables writing as much as needed. While the changelog is just a
record of a change that has potential end user impact and normally
doesn't provide the detail needed by users. Honestly the changelog
creation shouldn't be a manual process it should be automatically
generated using a combination of git and commit msg metadata.

Fixes #2230

* Add more release notes

* Add more release notes for new features

* Add more release notes

* Add more upgrade notes

* Add reno lint check to CI

* Add more notes

* Add release notes for changes that were missing a changelog entry

* Expand incomplete notes

* Fix whitespace

* Add documentation on release notes to CONTRIBUTING.md

* Add qsphere update release notes

* Update diagGate() name to diag_gate()

* Add release notes for pulse samplers

* Add release notes for layout in circuit drawers

* Add upgrade note about new warnings

* Replace stray hardtab with spaces

* Add release note on line magic api change

* Apply suggestions from code review

Co-Authored-By: Luciano <luciano.bello@ibm.com>

* Update CONTRIBUTING.md

Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Fix typo
2019-08-19 14:12:55 -04:00
Matthew Treinish 4cefde63de Update the CONTRIBUTING.md file (#2923)
* Update the CONTRIBUTING.md file

The CONTRIBUTING.md file was in need of updates. Besides a number of
markdown style issues, a lot of the language in the document was worded
in a confusing manner. It also was quite out of date, recommending
things that weren't quite accurate anymore and referring to processes
that no longer were used. This commit updates these and tries to make it
current and easier to read.

* Update based on review comments

* More tweaks

* Apply suggestions from code review

Co-Authored-By: Laura Zdanski <Laura.Zdanski@ibm.com>

* Update CONTRIBUTING.md

Co-Authored-By: Laura Zdanski <Laura.Zdanski@ibm.com>

* Updates from code review

* Fix a small typo

* Small typo and lint fixes
2019-08-09 13:23:51 -04:00
Kiran Johns 319c353c03 Fix broken link on installing Qiskit Terra from Source (#2911)
Fix broken link on how to install Qiskit Terra from source in the file CONTRIBUTING.md.

Fixes #2907
2019-08-06 05:14:04 -04:00
Diego M. Rodríguez 0be29f12fc Update CONTRIBUTING.md format glitches (#2787) 2019-07-15 10:39:41 -04:00
Luciano 41fde633c2
Section "Doc" from CONTRIBUTING.md (#2693)
* from unittest.mock import patch

* doc section

* back section

* undo unreleasted change
2019-07-12 09:27:17 -04:00
Diego M. Rodríguez 9e03d797ec Update CONTRBUTING table and CLA (#2649) 2019-06-18 14:43:51 -04:00
Matthew Treinish 34bf43b968 Move CONTRIBUTING.rst to top level (#2359)
* Move CONTRIBUTING.rst to top level

The CONTRIBUTING.rst doc contains a lot of useful information about the
not only contributing to the project but also some useful information
about project policy and conventions. But it's currently in a hidden
directory so that github ui will show it on a help menu. So unless you
know to click on that help menu or that it's hidding in the .github
directory you'll never see it. This commit addresses this by moving the
file to the repo root so it's more obvious where it is, and to not break
the github ui it symlinks the file to the .github directory.

* Move code of conduct and switch to md

* Convert CONTRIBUTING to markdown
2019-06-07 14:53:10 -04:00
Erick Winston 7c4902fc60 sphinx autodoc setup.
Documents the project source code from python docstrings. Run "make doc"
from the top level to generate the html in doc/_build/html.
2017-07-27 14:14:41 -04:00
Jesús Pérez 9e88ba90be Update to respect the new Makefile.
Also making the linter happy.
2017-06-27 13:13:07 +02:00
ismael faro 9ec2827e4d Revert "Merge branch 'isma/clean-quantum-program'"
This reverts commit 19910ea9a4, reversing
changes made to b8727fdc4e.
2017-05-22 11:30:47 -04:00