Skip to content

feat: add circuit instruction density summary#1295

Open
jaimeajl wants to merge 1 commit into
amazon-braket:mainfrom
jaimeajl:unitaryhack/circuit-instruction-density
Open

feat: add circuit instruction density summary#1295
jaimeajl wants to merge 1 commit into
amazon-braket:mainfrom
jaimeajl:unitaryhack/circuit-instruction-density

Conversation

@jaimeajl

@jaimeajl jaimeajl commented Jun 9, 2026

Copy link
Copy Markdown

Issue #, if available:

Addresses part of #1235

Description of changes:

This PR adds Circuit.instruction_density() as a deterministic instruction density summary for circuits.

It complements raw instruction counting by reporting both counts and normalized densities:

  • total instruction count
  • counts by operator name
  • operator density normalized by total instructions
  • per-qubit instruction counts
  • per-qubit density normalized by total instructions

Multi-qubit instructions contribute once to each qubit they touch, including control qubits. The output is deterministic, with sorted operator and qubit summaries, making it useful for benchmarking, sanity checks, and comparing generated or transformed circuits.

This implements the operator density stretch goal from #1235 without duplicating the raw instruction count API.

Testing done:

  • ruff format --check src/braket/circuits/circuit.py test/unit_tests/braket/circuits/test_circuit.py
  • ruff check src/braket/circuits/circuit.py
  • pytest -o addopts='' test/unit_tests/braket/circuits/test_circuit.py -q
    • 338 passed, 2 xfailed
  • git diff --check

AI assistance disclosure: I used AI assistance for design review and wording, then implemented, reviewed, and validated the changes locally.

@jaimeajl jaimeajl requested a review from a team as a code owner June 9, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants