Add channel random circuit test coverage#1080
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds two new unit tests, test_random_circuit_resolver_batch_channels_present and test_random_symbol_circuit_resolver_batch_channels_present, to verify that channel operations are included in generated circuits when include_channels=True and that the resulting circuits are serializable. The reviewer recommends strengthening the serialization checks in both tests by performing a full round-trip serialization and deserialization verification instead of only asserting that the serialized output is not null.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Address review feedback: verify channel-containing circuits survive a full convert_to_tensor/from_tensor round-trip instead of only asserting non-null serialization.
|
@arnavnagzirkar Thank you for this contribution. Gemini Code Assist's review comments seem reasonable. If you don't disagree with them, could you got ahead and make those changes? Also, in the PR description, it talks about include_channels=True, but it doesn't mention which function or module that refers to. Could you add that information to the description? |
|
Thanks @mhucka. Two quick updates:
Let me know if you would like anything else adjusted. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds two new unit tests to tensorflow_quantum/python/util_test.py: test_random_circuit_resolver_batch_channels_present and test_random_symbol_circuit_resolver_batch_channels_present. These tests verify that channel operations are correctly included in generated circuits when include_channels=True and that the resulting circuits can be successfully serialized and deserialized. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
mhucka
left a comment
There was a problem hiding this comment.
Thank you for working on this. I have a small change request, but otherwise this looks good and almost ready to merge.
| channel_types = tuple(type(c) for c in util.get_supported_channels()) | ||
|
|
||
| circuits, _ = util.random_circuit_resolver_batch(qubits, | ||
| batch_size=5, |
There was a problem hiding this comment.
For this and the next new function, could you please use a variable to set the batch size, following the pattern of the other functions in this file? (See for example this line: https://github.com/tensorflow/quantum/pull/1080/changes#diff-0605f6d13dea49e94d3ddf78736d228215528e5f046a281dfddc1ad9afd63cddR119)
|
Thanks @mhucka for the review and for the time on this. I see that #1091 was merged in the meantime and already adds comprehensive channel coverage for the random circuit generators, closing issue #1066. Its tests (test_random_circuit_resolver_batch_channel_content, test_random_symbol_circuit_resolver_batch_channel_content, and test_random_symbol_circuit_channel_content) cover everything in this PR and more, including the include_channels=False path and validation that channel ops are not controlled or parameterized. Since the two tests here are now a subset of what is already on master, I am closing this PR to avoid duplicate coverage. Happy to help elsewhere if there is a follow up you would like. Thanks again. |
Adds regression coverage for random circuit generation with channels.
The
include_channels=Trueargument mentioned here is a parameter of two functions in thetensorflow_quantum.python.utilmodule (imported asutilin the tests):util.random_circuit_resolver_batchutil.random_symbol_circuit_resolver_batchThe new tests in
tensorflow_quantum/python/util_test.pyassert that, when each of these functions is called withinclude_channels=True, the generated random circuits contain at least one supported channel operation (taken fromutil.get_supported_channels()).Following the Gemini Code Assist review, the tests also verify that the circuits survive a full serialization round trip:
util.convert_to_tensoris used to serialize,util.from_tensorto deserialize, and the re-serialized result is compared for equality. This is stronger than only checking that serialization does not return null.This addresses issue #1066.