strangeworks_braket package#

Subpackages#

Submodules#

strangeworks_braket.device module#

class StrangeworksDevice(arn: str, name: str | None = None, status: str | None = None, slug: str | None = None, **kwargs)#

Bases: Device

property certificate: DeviceCapabilities#

!! processed by numpydoc !!

get_Borealis_Properties() DeviceCapabilities#
static get_devices(arns: list[str] | None = None, names: list[str] | None = None, statuses: list[str] | None = None) list[strangeworks_braket.device.StrangeworksDevice]#

Get a list of devices. :param arns: Filter by list of device ARNs. Defaults to None. :type arns: Optional[list[str] :param names: Filter by list of device names. Defaults to None. :type names: Optional[list[str]] :param statuses: Filter by list of device statuses. Defaults to None. :type statuses: Optional[list[str]]

Returns:

devices – List of devices that match the provided filters.

Return type:

list[SwDevice]

get_properties() DeviceCapabilities#
property layout: DeviceCapabilities#

!! processed by numpydoc !!

property modes: DeviceCapabilities#

!! processed by numpydoc !!

property properties: DeviceCapabilities#

!! processed by numpydoc !!

run(task_specification: Circuit | Problem | Program, shots: int | None, *args, **kwargs) QuantumTask#

Run a task on the device. :param task_specification: The task specification. :type task_specification: Union[Circuit, Problem, OpenQasmProgram] :param shots: The number of shots to run the task for. Defaults to 1000. :type shots: Optional[int]

Returns:

task – The task that was run.

Return type:

QuantumTask (StrangeworksQuantumTask)

run_batch(task_specifications: Circuit | Problem | list[Circuit | Problem], shots: int | None, max_parallel: int | None, inputs: Dict[str, float] | list[Dict[str, float]] | None, *args, **kwargs) QuantumTaskBatch#

Executes a batch of tasks in parallel

Parameters:
  • task_specifications (Union[Union[Circuit, Problem], List[Union[Circuit, Problem]]]) – Single instance or list of circuits or problems to run on device.

  • shots (Optional[int]) – The number of times to run the circuit or annealing problem.

  • max_parallel (Optional[int]) – The maximum number of tasks to run in parallel. Batch creation will fail if this value is greater than the maximum allowed concurrent tasks on the device.

  • inputs (Optional[Union[Dict[str, float], List[Dict[str, float]]]]) – Inputs to be passed along with the IR. If the IR supports inputs, the inputs will be updated with this value.

Returns:

A batch containing all of the tasks run

Return type:

QuantumTaskBatch

run_hybrid(filepath: str, hyperparameters: Dict[str, Any], *args, **kwargs) QuantumTask#

Run a task on the device. :param filepath: Path to the python file that will be run. :type filepath: str :param hyperparameters: Dictionary of hyperparameters to pass to the task.

Must be json serializable.

Returns:

Job – The job that was run.

Return type:

QuantumJob (StrangeworksQuantumJob)

property target: DeviceCapabilities#

!! processed by numpydoc !!

strangeworks_braket.job module#

class StrangeworksQuantumJob(job: Job, *args, **kwargs)#

Bases: QuantumTask

async_result() Task#

Get the quantum task result asynchronously. :returns: Get the quantum task result asynchronously. :rtype: Task

cancel() None#

Cancel the job.

Raises:
StrangeworksError

If the job has not been submitted yet.

static create_hybrid(device_arn: str, filepath: str, hyperparameters: Dict[str, Any], device_parameters: Dict[str, Any] | None = None, tags: Dict[str, str] | None = None, *args, **kwargs) StrangeworksQuantumJob#

Create a job.

Parameters:
device_arn: str

The name of the device to run the job on.

filepath: str

Path to the python file that will be run.

hyperparameters: Dict[str, Any]

Dictionary of hyperparameters to pass to the job. Must be json serializable.

device_parameters: Optional[Dict[str, Any]]

The device parameters.

tags: Optional[Dict[str, str]]

The tags to add to the strangeworks job.

Returns:
job: StrangeworksQuantumJob

The job.

Raises:
StrangeworksError

If the job specification is not a circuit, or openqasm program.

static from_strangeworks_slug(id: str) StrangeworksQuantumJob#

Get a job from a strangeworks id.

Parameters:
id: str

The strangeworks id of the job.

Returns:
job: StrangeworksQuantumJob

The job.

Raises:
StrangeworksError

If no job is found for the id. Or if multiple job are found for the id.

property id: str#

The id of the job.

Returns:
id: str

The id of the job. This is the id of the job in Strangeworks.

metadata(use_cached_value: bool = False) Dict[str, Any]#

Get task metadata.

Parameters:

use_cached_value (bool) – If True, uses the value retrieved from the previous request. Default is False.

Returns:

The metadata regarding the task. If use_cached_value is True, then the value retrieved from the most recent request is used.

Return type:

Dict[str, Any]

result() Dict[str, Any]#

Get the result of the job.

Returns:
result: BraketSchemaBase

The result of the job.

Raises:
StrangeworksError

If the job has not been submitted yet. Or if the job did not complete successfully. Or unable to fetch the results for the job.

state() str#

Get the state of the job.

Returns:
state: str

The state of the job.

Raises:
StrangeworksError

If the job has not been submitted yet. Or if we find are not able to find the status.

strangeworks_braket.task module#

class StrangeworksQuantumTask(job: Job, *args, **kwargs)#

Bases: QuantumTask

async_result() Task#

Get the quantum task result asynchronously. :returns: Get the quantum task result asynchronously. :rtype: Task

cancel() None#

Cancel the task.

Raises:
StrangeworksError

If the task has not been submitted yet.

static create(device_arn: str, task_specification: Circuit | Problem | Program | AnalogHamiltonianSimulation, shots: int, device_parameters: Dict[str, Any] | None = None, tags: Dict[str, str] | None = None, *args, **kwargs) StrangeworksQuantumTask#

Create a task.

Parameters:
device_arn: str

The name of the device to run the task on.

task_specification: Union[Circuit, Problem, OpenQasmProgram]

The task specification.

shots: int

The number of shots to run the task for.

device_parameters: Optional[Dict[str, Any]]

The device parameters.

tags: Optional[Dict[str, str]]

The tags to add to the strangeworks job.

Returns:
task: StrangeworksQuantumTask

The task.

Raises:
StrangeworksError

If the task specification is not a circuit, or openqasm program.

static from_strangeworks_slug(id: str) StrangeworksQuantumTask#

Get a task from a strangeworks id.

Parameters:
id: str

The strangeworks id of the task.

Returns:
task: StrangeworksQuantumTask

The task.

Raises:
StrangeworksError

If no task is found for the id. Or if multiple tasks are found for the id.

property id: str#

The id of the task.

Returns:
id: str

The id of the task. This is the id of the job in Strangeworks.

metadata(use_cached_value: bool = False) Dict[str, Any]#

Get task metadata.

Parameters:

use_cached_value (bool) – If True, uses the value retrieved from the previous request. Default is False.

Returns:

The metadata regarding the task. If use_cached_value is True, then the value retrieved from the most recent request is used.

Return type:

Dict[str, Any]

result() GateModelQuantumTaskResult | AnnealingQuantumTaskResult#

Get the result of the task.

Returns:
result: Union[GateModelQuantumTaskResult, AnnealingQuantumTaskResult]

The result of the task.

Raises:
StrangeworksError

If the task has not been submitted yet. Or if the task did not complete successfully. Or unable to fetch the results for the task.

state() str#

Get the state of the task.

Returns:
state: str

The state of the task.

Raises:
StrangeworksError

If the task has not been submitted yet. Or if we find are not able to find the status.

Module contents#

Strangeworks Braket SDK