braket.tracking.tracker module

class braket.tracking.tracker.Tracker[source]

Bases: object

Amazon Braket cost tracker. Use this class to track costs incurred from quantum tasks on Amazon Braket.

start() Tracker[source]

Start tracking resources with this tracker.

Returns:

Tracker – self.

stop() Tracker[source]

Stop tracking resources with this tracker.

Returns:

Tracker – self.

receive_event(event: _TaskCreationEvent) None[source]

Process a Tack Creation Event.

Parameters:

event (_TaskCreationEvent) – The event to process.

tracked_resources() list[str][source]

Resources tracked by this tracker.

Returns:

list[str] – The list of quantum task ids for quantum tasks tracked by this tracker.

qpu_tasks_cost() Decimal[source]

Estimate cost of all quantum tasks tracked by this tracker that use Braket qpu devices.

Note: Charges shown are estimates based on your Amazon Braket simulator and quantum processing unit (QPU) task usage. Estimated charges shown may differ from your actual charges. Estimated charges do not factor in any discounts or credits, and you may experience additional charges based on your use of other services such as Amazon Elastic Compute Cloud (Amazon EC2).

Returns:

Decimal – The estimated total cost in USD

simulator_tasks_cost() Decimal[source]
Estimate cost of all quantum tasks tracked by this tracker using Braket simulator

devices.

Note: The cost of a simulator quantum task is not available until after the results for the task have been fetched. Call result() on an AwsQuantumTask before estimating its cost to ensure that the simulator usage is included in the cost estimate.

Note: Charges shown are estimates based on your Amazon Braket simulator and quantum processing unit (QPU) task usage. Estimated charges shown may differ from your actual charges. Estimated charges do not factor in any discounts or credits, and you may experience additional charges based on your use of other services such as Amazon Elastic Compute Cloud (Amazon EC2).

Returns:

Decimal – The estimated total cost in USD

quantum_tasks_statistics() dict[str, dict[str, Any]][source]

Get a summary of quantum tasks grouped by device.

Returns:

dict[str, dict[str, Any]] – A dictionary where each key is a device arn, and maps to a dictionary summarizing the quantum tasks run on the device. The summary includes the total shots sent to the device and the most recent status of the quantum tasks created on this device. For finished quantum tasks on simulator devices, the summary also includes the duration of the simulation.

Example

>>> tracker.quantum_tasks_statistics()
{'qpu_device_foo':
    {'shots' : 1000,
     'tasks' : { 'COMPLETED' : 4,
                 'QUEUED' : 1 },
    },
 'simulator_device_bar':
    {'shots' : 1000
     'tasks' : { 'COMPLETED' : 2,
                  'CREATED' : 1},
     'execution_duration' : datetime.timedelta(seconds=5, microseconds=654321),
     'billed_execution_duration' : datetime.timedelta(seconds=6, microseconds=123456)}}