Skip to content

[workflow] Preliminary timing information #5021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 26, 2022

Conversation

mpharrigan
Copy link
Collaborator

Add a RuntimeInfo field to store timing information. Augment the execute loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.

@@ -80,10 +81,12 @@ class RuntimeInfo:
`cg.QuantumExecutable` was executed.
qubit_placement: If a QubitPlacer was used, a record of the mapping
from problem-qubits to device-qubits.
timings: A dictionary of the duration of various steps in the workflow.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific. What are the keys and values? Are the values in seconds, millis, micros, nanos, etc?
Also, I would consider changing the name to include units for clarity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added docstrings and changed name

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be re-inventing the wheel a little bit here. Why can't we just use something like the built-in python logger ? Also wondering if the use of logging and handlers would greatly simplify the saver and logger variables used here as well ?

@mpharrigan
Copy link
Collaborator Author

@MichaelBroughton python logging functionality would likely be useful for fleshing out the logger stuff.

This PR concerns itself with timing various phases of the execution. We don't want to stream this data to the console; we want to save it as numeric data to do analysis/plotting/databasing. Wall-clock performance is a key dimension to benchmark in a quantum system. However, if you have some concrete ideas on how to leverage python functionality to do this I'm happy to hear it.

@MichaelBroughton
Copy link
Collaborator

This was the kind of thing I had in mind:

import logging
import random

logging.basicConfig(format="%(levelname)s %(asctime)s - %(message)s")


class PartialStateFromRunning(object):
    def __init__(self):
        self.complicated_data = [1, 2, 3, 4, 5]

    def to_str(self):
        return str(self.complicated_data)


class MyPrintyHandler(logging.Handler):
    def __init__(self):
        super().__init__()

    def emit(self, record):
        # print(record)
        # print('I CAN DO ANYTHING HERE!')
        # print('Timey stuff', record.created)
        # print(record.__dict__)
        return


class MySaveyHandler(logging.Handler):
    def __init__(self, run_state):
        super().__init__()
        self.run_state = run_state

    def emit(self, record):
        if record.levelno == logging.INFO:
                # pretend to save to DB or file or whatever.
        	print('SAVING RUN STATE', self.run_state)
        	print('DATA=', self.run_state.to_str())
        return


def do_placement(state):
    state.complicated_data += [random.random()]


def do_run(state):
    state.complicated_data += [1234]


my_big_global_state = PartialStateFromRunning()

plain_logger = logging.getLogger("testbed.logger")

# Add any handlers to the logger.
print_handler = MyPrintyHandler()
save_handler = MySaveyHandler(my_big_global_state)  # can link to global state objects.
plain_logger.addHandler(print_handler)
plain_logger.addHandler(save_handler)

# Let a user change this around as they like.
plain_logger.setLevel(logging.DEBUG)

for i in range(10):

    # Keep main computation logging events the same, but can now emmit events to handlers
    # to do more intricate saving/storing/printing whatever.
    plain_logger.info(f"Beginning placement {i}")
    do_placement(my_big_global_state)
    plain_logger.info(f"Finished placement {i}")
    plain_logger.debug(f"Resulting placement {123455987765}")
    plain_logger.info(f"Beginning run {i}")
    do_run(my_big_global_state)
    plain_logger.info(f"Finished run {i}")
    plain_logger.debug(f"All bitstring data {10101010101010}")

Key ideas here are:

  1. LogRecords always have time information with them so it's easy to track timing
  2. If we want the ability to scale the number of "events" that should take place after something significant happens (an individual run finishing, a placement being computed, whatever) adding handlers will scale much better than adding more contexts and complicating the inner loop to accommodate each of these events.
  3. With logging levels we can keep more careful track of what events happen when based around logging levels and the connotations they carry as apposed to forcing the reader to have to parse some big docstring or config setups.

Here are some other Handler patterns .

@mpharrigan
Copy link
Collaborator Author

Point taken that log messages capture timestamps. However, I've modified this PR to use time.monotonic() because we're interested in measuring durations. Do you know what clock source the logging module uses?

We don't want to let users add arbitrary handlers. We want a taxonomy of runtime features. If you just want arbitrary code execution, you might be better off writing your own execution loop.

I don't want whether or not we save durations to be affected by the logging level.

@MichaelBroughton
Copy link
Collaborator

We don't want to stream this data to the console; we want to save it as numeric data to do analysis/plotting/databasing. Wall-clock performance is a key dimension to benchmark in a quantum system

Point taken that log messages capture timestamps. However, I've modified this PR to use time.monotonic() because we're interested in measuring durations. Do you know what clock source the logging module uses?

Durations can be calculated from taking the difference of two timestamps from LogRecords which are computed using time.time() in addition to this you can compute the durations of events by using the relativeCreated property of a LogRecord. I'm also a little confused here, if we want to do things like databasing or plotting, wouldn't we want full blown time data and not just duration data. If a user wants to comb over it later for durations they could do that, but I can also certainly see a case where a user would want to know at roughly what time something was run or finished etc.

We don't want to let users add arbitrary handlers. We want a taxonomy of runtime features. If you just want arbitrary code execution, you might be better off writing your own execution loop.

Right, I was more referring to internally we should use these because it's easier to hook up logging Handlers in a structured fashion than it is to keep having to change the inner loop. A user could then turn them on and off easily with whatever function arguments they want i.e. run(..., do_savey_things=True, do_printy_things=False).

@mpharrigan
Copy link
Collaborator Author

I think you're conflating things a bit. I think we've talked before about moving data saving and printing to a callback-y format, which I agree with; but that's not the point of this PR.

Here, I want to measure e.g. how long it takes to run an executable and how long it takes to do various preprocessing steps. It seems like the logging module would be akin to fitting a square peg into a round hole. The one feature that we get is the automatic inclusion of timestamps; but I really don't think it's onerous to call time.time() ourselves, especially when I now get to use the much more suitable time.monotonic() since I'm primarily interested in durations (and the former can get screwed up if the system clock changes during execution; happy day after daylight savings day!)

re: durations from timestamps: you need to make sure you have a timing (or logging) call before and after your function call of interest. Context managers are a good fit here. You can imagine an alternative scenario where you rely on each phase being demarcated with a logging call. But if you add or remove phases, you need to update which quantities you're subtracting to get the duration.

@mpharrigan
Copy link
Collaborator Author

@MichaelBroughton are you ok moving forward with the PR as written?

self.start = time.monotonic()
return self

def __exit__(self, *args):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the timing be recorded if there's an error? I saw for example RandomDevicePlacer.place_circuit() could raise a ValueError.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so(?) Curious to hear your thoughts

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good just a nit from me. After our discussions if all we want is timing for RunTimeInfo, I think this code can be made a lot shorter also. WIll leave to @dstrain115 for final say here.

Comment on lines 84 to 85
timings_s: A dictionary of the duration of various steps in the workflow,
measured in fractional seconds.
Copy link
Collaborator

@MichaelBroughton MichaelBroughton Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this docstring (and ones above it too) seems like it is more ambiguous than it needs to be. Thoughts on: timings: Dictionary mapping from str to float. Each entry corresponds to the number of seconds a particular execution subroutine took. <name all subroutines that are tracked> ?

Mentioning things are timed in fractional seconds made me think "what denomination is used here do I have 40 half seconds which is really 20 full seconds etc. ?"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworded inspired by your suggestion. I think I took "fractional seconds" from the python docs, but I agree it is weird

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to punt on listing all the possible names, as 1) it will likely change in the next couple of PRs 2) will depend on the particular QuantumRuntimeConfiguration, and I would like to document it there so all docstrings can point to one place.

# See the License for the specific language governing permissions and
# limitations under the License.

"""Utilities for timing execution."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of this module coupling it's functionality to RunTimeInfo just so we can mutate a key in some dictionary for a specific type of object. It feels like a weird hybrid of accessor and mutator where we could very easily just have one or the other.

If all we need to do is get timing information for RuntTimeInfo why not just add something like:

@contextlib.contextmanager
def _add_time_to_runtime(cur_runtime) -> None:
    start = time.time()
    yield
    cur_runtime.whatever = time.time() - start

to the top of the quantum_runtime.py module and use that instead ? Or make a more general timer that doesn't couple to this part of the codebase ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to a private context manager. changed to use decorator instead of class.

@mpharrigan
Copy link
Collaborator Author

@mpharrigan mpharrigan added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 26, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 26, 2022
@CirqBot CirqBot merged commit ed56edc into quantumlib:master Mar 26, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 26, 2022
tonybruguier pushed a commit to tonybruguier/Cirq that referenced this pull request Apr 14, 2022
Add a `RuntimeInfo` field to store timing information. Augment the `execute` loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.
tonybruguier pushed a commit to tonybruguier/Cirq that referenced this pull request Apr 19, 2022
Add a `RuntimeInfo` field to store timing information. Augment the `execute` loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.
MichaelBroughton added a commit that referenced this pull request Apr 26, 2022
* Use Boolean Hamiltonian gates for QAOA example

* Don't use deprecated function

* More deprecation

* Deprectate log_of_measurement_result input (#5100)

Co-authored-by: Cirq Bot <[email protected]>

* Improve support for recursively applying transformer primitives on circuit operations using `deep=True` (#5103)

- Part of fixing #5039
- Fixes multiple bugs and improves support for `deep=True` flag in transformer primitives.

* Add support for deep=True flag to remaining transformer primitives (#5106)

* Add `assert_decompose_ends_at_default_gateset` to consistent protocols test to ensure all cirq gates decompose to default gateset (#5107)

* Extract BufferedDM/SV/MPS from ActOnDM/SV/MPSArgs (#4979)

* Extract BufferedDensityMatrix from ActOnDensityMatrixArgs

* state vector

* clean up code

* clean up code

* clean up code

* format

* docs

* test

* coverage

* improve state vector

* improve state vector

* replace deleted functions

* replace deleted functions

* replace deleted functions

* replace deleted functions

* lint

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* coverage

* fix merge errors

* Code review comments

* Remove todo

Co-authored-by: Orion Martin <[email protected]>

* Bugfixes in handling nested tags_to_ignore + deep=True in `cirq.map_moments` and `cirq.map_operations` transformer primitives (#5109)

- Fixes a few more bugs in the handling of deep=True flag and nested operations to ignore using `tags_to_ignore` in `cirq.map_operations` and `cirq.map_moments` transformer primitives. Also added more tests. 
- Step towards fixing #5039

* Add `add_deep_support ` flag to `@cirq.transformer` decorator (#5108)

* Add  flag to @cirq.transformer decorator

* Fix mypy type errors and remove typos

* Rename add_support_for_deep to add_deep_support

* Add support for deep=True to `cirq.drop_empty_moments` transformer (#5113)

- Adds support to recursively run `cirq.drop_empty_moments` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.drop_negligible_operations` transformer (#5114)

- Adds support to recursively run `cirq.drop_negligible_operations` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.stratified_circuit` transformer (#5117)

- Adds support to recursively run `cirq.stratified_circuit` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.synchronize_terminal_measurements` transformer (#5118)

- Adds support to recursively run `cirq.synchronize_terminal_measurements` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.expand_composite` transformer (#5119)

- Adds support to recursively run `cirq.expand_composite` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Note that this does not rely on `preserve_structure` argument of `protocols.decompose` because the latter does not support handling nested circuit operations tagged with a no-compile tag (the added tests would fail if we rely on protocols.decompose(preserve_structure=True) instead transformer primitives). Hence, I would argue that we should deprecate the preserve_structure=True flag in protocols.decompose in-favour of this transformer. cc @95-martin-orion 
- Part of #5039

* Add support for deep=True to `cirq.eject_phased_paulis` transformer (#5116)

- Adds support to recursively run `cirq.eject_phased_paulis` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.align_left` and `cirq.align_right` transformers (#5112)

- Adds support to recursively run `cirq.align_left` and `cirq.align_right` transformers on circuits wrapped inside a circuit operation by setting `deep=True` in transformer context.
- Part of #5039

* Add support for deep=True to `cirq.eject_z` transformer (#5115)

- Adds support to recursively run `cirq.eject_z` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of #5039

* Add support for deep=True to cirq.merge_k_qubit_unitaries transformer (#5122)

* Add support for deep=True to merge_single_qubit_gates* transformers (#5123)

- Adds support to recursively run `cirq.merge_single_qubit_moments_to_phxz` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Also adds tests for `cirq.merge_single_qubit_gates_to_phxz` and `cirq.merge_single_qubit_gates_to_phased_x_and_z`, both of which automatically support deep=True flag after #5122
- Part of #5039

* Add support for deep=True to `cirq.optimize_for_target_gateset` transformer (#5124)

- Adds support for `deep=True` flag to `cirq.optimize_for_target_gateset` which enables optimizing circuits preserving the sub-circuit structure (i.e. without unrolling circuit operations).
- Part of #5039

* Bugfix in handling of deep=True flag in `cirq.merge_k_qubit_unitaries` transformer (#5125)

- Fixes a bug in `cirq.merge_k_qubit_unitaries` due to which the transformer was applied recursively only on circuit operations satisfying `cirq.num_qubits(op) <= k and cirq.has_unitary(op)`.  Fixed the bug and added more tests. 
- Part of #5039

* DeviceSpecification proto updates (#5056)

Part of #5050

Since each gate has its own message now, target specification could potentially be moved inside gate messages (e.g. for 2-qubit gates) or disappear entirely and embed the target set in Cirq (e.g. measurement). This is lower priority since there are no major problems with the existing setup, so deferring this for now and get back to it before Cirq 1.0 if there's time.

Micro-optimization: Leaving `GateSpecification` field numbers < 16 empty to allow for potential future common fields.

@dstrain115 @maffoo

* Add support for deep=True flag in `cg.optimized_for_sycamore` and `cg.SycamoreTargetGateset` transformers (#5126)

- Adds support for deep=True flag in `sycamore_gateset.merge_swap_rzz_and_2q_unitaries` transformer
- Updates `cg.optimized_for_sycamore` to call `cirq.optimize_for_target_gateset` with `deep=True` by default, such that the method preserves circuit structure by default (which corresponds to its old behavior). 
- Fixes #5039

* Rename TestDevice -> FakeDevice to avoid pytest confusion (#5066)

Pytest tries to collect `TestDevice` as a test class, and fails with the following wraning:
```
cirq-core/cirq/circuits/circuit_dag_test.py:24
cirq-core/cirq/circuits/circuit_dag_test.py:24
  /home/runner/work/Cirq/Cirq/cirq-core/cirq/circuits/circuit_dag_test.py:24: PytestCollectionWarning: cannot collect test class 'TestDevice' because it has a __init__ constructor (from: cirq-core/cirq/circuits/circuit_dag_test.py)
    class TestDevice(cirq.Device):
```

* Add iterator support for AbstractJob (#5136)

- Add support for next() in AbstractJob
- Changes __iter__ to return a generator, which
will have support for iteration in for loops, as well as
next().
- Also improve the iteration tests to be more thorough and accurate.

Fixes: #5120

* Pin Jinja2 version for build_docs CI. (#5138)

See CI failure here: #5134

* Bump cirq version to 0.15.0 (#5134)

Bumps working version to v0.15.0

* Bump minimist from 1.2.5 to 1.2.6 in /cirq-web/cirq_ts (#5140)

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/substack/minimist/commit/7efb22a518b53b06f5b02a1038a88bd6290c2846"><code>7efb22a</code></a> 1.2.6</li>
<li><a href="https://github.com/substack/minimist/commit/ef88b9325f77b5ee643ccfc97e2ebda577e4c4e2"><code>ef88b93</code></a> security notice for additional prototype pollution issue</li>
<li><a href="https://github.com/substack/minimist/commit/c2b981977fa834b223b408cfb860f933c9811e4d"><code>c2b9819</code></a> isConstructorOrProto adapted from PR</li>
<li><a href="https://github.com/substack/minimist/commit/bc8ecee43875261f4f17eb20b1243d3ed15e70eb"><code>bc8ecee</code></a> test from prototype pollution PR</li>
<li>See full diff in <a href="https://github.com/substack/minimist/compare/1.2.5...1.2.6">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=minimist&package-manager=npm_and_yarn&previous-version=1.2.5&new-version=1.2.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/quantumlib/Cirq/network/alerts).

</details>

* Remove deprecated two_qubit_matrix_to_diagonal_and_operations and two_qubit_matrix_to_operations (#5102)

see title.

* Fix broken caching in CliffordGate and add test (#5142)

Looks like copy-pasta errors to me.

Also update a test to being parameterized and complete.

* Cleanup docs/noise.ipynb in preparation for Cirq 1.0 launch (#5147)

* Speed up a slow transformer test (#5146)

This test was the slowest that we run, 45 seconds, so I cut down on the parameterized range.  @tanujkhattar

* Make pylint parallel (#5144)

On my local machine this took pylint from 3 minutes to less than one.

* [workflow] Preliminary timing information (#5021)

Add a `RuntimeInfo` field to store timing information. Augment the `execute` loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.

* Add docstring for `cirq.TRANSFORMER` public object (#5149)

Adds docstring for `cirq.TRANSFORMER` public object. The api reference automatically creates a reference page for the public object, and currently inherits the docstring from the `Protocol` base class, which is irrelevant and the PR fixes it.

* Base class for quantum states (#5065)

Creates a base class for all the quantum state classes created in #4979, and uses the inheritance to push the implementation of `ActOn<State>Args.kron`, `factor`, etc into the base class.

Closes #4827
Resolves #3841 (comment) that's been bugging me for a year.

* Allow any object with supporting protocols to be the action in act_on (#5111)

* Allow any object with supporting protocols to be the action in act_on

* lint

* Fix raiser is not callable. (#5155)

Appears to have broken other PRs. https://github.com/quantumlib/Cirq/runs/5724527312?check_suite_focus=true

* Corrected result.data implementation. (#5153)

When looking into #4774 auto type promotion to objects raised a ValueError and was not tested. This PR fixes this and introduces the intended behavior as well as boosting performance slightly when qubit counts are < 64.

* Support specific IonQ targets (qpu.generation) (#5141)

* Support specific IonQ targets

Allows for more specific backend targets.

* fmt

* Upgrade black to stable version with format stability guarantees (#5157)

Version [22.1.0](https://black.readthedocs.io/en/latest/change_log.html#id1) is the first non-beta version of black and has a new [stability policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy). The last time we bumped the black version in #4753 we did not actually reformat any code, so we could do that here and just rely on incremental formatting going forward, or we could do a global reformat to bring things up to date as we did when we originally switched to black in #3516. I think the changes this time would be much less drastic than in the original switch. The main thing we've seen internally is tighter binding of the power operator, e.g. new black does `a**b + c**d` instead of `a ** b + c ** d`, which is a definite improvement.

* Format cirq-core with latest version of black (#5159)

Review: @dabacon

* Clarify virtual tag docstring (#5161)

Propose that instead of changing whether virtual tags are applied to noise models, we instead just clarify what it means to be virtual.  

Fixes: #2984

* Format cirq-google with latest version of black (#5160)

Follow-up to #5157. Format code in cirq-google to ensure these formatting changes don't get mixed in with future logic changes.

* Ignore large-scale formatting changes for git blame (#5162)

Follow-up to #5159 and #5160. Ignore these large-scale formatting changes when goind git blame, as suggested by @dabacon.

* Remove --pre from notebooks after release. (#5135)

For review after #5134

* Update to pylint 2.13 (#5156)

Review: @mpharrigan

* Update educators/intro.ipynb in preparation for Cirq 1.0 launch (#5163)

* Updated the educator intro notebook to remove deprecated items and introduce newly added concepts like gatesets and transformers. 
* Part of docs cleanup effort in preparation of Cirq 1.0 launch.

* Disable broken symbols. (#5165)

* Autoformat all of engine_client_test.py (#5164)

ReviewL @dabacon

* Allow specifying timeout_seconds when constructing an ionq Sampler (#5133)

* Allow specifying timeout_seconds when constructing an ionq Sampler

This allows users of tensorflow quantum to use a high timeout and https://github.com/tensorflow/quantum/blob/f10d36b64761a003fd542392767fa079d57df0aa/tensorflow_quantum/python/quantum_context.py\#L82-L101 to run highly parallel workloads that may take very long times per-job without flakiness.

* fmt

* Python map

* Coverage

* Remove reservation colab (#5168)

- We no longer need this colab, as the UI now
supports all reservation operations and is much easier.

Fixes: #3588

* Add Google-specific variant for noise properties. (#5082)

This PR provides an implementation of `SuperconductingQubitsNoiseProperties` for Google hardware. Now that SQNP is an abstract type, this is a prerequisite for re-enabling calibration-to-noise tools.

This is part 3 of #4666; part 2 was #4964. Remaining steps include:

- Reinstatement of calibration_to_noise_properties using new types
- Reinstatement of compare_generated_noise_to_metrics using new types

* Update docs/transform.ipynb based on new transformer framework. (#5154)

Fixes #4960


This notebook provides a high level overview of all the newly added features to Cirq's transformer infrastructure. We can discuss whether we need more details docs on each of the specific topics -- I think a high level overview with links to reference pages of individual methods (i.e. the current PR) should be enough to close #4960, but I'm curious to hear what others think.

* Enforce same control order in ControlledGate equality check (#5131)

**Breaking Change**

Changes ControlledGate equality check to enforce gates have same order.

Fixes #5110

* Fix gates.ipynb formatting (#5175)

- Move import cirq up into top block.
- Clear outputs.

* Cleaning up cirq/install docs (#5178)

* Corrected virtual environment link.
* Replaced Foxtail with Sycamore.

* Fix docs/circuits.ipynb as part of docs cleanup for Cirq 1.0 (#5177)

- Remove output
- Move import to top
- Minor changes to content (add `cirq.` prefix to many quoted words)
- Remove broken link to devices.ipynb

* Update simulator docs (#5182)

Quick cleanup pass for simulator docs. Nontrivial changes:
- include note for `seed` parameter of simulator
- remove comments about modifying StepResult state (deprecated)
- clarify pure/mixed state behaviors and advantages
- external simulator focus: qsim++, qFlex--

Everything else is cleaning format and refreshing links.

* Fix broken link from cirq/tutorials page as part of docs cleanup (#5174)

Removes broken link from cirq/tutorials as part of docs cleanup.

* Convert start.md to start.ipynb. (#5176)

Converts `start.md` -> `start.ipyb`. This lets us run the code block and make the notebook runnable in colab by our users.

* Update google concepts doc. (#5186)

* Update google concepts doc.

- Remove form for applying to EAP program.
- Remove references to simulators.
- Change images to remove simulators.
- Remove dangling "Installing cirq".
- Add commas and improve sentences in a few places.

Co-authored-by: Matthew Neeley <[email protected]>

* Fix docs/qubits.ipynb as part of docs cleanup for Cirq 1.0 (#5179)

- Move import to top

* Minor cleanup of QCS tutorial (#5184)

@dstrain115 @MichaelBroughton @wcourtney

* Link fix on start page. (#5191)

Remove extra paranthesis.

* Neutral atom update (#5192)

Updates neutral atom tutorial to remove uses of deprecated device behavior.

* Remove use of deprecated device behavior from quantum_volume_errors. (#5198)

Title

* Remove BooleanHamiltonian object (#5099)

Now that v0.14 is released, delete deprecate object

* Refactor qcs_notebook to use application default creds (#5045)

Review: @95-martin-orion

* Cirq web supports LineQubits (#5211)

This would be to fix #5173

* Import new gapic generated code for quantum engine API (#5139)

This is some very preliminary work to import new generated code for the quantum engine API. Of note is that the new code includes async support and is now using [proto-plus](https://github.com/googleapis/proto-plus-python) rather than the standard generated proto code for messages.

* Fix basics (#5180)

Cleans up basics.ipynb and removes mention of old devices behavior.

* Deprecate `gate_set` parameter on engine classes. (#5207)

Fixes #4995

Review: @verult

* Tweak quantum walks doc (#5212)

* Tweak quantum walks doc

- Removed output cells and tweaked imports
- Move print out of function.

* Deprecate json_serializable_dataclass (#5208)

Fixes #4460

* Fix error and add test for mutable pauli string (#5213)

#4001 looks abandoned so this does the change and adds the test as requested.

* Fix tutorials/state_histograms.ipynb as part of docs cleanup for Cirq 1.0 (#5206)

* Cleared output
* Fixed broken links
* Minor improvements in content

* Fix tutorials/heatmaps.ipynb as part of docs cleanup for Cirq 1.0 (#5205)

* Cleared output
* Fixed typos and broken links
* Changed language to second person

* Remove some 0.15 items from cirq.sim (#5137)

This covers most of the deprecations for `cirq.sim` in 0.15. The two remaining ones have some challenges:

* Removing `target_tensor` etc from the initializers and replacing with `initial_state`: The repr still emits `target_tensor` so it wouldn't round-trip.
* Removing `log_of_measurement_results`: Same thing. Plus we forgot to deprecate it in a couple places.

Also this closes #3898, as the pattern we used to deprecate `copy` without parameters works well.

* Add Cynocracy to owners of cirq-ionq (#5145)

@Cynocracy let me know if you want to remove any of the others, or keep them as is.

* Fix educators/qaoa_ising.ipynb as part of docs cleanup for Cirq 1.0 (#5204)

* Moved cirq import to top
* Cleared output
* Fixed typos in text

* Improve documentation about writing type annotations (#5218)

Fixes #4383

* customer_gates.ipynb - minor content cleanup (#5215)

cc @tanujkhattar

* Make _commutes_ consistent (#5217)

- Requires atol to be a named parameter.
- Also changes atol to be uniformly float around the codebase.
  (not sure why it would be int, are people using an atol=1?)
- Technically a breaking change, but it's unlikely people are using
  this widely as most commutes do not even use atol.

Fixes: #3695

* Fix numpy annotations np.array -> np.ndarray (#5227)

`np.array` is not a valid type, but rather a factory function for creating arrays. The actual type is `np.ndarray`. This change reduces the number of `check/mypy --next` errors by >60% from 244 to 96 on my machine.

* Delete the target_tensor parameter that was deprecated in 0.15 (#5225)

A few simulators used either initial_state or target_tensor to initialize their ActOnArgs. We deprecated the latter in 0.15. This PR deletes those. Note that one follow-on change included here is that the repr functions needed to be changed to emit the field as `initial_state` too. (I wish I'd just called it `quantum_state` now, but oh well). @95-martin-orion

I also went ahead and removed the buffer from the repr, since it is just noise.

* Deprecate the ActOnArgs._on_* methods (#5224)

Now that we have separated out the `QuantumStateRepresentation` from `ActOnArgs`, there is no need for the `_on_*` methods anymore. This PR deprecates those, adds deprecation tests, and updates any old test ActOnArgs to use the new QuantumStateRepresentation internally. @95-martin-orion

* Allow specifying initial state vector in DensityMatrixSimulator (#5223)

This changes how ActOnDensityMatrixArgs is constructed to allow specifying the initial state as a state vector or state tensor, or as a density matrix or density tensor. Some of this could perhaps be moved into `cirq.to_valid_density_matrix` if people think that is a better place. Currently `to_valid_density_matrix` only handles 1D state vectors or 2D density matrices, not 2x2x..2 tensors in either case, but if we have the qid_shape we can tell handle these unambiguously.

Fixes #3958

* Unquote example code in ArithmeticOperation (#5230)

Fixes #5228 (I hope)

* Document CircuitOp optimizer best practices (#5221)

Final item for #3634.

With the new transformers, there is a clean pipeline for optimizing nested circuits and sending the (concise!) result to hardware for execution.

* Remove the deprecated mutators in cirq/ops (#5201)

Removes all the deprecated mutators.

* Allow server-side warnings from IonQ (#5222)

This will be used to notify users about deprecations and changes to the API without needing to update Cirq independently.

* Fix educators/textbook_algorithms.ipynb as part of docs cleanup for Cirq 1.0 (#5199)

* Fixes typos
* Removes outputs
* Move import to top

* Fix qcvv/xeb_theory.ipynb as part of docs cleanup for Cirq 1.0 (#5202)

* Moved import to top
* Fixed broken link to quantum ai website
* Minor improvements in text formatting

* Cleaning up tutorials/variational_algorithm.ipynb (#5185)

* Move cirq import to top
* Remove outputs

* Document CIRCUIT_TYPE and hide other typevars/aliases in circuits.py (#5229)

Fixes #5150 (assuming this renders nicely on the docsite; how can I check that locally?)

This adds an underscore prefix to hide some type aliases and type vars that are not part of the public interface of the module. Also adds a docstring to the `CIRCUIT_TYPE` variable, which is used in a few other places.

* Make check scripts run pytest in parallel (#5143)

The tests were made parallel in CI, but this updates the scripts to run in parallel. Respects if user overrides with different level of parallelism.

* cirq-ionq: Retry non-standard cloudflare errors (#5237)

* Add q helper function for constructing common qubit types. (#5181)

* Add q helper function

* fmt

* Ignore static type errors in tests

* Ignore intentional type errors

* Fix Raises docstring

* Fixes from review

* Use *args

* remove unused import

* Unpin sympy and ignore sympy type errors (#5226)

Fixes #5058
Review: @dabacon

* Add calibration-to-noise pipeline (#5187)

This PR reinstates the cirq_google utility for converting `Calibration` objects to noise properties. To create a simulator with behavior that mimics some `Calibration` "cal", the expected usage is:
```python
noise_props = cg.noise_properties_from_calibration(cal)
noise_model = cg.NoiseModelFromGoogleNoiseProperties(noise_props)
simulator = cirq.Simulator(noise=noise_model)  # will mimic noise from `calibration`
```

This is part 4 of #4666; part 3 was #5082. Remaining steps include:
- Convenience methods for modifying noise properties
- Reinstatement of compare_generated_noise_to_metrics using new types

* Remove device from circuits (#5189)

Removes v0.15 deprecation items for attaching devices to circuits.

* Bump tensorflow-docs version (#5250)

* Fix tutorials/qaoa.ipynb as part of docs cleanup for Cirq 1.0 (#5200)

* Change example device from `cg.Bristlecone` (now deprecated) to `cg.Sycamore`.
* Use new GridDeviceMetadata instead of deprecated device properties (like neighbors_of)
* Move import to top
* Clear outputs

* Remove custom cirq_type (#5249)

Custom `cirq_type` was deprecated in #4704 and not necessary for internal types.

* Skip "magic trailing comma" when formatting with black (#5170)

The "magic trailing comma" is a comma at the end of bracketed list that forces black to format the list entries on separate lines, even if they would fit on one line. For example, if you write:
```python
foo(a, b,)
```
black will see that trailing comma and format this as:
```python
foo(
    a,
    b,
)
```
But with the `skip-magic-trailing-comma` setting enabled this will format on a single line instead
```python
foo(a, b)
```
IME the trailing commas are almost always unintentional, e.g. left over from other refactos, and result in wasted vertical space. I suggest we enable this flag.

* Remove deprecated log_of_measurement_results parameters (#5233)

* deprecate log_of_measurement_results

* Fix test

* coverage

* Add empty ClassicalDataDictionaryStore.repr test

* Add ActOnArgs test

* Add tests

* Add ActOnStabilizerArgs tests

* nits

* coverGE

* format

Co-authored-by: Cirq Bot <[email protected]>

* Make the quantum state generic (#5255)

* Migrate google/best_practices.md to google/best_practices.ipynb as part of docs cleanup for Cirq 1.0 (#5236)

- Fixes bugs in code demonstrating use of circuit operations and compiling them using new transformers. 

Follow up of #5221

* Format cirq-google with skip-magic-trailing-comma (#5171)

Review: @95-martin-orion

* Format according to new black rules (#5259)

Follow up by will add hash to  .git-blame-ignore-revs

* Ignore skip-magic-trailing-comma formatting with git blame (#5257)

This adds a formatting commit to ignore when doing git blame.

* Use sorted instead of set for random.sample (#5248)

* Fix Docs: cirq/tutorials/educators/chemistry (#5251)

* Convenience methods for modifying GoogleNoiseProperties (#5188)

* Add override methods.

* Mypy passes, weak typing

* Resolved mypy conundrum

* with_params

* Deprecate Gateset.accept_global_phase_op (#5239)

Deprecates Gateset.accept_global_phase_op

**Breaking Change:** Changes the default value of `Gateset.accept_global_phase_op` from `True` to `False`. I can't think of any way to remove this parameter without eventually needing this breaking change. Currently all gatesets that are created allow global phase gates if they don't specify `accept_global_phase_op=False` explicitly. But the end goal is only to allow global phase gates if they're included in the `gates` list. So at some point in the transition the default behavior needs to break, and I can't think of a way of doing that via deprecation. Therefore I think we may as well do it now via this breaking change.

Note that even though it's breaking, it isn't breaking in a bad way. Users who are adding global phase gates to things that suddenly don't accept them will just see an error that the gate is not in the gateset, and then go add it. It's much safer than breaking in the other direction in which we silently start allowing new gate types.

Closes #4741

@tanujkhattar

* Exclude TYPE_CHECKING from docs (#5261)

This would be an attempt to fix #5231

* Add unit test

Co-authored-by: Dax Fohl <[email protected]>
Co-authored-by: Cirq Bot <[email protected]>
Co-authored-by: Tanuj Khattar <[email protected]>
Co-authored-by: Orion Martin <[email protected]>
Co-authored-by: Cheng Xing <[email protected]>
Co-authored-by: Matthew Neeley <[email protected]>
Co-authored-by: Doug Strain <[email protected]>
Co-authored-by: MichaelBroughton <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dave Bacon <[email protected]>
Co-authored-by: Matthew Harrigan <[email protected]>
Co-authored-by: Jon Donovan <[email protected]>
Co-authored-by: Matthew Neeley <[email protected]>
Co-authored-by: Timo Eckstein <[email protected]>
Co-authored-by: Dax Fohl <[email protected]>
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Add a `RuntimeInfo` field to store timing information. Augment the `execute` loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Use Boolean Hamiltonian gates for QAOA example

* Don't use deprecated function

* More deprecation

* Deprectate log_of_measurement_result input (quantumlib#5100)

Co-authored-by: Cirq Bot <[email protected]>

* Improve support for recursively applying transformer primitives on circuit operations using `deep=True` (quantumlib#5103)

- Part of fixing quantumlib#5039
- Fixes multiple bugs and improves support for `deep=True` flag in transformer primitives.

* Add support for deep=True flag to remaining transformer primitives (quantumlib#5106)

* Add `assert_decompose_ends_at_default_gateset` to consistent protocols test to ensure all cirq gates decompose to default gateset (quantumlib#5107)

* Extract BufferedDM/SV/MPS from ActOnDM/SV/MPSArgs (quantumlib#4979)

* Extract BufferedDensityMatrix from ActOnDensityMatrixArgs

* state vector

* clean up code

* clean up code

* clean up code

* format

* docs

* test

* coverage

* improve state vector

* improve state vector

* replace deleted functions

* replace deleted functions

* replace deleted functions

* replace deleted functions

* lint

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* mps quantum state

* coverage

* fix merge errors

* Code review comments

* Remove todo

Co-authored-by: Orion Martin <[email protected]>

* Bugfixes in handling nested tags_to_ignore + deep=True in `cirq.map_moments` and `cirq.map_operations` transformer primitives (quantumlib#5109)

- Fixes a few more bugs in the handling of deep=True flag and nested operations to ignore using `tags_to_ignore` in `cirq.map_operations` and `cirq.map_moments` transformer primitives. Also added more tests. 
- Step towards fixing quantumlib#5039

* Add `add_deep_support ` flag to `@cirq.transformer` decorator (quantumlib#5108)

* Add  flag to @cirq.transformer decorator

* Fix mypy type errors and remove typos

* Rename add_support_for_deep to add_deep_support

* Add support for deep=True to `cirq.drop_empty_moments` transformer (quantumlib#5113)

- Adds support to recursively run `cirq.drop_empty_moments` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.drop_negligible_operations` transformer (quantumlib#5114)

- Adds support to recursively run `cirq.drop_negligible_operations` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.stratified_circuit` transformer (quantumlib#5117)

- Adds support to recursively run `cirq.stratified_circuit` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.synchronize_terminal_measurements` transformer (quantumlib#5118)

- Adds support to recursively run `cirq.synchronize_terminal_measurements` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.expand_composite` transformer (quantumlib#5119)

- Adds support to recursively run `cirq.expand_composite` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Note that this does not rely on `preserve_structure` argument of `protocols.decompose` because the latter does not support handling nested circuit operations tagged with a no-compile tag (the added tests would fail if we rely on protocols.decompose(preserve_structure=True) instead transformer primitives). Hence, I would argue that we should deprecate the preserve_structure=True flag in protocols.decompose in-favour of this transformer. cc @95-martin-orion 
- Part of quantumlib#5039

* Add support for deep=True to `cirq.eject_phased_paulis` transformer (quantumlib#5116)

- Adds support to recursively run `cirq.eject_phased_paulis` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.align_left` and `cirq.align_right` transformers (quantumlib#5112)

- Adds support to recursively run `cirq.align_left` and `cirq.align_right` transformers on circuits wrapped inside a circuit operation by setting `deep=True` in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to `cirq.eject_z` transformer (quantumlib#5115)

- Adds support to recursively run `cirq.eject_z` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Part of quantumlib#5039

* Add support for deep=True to cirq.merge_k_qubit_unitaries transformer (quantumlib#5122)

* Add support for deep=True to merge_single_qubit_gates* transformers (quantumlib#5123)

- Adds support to recursively run `cirq.merge_single_qubit_moments_to_phxz` transformer on circuits wrapped inside a circuit operation by setting deep=True in transformer context.
- Also adds tests for `cirq.merge_single_qubit_gates_to_phxz` and `cirq.merge_single_qubit_gates_to_phased_x_and_z`, both of which automatically support deep=True flag after quantumlib#5122
- Part of quantumlib#5039

* Add support for deep=True to `cirq.optimize_for_target_gateset` transformer (quantumlib#5124)

- Adds support for `deep=True` flag to `cirq.optimize_for_target_gateset` which enables optimizing circuits preserving the sub-circuit structure (i.e. without unrolling circuit operations).
- Part of quantumlib#5039

* Bugfix in handling of deep=True flag in `cirq.merge_k_qubit_unitaries` transformer (quantumlib#5125)

- Fixes a bug in `cirq.merge_k_qubit_unitaries` due to which the transformer was applied recursively only on circuit operations satisfying `cirq.num_qubits(op) <= k and cirq.has_unitary(op)`.  Fixed the bug and added more tests. 
- Part of quantumlib#5039

* DeviceSpecification proto updates (quantumlib#5056)

Part of quantumlib#5050

Since each gate has its own message now, target specification could potentially be moved inside gate messages (e.g. for 2-qubit gates) or disappear entirely and embed the target set in Cirq (e.g. measurement). This is lower priority since there are no major problems with the existing setup, so deferring this for now and get back to it before Cirq 1.0 if there's time.

Micro-optimization: Leaving `GateSpecification` field numbers < 16 empty to allow for potential future common fields.

@dstrain115 @maffoo

* Add support for deep=True flag in `cg.optimized_for_sycamore` and `cg.SycamoreTargetGateset` transformers (quantumlib#5126)

- Adds support for deep=True flag in `sycamore_gateset.merge_swap_rzz_and_2q_unitaries` transformer
- Updates `cg.optimized_for_sycamore` to call `cirq.optimize_for_target_gateset` with `deep=True` by default, such that the method preserves circuit structure by default (which corresponds to its old behavior). 
- Fixes quantumlib#5039

* Rename TestDevice -> FakeDevice to avoid pytest confusion (quantumlib#5066)

Pytest tries to collect `TestDevice` as a test class, and fails with the following wraning:
```
cirq-core/cirq/circuits/circuit_dag_test.py:24
cirq-core/cirq/circuits/circuit_dag_test.py:24
  /home/runner/work/Cirq/Cirq/cirq-core/cirq/circuits/circuit_dag_test.py:24: PytestCollectionWarning: cannot collect test class 'TestDevice' because it has a __init__ constructor (from: cirq-core/cirq/circuits/circuit_dag_test.py)
    class TestDevice(cirq.Device):
```

* Add iterator support for AbstractJob (quantumlib#5136)

- Add support for next() in AbstractJob
- Changes __iter__ to return a generator, which
will have support for iteration in for loops, as well as
next().
- Also improve the iteration tests to be more thorough and accurate.

Fixes: quantumlib#5120

* Pin Jinja2 version for build_docs CI. (quantumlib#5138)

See CI failure here: quantumlib#5134

* Bump cirq version to 0.15.0 (quantumlib#5134)

Bumps working version to v0.15.0

* Bump minimist from 1.2.5 to 1.2.6 in /cirq-web/cirq_ts (quantumlib#5140)

Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/substack/minimist/commit/7efb22a518b53b06f5b02a1038a88bd6290c2846"><code>7efb22a</code></a> 1.2.6</li>
<li><a href="https://github.com/substack/minimist/commit/ef88b9325f77b5ee643ccfc97e2ebda577e4c4e2"><code>ef88b93</code></a> security notice for additional prototype pollution issue</li>
<li><a href="https://github.com/substack/minimist/commit/c2b981977fa834b223b408cfb860f933c9811e4d"><code>c2b9819</code></a> isConstructorOrProto adapted from PR</li>
<li><a href="https://github.com/substack/minimist/commit/bc8ecee43875261f4f17eb20b1243d3ed15e70eb"><code>bc8ecee</code></a> test from prototype pollution PR</li>
<li>See full diff in <a href="https://github.com/substack/minimist/compare/1.2.5...1.2.6">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=minimist&package-manager=npm_and_yarn&previous-version=1.2.5&new-version=1.2.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/quantumlib/Cirq/network/alerts).

</details>

* Remove deprecated two_qubit_matrix_to_diagonal_and_operations and two_qubit_matrix_to_operations (quantumlib#5102)

see title.

* Fix broken caching in CliffordGate and add test (quantumlib#5142)

Looks like copy-pasta errors to me.

Also update a test to being parameterized and complete.

* Cleanup docs/noise.ipynb in preparation for Cirq 1.0 launch (quantumlib#5147)

* Speed up a slow transformer test (quantumlib#5146)

This test was the slowest that we run, 45 seconds, so I cut down on the parameterized range.  @tanujkhattar

* Make pylint parallel (quantumlib#5144)

On my local machine this took pylint from 3 minutes to less than one.

* [workflow] Preliminary timing information (quantumlib#5021)

Add a `RuntimeInfo` field to store timing information. Augment the `execute` loop to record some basic timing info. Provide a utility context manager to make it easier to record timing information.

* Add docstring for `cirq.TRANSFORMER` public object (quantumlib#5149)

Adds docstring for `cirq.TRANSFORMER` public object. The api reference automatically creates a reference page for the public object, and currently inherits the docstring from the `Protocol` base class, which is irrelevant and the PR fixes it.

* Base class for quantum states (quantumlib#5065)

Creates a base class for all the quantum state classes created in quantumlib#4979, and uses the inheritance to push the implementation of `ActOn<State>Args.kron`, `factor`, etc into the base class.

Closes quantumlib#4827
Resolves quantumlib#3841 (comment) that's been bugging me for a year.

* Allow any object with supporting protocols to be the action in act_on (quantumlib#5111)

* Allow any object with supporting protocols to be the action in act_on

* lint

* Fix raiser is not callable. (quantumlib#5155)

Appears to have broken other PRs. https://github.com/quantumlib/Cirq/runs/5724527312?check_suite_focus=true

* Corrected result.data implementation. (quantumlib#5153)

When looking into quantumlib#4774 auto type promotion to objects raised a ValueError and was not tested. This PR fixes this and introduces the intended behavior as well as boosting performance slightly when qubit counts are < 64.

* Support specific IonQ targets (qpu.generation) (quantumlib#5141)

* Support specific IonQ targets

Allows for more specific backend targets.

* fmt

* Upgrade black to stable version with format stability guarantees (quantumlib#5157)

Version [22.1.0](https://black.readthedocs.io/en/latest/change_log.html#id1) is the first non-beta version of black and has a new [stability policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy). The last time we bumped the black version in quantumlib#4753 we did not actually reformat any code, so we could do that here and just rely on incremental formatting going forward, or we could do a global reformat to bring things up to date as we did when we originally switched to black in quantumlib#3516. I think the changes this time would be much less drastic than in the original switch. The main thing we've seen internally is tighter binding of the power operator, e.g. new black does `a**b + c**d` instead of `a ** b + c ** d`, which is a definite improvement.

* Format cirq-core with latest version of black (quantumlib#5159)

Review: @dabacon

* Clarify virtual tag docstring (quantumlib#5161)

Propose that instead of changing whether virtual tags are applied to noise models, we instead just clarify what it means to be virtual.  

Fixes: quantumlib#2984

* Format cirq-google with latest version of black (quantumlib#5160)

Follow-up to quantumlib#5157. Format code in cirq-google to ensure these formatting changes don't get mixed in with future logic changes.

* Ignore large-scale formatting changes for git blame (quantumlib#5162)

Follow-up to quantumlib#5159 and quantumlib#5160. Ignore these large-scale formatting changes when goind git blame, as suggested by @dabacon.

* Remove --pre from notebooks after release. (quantumlib#5135)

For review after quantumlib#5134

* Update to pylint 2.13 (quantumlib#5156)

Review: @mpharrigan

* Update educators/intro.ipynb in preparation for Cirq 1.0 launch (quantumlib#5163)

* Updated the educator intro notebook to remove deprecated items and introduce newly added concepts like gatesets and transformers. 
* Part of docs cleanup effort in preparation of Cirq 1.0 launch.

* Disable broken symbols. (quantumlib#5165)

* Autoformat all of engine_client_test.py (quantumlib#5164)

ReviewL @dabacon

* Allow specifying timeout_seconds when constructing an ionq Sampler (quantumlib#5133)

* Allow specifying timeout_seconds when constructing an ionq Sampler

This allows users of tensorflow quantum to use a high timeout and https://github.com/tensorflow/quantum/blob/f10d36b64761a003fd542392767fa079d57df0aa/tensorflow_quantum/python/quantum_context.py\#L82-L101 to run highly parallel workloads that may take very long times per-job without flakiness.

* fmt

* Python map

* Coverage

* Remove reservation colab (quantumlib#5168)

- We no longer need this colab, as the UI now
supports all reservation operations and is much easier.

Fixes: quantumlib#3588

* Add Google-specific variant for noise properties. (quantumlib#5082)

This PR provides an implementation of `SuperconductingQubitsNoiseProperties` for Google hardware. Now that SQNP is an abstract type, this is a prerequisite for re-enabling calibration-to-noise tools.

This is part 3 of quantumlib#4666; part 2 was quantumlib#4964. Remaining steps include:

- Reinstatement of calibration_to_noise_properties using new types
- Reinstatement of compare_generated_noise_to_metrics using new types

* Update docs/transform.ipynb based on new transformer framework. (quantumlib#5154)

Fixes quantumlib#4960


This notebook provides a high level overview of all the newly added features to Cirq's transformer infrastructure. We can discuss whether we need more details docs on each of the specific topics -- I think a high level overview with links to reference pages of individual methods (i.e. the current PR) should be enough to close quantumlib#4960, but I'm curious to hear what others think.

* Enforce same control order in ControlledGate equality check (quantumlib#5131)

**Breaking Change**

Changes ControlledGate equality check to enforce gates have same order.

Fixes quantumlib#5110

* Fix gates.ipynb formatting (quantumlib#5175)

- Move import cirq up into top block.
- Clear outputs.

* Cleaning up cirq/install docs (quantumlib#5178)

* Corrected virtual environment link.
* Replaced Foxtail with Sycamore.

* Fix docs/circuits.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5177)

- Remove output
- Move import to top
- Minor changes to content (add `cirq.` prefix to many quoted words)
- Remove broken link to devices.ipynb

* Update simulator docs (quantumlib#5182)

Quick cleanup pass for simulator docs. Nontrivial changes:
- include note for `seed` parameter of simulator
- remove comments about modifying StepResult state (deprecated)
- clarify pure/mixed state behaviors and advantages
- external simulator focus: qsim++, qFlex--

Everything else is cleaning format and refreshing links.

* Fix broken link from cirq/tutorials page as part of docs cleanup (quantumlib#5174)

Removes broken link from cirq/tutorials as part of docs cleanup.

* Convert start.md to start.ipynb. (quantumlib#5176)

Converts `start.md` -> `start.ipyb`. This lets us run the code block and make the notebook runnable in colab by our users.

* Update google concepts doc. (quantumlib#5186)

* Update google concepts doc.

- Remove form for applying to EAP program.
- Remove references to simulators.
- Change images to remove simulators.
- Remove dangling "Installing cirq".
- Add commas and improve sentences in a few places.

Co-authored-by: Matthew Neeley <[email protected]>

* Fix docs/qubits.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5179)

- Move import to top

* Minor cleanup of QCS tutorial (quantumlib#5184)

@dstrain115 @MichaelBroughton @wcourtney

* Link fix on start page. (quantumlib#5191)

Remove extra paranthesis.

* Neutral atom update (quantumlib#5192)

Updates neutral atom tutorial to remove uses of deprecated device behavior.

* Remove use of deprecated device behavior from quantum_volume_errors. (quantumlib#5198)

Title

* Remove BooleanHamiltonian object (quantumlib#5099)

Now that v0.14 is released, delete deprecate object

* Refactor qcs_notebook to use application default creds (quantumlib#5045)

Review: @95-martin-orion

* Cirq web supports LineQubits (quantumlib#5211)

This would be to fix quantumlib#5173

* Import new gapic generated code for quantum engine API (quantumlib#5139)

This is some very preliminary work to import new generated code for the quantum engine API. Of note is that the new code includes async support and is now using [proto-plus](https://github.com/googleapis/proto-plus-python) rather than the standard generated proto code for messages.

* Fix basics (quantumlib#5180)

Cleans up basics.ipynb and removes mention of old devices behavior.

* Deprecate `gate_set` parameter on engine classes. (quantumlib#5207)

Fixes quantumlib#4995

Review: @verult

* Tweak quantum walks doc (quantumlib#5212)

* Tweak quantum walks doc

- Removed output cells and tweaked imports
- Move print out of function.

* Deprecate json_serializable_dataclass (quantumlib#5208)

Fixes quantumlib#4460

* Fix error and add test for mutable pauli string (quantumlib#5213)

quantumlib#4001 looks abandoned so this does the change and adds the test as requested.

* Fix tutorials/state_histograms.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5206)

* Cleared output
* Fixed broken links
* Minor improvements in content

* Fix tutorials/heatmaps.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5205)

* Cleared output
* Fixed typos and broken links
* Changed language to second person

* Remove some 0.15 items from cirq.sim (quantumlib#5137)

This covers most of the deprecations for `cirq.sim` in 0.15. The two remaining ones have some challenges:

* Removing `target_tensor` etc from the initializers and replacing with `initial_state`: The repr still emits `target_tensor` so it wouldn't round-trip.
* Removing `log_of_measurement_results`: Same thing. Plus we forgot to deprecate it in a couple places.

Also this closes quantumlib#3898, as the pattern we used to deprecate `copy` without parameters works well.

* Add Cynocracy to owners of cirq-ionq (quantumlib#5145)

@Cynocracy let me know if you want to remove any of the others, or keep them as is.

* Fix educators/qaoa_ising.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5204)

* Moved cirq import to top
* Cleared output
* Fixed typos in text

* Improve documentation about writing type annotations (quantumlib#5218)

Fixes quantumlib#4383

* customer_gates.ipynb - minor content cleanup (quantumlib#5215)

cc @tanujkhattar

* Make _commutes_ consistent (quantumlib#5217)

- Requires atol to be a named parameter.
- Also changes atol to be uniformly float around the codebase.
  (not sure why it would be int, are people using an atol=1?)
- Technically a breaking change, but it's unlikely people are using
  this widely as most commutes do not even use atol.

Fixes: quantumlib#3695

* Fix numpy annotations np.array -> np.ndarray (quantumlib#5227)

`np.array` is not a valid type, but rather a factory function for creating arrays. The actual type is `np.ndarray`. This change reduces the number of `check/mypy --next` errors by >60% from 244 to 96 on my machine.

* Delete the target_tensor parameter that was deprecated in 0.15 (quantumlib#5225)

A few simulators used either initial_state or target_tensor to initialize their ActOnArgs. We deprecated the latter in 0.15. This PR deletes those. Note that one follow-on change included here is that the repr functions needed to be changed to emit the field as `initial_state` too. (I wish I'd just called it `quantum_state` now, but oh well). @95-martin-orion

I also went ahead and removed the buffer from the repr, since it is just noise.

* Deprecate the ActOnArgs._on_* methods (quantumlib#5224)

Now that we have separated out the `QuantumStateRepresentation` from `ActOnArgs`, there is no need for the `_on_*` methods anymore. This PR deprecates those, adds deprecation tests, and updates any old test ActOnArgs to use the new QuantumStateRepresentation internally. @95-martin-orion

* Allow specifying initial state vector in DensityMatrixSimulator (quantumlib#5223)

This changes how ActOnDensityMatrixArgs is constructed to allow specifying the initial state as a state vector or state tensor, or as a density matrix or density tensor. Some of this could perhaps be moved into `cirq.to_valid_density_matrix` if people think that is a better place. Currently `to_valid_density_matrix` only handles 1D state vectors or 2D density matrices, not 2x2x..2 tensors in either case, but if we have the qid_shape we can tell handle these unambiguously.

Fixes quantumlib#3958

* Unquote example code in ArithmeticOperation (quantumlib#5230)

Fixes quantumlib#5228 (I hope)

* Document CircuitOp optimizer best practices (quantumlib#5221)

Final item for quantumlib#3634.

With the new transformers, there is a clean pipeline for optimizing nested circuits and sending the (concise!) result to hardware for execution.

* Remove the deprecated mutators in cirq/ops (quantumlib#5201)

Removes all the deprecated mutators.

* Allow server-side warnings from IonQ (quantumlib#5222)

This will be used to notify users about deprecations and changes to the API without needing to update Cirq independently.

* Fix educators/textbook_algorithms.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5199)

* Fixes typos
* Removes outputs
* Move import to top

* Fix qcvv/xeb_theory.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5202)

* Moved import to top
* Fixed broken link to quantum ai website
* Minor improvements in text formatting

* Cleaning up tutorials/variational_algorithm.ipynb (quantumlib#5185)

* Move cirq import to top
* Remove outputs

* Document CIRCUIT_TYPE and hide other typevars/aliases in circuits.py (quantumlib#5229)

Fixes quantumlib#5150 (assuming this renders nicely on the docsite; how can I check that locally?)

This adds an underscore prefix to hide some type aliases and type vars that are not part of the public interface of the module. Also adds a docstring to the `CIRCUIT_TYPE` variable, which is used in a few other places.

* Make check scripts run pytest in parallel (quantumlib#5143)

The tests were made parallel in CI, but this updates the scripts to run in parallel. Respects if user overrides with different level of parallelism.

* cirq-ionq: Retry non-standard cloudflare errors (quantumlib#5237)

* Add q helper function for constructing common qubit types. (quantumlib#5181)

* Add q helper function

* fmt

* Ignore static type errors in tests

* Ignore intentional type errors

* Fix Raises docstring

* Fixes from review

* Use *args

* remove unused import

* Unpin sympy and ignore sympy type errors (quantumlib#5226)

Fixes quantumlib#5058
Review: @dabacon

* Add calibration-to-noise pipeline (quantumlib#5187)

This PR reinstates the cirq_google utility for converting `Calibration` objects to noise properties. To create a simulator with behavior that mimics some `Calibration` "cal", the expected usage is:
```python
noise_props = cg.noise_properties_from_calibration(cal)
noise_model = cg.NoiseModelFromGoogleNoiseProperties(noise_props)
simulator = cirq.Simulator(noise=noise_model)  # will mimic noise from `calibration`
```

This is part 4 of quantumlib#4666; part 3 was quantumlib#5082. Remaining steps include:
- Convenience methods for modifying noise properties
- Reinstatement of compare_generated_noise_to_metrics using new types

* Remove device from circuits (quantumlib#5189)

Removes v0.15 deprecation items for attaching devices to circuits.

* Bump tensorflow-docs version (quantumlib#5250)

* Fix tutorials/qaoa.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5200)

* Change example device from `cg.Bristlecone` (now deprecated) to `cg.Sycamore`.
* Use new GridDeviceMetadata instead of deprecated device properties (like neighbors_of)
* Move import to top
* Clear outputs

* Remove custom cirq_type (quantumlib#5249)

Custom `cirq_type` was deprecated in quantumlib#4704 and not necessary for internal types.

* Skip "magic trailing comma" when formatting with black (quantumlib#5170)

The "magic trailing comma" is a comma at the end of bracketed list that forces black to format the list entries on separate lines, even if they would fit on one line. For example, if you write:
```python
foo(a, b,)
```
black will see that trailing comma and format this as:
```python
foo(
    a,
    b,
)
```
But with the `skip-magic-trailing-comma` setting enabled this will format on a single line instead
```python
foo(a, b)
```
IME the trailing commas are almost always unintentional, e.g. left over from other refactos, and result in wasted vertical space. I suggest we enable this flag.

* Remove deprecated log_of_measurement_results parameters (quantumlib#5233)

* deprecate log_of_measurement_results

* Fix test

* coverage

* Add empty ClassicalDataDictionaryStore.repr test

* Add ActOnArgs test

* Add tests

* Add ActOnStabilizerArgs tests

* nits

* coverGE

* format

Co-authored-by: Cirq Bot <[email protected]>

* Make the quantum state generic (quantumlib#5255)

* Migrate google/best_practices.md to google/best_practices.ipynb as part of docs cleanup for Cirq 1.0 (quantumlib#5236)

- Fixes bugs in code demonstrating use of circuit operations and compiling them using new transformers. 

Follow up of quantumlib#5221

* Format cirq-google with skip-magic-trailing-comma (quantumlib#5171)

Review: @95-martin-orion

* Format according to new black rules (quantumlib#5259)

Follow up by will add hash to  .git-blame-ignore-revs

* Ignore skip-magic-trailing-comma formatting with git blame (quantumlib#5257)

This adds a formatting commit to ignore when doing git blame.

* Use sorted instead of set for random.sample (quantumlib#5248)

* Fix Docs: cirq/tutorials/educators/chemistry (quantumlib#5251)

* Convenience methods for modifying GoogleNoiseProperties (quantumlib#5188)

* Add override methods.

* Mypy passes, weak typing

* Resolved mypy conundrum

* with_params

* Deprecate Gateset.accept_global_phase_op (quantumlib#5239)

Deprecates Gateset.accept_global_phase_op

**Breaking Change:** Changes the default value of `Gateset.accept_global_phase_op` from `True` to `False`. I can't think of any way to remove this parameter without eventually needing this breaking change. Currently all gatesets that are created allow global phase gates if they don't specify `accept_global_phase_op=False` explicitly. But the end goal is only to allow global phase gates if they're included in the `gates` list. So at some point in the transition the default behavior needs to break, and I can't think of a way of doing that via deprecation. Therefore I think we may as well do it now via this breaking change.

Note that even though it's breaking, it isn't breaking in a bad way. Users who are adding global phase gates to things that suddenly don't accept them will just see an error that the gate is not in the gateset, and then go add it. It's much safer than breaking in the other direction in which we silently start allowing new gate types.

Closes quantumlib#4741

@tanujkhattar

* Exclude TYPE_CHECKING from docs (quantumlib#5261)

This would be an attempt to fix quantumlib#5231

* Add unit test

Co-authored-by: Dax Fohl <[email protected]>
Co-authored-by: Cirq Bot <[email protected]>
Co-authored-by: Tanuj Khattar <[email protected]>
Co-authored-by: Orion Martin <[email protected]>
Co-authored-by: Cheng Xing <[email protected]>
Co-authored-by: Matthew Neeley <[email protected]>
Co-authored-by: Doug Strain <[email protected]>
Co-authored-by: MichaelBroughton <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dave Bacon <[email protected]>
Co-authored-by: Matthew Harrigan <[email protected]>
Co-authored-by: Jon Donovan <[email protected]>
Co-authored-by: Matthew Neeley <[email protected]>
Co-authored-by: Timo Eckstein <[email protected]>
Co-authored-by: Dax Fohl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/workflow size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants