BraketSimulator.jl
No description available
Install / Use
/learn @amazon-braket/BraketSimulator.jlREADME
BraketSimulator
This package is a quantum circuit simulator written in the Julia programming language, meant to be compatible with the Amazon Braket SDK. It can simulate gate-based quantum circuits using both statevectors and density matrices (when noise is present).
Installation & Prerequisites
You do not need a Python installation or the Python Amazon Braket SDK installed to use this package.
Supported operating systems and architectures:
| CPU arch \ OS | Linux | macOS | Windows | | ------------- | ----- | ----- | ------- | | x86_64 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | aarch64 (ARM) | :white_check_mark: | :white_check_mark: | :interrobang: |
All necessary Julia packages will be installed for you when you run Pkg.add("BraketSimulator") or ] instantiate (if you're doing a dev install). The minimum supported Julia version is 1.9.
Generating precompilation instructions
In order to generate a new set of precompilation instructions, you'll need to comment out the include("precompile.jl") lines in src/BraketSimulator.jl and ext/BraketSimulatorPythonExt/BraketSimulatorPythonExt.jl. Then, cd to precompile and run:
julia --project=../test snoop_compilation.jl
This will run the test suite using SnoopCompile.jl to generate precompilation instructions. Once this is completed, you can uncomment include("precompile.jl") lines in src/BraketSimulator.jl and ext/BraketSimulatorPythonExt/BraketSimulatorPythonExt.jl.
Package Extensions
BraketSimulator.jl has an optional extension to support integration with Python (BraketSimulatorPythonExt).
To use BraketSimulatorPythonExt, you will need to install PythonCall.jl, and then load it before BraketSimulator.jl like so:
using PythonCall, BraketSimulator
PythonCall.jl will try to install the necessary Python dependencies using the CondaPkg.toml present in top-level package folder. If you already have all the necessary Python dependencies installed, you can set the environment variable JULIA_CONDAPKG_BACKEND="Null" to have CondaPkg.jl use your system Python and its installed packages.
Usage Notes
If you want to use this package from Python, see the Python wrapper package amazon-braket-simulator-v2-python, which provides a Python interaction layer and will install Julia, this package and other Julia dependencies in a sandboxed virtual environment for you.
Launch Julia with the command line option -t auto to have Julia launch and manage threads to parallelize the simulation(s). BraketSimulator.jl will parallelize both across tasks within a batch and inside a single task's evolution.
Keep in mind that the first qubit has index 0, not index 1.
Example
In this example, we create a Greenberger-Horne-Zeilinger (GHZ) state and simulate it:
using Braket, BraketSimulator
function ghz_circuit(qubit_count::Int)
ghz_circ = Circuit()
H(ghz_circ, 0)
for target_qubit = 1:qubit_count-1
CNot(ghz_circ, 0, target_qubit)
end
return ghz_circ
end
device = LocalSimulator("braket_sv_v2")
n_qubits = 10
task_result = simulate(device, ghz_circuit(n_qubits), shots=10)
Security
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
