test: add channel random circuit 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.
| # Verify circuits containing channels are serializable. | ||
| self.assertIsNotNone(util.convert_to_tensor(circuits)) |
There was a problem hiding this comment.
Asserting assertIsNotNone on the result of util.convert_to_tensor only verifies that the serialization function does not raise an exception. It does not guarantee that the channels are correctly serialized and can be deserialized back without data loss or corruption. Performing a round-trip serialization and deserialization check provides a much stronger correctness guarantee.
| # Verify circuits containing channels are serializable. | |
| self.assertIsNotNone(util.convert_to_tensor(circuits)) | |
| # Verify circuits containing channels are correctly serializable round-trip. | |
| serialized = util.convert_to_tensor(circuits, deterministic_proto_serialize=True) | |
| deserialized = util.from_tensor(serialized) | |
| self.assertAllEqual( | |
| serialized, | |
| util.convert_to_tensor(deserialized, deterministic_proto_serialize=True)) |
| # Verify circuits containing channels are serializable. | ||
| self.assertIsNotNone(util.convert_to_tensor(circuits)) |
There was a problem hiding this comment.
Asserting assertIsNotNone on the result of util.convert_to_tensor only verifies that the serialization function does not raise an exception. It does not guarantee that the channels are correctly serialized and can be deserialized back without data loss or corruption. Performing a round-trip serialization and deserialization check provides a much stronger correctness guarantee.
# Verify circuits containing channels are correctly serializable round-trip.
serialized = util.convert_to_tensor(circuits, deterministic_proto_serialize=True)
deserialized = util.from_tensor(serialized)
self.assertAllEqual(
serialized,
util.convert_to_tensor(deserialized, deterministic_proto_serialize=True))Address review feedback: verify channel-containing circuits survive a full convert_to_tensor/from_tensor round-trip instead of only asserting non-null serialization.
Adds regression coverage for random circuit generation with include_channels=True.\n\nThe new tests assert that generated random circuits contain at least one supported channel operation and remain serializable via util.convert_to_tensor.