feature: emulator support for ProgramSets, transformation passes
Issue #, if available:
Emulator currently does not support ProgramSet, despite braket_dm supporting ProgramSet. Complicating this, there also are discrepancies between the Validation passes and the supported SpecificationTypes, as only Circuit is currently supported.
Description of changes:
Added support for ProgramSet in the LocalEmulator, and also clarified emulator support for different specifications.
Updated EmulatorPropertes
- EmulatorProperties has two more optional attributes, supportedSpecification and supportedActions
- supportedSpecification defaults to Circuit
- supportedActions defaults to empty dict, only used by program set validator (could also be used for a shot validator)
Updated ValidationPasses:
- Each ValidationPass also now has a _supported_specifications attribute, which dictated which TaskSpecification it can run.
- PassManager will check if the current instance is supported by the pass, and otherwise ignore it
- Added two Validations (generic, not just for circuits)
- SpecificationValidator - checks whether the specification is supported by emulator
- ProgramSetValidator - checks whether or not the program set is valid based on MaximumExecutables and TotalShots
- NotImplementedValidator - program sets supported, but other task types are not
- Relevant circuit_passes validators now support Circuit and ProgramSet specifications
Added TransformationPasses:
- Analogous to ValidatorPasses, these are modifying passes that return a specification instead of raising exceptions
- Added Transformations for circuit | programset:
- VerbatimTransformation - Removes Verbatim from the circuit
- NoiseModelTransformation - applies a NoiseModel
- MeasurementTransformation- appends measurements if none detected
Updated Emulator:
- Still has private remove_verbatim_box attribute, but functionally moved towards passes.
- Changed noise model loading from backend to a pass
Other considerations:
- Simpler modifications for just ProgramSets would make longer term support and validation of other specifications harder
- Specification-specific pass sequences in the LocalEmulator (i.e. for circuit, ProgramSet, etc.) also were considered, but would be more bloated. There also is substantial reuse between certain passes.
- NoiseModel also does not support ProgramSet, so needed to move from supply NoiseModel on the backend to applying it to a circuit
Testing done:
Added relevant tests.
Merge Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.
General
- [x] I have read the CONTRIBUTING doc
- [x] I used the PR title format described in CONTRIBUTING
- [ ] I have updated any necessary documentation, including READMEs and API docs (if appropriate)
Tests
- [x] I have added tests that prove my fix is effective or that my feature works (if appropriate)
- [ ] I have checked that my tests are not configured for a specific region or account (if appropriate)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 100.00%. Comparing base (4f2afaf) to head (fe8de1b).
Additional details and impacted files
@@ Coverage Diff @@
## main #1163 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 162 169 +7
Lines 10560 10722 +162
Branches 1323 1350 +27
==========================================
+ Hits 10560 10722 +162
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.