Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fast transpilation method to BaseExperiment #1459

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wshanks
Copy link
Collaborator

@wshanks wshanks commented Jun 4, 2024

No description provided.

@wshanks
Copy link
Collaborator Author

wshanks commented Jun 5, 2024

Current status:

  • All the tests and linting pass
  • Docs failing because of a change to transpile options. I haven't looked at updating the docs so far
  • I added a new module qiskit_experiments.framework.transpilation with functions map_qubits, check_transpilation_needed, and minimal_transpile (but I don't feel strongly about location or naming).
  • BaseExperiment._transpiled_circuits calls map_qubits on all the circuits to map them to the physical_qubits. Then it calls minimal_transpile which calls check_transpilation_needed and then transpile only if needed.
  • BaseCalibrationExperiment._transpiled_circuits calls map_qubits, then self._attach_calibrations, and then minimal_transpile. I split up map_qubits and minimal_transpile like this so that _attach_calibrations could be inserted in the middle like this. It would be nice to call super()._transpiled_circuits() and then self._attach_calibrations() but the calibrations need to be attached after mapping and before checking for transpilation to make sure that any custom gate calibrations are attached to the right qubits and don't cause the check to determine that transpilation is needed for the custom gate.
  • I added full_transpile as a default transpilation option. It seemed the most appropriate place to put the option. When it is set, transpile is called by _transpiled_circuits rather than just doing the check. This is an escape hatch when the user wants to use the transpiler for something. A possible problem is that some code (like the docs and the HalfAngle test that had to be modified) might assume that every transpile option is valid to pass to transpile() (the changes here filter it out). Do we want to maintain that assumption? Where should be put full_transpile then?
  • I modified the restless test code because it didn't make sense to me. It was forcing the backend to be two qubits and return two qubit results even for an experiment that only measured one qubit.
  • I modified a resonator spectroscopy test that tested that the transpiled circuits were expanded to the size of the backend. Now circuits are only mapped up to the highest physical qubit index and ancillas are not filled in like calling transpile with initial_layout does.
  • I modified one BaseCalibrationExperiment test which was passing because BaseCalibrationExperiment was bypassing transpile but the experiment did not make sense. It generated a circuit with an x gate for a backend that had no x gate. I just removed the x gate from the circuit as the simplest solution. That test wasn't doing much validation of transpilation any way besides checking it did not error.
  • There is a change related to error_message not being in AerJob. I will factor that out to another PR.
  • There is a has_calibration workaround for a bug I want to fix in main Qiskit.
  • I still want to review how the PulseGates pass works and make sure that these changes work with it in the right way (getting calibrations attached when in the target and needed).
  • I decided not to try to support BackendV1 for the fast transpile.

I added the following code to minimal_transpile to check which tests were still using transpile:

    import inspect
    import unittest
    test_frame = next(f[0] for f in inspect.stack() if any(isinstance(l, unittest.TestCase) for n, l in f[0].f_locals.items()))
    test = next(v for v in test_frame.f_locals.values())
    print(f"full_transpile={full_transpile} for {test.id()}")

Here is the full output from running the tests. I have not gone through yet to check that it makes sense which tests are using transpile or not (EDIT: force pushed and regenerated the list after finding that calibrations on circuits were not being checked correctly when determining if transpilation was needed; many of the remaining tests doing transpilation now use MockIQBackend which uses the u gate basis instead of sx and rz).

full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_transpiled_circuits_no_coupling_map
full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_update_calibration
full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_update_calibration_batch
full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_update_calibration_custom_analysis
full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_update_calibration_parallel
full_transpile=False for test.calibration.test_base_calibration_experiment.TestBaseCalibrationClass.test_update_calibration_update_analysis
full_transpile=False for test.calibration.test_update_library.TestFrequencyUpdate.test_frequency
full_transpile=False for test.database_service.test_db_experiment_data.TestDbExperimentData.test_copy_figure_artifacts
full_transpile=False for test.database_service.test_db_experiment_data.TestDbExperimentData.test_copy_metadata
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_1__0_03
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_2__0_01
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_3_0_02
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_4_0_04
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_standard_processor_1__0_02
full_transpile=False for test.data_processing.test_restless_experiment.TestFineAmpEndToEndRestless.test_end_to_end_restless_standard_processor_2_0_04
full_transpile=False for test.framework.test_composite.TestBatchTranspileOptions.test_batch_transpile_options_integrated
full_transpile=False for test.framework.test_composite.TestBatchTranspileOptions.test_separate_jobs
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_analysis_replace_results_false
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_analysis_replace_results_true
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_analysis_options
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_analysis_options_cascade
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_auto_save
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_avg_kerneled_memory_marginalization
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_copy
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_copy_analysis_ref
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_count_memory_marginalization_1___0x0____0x2____0x3____0x0____0x0____0x1____0x3____0x0____0x2____0x3__
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_count_memory_marginalization_2___00____10____11____00____00____01____11____00____10____11__
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_experiment_data_attributes
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_figures
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_properties_setting
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_save_load
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_save_metadata
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_single_kerneled_memory_marginalization
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_subexp_data
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_composite_tags
full_transpile=False for test.framework.test_composite.TestCompositeExperimentData.test_nested_composite
full_transpile=False for test.framework.test_composite.TestComposite.test_flatten_results_nested
full_transpile=False for test.framework.test_composite.TestComposite.test_flatten_results_partial
full_transpile=False for test.framework.test_composite.TestComposite.test_parallel_options
full_transpile=False for test.framework.test_framework.TestFramework.test_after_job_fail
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_01__None__None_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_02__None__1_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_03__None__2_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_04__None__3_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_05__1__None_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_06__1__1_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_07__1__2_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_08__1__3_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_09__2__None_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_10__2__1_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_11__2__2_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_12__2__3_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_13__3__None_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_14__3__1_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_15__3__2_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_circuits_16__3__3_
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_experiments_1_None
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_experiments_2_1
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_experiments_3_2
full_transpile=False for test.framework.test_framework.TestFramework.test_job_splitting_max_experiments_4_3
full_transpile=False for test.framework.test_framework.TestFramework.test_metadata
full_transpile=False for test.library.calibration.test_drag.TestDragCircuits.test_circuit_roundtrip_serializable
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_circuits_serialization
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_1_0_02
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_2_0_03
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_3_0_04
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_4_0_05
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_5_0_06
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_6_0_07
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_over_rotation_7_0_08
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_1_0_02
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_2_0_03
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_3_0_04
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_4_0_05
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_5_0_06
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_6_0_07
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmpEndToEnd.test_end_to_end_under_rotation_7_0_08
full_transpile=False for test.library.calibration.test_fine_amplitude.TestFineAmplitudeCal.test_run_sx_cal
full_transpile=False for test.library.calibration.test_fine_drag.TestFineDrag.test_circuits_roundtrip_serializable
full_transpile=False for test.library.calibration.test_half_angle.TestHalfAngleCal.test_circuits_roundtrip_serializable
full_transpile=False for test.library.calibration.test_rabi.TestEFRabi.test_ef_rabi_end_to_end
full_transpile=False for test.library.calibration.test_rabi.TestRabiEndToEnd.test_rabi_end_to_end
full_transpile=False for test.library.calibration.test_rabi.TestRabiEndToEnd.test_wrong_processor
full_transpile=False for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_circuit_roundtrip_serializable
full_transpile=False for test.library.calibration.test_rough_amplitude.TestRoughAmpCal.test_circuit_roundtrip_serializable
full_transpile=False for test.library.calibration.test_rough_amplitude.TestRoughAmpCal.test_circuits
full_transpile=False for test.library.calibration.test_rough_amplitude.TestRoughAmpCal.test_update
full_transpile=False for test.library.calibration.test_rough_amplitude.TestSpecializations.test_ef_circuits
full_transpile=False for test.library.calibration.test_rough_amplitude.TestSpecializations.test_ef_update
full_transpile=False for test.library.calibration.test_rough_frequency.TestRoughFrequency.test_update_calibrations
full_transpile=False for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_circuit_serialization
full_transpile=False for test.library.characterization.test_multi_state_discrimination.TestMultiStateDiscrimination.test_circuit_roundtrip_serializable
full_transpile=False for test.library.characterization.test_multi_state_discrimination.TestMultiStateDiscrimination.test_discrimination_analysis_1_2
full_transpile=False for test.library.characterization.test_multi_state_discrimination.TestMultiStateDiscrimination.test_discrimination_analysis_2_3
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_circuit_roundtrip_serializable
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_expdata_serialization
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_kerneled_expdata_serialization
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_parallel_experiment
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_spectroscopy12_end2end_classified
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_spectroscopy_end2end_classified
full_transpile=False for test.library.characterization.test_qubit_spectroscopy.TestQubitSpectroscopy.test_spectroscopy_end2end_kerneled
full_transpile=False for test.library.characterization.test_readout_error.TestReadoutError.test_correlated_analysis_ideal
full_transpile=False for test.library.characterization.test_readout_error.TestReadoutError.test_database_save_and_load
full_transpile=False for test.library.characterization.test_readout_error.TestReadoutError.test_json_serialization
full_transpile=False for test.library.characterization.test_readout_error.TestReadoutError.test_local_analysis_ideal
full_transpile=False for test.library.characterization.test_readout_error.TestReadoutError.test_parallel_running
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_circuit_roundtrip_serializable
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_end_to_end_1__5000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_end_to_end_2__2000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_end_to_end_3_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_end_to_end_4_1000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_end_to_end_5_3000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_initial_circuit_transpiled
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_kerneled_expdata_serialization_1__5000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_kerneled_expdata_serialization_2_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_kerneled_expdata_serialization_3_3000000_0
full_transpile=False for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_parallel_experiment
full_transpile=False for test.library.characterization.test_t1.TestT1.test_t1_end2end
full_transpile=False for test.library.characterization.test_t1.TestT1.test_t1_parallel
full_transpile=False for test.library.characterization.test_t2ramsey.TestT2Ramsey.test_circuit_roundtrip_serializable
full_transpile=False for test.library.characterization.test_t2ramsey.TestT2Ramsey.test_t2ramsey_concat_2_experiments
full_transpile=False for test.library.characterization.test_t2ramsey.TestT2Ramsey.test_t2ramsey_parallel
full_transpile=False for test.library.characterization.test_t2ramsey.TestT2Ramsey.test_t2ramsey_run_end2end
full_transpile=False for test.library.characterization.test_tphi.TestTphi.test_tphi_ramsey_end_to_end
full_transpile=False for test.library.characterization.test_tphi.TestTphi.test_tphi_with_changing_params
full_transpile=False for test.library.characterization.test_zz_ramsey.TestZZRamsey.test_circuit_roundtrip_serializable
full_transpile=False for test.library.driven_freq_tuning.test_stark_ramsey_xy.TestStarkRamseyXY.test_circuit_roundtrip_serializable


full_transpile=True for test.framework.test_composite.TestBatchTranspileOptions.test_batch_transpiled_circuits
full_transpile=True for test.framework.test_composite.TestBatchTranspileOptions.test_batch_transpile_options_integrated
full_transpile=True for test.library.calibration.test_drag.TestDragCircuits.test_default_circuits
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_drag_reanalysis
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_end_to_end_1__None__None__None_
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_end_to_end_2__0_0044__None__None_
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_end_to_end_3
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_nasty_data_1__0_004__1_0__0_0___1__3__5___None__0_2_
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_nasty_data_2__0_002__0_5__0_0___1__3__5___None__1_0_
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_nasty_data_3__0_004__0_8__0_05___3__5__7___None__0_2_
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_nasty_data_4
full_transpile=True for test.library.calibration.test_drag.TestDragEndToEnd.test_nasty_data_5
full_transpile=True for test.library.calibration.test_drag.TestRoughDragCalUpdate.test_update
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineAmplitudeCal.test_run_x_cal
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_1__0_08
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_2__0_03
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_3__0_02
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_4_0_02
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_5_0_06
full_transpile=True for test.library.calibration.test_fine_amplitude.TestFineZXAmpEndToEnd.test_end_to_end_6_0_07
full_transpile=True for test.library.calibration.test_fine_drag.TestFineDragCal.test_update_cals
full_transpile=True for test.library.calibration.test_fine_drag.TestFineDrag.test_end_to_end
full_transpile=True for test.library.calibration.test_fine_drag.TestFineDrag.test_end_to_end_no_schedule
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_calibration_version
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_circuits_roundtrip_serializable
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_end_to_end_1__500000_0
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_end_to_end_2__100000_0
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_end_to_end_3_100000_0
full_transpile=True for test.library.calibration.test_fine_frequency.TestFineFreqEndToEnd.test_end_to_end_4_500000_0
full_transpile=True for test.library.calibration.test_rabi.TestCompositeExperiment.test_calibrations
full_transpile=True for test.library.calibration.test_rabi.TestRabiCircuits.test_circuits_roundtrip_serializable
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_1_2000000_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_2__3000000_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_3_1000_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_4_0_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_5_200000_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_end_to_end_6_300000_0
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_residual_plot
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_update_calibrations
full_transpile=True for test.library.calibration.test_ramsey_xy.TestRamseyXY.test_update_with_failed_analysis
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_1__1000000_0__2000000_0__1000_0___3000000_0___2000000_0__10000_0_
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_2___1000000_0___2000000_0__1000_0__3000000_0__2000000_0__10000_0_
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_3__10000_0__20000_0__1000_0__5000000_0__1000000_0__2000_0_
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_4__10000_0___1000_0__1000_0__500000_0__1000_0___1000_0_
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_5___100000_0__120000_0__1000_0__150000_0___110000_0___1000_0_
full_transpile=True for test.library.characterization.test_cross_resonance_hamiltonian.TestCrossResonanceHamiltonian.test_integration_backward_compat
full_transpile=True for test.library.characterization.test_half_angle.TestHalfAngle.test_circuit_roundtrip_serializable
full_transpile=True for test.library.characterization.test_half_angle.TestHalfAngle.test_circuits
full_transpile=True for test.library.characterization.test_half_angle.TestHalfAngle.test_end_to_end
full_transpile=True for test.library.characterization.test_readout_angle.TestReadoutAngle.test_kerneled_expdata_serialization
full_transpile=True for test.library.characterization.test_readout_angle.TestReadoutAngle.test_readout_angle_end2end
full_transpile=True for test.library.characterization.test_readout_error.TestReadoutError.test_circuit_roundtrip_serializable
full_transpile=True for test.library.characterization.test_resonator_spectroscopy.TestResonatorSpectroscopy.test_initial_circuit_transpiled
full_transpile=True for test.library.characterization.test_t1.TestT1.test_circuit_roundtrip_serializable
full_transpile=True for test.library.characterization.test_t1.TestT1.test_t1_measurement_level_1
full_transpile=True for test.library.characterization.test_t1.TestT1.test_t1_parallel_exp_transpile
full_transpile=True for test.library.characterization.test_t1.TestT1.test_t1_parallel_measurement_level_1
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_circuit_roundtrip_serializable
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_roundtrip_serializable
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_t2hahn_concat_2_experiments
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_t2hahn_parallel
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_t2hahn_run_end2end_1__0_
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_t2hahn_run_end2end_2__1_
full_transpile=True for test.library.characterization.test_t2hahn.TestT2Hahn.test_t2hahn_run_end2end_3__2_
full_transpile=True for test.library.characterization.test_tphi.TestTphi.test_circuits_roundtrip_serializable
full_transpile=True for test.library.characterization.test_zz_ramsey.TestZZRamsey.test_end_to_end_1__200000_0__4_
full_transpile=True for test.library.characterization.test_zz_ramsey.TestZZRamsey.test_end_to_end_2__200000_0__5_
full_transpile=True for test.library.characterization.test_zz_ramsey.TestZZRamsey.test_end_to_end_3___300000_0__4_
full_transpile=True for test.library.characterization.test_zz_ramsey.TestZZRamsey.test_end_to_end_4___300000_0__5_
full_transpile=True for test.library.quantum_volume.test_qv.TestQuantumVolume.test_circuit_roundtrip_serializable
full_transpile=True for test.library.quantum_volume.test_qv.TestQuantumVolume.test_qv_sigma_decreasing
full_transpile=True for test.library.randomized_benchmarking.test_standard_rb.TestStandardRB.test_calibrations_via_transpile_options
full_transpile=True for test.library.tomography.test_composite_tomography.TestCompositeTomography.test_batch_qpt_exp_with_measurement_indices
full_transpile=True for test.library.tomography.test_composite_tomography.TestCompositeTomography.test_batch_qst_exp
full_transpile=True for test.library.tomography.test_composite_tomography.TestCompositeTomography.test_mixed_batch_exp
full_transpile=True for test.library.tomography.test_composite_tomography.TestCompositeTomography.test_parallel_qpt_exp
full_transpile=True for test.library.tomography.test_composite_tomography.TestCompositeTomography.test_parallel_qst_exp
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_dimensions_1___0_____1__2__
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_dimensions_2___2__0____2___
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_1__0__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_2__0__2_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_3__1__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_4__1__2_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_5__2__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_asymmetric_qubits_6__2__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_bootstrap_qpt
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_circuit_roundtrip_serializable
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_cvxpy_gaussian_lstsq_cx
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_expdata_serialization
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_exp_meas_prep_qubits_1__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_exp_meas_prep_qubits_2__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_exp_meas_prep_qubits_3__1__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_qpt_analysis_none
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_qpt_random_unitary_1_1
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_full_qpt_random_unitary_2_2
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_ghz_conditional_clbit
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_ghz_conditional_meas
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_1__0__
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_2__1__
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_3__2__
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_4__3__
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_5__0__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_6__2__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_mitigated_full_qpt_random_unitary_7__0__3_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_amat_pauli_basis
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_circuit_1__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_circuit_2__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_circuit_3__0__1_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_circuit_4__1__0_
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_meas
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_conditional_prep
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_spam_mitigated_basis
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_teleport_1_True
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_teleport_2_False
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_teleport_bell_1_True
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_qpt_teleport_bell_2_False
full_transpile=True for test.library.tomography.test_process_tomography.TestProcessTomography.test_target_none
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_bootstrap_qst
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_circuit_roundtrip_serializable
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_expdata_serialization
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_1__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_2__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_3__2_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_4__0__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_5__1__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_6__0__2_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_7__2__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_8__1__2_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_exp_measurement_indices_9__2__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_qst_1_1
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_qst_2_2
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_full_qst_analysis_none
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_1__0__
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_2__1__
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_3__2__
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_4__3__
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_5__0__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_6__2__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_7__0__3_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_mitigated_full_qst_8__0__3__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_amat_pauli_basis
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_circuit_1__None__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_circuit_2__True__4_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_circuit_3___0___2_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_circuit_4___1___2_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_circuit_5___0__1___4_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_measurement_1_None
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_measurement_2__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_measurement_3__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_measurement_4__0__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_zeros_circuit_1__0_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_zeros_circuit_2__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_conditional_zeros_circuit_3__0__1_
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_spam_mitigated_basis
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_teleport_1_True
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_teleport_2_False
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_teleport_bell_1_True
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_qst_teleport_bell_2_False
full_transpile=True for test.library.tomography.test_state_tomography.TestStateTomography.test_target_none

Copy link
Collaborator

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

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

I like new transpile module and how it's implemented :) We can get more performance boost once after Qiskit core moves to Rust and the .compose method is reimplemented in Rust too. I'm curious what happens if we just set _layout and dump it into oq3 string as a payload, instead of expanding the circuit object (of course this will break simulator workflow and not realistic).

transpilation_needed = False

if getattr(backend, "version", 0) <= 1:
# Fall back to transpilation for BackendV1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this always requires full transpile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could relax this condition if we want. For simplicity, I just wanted to use a Target below. Since the fall back case is just the current status, it is not a regression to ignore BackendV1. We could instead do the BackendV1 to BackendV2 conversion or some other approach. Partly I was thinking that that backend conversion occasionally hits edge cases and also Qiskit wants to drop BackendV1 in 2.0, I think, so it seemed more future proof not handle BackendV1, but I don't feel strongly.

target = backend.target

for circ in circuits:
for inst in circ.data:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have performance profile for something like RB which is ISA but circuit is extremely deep? (RB overwrites the transpile method and probably not a good test case though). The most of experiment instances in our library are with short depth circuit and this double loop should be acceptable considering the transpiler overhead, but I'd like to see some extreme case.

Alternatively we can let experiment class report dependency (e.g. BaseExperiment.__required_gates__) and we can test against it, which seems very performant but not really maintainable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I wish Qiskit maintained something like the equivalent of count_ops in QuantumCircuit as it is built, so it would not be necessary to iterate through the circuit to find its instructions. I wonder if that has been considered before?

I did not feel too bad about this double loop because I think that transpile has to do it as well for every transpiler pass that operates on individual instructions, like BasisTranslator, so I don't think this could be slower.

RB is a good example of where _transpiled_circuits can still be overridden when necessary for performance.

I don't like BaseExperiment.__required_gates__ unless there is a convenient way to manage it since most experiments have small circuits like you mentioned. I have also wondered about transpiling on the fly -- instead of doing circ.x(0), doing circ.compose(self.get("x")) (needs the backend to already be set), but I don't like the way it breaks from idiomatic way of building circuits.

transpile_opts = copy.copy(self.transpile_options.__dict__)
transpile_opts["initial_layout"] = list(self.physical_qubits)
transpiled = transpile(self.circuits(), self.backend, **transpile_opts)
circuits = [map_qubits(c, self.physical_qubits) for c in self.circuits()]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why you don't take actual qubit size from the backend when available?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just because I had never seen it matter that the circuit size matched the backend. We can set it if it matters (for qasm3?).

inplace=True,
copy=False,
)
return p_circ
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps you need to set ._layout since this is how the Qiskit qasm3 module distinguishes between physical and virtual circuits (our primary payload is qpy which doesn't care layout but in case someone prefers qasm3).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting. I was not familiar with that property. It does seem like it should be set. I would want to check that it is right to set that private attribute for this case.

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.

2 participants