Skip to content

Commit

Permalink
Feedback: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ykharkov committed Mar 29, 2024
1 parent a4bbe3c commit f413226
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"<u>Circuit Generation for Testing</u>\n",
"\n",
"Random quantum circuits generator allows to create a diverse set of circuits with a variety of output probability distributions. Users can utilize random circuits to test performance of quantum simulators and QPUs. \n",
"Random quantum circuit generator allows creation of a diverse set of circuits with a variety of output probability distributions. Users can utilize random circuits to test performance of quantum simulators and QPUs. \n",
"\n",
"<u> Benchmarking quantum compilation stacks</u>\n",
"\n",
Expand All @@ -32,7 +32,7 @@
"outputs": [],
"source": [
"from braket.devices import LocalSimulator\n",
"from braket.experimental.auxilary_functions.random_circuit.random_circuit import random_circuit\n",
"from braket.experimental.auxiliary_functions.random_circuit import random_circuit\n",
"from braket.circuits.gates import CNot, Rx, Rz, CPhaseShift, XY\n",
"\n",
"# Code here\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from .random_circuit import random_circuit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from .random_circuit import random_circuit
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import inspect
import math
import random
from typing import List
from typing import Optional

from braket.circuits import Circuit, Gate, Instruction
from braket.circuits import Circuit, Instruction
from braket.circuits.gates import CNot, H, S, T


def random_circuit(
num_qubits: int, num_gates: int, gate_set: List[Gate] = [CNot, S, T, H], seed=None
num_qubits: int, num_gates: int, gate_set=None, seed: Optional[int] = None
) -> Circuit:
"""
Generates a random quantum circuit.
Args:
num_qubits (int): Number of qubits in the circuit.
num_gates (int): Number of instructions (gates) in the circuit.
gate_set (List[Gate]): List of basis gates for the random circuit.
gate_set (List[Gate]): List of basis gates for the random circuit (default is None).
seed (Optional[int]): Random seed for reproducibility (default is None).
Returns:
Expand All @@ -26,6 +26,10 @@ def random_circuit(
if seed is not None:
random.seed(seed)

# Default gate_set (Clifford + T) if gate_set is None
if not gate_set:
gate_set = [CNot, S, T, H]

instructions = []
for _ in range(num_gates):
gate = random.choice(gate_set)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from braket.circuits import Circuit

from braket.experimental.auxilary_functions.random_circuit.random_circuit import random_circuit
from braket.experimental.auxiliary_functions.random_circuit import random_circuit


def test_random_circuit_returns_circuit():
Expand Down

0 comments on commit f413226

Please sign in to comment.