Skip to content

Fixes to benchmark test code due to missing updates in dependency methods#1035

Open
kenya-sk wants to merge 5 commits intotensorflow:masterfrom
kenya-sk:fix-benchmarks-test
Open

Fixes to benchmark test code due to missing updates in dependency methods#1035
kenya-sk wants to merge 5 commits intotensorflow:masterfrom
kenya-sk:fix-benchmarks-test

Conversation

@kenya-sk
Copy link
Copy Markdown
Contributor

@kenya-sk kenya-sk commented Apr 6, 2026

This PR fixes benchmark breakages in benchmarks/scripts and restores Bazel test coverage for the benchmark targets.

Changes

  • Fixed missing Bazel deps in benchmarks/scripts/BUILD and made random_clifford_circuit importable by switching to py_library in benchmarks/scripts/models/BUILD.
  • Fixed TFQ gradient benchmark input handling in benchmark_op_gradients.py by passing symbol_names as a tensor.
  • Replaced removed Cirq API usage in benchmark_random_circuit.py with an in-file implementation based on ReCirq’s google_v2_beyond_classical.py logic (with source attribution), while preserving existing benchmark behavior (fixed-depth output).

Note
Direct ReCirq adoption was intentionally deferred in this PR because it introduces a broader dependency migration than needed for a benchmark-fix change. In this repo, adding ReCirq as a required dependency impacts Python lockfile resolution and Bazel external dependency wiring, and we hit dependency-resolution conflicts while trying to make it mandatory. To keep this PR focused, low-risk, and test-stable, we inlined the minimal circuit-generation logic with source attribution, and left full ReCirq integration as follow-up work once dependency constraints are aligned.

Results
All benchmark tests have passed.

$ bash scripts/test_benchmarks.sh 
Testing all Benchmarks.
Loading: 0 packages loaded
Loading: 0 packages loaded
INFO: Analyzed 6 targets (21 packages loaded, 225 targets configured).
INFO: Found 2 targets and 4 test targets...
INFO: Elapsed time: 5.054s, Critical Path: 4.64s
INFO: 2 processes: 1 internal, 1 local.
INFO: Build completed successfully, 2 total actions
//benchmarks/scripts:benchmark_clifford_circuit                 (cached) PASSED in 6.9s
//benchmarks/scripts:benchmark_op_gradients                     (cached) PASSED in 8.9s
//benchmarks/scripts:benchmark_util_test                        (cached) PASSED in 4.3s
//benchmarks/scripts:benchmark_random_circuit                            PASSED in 4.6s

Executed 1 out of 4 tests: 4 tests pass.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
Testing Complete!

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the benchmarking infrastructure by refining build dependencies, optimizing tensor conversions in gradient benchmarks, and implementing a custom random circuit generator. The changes include converting symbol_names to a TensorFlow tensor to avoid repeated conversions during benchmarking and replacing a library-dependent circuit generator with a manual implementation. Feedback suggests simplifying the redundant logic for determining circuit interaction orientation and improving the connectivity of the generated random circuits to ensure they are more representative for benchmarking purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant