Skip to content

deprecation: change Circuit.to_ir default to OPENQASM and warn on JAQCD (MCM-150287739)#1262

Closed
jacofeld wants to merge 1 commit into
mainfrom
deprecation/jaqcd-mcm-150287739
Closed

deprecation: change Circuit.to_ir default to OPENQASM and warn on JAQCD (MCM-150287739)#1262
jacofeld wants to merge 1 commit into
mainfrom
deprecation/jaqcd-mcm-150287739

Conversation

@jacofeld

@jacofeld jacofeld commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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:
    • Default change: Circuit.to_ir(ir_type=IRType.JAQCD)Circuit.to_ir(ir_type=IRType.OPENQASM). Calls to circuit.to_ir() (no arg) now return an OpenQASM program instead of a JAQCD program.
    • Runtime warning: when ir_type=IRType.JAQCD is passed explicitly, emit a UserWarning pointing the caller at OpenQASM 3 and referencing MCM-150287739.
    • Docstring: added .. versionchanged:: 1.117.4 and .. deprecated:: 1.117.4 directives.
  • src/braket/circuits/serialization.py: added .. deprecated:: 1.117.4 note to the IRType enum docstring. IRType.JAQCD itself is not removed — historical task results, the JAQCD conversion path, and external callers that need to produce JAQCD continue to function.

Why UserWarning and not DeprecationWarning

DeprecationWarning is 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. UserWarning is visible by default and matches every existing warnings.warn call 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:

  1. Historical task results must keep parsing. Customer S3 buckets contain GateModelTaskResult JSON with additionalMetadata.action of type JaqcdProgram. task.result() deserializing those into Pydantic models cannot break.
  2. External callers may need to produce JAQCD for tooling, debugging, or integration with the local simulator's JAQCD path.

So this PR is purely additive: warning + default flip + docstring.

Internal-caller audit

Verified that internal BDK callers of Circuit.to_ir() already pass ir_type explicitly:

  • src/braket/aws/aws_quantum_task.py — uses IRType.OPENQASM (line 669 area).
  • src/braket/devices/local_simulator.py — explicit IRType.OPENQASM and IRType.JAQCD branches based on the simulator's advertised actions.

Therefore the default flip does not silently change service-bound payloads.

Testing done

tox -e unit-tests   # 3299 passed, 131 xfailed, 28 warnings
tox -e linters      # ruff format + ruff check, all clean

Test changes:

  • Existing tests that asserted JAQCD shape via the no-arg default (test_ir_empty_instructions_result_types, test_ir_non_empty_instructions_result_types, test_ir_non_empty_instructions_result_types_basis_rotation_instructions) now pass IRType.JAQCD explicitly and wrap in pytest.warns(UserWarning, match=\"JAQCD\"). The shape assertions are unchanged.
  • test_barrier_jaqcd_export_fails likewise wrapped.
  • test_run_jaqcd_only (test/unit_tests/braket/devices/test_local_simulator.py) wrapped in pytest.warns — the LocalSimulator's JAQCD-fallback payload constructor now correctly emits the deprecation warning when the simulator advertises only JAQCD.
  • New tests in test_circuit.py:
    • test_to_ir_default_is_openqasm
    • test_to_ir_jaqcd_emits_warning
    • test_to_ir_default_emits_no_jaqcd_warning

Manual verification (visible-by-default warning, customer-facing migration):

# In a fresh interpreter, no warnings filters set:
from braket.circuits import Circuit
from braket.circuits.serialization import IRType
Circuit().h(0).to_ir(IRType.JAQCD)
# stderr: <string>:4: UserWarning: JAQCD IR is deprecated and will be removed
# in a future release. Use IRType.OPENQASM instead. ...

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…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

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (11065d0) to head (60f99b6).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jacofeld

jacofeld commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing — replacing with a clean version that does not reference internal tracking IDs. No action needed from reviewers.

@jacofeld jacofeld closed this Jun 1, 2026
@jacofeld jacofeld deleted the deprecation/jaqcd-mcm-150287739 branch June 1, 2026 19:22
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.

1 participant