amazon-braket / amazon-braket-sdk-python

A Python SDK for interacting with quantum devices on Amazon Braket
https://aws.amazon.com/braket/
Apache License 2.0
294 stars 118 forks source link

cost tracking by ARN #581

Open balewski opened 1 year ago

balewski commented 1 year ago

Is your feature request related to a problem? Please describe. I'd like to be able to track acquired cost per task, after task has been executed.

When I submit a task to Aquila it may take a week until it gets executed. You provide the construct, which requires the Tracker() context to be active for the duration of the job.

from braket.tracking import Tracker
ahs_prog=ahs_problem()
with Tracker() as tracker:
        task = device.run(ahs_prog, shots=shots)
        results=task.result() 
print('status=%s, cost tracker, charge/$:'%task.state(),tracker.simulator_tasks_cost())

It takes a week+ for Aquila job to get executed and it is unrealistic to expect a program on my laptop maintains AWS connection for that long. If I want to place 20 jobs in the queue I'd need to keep 20 copies alive for that long.

Describe the solution you'd like Given a list of ARNs I'd like to construct a CSV table contacting information reported by

tracker.simulator_tasks_cost()
tracker.quantum_tasks_statistics() # preferably too

using a Python script executed on a terminal.

Describe alternatives you've considered Open 20 notebook for 20 submitted jobs and not close my laptop for a week+, until all complete.

shpface commented 1 year ago

Thank you for the request, this would be a nice feature addition to the cost tracking currently offered in the Braket SDK. Could you help us understand some more context around your use case? Are you wanting the cost tracking for informational purposes? Are you trying to use the cost for control flow in your code? Or something else? Have you tried the AWS wide tools offered by Cost Explorer and AWS Budgets?

balewski commented 1 year ago

It is for informal cost tracking purposes. I have not tried yet the tools you mentioned. Can you point me to a tutorial? I need nothing fancy, just a basic request for the cost of the list of jobs.

zmohammad01 commented 1 year ago

đŸ‘‹ I'm on the product team for Braket - cost management is a theme we are planning to expand on. In the interim, these two links shed light on AWS Cost Explore and Budgets. They provide higher level information for the Braket service, but your point on asking for granular cost information is valid.

AWS Cost Explorer AWS Budgets

speller26 commented 9 months ago

Following up on Cost Explorer, I've responded to your issue in amazon-braket-examples with instructions to view costs by ARN, both programmatically and through the console!