Skip to content

loschmidt.tilted_square_lattice Benchmark #236

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 11 commits into from
Jan 10, 2022
Merged

Conversation

mpharrigan
Copy link
Collaborator

@mpharrigan mpharrigan commented Dec 4, 2021

Adds the executable generation functionality for the following benchmark:

AlgorithmicBenchmark(
    domain='recirq.otoc',
    name='loschmidt.tilted_square_lattice',
    executable_family='recirq.otoc.loschmidt.tilted_square_lattice',
    spec_class=TiltedSquareLatticeLoschmidtSpec,
    executable_generator_func=get_all_tilted_square_lattice_executables,
)

The loschmidt echo runs a random unitary forward and backwards and measures how often we return to the starting state. This benchmark checks random unitaries generated on the TiltedSquareLattice topology.

Notes

This PR does not include any BenchmarkConfig's, namely scripts for launching execution and analysis.

I've also removed the data_class field from the AlgorithmicBenchmark card catalog. (1) I don't want to make this PR too big by including it (2) I want to work some of the kinks out of the design of the data analysis part of the flow without holding up committing the infrastructure for taking data.

Cirq requirements

Following #237 , this will only test the new functionality against the pre-release version of cirq where the cirq_google.workflow utilities are available.

I've noticed as well that Cirq 0.12 does not include cirq.NamedTopology. This is a case where keeping compatibility with the prior version of Cirq is not worth it, esp. since v0.13 has been out for a while. As part of this PR I've disabled the "pre" check with a note. We'll re-enable when Cirq 0.14 comes out.

@google-cla google-cla bot added the cla: yes label Dec 4, 2021
Base automatically changed from 2021-12-algo-library to master December 8, 2021 18:27
Change-Id: Id74c4e1c56cd7702862f6972d49d035eb83dd166
@mpharrigan mpharrigan force-pushed the 2021-12-loschmidt-tilted branch from 70b509d to 659e107 Compare December 8, 2021 18:40
Change-Id: Ie637306bd284cd20b09f464ee8551d48d1a1d684
Change-Id: Iadcaac412d43ccaa32140e7a0418011620ee8d8f
Change-Id: Ia229563ad399f1ae5e5c9916e70586623babb2c1
@mpharrigan mpharrigan marked this pull request as ready for review December 15, 2021 22:37


@lru_cache()
def _resolve_json(cirq_type: str) -> Optional[ObjectFactory]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like I missed a change somewhere, since this is likely not the first time this snippet has appeared.
However, what is this? I am confused why we need this. Maybe a code comment would be good to explain what this is for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is how we register modules for json deserialization; done after the separation of cirq_google and friends. You can see we add it to cirq's DEFAULT_RESOLVERS global variable

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

return cirq.Circuit()

monkeypatch.setattr(recirq.otoc.loschmidt.tilted_square_lattice.tilted_square_lattice,
"create_tilted_square_lattice_loschmidt_echo_circuit", mock_get_circuit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this monkeypatch? Is it just for test performance?
If so, how slow is the test without this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's for speed and so I can assert something, namely that it was called the correct number of times.

Creating random circuits is expensive -- or at least speeding that up is outside the scope for this work. I think I wanted a test that relied on the default arguments for this function. I can add another test that dials back the number of executables and makes other assertions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment to that effect above and explain what the test is actually testing.

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

@mpharrigan
Copy link
Collaborator Author

@dstrain115 I think I addressed your comments. PTAL if you have time

Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

Minor comments then I approve.

@@ -0,0 +1,39 @@
# Copyright 2021 Google
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ha, it's 2022 now! Gotcha!
(optional since you started it in 2021)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh no! now people can skirt our onerous apache2 license because the copyright is invalid!

return cirq.Circuit()

monkeypatch.setattr(recirq.otoc.loschmidt.tilted_square_lattice.tilted_square_lattice,
"create_tilted_square_lattice_loschmidt_echo_circuit", mock_get_circuit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment to that effect above and explain what the test is actually testing.

Change-Id: I48a9d4cd5e507d344b0f8f32f88c7485d627e0e2
Change-Id: Ib42d67bfc938e5d1fbcdef4a5aaf1cdb9d4d098c
…021-12-loschmidt-tilted

Change-Id: I35083c77b8a1b3372e935ccb68888dda8037351d
Change-Id: Ic9d4c7b3e2948a6d1121d7d915e525c38baad27a
@mpharrigan
Copy link
Collaborator Author

made the requested changes!

Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

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

LGTM

@mpharrigan mpharrigan merged commit 8ce5c4a into master Jan 10, 2022
@mpharrigan mpharrigan deleted the 2021-12-loschmidt-tilted branch January 10, 2022 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants