Tracker

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()[source]

Start tracking resources with this tracker.

Return type:

Tracker

Returns:

Tracker – self.

stop()[source]

Stop tracking resources with this tracker.

Return type:

Tracker

Returns:

Tracker – self.

receive_event(event)[source]

Process a Tack Creation Event.

Parameters:

event (_TaskCreationEvent) – The event to process.

Return type:

None

tracked_resources()[source]

Resources tracked by this tracker.

Return type:

list[str]

Returns:

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

qpu_tasks_cost()[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).

Return type:

Decimal

Returns:

Decimal – The estimated total cost in USD

simulator_tasks_cost()[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).

Return type:

Decimal

Returns:

Decimal – The estimated total cost in USD

quantum_tasks_statistics()[source]

Get a summary of quantum tasks grouped by device.

Return type:

dict[str, dict[str, Any]]

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)}}