Amazon Braket : 양자 컴퓨팅 시작하기

IBM, Microsoft 및 Google이 양자 컴퓨팅에 대한 주요 약속과 투자를했지만 Amazon은 최근까지이 분야에 대해 상당히 조용했습니다. 그것은 Amazon Braket의 도입으로 바뀌 었습니다.

Amazon은 여전히 ​​자체 양자 컴퓨터를 구축하려고하지 않지만 Braket을 통해 다른 회사의 양자 컴퓨터를 AWS를 통해 클라우드 사용자에게 제공하고 있습니다. Braket은 현재 D-Wave, IonQ 및 Rigetti의 세 가지 양자 컴퓨팅 서비스를 지원합니다.

[추가 정보 : Microsoft Quantum Development Kit 및 IBM Q 및 Qiskit 양자 컴퓨팅 SDK 실습보기]

D-Wave는 Braket SDK에 어닐링 모듈도 있지만 일반적으로 D-Wave Ocean 소프트웨어를 사용하여 프로그래밍되는 초전도 양자 어 닐러를 만듭니다. IonQ는 트랩 형 이온 양자 프로세서를 만들고 Rigetti는 초전도 양자 프로세서를 만듭니다. Braket에서는 Braket Python SDK 회로 모듈을 사용하여 IonQ 및 Rigetti 프로세서를 모두 프로그래밍 할 수 있습니다. 동일한 코드가 로컬 및 호스팅 된 양자 시뮬레이터에서도 실행됩니다.

Braket이라는 이름은 물리학 자들에게 일종의 농담입니다. Bra-ket 표기법은 양자 역학의 Dirac 공식화로 편미분 방정식보다 Schrödinger 방정식을 더 쉽게 표현할 수있는 방법입니다. Dirac 표기법에서 브래지어 is a row vector, and a ket |f> is a column vector. Writing a bra next to a ket implies matrix multiplication.

Amazon Braket and the Braket Python SDK compete with IBM Q and Qiskit, Azure Quantum and Microsoft Q#, and Google Cirq. IBM already has its own quantum computers and simulators available to the public online. Microsoft’s simulator is generally available, but its quantum offerings are currently in limited preview for early adopters, including access to quantum computers from Honeywell, IonQ, and Quantum Circuits, and optimization solutions from 1QBit. Microsoft hasn’t announced when its own topological superconducting quantum computers will become available, nor has Google announced when it will make its quantum computers or Sycamore chips available to the public.

Amazon Braket overview

Amazon Braket is a fully managed service that helps you get started with quantum computing. It has three modules, Build, Test, and Run. The Build module centers around managed Jupyter notebooks pre-configured with sample algorithms, resources, and developer tools, including the Amazon Braket SDK. The Test module provides access to managed, high-performance, quantum circuit simulators. The Run module provides secure, on-demand access to different types of quantum computers (QPUs): gate-based quantum computers from IonQ and Rigetti, and a quantum annealer from D-Wave.

Tasks may not run immediately on the QPU. The QPUs only execute tasks during execution windows.

Amazon Braket SDK API

The Braket Python SDK defines all of the operations you need to build, test, and run quantum circuits and annealers. It is organized into five packages: braket.annealing, braket.aws, braket.circuits, braket.devices, and braket.tasks.

The braket.annealing package allows you to define two kinds of binary quadratic models (BQMs): Ising (a mathematical model of ferromagnetism in statistical mechanics, using magnetic dipole moments of atomic “spins”) and QUBO (Quadratic Unconstrained Binary Optimization) problems, to solve on a quantum annealer, such as a D-Wave unit. The braket.circuits package lets you define quantum circuits based on a set of gates, to solve on gate-based quantum computers, such as ones from IonQ and Rigetti.

The other three packages control the running of your problem. The braket.aws package allows you to select quantum devices, load problems into tasks, and connect tasks to AWS sessions. The braket.devices package lets you run tasks on quantum devices and simulators. The braket.tasks package lets you manage, track, cancel, and get results from quantum tasks.

Amazon Braket circuits and gates

Circuits in a quantum computer such as the ones from IonQ or Rigetti (or IBM or Honeywell, for that matter) are built from a standard set of gates (see figure below), although not every QPU may have an implementation of every kind of gate. In the Braket SDK you define a circuit using the Circuit() method from the braket.circuits package, qualified by the gates in the circuit and their parameters.

For example, this Braket code (from Amazon’s Deep_dive_into_the_anatomy_of_quantum_circuits example) defines a circuit that initializes four qubits to a Hadamard (equal probability of 1 and 0) state, then entangles qubit 2 with qubit 0 and qubit 3 with qubit 1 using Controlled Not operations.

# define circuit with 4 qubits

my_circuit = Circuit().h(range(4)).cnot(control=0, target=2).cnot(control=1, target=3)

The Braket SDK seems to have a nearly full set of quantum logic gates, as shown in this enumeration of the Gate class. I don’t see a Deutsch gate listed, but as far as I know it hasn’t yet been implemented on a real QPU.

# print all available gates currently available within SDK

gate_set = [attr for attr in dir(Gate) if attr[0] in string.ascii_uppercase]

print(gate_set)

['CCNot', 'CNot', 'CPhaseShift', 'CPhaseShift00', 'CPhaseShift01', 'CPhaseShift10', 'CSwap', 'CY', 'CZ', 'H', 'I', 'ISwap', 'PSwap', 'PhaseShift', 'Rx', 'Ry', 'Rz', 'S', 'Si', 'Swap', 'T', 'Ti', 'Unitary', 'V', 'Vi', 'X', 'XX', 'XY', 'Y', 'YY', 'Z', 'ZZ']

Rxtreme (CC BY-SA 4.0)

D-Wave Ocean

Ocean is the native Python-based software stack for D-Wave quantum annealers. For use via Braket, you can combine the Ocean software with the Amazon Braket Ocean plug-in, which translates between Ocean and Braket formats.

Quantum annealers function quite differently than gate-based QPUs. Essentially, you formulate your problem as a binary quadratic model (BQM) that has a global minimum at the solution you want to find. Then you use the annealer to sample the function many times (since the annealer isn’t perfect) to find the minimum. You can create the BQM for a given problem mathematically or generate the BQM using Ocean software. The code that follows, from Amazon’s D-Wave_Anatomy example, uses the Braket Ocean plug-in to solve a BQM on a D-Wave device.

# set parameters

num_reads = 1000

# define BQM

bqm = dimod.BinaryQuadraticModel(linear, quadratic, offset, vartype)

# run BQM: solve with D-Wave device

sampler = BraketDWaveSampler(s3_folder,'arn:aws:braket:::device/qpu/d-wave/DW_2000Q_6')

sampler = EmbeddingComposite(sampler)

sampleset = sampler.sample(bqm, num_reads=num_reads)

# aggregate solution:

sampleset = sampleset.aggregate()

D-Wave Systems

Enabling Amazon Braket and using notebooks

Before you can use Braket, you need to enable it in your AWS account.

Then you need to create a notebook instance. Notebooks use Amazon SageMaker (read my review).

When you open a notebook, you can enter new code or use one of Amazon’s examples.

You need to check the status of the QPU devices, as they aren’t always available.

While you can run them yourself, the Braket example notebooks have been saved with results from a previous run.

There are examples for both gate-based QPUs, as above, and quantum annealers, as below.

Learn today, useful tomorrow

Amazon Braket is a reasonable way to get your feet wet with quantum computers and simulators. Since we’re still in the NISQ (Noisy Intermediate Scale Quantum) phase of quantum computing, you can’t really expect useful results from Braket. We’ll need more qubits, less noise, and longer coherence times, all of which are being actively researched.

Braket’s current QPU offerings are modest. The 2048-qubit D-Wave annealer is mostly useful for optimization problems; it’s about half the size of D-Wave’s latest-generation annealer. The 11-qubit IonQ QPU, which has relatively long coherence times, is way too small to implement the algorithms for quantum computers that should exhibit useful quantum supremacy, such as Grover’s algorithm for finding the inverse of a function and Shor’s algorithm for finding the prime factors of an integer. The 30-qubit Rigetti Aspen-8 is also too small.

Braket is not free, although it is relatively cheap to use. By comparison, IBM Q is completely free, although the publicly available IBM QPUs are very small: they range from a 1 qubit QPU in Armonk to a 15-qubit QPU in Melbourne. IBM also offers a paid premium QPU service.

[ Also on : Review: Amazon SageMaker plays catch-up ]

IBM also rates its QPUs by their quantum volume (QV), a measure that combines the number of qubits with their error rate and coherence time. There are five-qubit IBM QPUs ranging from QV8 to QV64: higher is better. Honeywell has also announced achieving QV64.

What Braket is currently good for is learning about quantum computing and developing NISQ-regime quantum algorithms. Stay tuned, though. As QPUs improve and are plugged into AWS, Braket will become more and more useful.

Cost: Managed notebooks: $0.04 to $34.27 per instance-hour; quantum simulator: $4.50 per hour; quantum computers: $0.30 per task plus $0.00019 to $0.01 per shot (repetition of a circuit). 

Platform: AWS; installing the Braket SDK locally requires Python 3.7.2 or greater, and Git.