From de7c7a5c5392aa4d3960989ea799d288c34a9824 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Jaskula Date: Wed, 22 May 2024 16:33:14 -0400 Subject: [PATCH 1/3] add cheat sheet --- .github/workflows/publish-cheat-sheet.yml | 48 ++ doc/cheat_sheet/LICENSE | 23 + doc/cheat_sheet/Translation.md | 17 + doc/cheat_sheet/_config.yml | 23 + doc/cheat_sheet/_data/blocks.yml | 41 ++ doc/cheat_sheet/_includes/blocks.html | 22 + doc/cheat_sheet/_includes/en/AHS.md | 7 + doc/cheat_sheet/_includes/en/APICalls.md | 13 + doc/cheat_sheet/_includes/en/Circuits.md | 15 + doc/cheat_sheet/_includes/en/Console.md | 5 + doc/cheat_sheet/_includes/en/Device.md | 5 + .../_includes/en/DeviceProperties.md | 7 + .../_includes/en/ErrorMitigation.md | 2 + .../_includes/en/FreeParameters.md | 7 + doc/cheat_sheet/_includes/en/HybridJobs.md | 5 + doc/cheat_sheet/_includes/en/LLDC.md | 13 + .../_includes/en/NoiseSimulation.md | 5 + doc/cheat_sheet/_includes/en/Pricing.md | 4 + .../_includes/en/QiskitProvider.md | 3 + doc/cheat_sheet/_includes/en/Resources.md | 10 + doc/cheat_sheet/_includes/en/Results.md | 4 + doc/cheat_sheet/_includes/en/Simulators.md | 2 + doc/cheat_sheet/_includes/en/Tasks.md | 6 + doc/cheat_sheet/_includes/en/What-is.md | 1 + doc/cheat_sheet/_includes/fr/AHS.md | 8 + doc/cheat_sheet/_includes/fr/APICalls.md | 2 + doc/cheat_sheet/_includes/fr/Basics.md | 9 + doc/cheat_sheet/_includes/fr/Circuits.md | 11 + doc/cheat_sheet/_includes/fr/Console.md | 2 + doc/cheat_sheet/_includes/fr/Device.md | 6 + .../_includes/fr/DeviceProperties.md | 9 + .../_includes/fr/ErrorMitigation.md | 4 + .../_includes/fr/FreeParameters.md | 7 + doc/cheat_sheet/_includes/fr/HybridJobs.md | 5 + doc/cheat_sheet/_includes/fr/LLDC.md | 12 + .../_includes/fr/NoiseSimulation.md | 6 + doc/cheat_sheet/_includes/fr/Pricing.md | 5 + .../_includes/fr/QiskitProvider.md | 3 + doc/cheat_sheet/_includes/fr/Resources.md | 10 + doc/cheat_sheet/_includes/fr/Results.md | 6 + doc/cheat_sheet/_includes/fr/Simulators.md | 3 + doc/cheat_sheet/_includes/fr/Tasks.md | 7 + doc/cheat_sheet/_includes/fr/What-is.md | 1 + doc/cheat_sheet/_includes/header.html | 28 + doc/cheat_sheet/_layouts/default.html | 33 ++ doc/cheat_sheet/braket.svg | 1 + doc/cheat_sheet/cheatsheet.css | 497 ++++++++++++++++++ doc/cheat_sheet/favicon.svg | 18 + doc/cheat_sheet/index.fr.html | 7 + doc/cheat_sheet/index.html | 6 + 50 files changed, 994 insertions(+) create mode 100644 .github/workflows/publish-cheat-sheet.yml create mode 100644 doc/cheat_sheet/LICENSE create mode 100644 doc/cheat_sheet/Translation.md create mode 100644 doc/cheat_sheet/_config.yml create mode 100644 doc/cheat_sheet/_data/blocks.yml create mode 100644 doc/cheat_sheet/_includes/blocks.html create mode 100644 doc/cheat_sheet/_includes/en/AHS.md create mode 100644 doc/cheat_sheet/_includes/en/APICalls.md create mode 100644 doc/cheat_sheet/_includes/en/Circuits.md create mode 100644 doc/cheat_sheet/_includes/en/Console.md create mode 100644 doc/cheat_sheet/_includes/en/Device.md create mode 100644 doc/cheat_sheet/_includes/en/DeviceProperties.md create mode 100644 doc/cheat_sheet/_includes/en/ErrorMitigation.md create mode 100644 doc/cheat_sheet/_includes/en/FreeParameters.md create mode 100644 doc/cheat_sheet/_includes/en/HybridJobs.md create mode 100644 doc/cheat_sheet/_includes/en/LLDC.md create mode 100644 doc/cheat_sheet/_includes/en/NoiseSimulation.md create mode 100644 doc/cheat_sheet/_includes/en/Pricing.md create mode 100644 doc/cheat_sheet/_includes/en/QiskitProvider.md create mode 100644 doc/cheat_sheet/_includes/en/Resources.md create mode 100644 doc/cheat_sheet/_includes/en/Results.md create mode 100644 doc/cheat_sheet/_includes/en/Simulators.md create mode 100644 doc/cheat_sheet/_includes/en/Tasks.md create mode 100644 doc/cheat_sheet/_includes/en/What-is.md create mode 100644 doc/cheat_sheet/_includes/fr/AHS.md create mode 100644 doc/cheat_sheet/_includes/fr/APICalls.md create mode 100644 doc/cheat_sheet/_includes/fr/Basics.md create mode 100644 doc/cheat_sheet/_includes/fr/Circuits.md create mode 100644 doc/cheat_sheet/_includes/fr/Console.md create mode 100644 doc/cheat_sheet/_includes/fr/Device.md create mode 100644 doc/cheat_sheet/_includes/fr/DeviceProperties.md create mode 100644 doc/cheat_sheet/_includes/fr/ErrorMitigation.md create mode 100644 doc/cheat_sheet/_includes/fr/FreeParameters.md create mode 100644 doc/cheat_sheet/_includes/fr/HybridJobs.md create mode 100644 doc/cheat_sheet/_includes/fr/LLDC.md create mode 100644 doc/cheat_sheet/_includes/fr/NoiseSimulation.md create mode 100644 doc/cheat_sheet/_includes/fr/Pricing.md create mode 100644 doc/cheat_sheet/_includes/fr/QiskitProvider.md create mode 100644 doc/cheat_sheet/_includes/fr/Resources.md create mode 100644 doc/cheat_sheet/_includes/fr/Results.md create mode 100644 doc/cheat_sheet/_includes/fr/Simulators.md create mode 100644 doc/cheat_sheet/_includes/fr/Tasks.md create mode 100644 doc/cheat_sheet/_includes/fr/What-is.md create mode 100644 doc/cheat_sheet/_includes/header.html create mode 100644 doc/cheat_sheet/_layouts/default.html create mode 100644 doc/cheat_sheet/braket.svg create mode 100644 doc/cheat_sheet/cheatsheet.css create mode 100644 doc/cheat_sheet/favicon.svg create mode 100644 doc/cheat_sheet/index.fr.html create mode 100644 doc/cheat_sheet/index.html diff --git a/.github/workflows/publish-cheat-sheet.yml b/.github/workflows/publish-cheat-sheet.yml new file mode 100644 index 000000000..989a51688 --- /dev/null +++ b/.github/workflows/publish-cheat-sheet.yml @@ -0,0 +1,48 @@ +name: Publish Cheat Sheet + +on: + push: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./doc/cheat_sheet + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/doc/cheat_sheet/LICENSE b/doc/cheat_sheet/LICENSE new file mode 100644 index 000000000..e4c408213 --- /dev/null +++ b/doc/cheat_sheet/LICENSE @@ -0,0 +1,23 @@ +MIT License + +Original (Julia cheat sheet) Copyright (c) 2015 Ian Hellström +Original (Julia cheat sheet) Copyright (c) 2016 Harris Brakmic +Modifications (Braket cheat sheet) Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/doc/cheat_sheet/Translation.md b/doc/cheat_sheet/Translation.md new file mode 100644 index 000000000..b5e05916e --- /dev/null +++ b/doc/cheat_sheet/Translation.md @@ -0,0 +1,17 @@ +# Translation Guide + +TL;DR: + +- See `_config.yml`, `index.br.html` and `_includes/` + +The translation of this cheat-sheet requires the followings steps: + +- Choose a tag for your language, such as `en` for English or `fr` for French; +- On [`_config.yml`](_config.yml), add your tag and translate the given phrases; +- Copy `index.html` to `index.TAG.html`, where TAG is your tag; +- Modify `index.TAG.html`, changing `lang: TAG` and `permalink: /TAG/`; +- Copy the folder `_includes/en/` to `_includes/TAG/`, i.e., create a folder `TAG` + inside `_includes` with a copy of all the `.md` files; **don't change the .md names**; +- On file `_data/blocks.yml`, add a ` TAG: translated title` line for each title; +- Translate each block in `_includes/TAG`. + diff --git a/doc/cheat_sheet/_config.yml b/doc/cheat_sheet/_config.yml new file mode 100644 index 000000000..5ecb3d672 --- /dev/null +++ b/doc/cheat_sheet/_config.yml @@ -0,0 +1,23 @@ +domain: amazon-braket.github.io +title: The Fast Track to Amazon Braket +description: "The Fast Track to Amazon Braket - Braket Cheat Sheet" +github_username: amazon-braket +markdown: kramdown + +t: + en: + name: "English" + fast-track: "The Fast Track to Amazon Braket" + github-1: "This page's source is" + github-2: "located here" + github-3: "Pull requests are welcome!" + github-4: "This cheat sheet is inspired by" + translate: "Help translate!" # Not used for `en` + fr: + name: "Français" + fast-track: "Aide-mémoire" + github-1: "Les sources de cette page sont" + github-2: "disponibles ici" + github-3: "Pull Requests bienvenues !" + github-4: "Cet aide-memoire est inspiré de" + translate: "Aidez à traduire !" # Not used for `en` diff --git a/doc/cheat_sheet/_data/blocks.yml b/doc/cheat_sheet/_data/blocks.yml new file mode 100644 index 000000000..46423afe5 --- /dev/null +++ b/doc/cheat_sheet/_data/blocks.yml @@ -0,0 +1,41 @@ +- file: What-is.md + title: What is…? + fr: De quoi s'agit-il ? +- file: Circuits.md + title: Circuits + fr: Circuits +- file: FreeParameters.md + title: FreeParameters + fr: Paramètres libres +- file: Tasks.md + title: Tasks + fr: Tâches +- file: Results.md + title: Results +- file: Device.md + title: Device +- file: DeviceProperties.md + title: Device Properties +- file: Pricing.md + title: Pricing +- file: HybridJobs.md + title: Hybrid Jobs + fr: Tâches +- file: Simulators.md + title: Simulators +- file: NoiseSimulation.md + title: Noise Simulation +- file: LLDC.md + title: Low-Level Device Control +- file: AHS.md + title: Analog Hamiltonian Simulation +- file: ErrorMitigation.md + title: Error Mitigation +- file: Console.md + title: Console +- file: APICalls.md + title: API Calls +- file: QiskitProvider.md + title: Qiskit Provider +- file: Resources.md + title: Resources diff --git a/doc/cheat_sheet/_includes/blocks.html b/doc/cheat_sheet/_includes/blocks.html new file mode 100644 index 000000000..64bccbbb4 --- /dev/null +++ b/doc/cheat_sheet/_includes/blocks.html @@ -0,0 +1,22 @@ +
+ +
diff --git a/doc/cheat_sheet/_includes/en/AHS.md b/doc/cheat_sheet/_includes/en/AHS.md new file mode 100644 index 000000000..3b47bf2d7 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/AHS.md @@ -0,0 +1,7 @@ +| Imports | `from braket.ahs import AtomArrangement, DrivingField, AnalogHamiltonianSimulation` | +| Atom arrangement | `register = AtomArrangement()` | +| Add an atom by coordinates (in meters) | `register.add((5.7e-6, 5.7e-6))` | +| Get coordinates | `register.coordinate_list(axis)` | +| Create a driving field | `DrivingField(amplitude, phase, detuning)` | +| Create an AHS program | `ahs_program = AnalogHamiltonianSimulation(register, drive)` | +| Run an AHS program | `device.run(ahs_program)` | diff --git a/doc/cheat_sheet/_includes/en/APICalls.md b/doc/cheat_sheet/_includes/en/APICalls.md new file mode 100644 index 000000000..b6dc0e15b --- /dev/null +++ b/doc/cheat_sheet/_includes/en/APICalls.md @@ -0,0 +1,13 @@ +| Cancel a Braket hybrid job | CancelJob | +| Cancel the specified task | CancelQuantumTask | +| Create a Braket hybrid job | CreateJob | +| Create a quantum task | CreateQuantumTask | +| Retrieve the devices available in Braket | GetDevice | +| Retrieve the specified Braket hybrid job | GetJob | +| Retrieve the specified quantum task | GetQuantumTask | +| Show the tags associated with this resource | ListTagsForResource | +| Search for devices using the specified filters | SearchDevices | +| Search for Braket hybrid jobs that match the specified filter values | SearchJobs | +| Search for tasks that match the specified filter values | SearchQuantumTasks | +| Add a tag to the specified resource | TagResource | +| Remove tags from a resource | UntagResource | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/Circuits.md b/doc/cheat_sheet/_includes/en/Circuits.md new file mode 100644 index 000000000..a376732f0 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Circuits.md @@ -0,0 +1,15 @@ +| Imports | `from braket.circuits import Circuit, Gate, Instruction`
`from braket.circuits.observables import X` | +| Create a circuit | `circuit = Circuit()` | +| Add gates | `circuit.x(0).rx(1, 1.23).cnot(0, 1)` | +| Get the list of available gates | `[attr for attr in dir(Gate) if attr[0].isupper()]` | +| Apply a unitary matrix | `circuit.unitary(matrix, [0])` | +| Get the circuit unitary | `circuit.to_unitary()` | +| Add a result type | `circuit.probability(0)`
`circuit.expectation(0.5 * X() @ X(), target=[0, 1])` | +| List of the available result types | adjoint_gradient, amplitude, density_matrix, expectation, probability, sample, state_vector, variance | +| Add a verbatim box | `circuit.add_verbatim_box(circuit2)` | +| Gate modifiers | `circuit.x(0, control=[1, 2], control_state=[0, 1], power=-0.5)` | +| Draw a circuit | `print(circuit)` | +| Import from OpenQASM3 | `Circuit.from_ir(source=qasm_str)` | +| Export to OpenQASM3 | `Circuit.to_ir("OPENQASM")` | +| Create an instruction | `inst = Instruction(Gate.CPhaseShift(1.23), target=[0, 1])` | +| Add an instruction | `circuit.add(inst)` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/Console.md b/doc/cheat_sheet/_includes/en/Console.md new file mode 100644 index 000000000..b1a113c68 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Console.md @@ -0,0 +1,5 @@ +The console is a web interface where you can find important up-to-date information about the Braket service and the available devices. + +| Device tab | Device summary
Connectivity | +| Notebook | Jupyter hub | +| Braket Direct | Device reservation
Office hours | diff --git a/doc/cheat_sheet/_includes/en/Device.md b/doc/cheat_sheet/_includes/en/Device.md new file mode 100644 index 000000000..8dd9fcd9f --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Device.md @@ -0,0 +1,5 @@ +| Imports | `from braket.aws import AwsDevice`
`from braket.devices import Devices` | +| Instantiate a device | `AwsDevice("")` | +| Device alias (use in place of string ARN) | `Devices.Rigetti.AspenM3` | +| Queue depth | `device.queue_depth()` | +| Gate pulse implementation | `device.gate_calibrations` | diff --git a/doc/cheat_sheet/_includes/en/DeviceProperties.md b/doc/cheat_sheet/_includes/en/DeviceProperties.md new file mode 100644 index 000000000..eb83a5b56 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/DeviceProperties.md @@ -0,0 +1,7 @@ +| Connectivity graph| `device.properties.paradigm.connectivity` | +| Fidelities dictionary| `device.properties.provider.specs` | +| Native gate set| `device.properties.paradigm.nativeGateSet` | +| Cost and availability| `device.properties.service` | +| Pulse properties| `device.properties.pulse` | +| Actions properties| `action_properties = device.properties.action['braket.ir.openqasm.program']` | +| Supported gates| `action_properties.supportedOperations` | diff --git a/doc/cheat_sheet/_includes/en/ErrorMitigation.md b/doc/cheat_sheet/_includes/en/ErrorMitigation.md new file mode 100644 index 000000000..45e1ce0f8 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/ErrorMitigation.md @@ -0,0 +1,2 @@ +| Debias | `device.run(circuit, shots=2500, device_parameters={"errorMitigation": Debias()})` | +| Sharpening (if debiasing used) | `result.additional_metadata.ionqMetadata.sharpenedProbabilities` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/FreeParameters.md b/doc/cheat_sheet/_includes/en/FreeParameters.md new file mode 100644 index 000000000..68f02fa02 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/FreeParameters.md @@ -0,0 +1,7 @@ +| Imports | `from braket.circuits import FreeParameter` | +| Create a free parameter | `alpha = FreeParameter(“alpha”)` | +| Use a free Parameter | `circuit.rx(0, alpha)`| +| Free parameter algebra | `beta = 2 * alpha + 1`| +| Bind a value | `circuit.make_bound_circuit({“alpha”: 0.1})`| +| Get the list of unbound FreeParameters| `circuit.parameters`| +| Inline compilation| `device.run(circuit, inputs={“alpha”: 0.1})`| diff --git a/doc/cheat_sheet/_includes/en/HybridJobs.md b/doc/cheat_sheet/_includes/en/HybridJobs.md new file mode 100644 index 000000000..8cd7ebc10 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/HybridJobs.md @@ -0,0 +1,5 @@ +| Imports | `from braket.aws import AwsQuantumJob` | +| Create a job | `job = AwsQuantumJob.create(arn, source_module="algorithm_script.py", entry_point="algorithm_script:start_here", wait_until_complete=True)` | +| Queue position | `job.queue_position()` | +| Job decorator | `@hybrid_job(device=None, local=True)` | +| Records Braket Hybrid Job metrics | `log_metric(metric_name, value, iteration_number)` | diff --git a/doc/cheat_sheet/_includes/en/LLDC.md b/doc/cheat_sheet/_includes/en/LLDC.md new file mode 100644 index 000000000..e7245c262 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/LLDC.md @@ -0,0 +1,13 @@ +| Imports | `from braket.pulse import PulseSequence, Frame`
`from braket.pulse.waveforms import *` | +| Create a new pulse sequence | `pulse_sequence = PulseSequence()` | +| Predefined ports | `device.ports` | +| Predefined frames | `device.frames` | +| Create a frame | `Frame(port, frequency[, phase])` | +| Predefined waveforms | `ConstantWaveform(length, iq)`
`GaussianWaveform(length, width, amplitude, zero_at_edges)`
`DragGaussianWaveform(length, width, amplitude, beta, zero_at_edges)` | +| Play a waveform | `pulse_sequence.play(frame, waveform)` | +| Add a delay | `pulse_sequence.delay(frame, delay)` | +| Set frequency | `pulse_sequence.set_frequency(frame, frequency)` | +| Shift frequency | `pulse_sequence.shift_frequency(frame, detuning)` | +| Set phase | `pulse_sequence.set_phase(frame, phase)` | +| Shift phase | `pulse_sequence.shift_phase(frame, phi)` | +| Get the time series | `pulse_sequence.to_time_traces()` | diff --git a/doc/cheat_sheet/_includes/en/NoiseSimulation.md b/doc/cheat_sheet/_includes/en/NoiseSimulation.md new file mode 100644 index 000000000..a5de9bbbd --- /dev/null +++ b/doc/cheat_sheet/_includes/en/NoiseSimulation.md @@ -0,0 +1,5 @@ +| Imports | `from braket.circuits import Noise` | +| Depolarizing noise | `circuit.depolarizing(0, 0.1)` | +| Apply a Kraus operator | `circuit.kraus([0,2], [E0, E1])` | +| Phase dampling channel | `noise = Noise.PhaseDamping(0.1)` | +| Apply a noise channel | `circuit.apply_gate_noise(noise, Gate.X)` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/Pricing.md b/doc/cheat_sheet/_includes/en/Pricing.md new file mode 100644 index 000000000..8fac5a42f --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Pricing.md @@ -0,0 +1,4 @@ +| Imports | `from braket.tracking import Tracker` | +| Start the cost tracker | `tracker=Tracker().start()` | +| Print costs | `tracker.qpu_tasks_cost()`
`tracker.simulator_tasks_cost()` | +| Cost summary | `tracker.quantum_tasks_statistics()` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/QiskitProvider.md b/doc/cheat_sheet/_includes/en/QiskitProvider.md new file mode 100644 index 000000000..8214683af --- /dev/null +++ b/doc/cheat_sheet/_includes/en/QiskitProvider.md @@ -0,0 +1,3 @@ +| Imports | `from qiskit_braket_provider import AWSBraketProvider` | +| Instantiate a provider | `provider = AWSBraketProvider()` | +| Instantiate a backend | `provider.get_backend(name)` | diff --git a/doc/cheat_sheet/_includes/en/Resources.md b/doc/cheat_sheet/_includes/en/Resources.md new file mode 100644 index 000000000..5143bc9ed --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Resources.md @@ -0,0 +1,10 @@ +- [Amazon Braket](https://aws.amazon.com/braket/) +- [Official documentation](https://docs.aws.amazon.com/braket/) +- [AWS Quantum blog](https://aws.amazon.com/blogs/quantum-computing/) +- [Braket Python SDK source](https://github.com/amazon-braket/amazon-braket-sdk-python) +- [Default simulator source](https://github.com/amazon-braket/amazon-braket-default-simulator-python) +- [Notebook examples](https://github.com/amazon-braket/amazon-braket-examples) +- [Algorithm library](https://github.com/amazon-braket/amazon-braket-algorithm-library/tree/main) +- [Pennylane plugin](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python) +- [Qiskit-Braket plugin](https://github.com/qiskit-community/qiskit-braket-provider) +- [Braket Julia SDK](https://github.com/amazon-braket/Braket.jl) \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/Results.md b/doc/cheat_sheet/_includes/en/Results.md new file mode 100644 index 000000000..2eaff0f52 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Results.md @@ -0,0 +1,4 @@ +| Retrieve results | `result = task.results()` | +| Get measurement counts | `result.measurement_counts` | +| Get measured qubits | `result.measured_qubits` | +| Get compiled circuit | `result.get_compiled_circuit()` | diff --git a/doc/cheat_sheet/_includes/en/Simulators.md b/doc/cheat_sheet/_includes/en/Simulators.md new file mode 100644 index 000000000..f57c358f7 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Simulators.md @@ -0,0 +1,2 @@ +| Imports | `from braket.devices import LocalSimulator` | +| Instantiate the local simulator | `local_sim = LocalSimulator()` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/en/Tasks.md b/doc/cheat_sheet/_includes/en/Tasks.md new file mode 100644 index 000000000..b4defce9f --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Tasks.md @@ -0,0 +1,6 @@ +| Imports | `from braket.aws import AwsSession, AwsQuantumTask` | +| Create a quantum task by executing a circuit | `task = device.run(circuit)` | +| disable qubit rewiring| `device.run(circuit, disable_qubit_rewiring=True)` | +| Instantiate an AwsSession| `session = AwsSession(...)` | +| Recreate a quantum task| `task = AwsQuantumTask(arn[, aws_session])` | +| Queue position| `task.queue_position()` | diff --git a/doc/cheat_sheet/_includes/en/What-is.md b/doc/cheat_sheet/_includes/en/What-is.md new file mode 100644 index 000000000..9b587015f --- /dev/null +++ b/doc/cheat_sheet/_includes/en/What-is.md @@ -0,0 +1 @@ +[Amazon Braket](https://aws.amazon.com/braket/) is a fully managed AWS service that helps researchers, scientists, and developers get started with quantum computing. Quantum computing My tooltip has the potential to solve some computational problems that are beyond the reach of classical computers because it harnesses the laws of quantum mechanics to process information in new ways. diff --git a/doc/cheat_sheet/_includes/fr/AHS.md b/doc/cheat_sheet/_includes/fr/AHS.md new file mode 100644 index 000000000..fb6c5757b --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/AHS.md @@ -0,0 +1,8 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Atom arrangement | register = AtomArrangement() | +| Add an atom | register.add((5.7e-6, 5.7e-6)) | +| Get coordinates | register.coordinate_list(axis) | +| Create a driving field | DrivingField(amplitude, phase, detuning) | +| Create an AHS program | ahs_program = AnalogHamiltonianSimulation(register, drive) | +| Run an AHS program | device.run(ahs_program) | diff --git a/doc/cheat_sheet/_includes/fr/APICalls.md b/doc/cheat_sheet/_includes/fr/APICalls.md new file mode 100644 index 000000000..365e1fda0 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/APICalls.md @@ -0,0 +1,2 @@ +| | | +| -------------------- | ----------------------------------------------------- | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Basics.md b/doc/cheat_sheet/_includes/fr/Basics.md new file mode 100644 index 000000000..b18d82602 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Basics.md @@ -0,0 +1,9 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Assignment | `answer = 42`
`x, y, z = 1, [1:10; ], "A string"`
`x, y = y, x # swap x and y` | +| Constant declaration | `const DATE_OF_BIRTH = 2012` | +| End-of-line comment | `i = 1 # This is a comment` | +| Delimited comment | `#= This is another comment =#` | +| Chaining | `x = y = z = 1 # right-to-left`
`0 < x < 3 # true`
`5 < x != y < 5 # false` | +| Function definition | `function add_one(i)`
` return i + 1`
`end` | +| Insert LaTeX symbols | `\delta` + [Tab] | diff --git a/doc/cheat_sheet/_includes/fr/Circuits.md b/doc/cheat_sheet/_includes/fr/Circuits.md new file mode 100644 index 000000000..1cecf5893 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Circuits.md @@ -0,0 +1,11 @@ +| | | +| --------------------------------- | ------------------------------------------- | +| Create a circuit | `circuit = Circuit()` | +| Add gates | `circuit.x(0).cnot(0, 1)` | +| Apply a unitary matrix | `circuit.unitary(matrix, [0])` | +| Add a result type | `circuit.probability(0)` | +| Add a verbatim box | `circuit.add_verbatim_box(circuit2)` | +| Gate modifiers | `circuit.x(0, control=1, neg_control=2)` | +| Plot a circuit | `print(circuit)` | +| Observables | | +| Import from OpenQASM3 | `Circuit.from_ir(source)` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Console.md b/doc/cheat_sheet/_includes/fr/Console.md new file mode 100644 index 000000000..365e1fda0 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Console.md @@ -0,0 +1,2 @@ +| | | +| -------------------- | ----------------------------------------------------- | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Device.md b/doc/cheat_sheet/_includes/fr/Device.md new file mode 100644 index 000000000..54388b570 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Device.md @@ -0,0 +1,6 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Instantiate a device| AwsDevice(arn)| +| Queue depth| device.queue_depth()| +| Device helper objects| Devices.Rigetti.Aspen-M3| +| Gate pulse implementation| device.gate_calibrations| diff --git a/doc/cheat_sheet/_includes/fr/DeviceProperties.md b/doc/cheat_sheet/_includes/fr/DeviceProperties.md new file mode 100644 index 000000000..d18726266 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/DeviceProperties.md @@ -0,0 +1,9 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Connectivity graph| device.properties.paradigm.connectivity| +| Fidelities dictionary| device.properties.provider.specs| +| Native gate set| device.properties.paradigm.nativeGateSet| +| Cost and availability| device.properties.service| +| Pulse properties| device.properties.pulse| +| Actions properties| action_properties = device.properties.action['braket.ir.openqasm.program']| +| Supported gates| action_properties.supportedOperations| diff --git a/doc/cheat_sheet/_includes/fr/ErrorMitigation.md b/doc/cheat_sheet/_includes/fr/ErrorMitigation.md new file mode 100644 index 000000000..afbe80577 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/ErrorMitigation.md @@ -0,0 +1,4 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Debias | task = device.run(circuit, device_parameters={"errorMitigation": Debias()}) | +| Sharpening | result.additional_metadata.ionqMetadata.sharpenedProbabilities | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/FreeParameters.md b/doc/cheat_sheet/_includes/fr/FreeParameters.md new file mode 100644 index 000000000..2e0096ceb --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/FreeParameters.md @@ -0,0 +1,7 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Create a FreeParameter | `alpha=FreeParameter(“alpha”)` | +| Use FreeParameters | `circuit.rx(0, alpha+1)`| +| Bind a FreeParameter()| `circuit.make_bound_circuit({“alpha”: 0.1})`| +| Get the list of unbound FreeParameters| `circuit.parameters`| +| Inline compilation| `device.run(circuit, inputs={“alpha”: 0.1})`| diff --git a/doc/cheat_sheet/_includes/fr/HybridJobs.md b/doc/cheat_sheet/_includes/fr/HybridJobs.md new file mode 100644 index 000000000..2414808f2 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/HybridJobs.md @@ -0,0 +1,5 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Create a job | job = AwsQuantumJob.create(arn, source_module="algorithm_script.py", entry_point="algorithm_script:start_here", wait_until_complete=True) | +| Queue position | job.queue_position() | +| Job decorator | @hybrid_job(device=None, local=True) | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/LLDC.md b/doc/cheat_sheet/_includes/fr/LLDC.md new file mode 100644 index 000000000..8d08a6d0e --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/LLDC.md @@ -0,0 +1,12 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Create a pulse sequence | pulse_sequence = PulseSequence() | +| Dictionary of predefined ports | device.ports | +| Dictionary of predefined frames | device.frames | +| Create a frame | Frame(port, frequency[, phase]) | +| Predefined waveforms | ConstantWaveform(length, iq) | GaussianWaveform(length, width, amplitude, zero_at_edges) | DragGaussianWaveform(length, width, amplitude, beta, zero_at_edges) | +| Play a waveform | pulse_sequence.play(frame, waveform) | +| Add a delay | pulse_sequence.delay(frame, delay) | +| Set and Shift frequency | pulse_sequence.set_frequency(frame, frequency).shift_frequency(frame, detuning) | +| Set and Shift phase | pulse_sequence.set_phase(frame, phase).shift_phase(frame, phi) | +| Get the time series | pulse_sequence.to_time_traces() | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/NoiseSimulation.md b/doc/cheat_sheet/_includes/fr/NoiseSimulation.md new file mode 100644 index 000000000..681107ad4 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/NoiseSimulation.md @@ -0,0 +1,6 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Depolarizing noise | circuit.depolarizing(0, 0.1) | +| Apply a Kraus operator | circuit.kraus([0,2], [E0, E1]) | +| Phase dampling channel | noise = Noise.PhaseDamping(0.1) | +| Apply a noise channel | circuit.apply_gate_noise(noise, Gate.X) | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Pricing.md b/doc/cheat_sheet/_includes/fr/Pricing.md new file mode 100644 index 000000000..5e4f342c1 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Pricing.md @@ -0,0 +1,5 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Start the cost tracker| tracker=Tracker().start()| +| Print costs| tracker.qpu_tasks_cost()
tracker.simulator_tasks_cost()| +| Cost summary| tracker.quantum_tasks_statistics()| \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/QiskitProvider.md b/doc/cheat_sheet/_includes/fr/QiskitProvider.md new file mode 100644 index 000000000..7b4be4c86 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/QiskitProvider.md @@ -0,0 +1,3 @@ +| | | +| -------------------- | ----------------------------------------------------- | + diff --git a/doc/cheat_sheet/_includes/fr/Resources.md b/doc/cheat_sheet/_includes/fr/Resources.md new file mode 100644 index 000000000..7916db49e --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Resources.md @@ -0,0 +1,10 @@ +- [AWS Braket]() +- [Official documentation](). +- [Braket Python SDK]() +- [Local simulators]() +- [Notebook examples]() +- [Algorithm library]() +- [Pennylane plugin]() +- [Braket Julia SDK]() +- [AWS Quantum blog]() + diff --git a/doc/cheat_sheet/_includes/fr/Results.md b/doc/cheat_sheet/_includes/fr/Results.md new file mode 100644 index 000000000..41486553c --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Results.md @@ -0,0 +1,6 @@ +| | | +| ----------------------------------- | -------------------------------------- | +| Retrieve results | `result = task.results()` | +| Get measurement counts | `result.measurement_counts` | +| Get measured qubits | `result.measured_qubits` | +| Compiled programs | `res.additional_metadata.rigettiMetada.compiledProgram` | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Simulators.md b/doc/cheat_sheet/_includes/fr/Simulators.md new file mode 100644 index 000000000..1f1626510 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Simulators.md @@ -0,0 +1,3 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Instantiate the local simulator | local_sim = LocalSimulator() | \ No newline at end of file diff --git a/doc/cheat_sheet/_includes/fr/Tasks.md b/doc/cheat_sheet/_includes/fr/Tasks.md new file mode 100644 index 000000000..20d5b4938 --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/Tasks.md @@ -0,0 +1,7 @@ +| | | +| -------------------- | ----------------------------------------------------- | +| Create a quantum task by executing a circuit| `task = device.run(circuit)` | +| disable qubit rewiring| `device.run(circuit, disable_qubit_rewiring=true)` | +| Instantiate an AwsSession| `session = AwsSession...` | +| Recreate a quantum task| `task = AwsQuantumTask(“arn:....”[, awssession=session])` | +| Queue position| `task.queue_position()` | diff --git a/doc/cheat_sheet/_includes/fr/What-is.md b/doc/cheat_sheet/_includes/fr/What-is.md new file mode 100644 index 000000000..9b587015f --- /dev/null +++ b/doc/cheat_sheet/_includes/fr/What-is.md @@ -0,0 +1 @@ +[Amazon Braket](https://aws.amazon.com/braket/) is a fully managed AWS service that helps researchers, scientists, and developers get started with quantum computing. Quantum computing My tooltip has the potential to solve some computational problems that are beyond the reach of classical computers because it harnesses the laws of quantum mechanics to process information in new ways. diff --git a/doc/cheat_sheet/_includes/header.html b/doc/cheat_sheet/_includes/header.html new file mode 100644 index 000000000..e00fb8630 --- /dev/null +++ b/doc/cheat_sheet/_includes/header.html @@ -0,0 +1,28 @@ +
+ {{site.t[page.lang].name}} +
+ + + + {% for lang in site.t %} + {% if lang[0] != "en" %} + + + + {% endif %} + {% endfor %} +
+
+ +
+
+

{{ site.t[page.lang]["fast-track"] }}

+
+ +
+ + \ No newline at end of file diff --git a/doc/cheat_sheet/_layouts/default.html b/doc/cheat_sheet/_layouts/default.html new file mode 100644 index 000000000..3c013c2f9 --- /dev/null +++ b/doc/cheat_sheet/_layouts/default.html @@ -0,0 +1,33 @@ + + + + + + Amazon Braket in a nutshell + + + + +
+ {% include header.html %} +
+ {{ content }} + + + + + + \ No newline at end of file diff --git a/doc/cheat_sheet/braket.svg b/doc/cheat_sheet/braket.svg new file mode 100644 index 000000000..633c81140 --- /dev/null +++ b/doc/cheat_sheet/braket.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/doc/cheat_sheet/cheatsheet.css b/doc/cheat_sheet/cheatsheet.css new file mode 100644 index 000000000..03b9d8d46 --- /dev/null +++ b/doc/cheat_sheet/cheatsheet.css @@ -0,0 +1,497 @@ +@import url('https://fonts.cdnfonts.com/css/amazon-ember'); + +/******************************************************************* + * CSS reset adapted from http://meyerweb.com/eric/tools/css/reset * + *******************************************************************/ + +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +sub, +sup, +tt, +var, +b, +u, +i, +center, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; + text-decoration: none; +} + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +menu, +nav, +section { + display: block; +} + +body { + line-height: 1; +} + +blockquote, +q { + quotes: none; +} + +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ''; + content: none; +} + +table { + border-collapse: collapse; + border-spacing: 0; + width: 100%; +} + +/****************** + * Variables * + ******************/ +:root { + --box-width: 800px; +} + + + +/****************** + * Custom styling * + ******************/ + +body { + font-family: 'Amazon Ember', sans-serif; + text-align: center; + color: #16191f; + background-color: #f2f3f3; + margin: 0; + font-size: 14px; + line-height: 22px; +} + +h1 { + display: table-cell; + font-size: 200%; + font-weight: bold; + vertical-align: middle; + text-align: right; +} + +h2 { + font-size: 1.2em; + margin: 8px 0px 8px 20px; + color: #545b64; + font-weight: bold; +} + +#top h1 { + display: block; + text-align: right; +} + +#top h2 { + font-family: 'Amazon Ember Cd RC', sans-serif; + font-size: 120%; + text-align: right; + font-weight: normal; +} + +header { + width: 100%; + height: 50px; + line-height: 50px; + position: fixed; + top: 0; + left: 0; + z-index: 99; + background-color: #232f3e; + color: #ffffff; +} + +footer { + width: 100%; + height: 30px; + line-height: 15px; + font-size: 80%; + position: fixed; + bottom: 0; + left: 0; + background-color: #232f3e; + color: #ffffff; +} + +#thanks:before { + content: "Thanks (alphabetically): "; + font-size: larger; +} + +#top { + display: inline-flex; +} + +#title { + margin: auto; +} + +#version { + font-size: larger; + vertical-align: bottom; + margin-left: 0em; + margin-top: auto; + margin-bottom: 1.5em; +} + +#contents { + -webkit-columns: 6 34em; + -moz-columns: 6 34em; + columns: 6 calc(var(--box-width) + 4px); + -webkit-column-gap: 0.25em; + -moz-column-gap: 0.25em; + column-gap: 0.25em; + padding-top: 54px; + padding-bottom: 30px; +} + + +/* + * Note: a coloured box title for a rounded box would require a hidden overflow to + * avoid colour spilling over the border. This, however, clashes with tooltips in + * all but the very first column due to the absolute positioning. + */ + +.box { + display: inline-block; + position: relative; + border-top: 1px solid #eaeded; + box-shadow: 0 1px 1px 0 rgba(0, 28, 36, 0.3), 1px 1px 1px 0 rgba(0, 28, 36, 0.15), -1px 1px 1px 0 rgba(0, 28, 36, 0.15); + text-align: left; + background-color: #ffffff; + margin: 0.5em; + /* padding-bottom: 0.5em; */ + width: var(--box-width); + word-wrap: break-word; +} + +#contents>ol, +ul { + list-style: none; +} + +.box .title { + background: #fafafa; + border-bottom: 1px solid #eaeded; + padding: .5em; +} + +.box h1 { + font-family: 'Amazon Ember V2', sans-serif; + font-size: 120%; + font-weight: bold; + padding: 5px; + color: 16191f; +} + +.box p { + padding: 0.25em 0.5em 0.25em 0.5em; + text-align: justify; +} + +.box em { + font-style: italic; +} + +le .box table { + border-spacing: 0.1em; + border-collapse: collapse; + margin-left: 0.5em; + margin-right: 0.5em; +} + +.box table { + width: var(--box-width); + table-layout: fixed; +} + +.box table td { + padding: 0.1em 0.5em 0.1em 0.5em; + vertical-align: middle; + border: #eaeded; +} + +.box table td:first-child { + width: calc(var(--box-width)/3); +} + +/* .box table tr:nth-child(odd) { + background-color: #ffffff; +} */ + +.box table tr { + border-top: 1px solid #eaeded; +} + +.box table tr:first-child { + border-top: none; +} + +.box ul li { + list-style-type: square; + margin-left: 2em; +} + +.centred { + display: table; + margin-left: auto; + margin-right: auto; +} + +.indented { + display: block; + margin-left: auto; + margin-right: auto; + width: 32em; +} + +pre { + font-family: 'Amazon Ember Mono', sans-serif; + color: #80ab5d; +} + +code { + /* display: inline-block; */ + white-space: pre-wrap; + font-family: 'Amazon Ember Mono', sans-serif; + color: darkgreen; +} + +pre code { + margin-left: 20px; +} + +a { + color: #0073bb; + text-decoration: #2a2a2e; +} + +a:hover { + color: #0a4a74; + text-decoration: underline; +} + +footer a { + color: #fff; +} + +footer a:hover { + color: #ec7211; + text-decoration: none; +} + + +/******************************************************************** + * Tooltip adapted from http://www.menucool.com/tooltip/css-tooltip * + ********************************************************************/ + +a.tooltip { + outline: none; + color: #9e7abe; +} + +a.tooltip:hover { + color: #6b458d; + text-decoration: none; + cursor: help; +} + +a.tooltip span { + display: none; + max-width: 33.5em; + padding: 0.25em; + text-align: center; + color: #2a2a2a; +} + +a.tooltip:hover span { + display: block; + position: absolute; + border: 1px solid #5d5d5d; + background: rgba(195, 195, 195, 0.9); +} + +a.tooltip span { + border-radius: 0.25em; + box-shadow: 0.1em 0.1em 0.1em #909090; +} + +.footer-text { + padding-top: 2em; + padding-bottom: 1em; +} + +.individual-styling>.bold { + color: blue; +} + +.github-info { + font-style: italic; + font-size: smaller; +} + +small { + font-size: smaller; + font-style: italic; +} + +.languages { + display: inline-block; + float: left; + left: 20px; + text-align: left; + position: absolute; + transition: 0.1s; +} + +.language { + width: 32px; + padding: 3px; + vertical-align: middle; +} + +.language-link { + font-size: 1.25em; + background: #e6f2ff; + padding: 5px; +} + +.language-link:hover { + background: #fafcff; +} + +.others { + border: 2px #4d64ae solid; + visibility: hidden; + position: absolute; + z-index: 1; + opacity: 0; + min-width: 260px; + transform: translateY(-2em); + transition: all 0.2s ease-in-out 0s, visibility 0s linear 0.2s; +} + +.languages:hover .others { + visibility: visible; + transform: translateY(0em); + opacity: 1; + transition-delay: 0s, 0s; +} + +.languages a { + text-decoration: none; + color: black; +} + +/* @media(min-width:576px) {} + +@media(min-width:768px) {} + +@media(min-width:992px) { + .box { + width: 35em; + } +} + +@media(min-width:1500px) { + .box { + width: 43em; + } +} + +@media(min-width:1600px) { + .box { + width: 30em; + } +} */ \ No newline at end of file diff --git a/doc/cheat_sheet/favicon.svg b/doc/cheat_sheet/favicon.svg new file mode 100644 index 000000000..f9d583d5f --- /dev/null +++ b/doc/cheat_sheet/favicon.svg @@ -0,0 +1,18 @@ + + + + Icon-Architecture/16/Arch_AWS-Braket_16 + Created with Sketch. + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/cheat_sheet/index.fr.html b/doc/cheat_sheet/index.fr.html new file mode 100644 index 000000000..5696ab063 --- /dev/null +++ b/doc/cheat_sheet/index.fr.html @@ -0,0 +1,7 @@ +--- +lang: fr +layout: default +permalink: /fr/ +--- + +{% include blocks.html %} diff --git a/doc/cheat_sheet/index.html b/doc/cheat_sheet/index.html new file mode 100644 index 000000000..a9ff1acdc --- /dev/null +++ b/doc/cheat_sheet/index.html @@ -0,0 +1,6 @@ +--- +lang: en +layout: default +--- + +{% include blocks.html %} From 36f5f6e0b70ba2cdec20eebb1840eefd20f46aab Mon Sep 17 00:00:00 2001 From: Jean-Christophe Jaskula Date: Wed, 5 Jun 2024 16:44:11 -0400 Subject: [PATCH 2/3] use html comment for LLM agent --- .github/workflows/publish-cheat-sheet.yml | 2 + doc/cheat_sheet/_includes/en/Circuits.md | 2 +- .../_scripts/generate_genAI_cheat_sheet.py | 88 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py diff --git a/.github/workflows/publish-cheat-sheet.yml b/.github/workflows/publish-cheat-sheet.yml index 989a51688..0e9729226 100644 --- a/.github/workflows/publish-cheat-sheet.yml +++ b/.github/workflows/publish-cheat-sheet.yml @@ -33,6 +33,8 @@ jobs: with: source: ./doc/cheat_sheet destination: ./_site + - name: Compile cheat sheet for genAI + run: sudo python3 doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py -d _site - name: Upload artifact uses: actions/upload-pages-artifact@v3 diff --git a/doc/cheat_sheet/_includes/en/Circuits.md b/doc/cheat_sheet/_includes/en/Circuits.md index a376732f0..35f24aebd 100644 --- a/doc/cheat_sheet/_includes/en/Circuits.md +++ b/doc/cheat_sheet/_includes/en/Circuits.md @@ -1,5 +1,5 @@ | Imports | `from braket.circuits import Circuit, Gate, Instruction`
`from braket.circuits.observables import X` | -| Create a circuit | `circuit = Circuit()` | +| Create a circuit | `circuit = Circuit()`| | Add gates | `circuit.x(0).rx(1, 1.23).cnot(0, 1)` | | Get the list of available gates | `[attr for attr in dir(Gate) if attr[0].isupper()]` | | Apply a unitary matrix | `circuit.unitary(matrix, [0])` | diff --git a/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py b/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py new file mode 100644 index 000000000..84c697409 --- /dev/null +++ b/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py @@ -0,0 +1,88 @@ +import argparse +import io +import os +import re +import requests +import zipfile + + +def download_zip_file(version=None): + if version is None: + zip_file_url = "https://github.com/amazon-braket/amazon-braket-sdk-python/zipball/jcjaskula-aws/add_cheat_sheet" + else: + zip_file_url = f"https://github.com/amazon-braket/amazon-braket-sdk-python/archive/refs/tags/v{version}.zip" + + r = requests.get(zip_file_url) + return zipfile.ZipFile(io.BytesIO(r.content)) + + +def list_markdown_files(zip_file): + cs_folder = os.path.join(zip_file.namelist()[0], "doc/cheat_sheet/_includes/en/") + print(cs_folder) + excluded_files = ["What-is.md", "Resources.md"] + + zip_files = [ + os.path.join(cs_folder, file.name) + for file in zipfile.Path(zip_file, at=cs_folder).iterdir() + if file.name not in excluded_files + ] + return zip_files + + +def concatenate_files(zip_file, files): + content = {} + for file in files: + filename = os.path.split(file)[-1] + content[filename] = [] + with zip_file.open(file, "r") as f: + for line in f.readlines(): + if '|' not in line.decode(): + continue + result = re.match( + r"\|\s*(.*)\s*\|\s*(.*)\s*\|", line.decode() + ) + if result and len(result.groups()) == 2: + content[filename].append( + result.groups() + ) + else: + raise ValueError(f"Invalid line: {line} in {file}") + return content + + +def format_and_write(content, destination): + with open(os.path.join(destination, "genAI_optimized_cheat_sheet.md"), "w") as f: + f.write("# Braket CheatSheet\n\n") + for filename, file_content in content.items(): + f.write(f"**{filename[:-3]}**\n\n") + for description, command in file_content: + if result := re.match( + r"(.*)\(.*)", description + ): + description = "".join(result.groups()) + f.write(f"***{description.strip()}:***\n\n") + + if result := re.match( + r"(.*)\(.*)", command + ): + command = "".join(result.groups()) + if "
" in command: + command = command.strip().replace('`', '') + f.write("```\n{}\n```\n\n".format(command.replace('
', '\n'))) + else: + f.write(f"{command}\n\n") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("-d", "--destination", type=str) + parser.add_argument("-v", "--version", type=str) + + args = parser.parse_args() + version = args.version if args.version else None + destination = args.destination if args.destination else "." + + zip_file = download_zip_file(version) + markdown_file_names = list_markdown_files(zip_file) + content = concatenate_files(zip_file, markdown_file_names) + format_and_write(content, destination) From cb4e70aebd986c214b288c19cae90b8887d8088d Mon Sep 17 00:00:00 2001 From: Kish-00 Date: Tue, 16 Jun 2026 09:36:20 +0300 Subject: [PATCH 3/3] feat: update cheat sheet with new sections and features - Add ProgramSets section (ProgramSet, CircuitBinding) - Add Emulators section (LocalEmulator) - Add ExperimentalFeatures section (experimental capabilities) - Add Reservations section (DirectReservation) - Update HybridJobs with @hybrid_job decorator details - Update Simulators with braket_sv and braket_dm backends - Add new sections to blocks.yml for website navigation - Update Resources with Braket Direct and pricing links - Update Translation.md with extend/modify documentation - Update GenAI script to reference main instead of feature branch Addresses feature requests: program sets, emulators, experimental features, reservations, and hybrid job decorator. --- doc/cheat_sheet/Translation.md | 37 +++++++++++++------ doc/cheat_sheet/_data/blocks.yml | 8 ++++ doc/cheat_sheet/_includes/en/Emulators.md | 5 +++ .../_includes/en/ExperimentalFeatures.md | 6 +++ doc/cheat_sheet/_includes/en/HybridJobs.md | 10 +++-- doc/cheat_sheet/_includes/en/ProgramSets.md | 6 +++ doc/cheat_sheet/_includes/en/Reservations.md | 4 ++ doc/cheat_sheet/_includes/en/Resources.md | 4 +- doc/cheat_sheet/_includes/en/Simulators.md | 4 +- .../_scripts/generate_genAI_cheat_sheet.py | 2 +- 10 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 doc/cheat_sheet/_includes/en/Emulators.md create mode 100644 doc/cheat_sheet/_includes/en/ExperimentalFeatures.md create mode 100644 doc/cheat_sheet/_includes/en/ProgramSets.md create mode 100644 doc/cheat_sheet/_includes/en/Reservations.md diff --git a/doc/cheat_sheet/Translation.md b/doc/cheat_sheet/Translation.md index b5e05916e..0aa755e91 100644 --- a/doc/cheat_sheet/Translation.md +++ b/doc/cheat_sheet/Translation.md @@ -1,17 +1,30 @@ -# Translation Guide +# Translation -TL;DR: +Thank you for your interest in translating the Amazon Braket cheat sheet! -- See `_config.yml`, `index.br.html` and `_includes/` +## How to translate -The translation of this cheat-sheet requires the followings steps: +1. Copy the `doc/cheat_sheet/_includes/en/` directory to a new directory with your language code. + For example, for a French translation: `doc/cheat_sheet/_includes/fr/` -- Choose a tag for your language, such as `en` for English or `fr` for French; -- On [`_config.yml`](_config.yml), add your tag and translate the given phrases; -- Copy `index.html` to `index.TAG.html`, where TAG is your tag; -- Modify `index.TAG.html`, changing `lang: TAG` and `permalink: /TAG/`; -- Copy the folder `_includes/en/` to `_includes/TAG/`, i.e., create a folder `TAG` - inside `_includes` with a copy of all the `.md` files; **don't change the .md names**; -- On file `_data/blocks.yml`, add a ` TAG: translated title` line for each title; -- Translate each block in `_includes/TAG`. +2. Translate the content of each `.md` file, keeping the table structure intact. + * **Only translate the text after the `|` separators** — the pipe characters that separate columns. + Leave pipe characters, filenames, code snippets, and links unchanged. +3. Add your language code to `doc/cheat_sheet/_data/blocks.yml`. + For example, `fr: Votre titre` for a French title. + +4. Add your language to `doc/cheat_sheet/_config.yml` under the `t:` section. + +5. Create an `index..html` page (e.g., `index.fr.html`) with `lang: ` in the front matter. + +6. Submit a pull request with your translation. + +## How to add or modify sections + +1. Add a new `.md` file in `doc/cheat_sheet/_includes/en/` (or your language directory). +2. Add an entry for it in `doc/cheat_sheet/_data/blocks.yml`. + - `file`: The filename of your new section. + - `title`: The display title in English. + - `fr`: (optional) The display title in French. +3. Submit a pull request with your changes. diff --git a/doc/cheat_sheet/_data/blocks.yml b/doc/cheat_sheet/_data/blocks.yml index 46423afe5..6d40f80ad 100644 --- a/doc/cheat_sheet/_data/blocks.yml +++ b/doc/cheat_sheet/_data/blocks.yml @@ -12,6 +12,8 @@ fr: Tâches - file: Results.md title: Results +- file: ProgramSets.md + title: Program Sets - file: Device.md title: Device - file: DeviceProperties.md @@ -23,6 +25,8 @@ fr: Tâches - file: Simulators.md title: Simulators +- file: Emulators.md + title: Emulators - file: NoiseSimulation.md title: Noise Simulation - file: LLDC.md @@ -31,6 +35,10 @@ title: Analog Hamiltonian Simulation - file: ErrorMitigation.md title: Error Mitigation +- file: Reservations.md + title: Reservations +- file: ExperimentalFeatures.md + title: Experimental Features - file: Console.md title: Console - file: APICalls.md diff --git a/doc/cheat_sheet/_includes/en/Emulators.md b/doc/cheat_sheet/_includes/en/Emulators.md new file mode 100644 index 000000000..17b339fae --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Emulators.md @@ -0,0 +1,5 @@ +| Imports | `from braket.emulation import LocalEmulator` | +| Create from device properties | `emulator = LocalEmulator.from_device_properties(device.properties)` | +| With a noise model | `emulator = LocalEmulator.from_device_properties(device.properties, noise_model=noise_model)` | +| Backend simulator | `backend = LocalSimulator("braket_dm")`
`emulator = LocalEmulator.from_device_properties(device_properties, backend=backend)` | +| Run a circuit on the emulator | `task = emulator.run(circuit, shots=100)` | diff --git a/doc/cheat_sheet/_includes/en/ExperimentalFeatures.md b/doc/cheat_sheet/_includes/en/ExperimentalFeatures.md new file mode 100644 index 000000000..553fdd578 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/ExperimentalFeatures.md @@ -0,0 +1,6 @@ +| Imports | `from braket.experimental_capabilities import EnableExperimentalCapability` | +| Enable experimental features | `EnableExperimentalCapability("ALL")` | +| Disable experimental features | `EnableExperimentalCapability().disable()` | +| IQM classical control | `from braket.experimental_capabilities.iqm import classical_control` | + +Experimental capabilities provide access to hardware with limited availability and early software features. diff --git a/doc/cheat_sheet/_includes/en/HybridJobs.md b/doc/cheat_sheet/_includes/en/HybridJobs.md index 8cd7ebc10..af67ec87b 100644 --- a/doc/cheat_sheet/_includes/en/HybridJobs.md +++ b/doc/cheat_sheet/_includes/en/HybridJobs.md @@ -1,5 +1,7 @@ -| Imports | `from braket.aws import AwsQuantumJob` | +| Imports | `from braket.aws import AwsQuantumJob`
`from braket.jobs import hybrid_job` | | Create a job | `job = AwsQuantumJob.create(arn, source_module="algorithm_script.py", entry_point="algorithm_script:start_here", wait_until_complete=True)` | -| Queue position | `job.queue_position()` | -| Job decorator | `@hybrid_job(device=None, local=True)` | -| Records Braket Hybrid Job metrics | `log_metric(metric_name, value, iteration_number)` | +| Jobs queue position | `job.queue_position()` | +| `@hybrid_job` decorator | `@hybrid_job(device=None, local=True)`
`def my_function(): ...` | +| Job configuration | `@hybrid_job(device=arn, instance_config=InstanceConfig(instanceType="ml.m5.large"))` | +| Local debugging | `@hybrid_job(device=None, local=True)` | +| Log metrics | `log_metric(metric_name, value, iteration_number)` | diff --git a/doc/cheat_sheet/_includes/en/ProgramSets.md b/doc/cheat_sheet/_includes/en/ProgramSets.md new file mode 100644 index 000000000..0f3defa9c --- /dev/null +++ b/doc/cheat_sheet/_includes/en/ProgramSets.md @@ -0,0 +1,6 @@ +| Imports | `from braket.program_sets import ProgramSet, CircuitBinding` | +| Create a CircuitBinding | `binding = CircuitBinding(circuit)` | +| With parameter sets | `binding = CircuitBinding(circuit, input_sets=[{"theta": 0.1}, {"theta": 0.2}])` | +| With observables | `binding = CircuitBinding(circuit, observables=X() @ X())` | +| Combine into a ProgramSet | `program_set = ProgramSet([binding], shots_per_executable=100)` | +| Run a ProgramSet | `result = device.run(program_set)` | diff --git a/doc/cheat_sheet/_includes/en/Reservations.md b/doc/cheat_sheet/_includes/en/Reservations.md new file mode 100644 index 000000000..4c63e21b3 --- /dev/null +++ b/doc/cheat_sheet/_includes/en/Reservations.md @@ -0,0 +1,4 @@ +| Imports | `from braket.aws.direct_reservations import DirectReservation` | +| Use as a context manager | `with DirectReservation(device_arn, reservation_arn=""):`
` task = device.run(circuit, shots=100)` | +| Start a reservation | `DirectReservation(device_arn, reservation_arn="").start()` | +| Reserve a device from `AwsDevice` | `device.run(circuit, shots=100, reservation_arn="")` | diff --git a/doc/cheat_sheet/_includes/en/Resources.md b/doc/cheat_sheet/_includes/en/Resources.md index 5143bc9ed..6248db331 100644 --- a/doc/cheat_sheet/_includes/en/Resources.md +++ b/doc/cheat_sheet/_includes/en/Resources.md @@ -7,4 +7,6 @@ - [Algorithm library](https://github.com/amazon-braket/amazon-braket-algorithm-library/tree/main) - [Pennylane plugin](https://github.com/amazon-braket/amazon-braket-pennylane-plugin-python) - [Qiskit-Braket plugin](https://github.com/qiskit-community/qiskit-braket-provider) -- [Braket Julia SDK](https://github.com/amazon-braket/Braket.jl) \ No newline at end of file +- [Braket Julia SDK](https://github.com/amazon-braket/Braket.jl) +- [Braket Direct reservations](https://docs.aws.amazon.com/braket/latest/developerguide/braket-reservations.html) +- [Braket pricing](https://aws.amazon.com/braket/pricing/) diff --git a/doc/cheat_sheet/_includes/en/Simulators.md b/doc/cheat_sheet/_includes/en/Simulators.md index f57c358f7..ccff19a90 100644 --- a/doc/cheat_sheet/_includes/en/Simulators.md +++ b/doc/cheat_sheet/_includes/en/Simulators.md @@ -1,2 +1,4 @@ | Imports | `from braket.devices import LocalSimulator` | -| Instantiate the local simulator | `local_sim = LocalSimulator()` | \ No newline at end of file +| Instantiate the local simulator | `local_sim = LocalSimulator()` | +| State vector simulator | `local_sim = LocalSimulator("braket_sv")` | +| Density matrix simulator | `local_sim = LocalSimulator("braket_dm")` | diff --git a/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py b/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py index 84c697409..fd906909f 100644 --- a/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py +++ b/doc/cheat_sheet/_scripts/generate_genAI_cheat_sheet.py @@ -8,7 +8,7 @@ def download_zip_file(version=None): if version is None: - zip_file_url = "https://github.com/amazon-braket/amazon-braket-sdk-python/zipball/jcjaskula-aws/add_cheat_sheet" + zip_file_url = "https://github.com/amazon-braket/amazon-braket-sdk-python/zipball/main" else: zip_file_url = f"https://github.com/amazon-braket/amazon-braket-sdk-python/archive/refs/tags/v{version}.zip"