Skip to content

Instantly share code, notes, and snippets.

@Q-lds
Created December 14, 2022 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Q-lds/2f61e5c2e5be9d5cd31acf8eb78c677e to your computer and use it in GitHub Desktop.
Save Q-lds/2f61e5c2e5be9d5cd31acf8eb78c677e to your computer and use it in GitHub Desktop.
The openqaoa_job entrypoint script
from braket.aws import AwsQuantumJob
from openqaoa.workflows.optimizer import RQAOA
from openqaoa.problems.problem import NumberPartition
from openqaoa.workflows.aws_input.helpers import create_aws_input_data, save_input_data
np_qubo = NumberPartition.random_instance(n_numbers=8).get_qubo_problem()
# Define the RQAOA object (default rqaoa_type='adaptive')
r = RQAOA()
r.set_rqaoa_parameters(n_max=1, n_cutoff=3)
r.set_circuit_properties(p=1, param_type='standard', init_type='ramp', mixer_hamiltonian='x')
r.set_classical_optimizer(method='cobyla', maxiter=200, save_intermediate=False)
r.compile(np_qubo)
# Specify a path where to store the QUBO and the QAOA parameters
input_data = create_aws_input_data(r, vc)
save_input_data(input_data,'openqaoa_params.json')
job = AwsQuantumJob.create(
device="arn:aws:braket:::device/quantum-simulator/amazon/sv1",
job_name=job_name,
source_module="./scripts/rqaoa.py",
image_uri='XXX.dkr.ecr.us-east-1.amazonaws.com/amazon-braket-oq-dev:latest',
input_data={"input_data": 'openqaoa_params.json'},
wait_until_complete=True # This frees the console
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment