Skip to content

Conversation

vinayswamik
Copy link
Collaborator

@vinayswamik vinayswamik commented Aug 28, 2025

Summary of changes

  • Added asv benchmarking support in PyQASM.
  • Supported benchmarking functions are import, load, draw, unroll, validate, dump and ,dumps.
  • Also added benchmarks for Qubit Register Consolidation and Openpulse programs.

Verification Instructions:

From the project root, you can verify the benchmarks with the following steps:

Creates a benchmarking environment under .asv/.

asv run

Generates html output files containing benchmark results in tests/benchmarking/.

asv publish

Launches a local server to view benchmarking results in your browser.

asv preview

Notes

  • Currently, the benchmark results are based on the latest commit only (HEAD). So, only a single data point is shown until historical runs are added.

Profiling

Profiling data and visualizations for PyQASM functions

  • Added SVG flamegraphs for openpulse, qubit register consolidation, unroll, and validate profiling.
  • Included .speedscope.json files for detailed and interactive profiling data analysis.

Closes #67

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TheGupta2012
Copy link
Member

I ran the benchmarks locally, but they are failing in the pulse test -


· Creating environments.........
· Discovering benchmarks
·· Uninstalling from virtualenv-py3.11
·· Building d5bf684d <main> for virtualenv-py3.11.....
·· Installing d5bf684d <main> into virtualenv-py3.11...
· Running 27 total benchmarks (1 commits * 3 environments * 9 benchmarks)

[ 0.00%] · For pyqasm commit d5bf684d <main>:

[ 0.00%] ·· Benchmarking virtualenv-py3.11
[ 1.85%] ··· Running (import.PyqasmImport.time_pyqasm_import--)....
[ 9.26%] ··· Running (pyqasm_functions.PyqasmFunctions.time_dumps--)..
[12.96%] ··· Running (unroll.Unrolling.time_qubit_reg_consolidation--)..
[16.67%] ··· Running (validate.Validate.time_validate--).
[18.52%] ··· import.PyqasmImport.time_pyqasm_import                                                                           98.6±3ms
[20.37%] ··· openpulse.Openpulse.time_openpulse                                                                                 failed
[22.22%] ··· pyqasm_functions.PyqasmFunctions.time_draw                                                                      402±0.8ms
[24.07%] ··· pyqasm_functions.PyqasmFunctions.time_dump                                                                     72.9±0.4ms
[25.93%] ··· pyqasm_functions.PyqasmFunctions.time_dumps                                                                    71.5±0.5ms
[27.78%] ··· pyqasm_functions.PyqasmFunctions.time_load                                                                     2.52±0.01s
[29.63%] ··· unroll.Unrolling.time_qubit_reg_consolidation                                                                     676±2ms
[31.48%] ··· unroll.Unrolling.time_unroll                                                                                      640±6ms
[33.33%] ··· validate.Validate.time_validate                                                                                   626±2ms

[33.33%] ·· Building for virtualenv-py3.12......
[33.33%] ·· Benchmarking virtualenv-py3.12
[35.19%] ··· Running (import.PyqasmImport.time_pyqasm_import--)....
[42.59%] ··· Running (pyqasm_functions.PyqasmFunctions.time_dumps--)...
[48.15%] ··· Running (unroll.Unrolling.time_unroll--)..
[51.85%] ··· import.PyqasmImport.time_pyqasm_import                                                                          102±0.3ms
[53.70%] ··· openpulse.Openpulse.time_openpulse                                                                                 failed
[55.56%] ··· pyqasm_functions.PyqasmFunctions.time_draw                                                                      388±0.5ms
[57.41%] ··· pyqasm_functions.PyqasmFunctions.time_dump                                                                     64.3±0.8ms
[59.26%] ··· pyqasm_functions.PyqasmFunctions.time_dumps                                                                    62.8±0.4ms
[61.11%] ··· pyqasm_functions.PyqasmFunctions.time_load                                                                     2.35±0.01s
[62.96%] ··· unroll.Unrolling.time_qubit_reg_consolidation                                                                     661±3ms
[64.81%] ··· unroll.Unrolling.time_unroll                                                                                      638±2ms
[66.67%] ··· validate.Validate.time_validate                                                                                   623±1ms

[66.67%] ·· Building for virtualenv-py3.13......
[66.67%] ·· Benchmarking virtualenv-py3.13
[68.52%] ··· Running (import.PyqasmImport.time_pyqasm_import--)....
[75.93%] ··· Running (pyqasm_functions.PyqasmFunctions.time_dumps--)..
[79.63%] ··· Running (unroll.Unrolling.time_qubit_reg_consolidation--)..
[83.33%] ··· Running (validate.Validate.time_validate--).
[85.19%] ··· import.PyqasmImport.time_pyqasm_import                                                                          112±0.1ms
[87.04%] ··· openpulse.Openpulse.time_openpulse                                                                                 failed
[88.89%] ··· pyqasm_functions.PyqasmFunctions.time_draw                                                                      421±0.6ms
[90.74%] ··· pyqasm_functions.PyqasmFunctions.time_dump                                                                       74.2±1ms
[92.59%] ··· pyqasm_functions.PyqasmFunctions.time_dumps                                                                      73.1±1ms
[94.44%] ··· pyqasm_functions.PyqasmFunctions.time_load                                                                     2.78±0.02s
[96.30%] ··· unroll.Unrolling.time_qubit_reg_consolidation                                                                     734±2ms
[98.15%] ··· unroll.Unrolling.time_unroll                                                                                      694±3ms
[100.00%] ··· validate.Validate.time_validate                                                                                 691±0.9ms

@TheGupta2012
Copy link
Member

Also a couple of things about benchmarking -

  1. Benchmark trigger : We want benchmarks to be run via some "trigger" ideally through a Github action when a commit is merged to main. This is to detect any regression in performance caused by git commits. I believe we can take inspiration from qiskit.github.io and their workflow on how they publish these benchmarks. It doesn't need to be as extensive at first, we can target only a few machines and gradually build up from there.

  2. Test files : Current diff is 70k+ lines just from tests! While this is okay if we want version control for the tests, but, practically speaking, these tests will not change over time. It is better to keep a metadata file for the tests and either -

    • Generate the files on the fly
    • Pull the files from a public repository / Amazon s3 bucket.

    I think the second method would work better in our case as the benchpress repo is already public

@vinayswamik vinayswamik self-assigned this Aug 28, 2025
@vinayswamik vinayswamik changed the title Feature/pyqasm benchmarking Feature/pyqasm benchmarking and Profiling Sep 2, 2025
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.

[FEATURE] Create Benchmarks for pyqasm
4 participants