amazon-braket-sdk-python icon indicating copy to clipboard operation
amazon-braket-sdk-python copied to clipboard

Add Cost Tracker Support for AwsQuantumJobs

Open ldi18 opened this issue 1 year ago • 1 comments

The costs of a quantum task can be constrained by:

device = AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Ankaa-2")
with Tracker() as tracker:
    while tracker.qpu_tasks_cost() < 1:
        result = device.run(circ, shots=200).result()
print(tracker.quantum_tasks_statistics())
print(tracker.qpu_tasks_cost(), "USD")

As far as I know, there is no equivalent for AwsQuantumJobs yet. It would be nice to have a feature added so that a cost threshold for AwsQuantumJobs can be set either by:

with Tracker() as tracker:
    while tracker.qpu_tasks_cost() < 1:
          job = AwsQuantumJob.create(
              device="arn:aws:braket:::device/quantum-simulator/amazon/sv1",
              source_module="src",
              entry_point="src.test_code:run",
              hyperparameters={},
              job_name=f"job1",
          )
print(tracker.quantum_tasks_statistics())
print(tracker.qpu_tasks_cost(), "USD")

or by adding another parameter to the .create() method.

ldi18 avatar Nov 04 '24 14:11 ldi18

One way to track cost is to make use of job CloudWatch metrics; you can use the cost tracker inside your job code and emit metrics from there. However, to use the tracker locally would require some changes to the service.

speller26 avatar Jun 12 '25 17:06 speller26