deprecation: change Circuit.to_ir default to OPENQASM and warn on JAQCD (MCM-150287739)#1262
Closed
jacofeld wants to merge 1 commit into
Closed
deprecation: change Circuit.to_ir default to OPENQASM and warn on JAQCD (MCM-150287739)#1262jacofeld wants to merge 1 commit into
jacofeld wants to merge 1 commit into
Conversation
…CD (MCM-150287739)
Amazon Braket service devices no longer accept JAQCD program submissions.
This commit moves the customer-facing default off JAQCD and emits a
UserWarning when callers explicitly request JAQCD.
Changes:
* src/braket/circuits/circuit.py: change Circuit.to_ir default ir_type
from IRType.JAQCD to IRType.OPENQASM. When ir_type=IRType.JAQCD is
passed explicitly, emit a UserWarning telling the customer to use
IRType.OPENQASM and referencing MCM-150287739. The IRType.JAQCD
conversion path itself is preserved.
* src/braket/circuits/serialization.py: add a Sphinx
`.. deprecated:: 1.117.4` note to the IRType enum docstring.
The default flip is safe for internal callers: aws_quantum_task.py and
local_simulator.py already pass ir_type explicitly. External callers
relying on the no-arg JAQCD default see the new shape (OpenQASM)
documented in the docstring's `.. versionchanged::` note.
Test changes:
* test/unit_tests/braket/circuits/test_circuit.py: existing
test_ir_*_instructions_result_types tests now pass IRType.JAQCD
explicitly (with pytest.warns) since they test the JAQCD conversion
shape. test_barrier_jaqcd_export_fails likewise wraps in
pytest.warns. New tests:
- test_to_ir_default_is_openqasm
- test_to_ir_jaqcd_emits_warning
- test_to_ir_default_emits_no_jaqcd_warning
* test/unit_tests/braket/devices/test_local_simulator.py:
test_run_jaqcd_only wraps in pytest.warns, since LocalSimulator
falling back to JAQCD payload construction now correctly emits the
deprecation warning.
UserWarning (not DeprecationWarning) is used deliberately: PEP 565's
default filter hides DeprecationWarning from any code attributed
outside __main__, which would silently hide the warning from any
customer code that calls Braket from a helper function or library.
UserWarning is visible by default, and matches every existing
warnings.warn call site in the BDK
(aws_device.py, quantum_job_creation.py, circuit_binding.py).
See MCM-150287739.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1262 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 169 169
Lines 10963 10965 +2
Branches 1412 1412
=========================================
+ Hits 10963 10965 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Closing — replacing with a clean version that does not reference internal tracking IDs. No action needed from reviewers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue, if available
Internal: MCM-150287739 (Simulators broker migration removes JAQCD from Braket service device capabilities).
Coordinated deprecation across three Braket OSS Python packages:
Description of changes
Amazon Braket service devices no longer accept JAQCD program submissions. This PR moves the customer-facing default off JAQCD and adds a runtime warning when callers explicitly request JAQCD.
Code changes
src/braket/circuits/circuit.py:Circuit.to_ir(ir_type=IRType.JAQCD)→Circuit.to_ir(ir_type=IRType.OPENQASM). Calls tocircuit.to_ir()(no arg) now return an OpenQASM program instead of a JAQCD program.ir_type=IRType.JAQCDis passed explicitly, emit aUserWarningpointing the caller at OpenQASM 3 and referencing MCM-150287739... versionchanged:: 1.117.4and.. deprecated:: 1.117.4directives.src/braket/circuits/serialization.py: added.. deprecated:: 1.117.4note to theIRTypeenum docstring.IRType.JAQCDitself is not removed — historical task results, the JAQCD conversion path, and external callers that need to produce JAQCD continue to function.Why
UserWarningand notDeprecationWarningDeprecationWarningis suppressed by default (PEP 565) for any warning attributed outside__main__. That hides it from customer code that wraps Braket calls in helper functions or libraries — exactly the cases we need to reach.UserWarningis visible by default and matches every existingwarnings.warncall site in the BDK (aws_device.py:388,683,quantum_job_creation.py:275,circuit_binding.py:221).Why no symbols are removed
Two hard constraints:
GateModelTaskResultJSON withadditionalMetadata.actionof typeJaqcdProgram.task.result()deserializing those into Pydantic models cannot break.So this PR is purely additive: warning + default flip + docstring.
Internal-caller audit
Verified that internal BDK callers of
Circuit.to_ir()already passir_typeexplicitly:src/braket/aws/aws_quantum_task.py— usesIRType.OPENQASM(line 669 area).src/braket/devices/local_simulator.py— explicitIRType.OPENQASMandIRType.JAQCDbranches based on the simulator's advertised actions.Therefore the default flip does not silently change service-bound payloads.
Testing done
Test changes:
test_ir_empty_instructions_result_types,test_ir_non_empty_instructions_result_types,test_ir_non_empty_instructions_result_types_basis_rotation_instructions) now passIRType.JAQCDexplicitly and wrap inpytest.warns(UserWarning, match=\"JAQCD\"). The shape assertions are unchanged.test_barrier_jaqcd_export_failslikewise wrapped.test_run_jaqcd_only(test/unit_tests/braket/devices/test_local_simulator.py) wrapped inpytest.warns— the LocalSimulator's JAQCD-fallback payload constructor now correctly emits the deprecation warning when the simulator advertises only JAQCD.test_circuit.py:test_to_ir_default_is_openqasmtest_to_ir_jaqcd_emits_warningtest_to_ir_default_emits_no_jaqcd_warningManual verification (visible-by-default warning, customer-facing migration):
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.