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

feature: Use hybrid_job from braket.jobs #66

Merged
merged 3 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions doc/hybrid_jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,21 @@ job = AwsQuantumJob.create(
)
```

## Using the `@aq.hybrid_job` decorator
## Using the `@hybrid_job` decorator

Alternatively, you can use the `@aq.hybrid_job` decorator to create a hybrid job with AutoQASM. Because AutoQASM is currently not installed in the default job container, be sure to include AutoQASM in the `dependencies` keyword of the `@aq.hybrid_job` decorator, or add AutoQASM as a dependency when you build your own container.
Alternatively, you can use the `@hybrid_job` decorator to create a hybrid job with AutoQASM. Because AutoQASM is currently not installed in the default job container, be sure to include AutoQASM in the `dependencies` keyword of the `@hybrid_job` decorator, or add AutoQASM as a dependency when you build your own container.

One of the core mechanisms of AutoQASM is source code analysis. When calling an AutoQASM decorated function, the source code of the function is analyzed and converted into a transformed Python function by AutoGraph. With the the `@aq.hybrid_job` decorator, the source code of a function defined inside the `@aq.hybrid_job` decorated function is separately saved as input data to the job. When [AutoQASM decorators](decorators.md) wrap these functions, the source code is retrieved from the input data. Because of this, if you use an AutoQASM decorator to convert a function that is defined outside of the `@aq.hybrid_job` decorated function, it may not work properly. If your application requires AutoQASM decorated functions to be defined outside of the `@aq.hybrid_job` decorated function, we recommend that you use the option described in the "Using `AwsQuantumJob.create`" section above to create the hybrid job.
One of the core mechanisms of AutoQASM is source code analysis. When calling an AutoQASM decorated function, the source code of the function is analyzed and converted into a transformed Python function by AutoGraph. With the the `@hybrid_job` decorator, the source code of a function defined inside the `@hybrid_job` decorated function is separately saved as input data to the job. When [AutoQASM decorators](decorators.md) wrap these functions, the source code is retrieved from the input data. Because of this, if you use an AutoQASM decorator to convert a function that is defined outside of the `@hybrid_job` decorated function, it may not work properly. If your application requires AutoQASM decorated functions to be defined outside of the `@hybrid_job` decorated function, we recommend that you use the option described in the "Using `AwsQuantumJob.create`" section above to create the hybrid job.

Below is a working example to create an AutoQASM job with the `@aq.hybrid_job` decorator.
Below is a working example to create an AutoQASM job with the `@hybrid_job` decorator.
```python
from braket.devices import LocalSimulator
from braket.jobs import hybrid_job

import autoqasm as aq
from autoqasm.instructions import measure, h, cnot

@aq.hybrid_job(
@hybrid_job(
device="local:braket/simulator",
dependencies=["autoqasm"],
)
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For details on usage of AutoQASM decorators such as `@aq.main`, `@aq.subroutine`
and `@aq.gate_calibration`, see the decorators documentation at
https://github.com/amazon-braket/autoqasm/blob/main/doc/decorators.md.

For details on using AutoQASM with Amazon Braket Hybrid Jobs with the `@aq.hybrid_job` decorator,
For details on using AutoQASM with Amazon Braket Hybrid Jobs with the `@hybrid_job` decorator,
see the documentation at https://github.com/amazon-braket/autoqasm/blob/main/doc/hybrid_jobs.md


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
packages=find_namespace_packages(where="src", exclude=("test",)),
package_dir={"": "src"},
install_requires=[
"amazon-braket-sdk>=1.87.1",
"amazon-braket-sdk>=1.89.1",
"amazon-braket-default-simulator>=1.23.2",
"oqpy~=0.3.5",
"diastatic-malt",
Expand Down
1 change: 0 additions & 1 deletion src/autoqasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def my_program():

from . import errors, instructions, operators # noqa: F401
from .api import gate, gate_calibration, main, subroutine # noqa: F401
from .hybrid_job import hybrid_job # noqa: F401
from .instructions import QubitIdentifierType as Qubit # noqa: F401
from .program import Program, build_program, verbatim # noqa: F401
from .transpiler import transpiler # noqa: F401
Expand Down
340 changes: 0 additions & 340 deletions src/autoqasm/hybrid_job.py

This file was deleted.

Loading