-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Support for Braket Direct Reservations #87
Merged
kshyatt-aws
merged 19 commits into
amazon-braket:ksh/feature_bump
from
Fe-r-oz:DirectReservation
Aug 28, 2024
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b50615f
[Feature]: Support for Braket Direct reservations
42a5075
[Feature]: Support for Braket Direct reservations - adding docstrings…
c6a2bb3
[Feature]: Support for Braket Direct reservations - minor cleanup
c5c7254
[Feature]: Support for Braket Direct reservations - Adding more tests
4365624
[Feature]: Support for Braket Direct reservations - Final Polish
16b0d90
[Feature]: Support for Braket Direct reservations - Improving Indenta…
082ece3
[Feature]: Support for Braket Direct reservations - codereview
3db5912
[Feature]: Support for Braket Direct reservations - codereview
b67791c
[Feature]: Support for Braket Direct reservations - codereview
e127c8e
[Feature]: Support for Braket Direct reservations - codereview sugges…
815bf29
[Feature]: Support for Braket Direct reservations - formatting
5b22d5a
[Feature]: Support for Braket Direct reservations - formatting
1b2b572
Adding codereview suggestions
8d73982
Minor Formatting
9d0d8af
Minor Formatting
7fa635a
adding direct reservation details in docstring
226c0da
Minor formatting and cleanup
04a5253
CI documentation fix
0aef482
Merge branch 'amazon-braket:main' into DirectReservation
Fe-r-oz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ Braket.BraketDevice | |
isavailable | ||
search_devices | ||
get_devices | ||
Braket.AwsQuantumTask | ||
DirectReservation | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Reservations | ||
|
||
[Reservations](https://docs.aws.amazon.com/braket/latest/developerguide/braket-reservations.html) grant exclusive access to a specific quantum device for a predetermined time slot. This control over execution windows offers several advantages to users: | ||
|
||
* **Predictability:** Users have guaranteed knowledge of precisely when their tasks will be executed, eliminating scheduling uncertainties. | ||
* **Prioritization:** During the reservation window, the user's workloads take precedence over others, avoiding queueing delays and potential bottlenecks. | ||
* **Efficiency:** The cost is based solely on the reserved duration, irrespective of the number of tasks the user runs within that window. | ||
|
||
# Why Use Reservations? | ||
|
||
In certain scenarios, reservations provide significant benefits over on-demand access: | ||
|
||
- **Production Runs**: When finalizing research or performing critical computations, reservations guarantee timely completion, ensuring adherence to deadlines. | ||
- **Live Demos or Workshops**: Reservations secure exclusive device access for showcasing work or conducting workshops at specific times. | ||
- **Streamlined Workflows**: Users can schedule reservations for tasks requiring execution at particular moments within their workflows, optimizing their overall process. | ||
|
||
# Reservations vs. On-Demand Access | ||
|
||
On-demand access is better suited for the initial development and prototyping stages of a quantum project. This method allows for rapid iterations without the need for pre-scheduled reservations, facilitating agile development. However, once the project progresses towards final production runs requiring guaranteed execution times, reservations become the preferred choice. | ||
""" | ||
|
||
```@docs | ||
Braket.DirectReservation | ||
Braket.start_reservation! | ||
Braket.stop_reservation! | ||
Braket.direct_reservation | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Braket, Test, Mocking, JSON3, Dates, Graphs | ||
using Braket: status | ||
Mocking.activate() | ||
|
||
# Constants | ||
RESERVATION_ARN = "arn:aws:braket:us-east-1:123456789:reservation/uuid" | ||
DEVICE_ARN = "arn:aws:braket:us-east-1:123456789:device/qpu/ionq/Forte-1" | ||
|
||
@testset "DirectReservation Tests" begin | ||
# Creating a DirectReservation | ||
@testset "Creating DirectReservation" begin | ||
reservation = Braket.DirectReservation(DEVICE_ARN, RESERVATION_ARN) | ||
@test reservation.device_arn == DEVICE_ARN | ||
@test reservation.reservation_arn == RESERVATION_ARN | ||
@test reservation.is_active == false | ||
end | ||
|
||
# Starting and stopping a reservation | ||
@testset "Starting and Stopping Reservation" begin | ||
reservation = Braket.DirectReservation(DEVICE_ARN, RESERVATION_ARN) | ||
|
||
# Start reservation | ||
Braket.start_reservation!(reservation) | ||
@test reservation.is_active == true | ||
@test ENV["AMZN_BRAKET_RESERVATION_DEVICE_ARN"] == DEVICE_ARN | ||
@test ENV["AMZN_BRAKET_RESERVATION_TIME_WINDOW_ARN"] == RESERVATION_ARN | ||
|
||
# Stop reservation | ||
Braket.stop_reservation!(reservation) | ||
@test reservation.is_active == false | ||
@test !haskey(ENV, "AMZN_BRAKET_RESERVATION_DEVICE_ARN") | ||
@test !haskey(ENV, "AMZN_BRAKET_RESERVATION_TIME_WINDOW_ARN") | ||
|
||
end | ||
|
||
function test_func() | ||
println("Executing within reservation context") | ||
return 5 | ||
# Add actions as needed | ||
@test ENV["AMZN_BRAKET_RESERVATION_DEVICE_ARN"] == DEVICE_ARN | ||
@test ENV["AMZN_BRAKET_RESERVATION_TIME_WINDOW_ARN"] == RESERVATION_ARN | ||
end | ||
|
||
@testset "Direct Reservation Function" begin | ||
reservation = Braket.DirectReservation(DEVICE_ARN, RESERVATION_ARN) | ||
@test Braket.direct_reservation(reservation, test_func) == 5 | ||
end | ||
|
||
@testset "Invalid Device Type" begin | ||
invalid_device = 12345 # Not a valid device type | ||
@test_throws UndefVarError DirectReservation(invalid_device, RESERVATION_ARN) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have some flavour text here explaining what reservations are and why anyone would use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please checkout the documentation.