Git Product home page Git Product logo

amazon-braket-default-simulator-python's Introduction

Amazon Braket Default Simulator

Latest Version Supported Python Versions Build status codecov Documentation Status

The Amazon Braket Default Simulator is a Python open source library that provides an implementation of a quantum simulator that you can run locally. You can use the simulator to test quantum tasks that you construct for the Amazon Braket SDK before you submit them to the Amazon Braket service for execution.

Setting up Amazon Braket Default Simulator Python

You must have the Amazon Braket SDK installed to use the local simulator. Follow the instructions in the README for setup.

Checking the version of the default simulator

You can check your currently installed version of amazon-braket-default-simulator with pip show:

pip show amazon-braket-default-simulator

or alternatively from within Python:

>>> from braket import default_simulator
>>> default_simulator.__version__

Usage

The quantum simulator implementations StateVectorSimulator and DensityMatrixSimulator plug into the LocalSimulator interface in Amazon Braket SDK, with the backend parameters as "braket_sv" and "braket_dm", respectively. Alternatively, to use StateVectorSimulator, you can instantiate LocalSimulator with no arguments or with backend="default":

Executing a circuit using the default simulator

from braket.circuits import Circuit
from braket.devices import LocalSimulator

device = LocalSimulator()

bell = Circuit().h(0).cnot(0, 1)
print(device.run(bell, shots=100).result().measurement_counts)

Documentation

Detailed documentation, including the API reference, can be found on Read the Docs

To generate the API Reference HTML in your local environment

First, install tox:

pip install tox

To generate the HTML, first change directories (cd) to position the cursor in the amazon-braket-default-simulator-python directory. Then, run the following command to generate the HTML documentation files:

tox -e docs

To view the generated documentation, open the following file in a browser: ../amazon-braket-default-simulator-python/build/documentation/html/index.html

Testing

If you want to contribute to the project, be sure to run unit tests and get a successful result before you submit a pull request. To run the unit tests, first install the test dependencies using the following command:

pip install -e "amazon-braket-default-simulator-python[test]"

To run the unit tests:

tox -e unit-tests

You can also pass in various pytest arguments to run selected tests:

tox -e unit-tests -- your-arguments

For more information, please see pytest usage.

To run linters and doc generators and unit tests:

tox

To run the performance tests:

tox -e performance-tests

These tests will compare the performance of a series of simulator executions for your changes against the latest commit on the main branch. Note: The execution times for the performance tests are affected by the other processes running on the system. In order to get stable results, stop other applications when running these tests.

License

This project is licensed under the Apache-2.0 License.

amazon-braket-default-simulator-python's People

Contributors

ajberdy avatar amazon-auto avatar amazon-braket-ci-bot avatar ashlhans avatar avawang1 avatar dependabot[bot] avatar floralph avatar guomanmin avatar krneta avatar kshitijc avatar laurencap avatar licedric avatar maolinml avatar math411 avatar mbeach-aws avatar rchilaka-amzn avatar sai-prakash15 avatar shahakl avatar shpface avatar speller26 avatar unprovable avatar virajvchaudhari avatar weinbe58 avatar xiaosi-xu avatar yzbamazon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-braket-default-simulator-python's Issues

Incorrect error message "Identifier 'foo' is not initialized" for variable inside OpenQASM subroutine

Describe the bug
In specific cases (see below), a variable which is properly initialized in the OpenQASM program is encountering an error message about being uninitialized when attempting to run the code using the default simulator.

To reproduce
The following code snippet reproduces the bug:

from braket.devices import LocalSimulator
from braket.ir.openqasm import Program
qasm = '''
OPENQASM 3.0;
def foo() -> bit {
    h q[0];
    bit i;
    i = measure q[0];
    return i;
}
qubit[10] q;
foo();
'''
LocalSimulator().run(Program(source=qasm), shots=5).result()

This produces the error:

File ~\lib\site-packages\braket\default_simulator\openqasm\interpreter.py:223, in Interpreter._(self, node)
    221     return builtin_constants[node.name]
    222 if not self.context.is_initialized(node.name):
--> 223     raise NameError(f"Identifier '{node.name}' is not initialized.")
    224 return self.context.get_value_by_identifier(node)

NameError: Identifier 'i' is not initialized.

Expected behavior
No error, the program should run correctly, since i is initialized with a measure statement.

Note that this does not happen if I first add an initialization to the declaration statement, e.g. bit i = 0;. In that case the program works correctly.

Screenshots or logs

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: 1.36.2
  • Amazon Braket Python Schemas version: 1.15.0
  • Amazon Braket Python Default Simulator version: 1.12.1
  • Python version: 3.10.9

Additional context

AttributeError: 'ArrayLiteral' object has no attribute 'value'.

Describe the bug
In general the openQASM parsing errors are well handled in Braket. There are some cases where it is assumed that an object will have a .value and the exception is not caught. These are from auto-generated programs, so might not be an issue in practice; but perhaps the error message could be improved to include context if the exception was caught.

I'm not sure that this is really a bug, so please let me know if not and I will delete the issue. The example I include here is for ArrayLiterals, but there are a whole family of related errors I have triggered.

To reproduce

from braket.circuits import Circuit
from braket.devices import LocalSimulator

device = LocalSimulator()
Circuit.from_ir('''
OPENQASM 3.0;
include "stdgates.inc";
qubit["10"] r1;
''')

Expected behavior
Either return an error message indicating that bitstrings are not allowed for declaring register sizes, or parse the bitstring into a numeric constant (2) and create an array with that size.

Screenshots or logs

Traceback (most recent call last):
  File "/harnesses/./differential_harness.py", line 291, in <module>
    assert run_and_compare_exact_probabilities(qasm_content, 0.01)
  File "/harnesses/./differential_harness.py", line 177, in run_and_compare_exact_probabilities
    braket_circuit = braket_sim.build_circuit(qasm_content)
  File "/harnesses/./differential_harness.py", line 32, in build_circuit
    quantum_circuit = BraketCircuit.from_ir(qasm_content)
  File "/usr/local/lib/python3.10/dist-packages/braket/circuits/circuit.py", line 1167, in from_ir
    return Interpreter(BraketProgramContext()).build_circuit(
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 130, in build_circuit
    return self.run(source, inputs, is_file).circuit
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 145, in run
    self.visit(program)
  File "/usr/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 172, in _
    self.visit(node.statements)
  File "/usr/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 168, in _
    return [n for n in [self.visit(node) for node in node_list] if n is not None]
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 168, in <listcomp>
    return [n for n in [self.visit(node) for node in node_list] if n is not None]
  File "/usr/lib/python3.10/functools.py", line 926, in _method
    return method.__get__(obj, cls)(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/braket/default_simulator/openqasm/interpreter.py", line 250, in _
    size = self.visit(node.size).value if node.size else 1

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: v1.74.0
  • Amazon Braket Python Schemas version:
  • Amazon Braket Python Default Simulator version:
  • Python version: Python 3.10.12

Additional context
N/A

Add Clifford simulator implementation

Describe the feature you'd like
Stabilizer circuits can be classically simulated efficiently, and are very useful in quantum information research, for example in quantum error correction. To support these use cases, it would be good to have a Clifford simulator target for the local simulator:

sim = LocalSimulator("braket.clifford")

This should be done by implementing the OpenQASMSimulator interface to translated OpenQASM into simulator instructions.

How would this feature be used? Please describe.
Fast simulation of large stabilizer circuits, for example with thousands of qubits and gates.

Out of bounds error in SciPy solver

Describe the bug
Trying to run the following task:

from braket.devices import LocalSimulator
from braket.ir.ahs import Program

task_json = {
  "braketSchemaHeader": {
    "name": "braket.ir.ahs.program",
    "version": "1"
  },
  "setup": {
    "ahs_register": {
      "sites": [
        [
          "0E-8",
          "0E-8"
        ],
        [
          "0.00000610",
          "0E-8"
        ],
        [
          "0.00001220",
          "0E-8"
        ],
        [
          "0.00001830",
          "0E-8"
        ],
        [
          "0.00002440",
          "0E-8"
        ],
        [
          "0.00003050",
          "0E-8"
        ],
        [
          "0.00003660",
          "0E-8"
        ],
        [
          "0.00004270",
          "0E-8"
        ],
        [
          "0.00004880",
          "0E-8"
        ],
        [
          "0.00005490",
          "0E-8"
        ],
        [
          "0.00006100",
          "0E-8"
        ]
      ],
      "filling": [
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1
      ]
    }
  },
  "hamiltonian": {
    "drivingFields": [
      {
        "amplitude": {
          "time_series": {
            "values": [
              "0.0",
              "15700000.0",
              "15700000.0",
              "0.0"
            ],
            "times": [
              "0E-9",
              "3.00E-7",
              "6.00E-7",
              "6.60E-7"
            ]
          },
          "pattern": "uniform"
        },
        "phase": {
          "time_series": {
            "values": [
              "0E-7",
              "0E-7"
            ],
            "times": [
              "0E-9",
              "6.60E-7"
            ]
          },
          "pattern": "uniform"
        },
        "detuning": {
          "time_series": {
            "values": [
              "-18800000.0",
              "-18800000.0",
              "-12218750.0",
              "0.0"
            ],
            "times": [
              "0E-9",
              "3.00E-7",
              "6.00E-7",
              "6.60E-7"
            ]
          },
          "pattern": "uniform"
        }
      }
    ],
    "shiftingFields": []
  }
}

LocalSimulator("braket_ahs").run(Program(**task_json), shots = 10)

produces the following error:

capi_return is NULL
Call-back cb_f_in_zvode__user__routines failed.
Fatal Python error: F2PySwapThreadLocalCallbackPtr: F2PySwapThreadLocalCallbackPtr: PyLong_AsVoidPtr failed
Python runtime state: initialized
Traceback (most recent call last):
  File "/Users/jlong/Desktop/Github/bloqade-python/.venv/lib/python3.11/site-packages/braket/analog_hamiltonian_simulator/rydberg/scipy_solver.py", line 82, in f
    return -1j * dt * _apply_hamiltonian(index_time, operators_coefficients, y)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jlong/Desktop/Github/bloqade-python/.venv/lib/python3.11/site-packages/braket/analog_hamiltonian_simulator/rydberg/rydberg_simulator_helpers.py", line 566, in _apply_hamiltonian
    output_register += (rabi_coef[index_time] / 2) * rabi_op.dot(input_register)
                        ~~~~~~~~~^^^^^^^^^^^^
IndexError: index 1000 is out of bounds for axis 0 with size 1000

Extension modules: pydantic.typing, pydantic.errors, pydantic.version, pydantic.utils, pydantic.class_validators, pydantic.config, pydantic.color, pydantic.datetime_parse, pydantic.validators, pydantic.networks, pydantic.types, pydantic.json, pydantic.error_wrappers, pydantic.fields, pydantic.parse, pydantic.schema, pydantic.main, pydantic.dataclasses, pydantic.annotated_types, pydantic.decorator, pydantic.env_settings, pydantic.tools, pydantic, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, scipy._lib._ccallback_c, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg._cythonized_array_utils, scipy.linalg._flinalg, scipy.linalg._solve_toeplitz, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_lapack, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._isolve._iterative, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.special._ellip_harm_2, scipy.integrate._odepack, scipy.integrate._quadpack, scipy.integrate._vode, scipy.integrate._dop, scipy.integrate._lsoda, scipy.optimize._minpack2, scipy.optimize._group_columns, scipy._lib.messagestream, scipy.optimize._trlib._trlib, numpy.linalg.lapack_lite, scipy.optimize._lbfgsb, _moduleTNC, scipy.optimize._moduleTNC, scipy.optimize._cobyla, scipy.optimize._slsqp, scipy.optimize._minpack, scipy.optimize._lsq.givens_elimination, scipy.optimize._zeros, scipy.optimize.__nnls, scipy.optimize._highs.cython.src._highs_wrapper, scipy.optimize._highs._highs_wrapper, scipy.optimize._highs.cython.src._highs_constants, scipy.optimize._highs._highs_constants, scipy.linalg._interpolative, scipy.optimize._bglu_dense, scipy.optimize._lsap, scipy.spatial._ckdtree, scipy.spatial._qhull, scipy.spatial._voronoi, scipy.spatial._distance_wrap, scipy.spatial._hausdorff, scipy.spatial.transform._rotation, scipy.optimize._direct (total: 98)
[1]    82110 abort      python whitepaper/bug-report.py

To reproduce
See above

Expected behavior
Successful execution of emulator

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: 1.43.0
  • Amazon Braket Python Schemas version: 1.17.0
  • Amazon Braket Python Default Simulator version:1.14.0.post0
  • Python version: 3.11.3

Support non-contiguous qubit indices

Describe the feature you'd like
The local simulator should support programs which use non-contiguous qubit indices, including cases where the qubit indices do not start from qubit 0.

Right now, the local simulator requires all qubits to be contiguous; in other words, an $n$-qubit circuit must use exactly the qubits $0, 1, \ldots n - 1$, without omitting any or including any additional qubits:

from braket.circuits import Circuit
from braket.devices import LocalSimulator

# Won't run
circuit = Circuit().h(2).cnot(2, 9)
LocalSimulator().run(circuit, shots=1000)

This constraint is unnecessary, and it would be worth modifying the default simulator implementation to allow arbitrary qubit indices, as in the above example.

How would this feature be used? Please describe.
This would allow users to test circuits on the local simulator before running them, unmodified, on a QPU. For example, without this feature, a circuit meant to run on a QPU with indices $2, 4, 7$ would first need to be modified to use qubits $0, 1, 2$ before it can be tested locally. This feature would also help prevent bugs that arise from translating qubit indices.

Describe alternatives you've considered
Qubits could be mapped manually, but this is unnecessarily complicated.

OpenQASM 3 integer literals should use integer division

Describe the bug
After some discussion here: Qiskit/qiskit#12167, it seems that the stdgates.inc definition gate sx a { pow(1/2) @ x a; } should have the 1/2 resolve to 0 thanks to integer division (i.e. stdgates.inc has an incorrect definition of sx gate). As it stands, it seems that when interpreting openQASM 3, the Braket sim treats these values as floats (which makes that sx gate definition behave correctly). Apparently the relevant part of the specification is here: https://openqasm.com/language/classical.html#integers.

Being as 'fixing' this would break stdgates.inc as of right now, I don't think it should be 'fixed' yet. I'm not even sure how closely Braket promises to follow the openQASM specification, so perhaps it's a non-issue.

To reproduce

from braket.circuits import Circuit
from braket.devices import LocalSimulator

device = LocalSimulator()
quantum_circuit = Circuit.from_ir('''
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
ry(1/2) q;
''')
quantum_circuit.probability()
res = device.run(quantum_circuit, 0)
print(res.result().values)

Expected behavior
The ry(1/2) should resolve to ry(0) here resulting in a 1.0 probability of q being 0. To use floating point division it would need to be 1.0 / 2, 1 / 2.0 or 1.0 / 2.0.

Screenshots or logs
Actual output: [array([0.93879128, 0.06120872])]

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: v1.74.0
  • Amazon Braket Python Schemas version:
  • Amazon Braket Python Default Simulator version:
  • Python version: Python 3.10.12

Additional context
N/A

Support for pydantic v2

Describe the feature you'd like
Support for at least one 2.X.X version of pydantic.

How would this feature be used? Please describe.
Adding support for pydantic v2 would allow us to upgrade orquestra-sdk to also use pydantic v2 and benefit from the improvements it offers.

The reason for this is that the orquestra-core metapackage depends on pydantic transitively through orquestra-sdk as well as amazon-braket-default-simulator and amazon-braket-schemas-python. So currently, upgrading orquestra-sdk to pydantic v2 would create a dependency conflict for orquestra-core.

Describe alternatives you've considered
Our current strategy is to continue using pydantic < 2.0.0.

Looser validation for Braket AHS local simulator.

Describe the feature you'd like
Relax validation on AHS local simulator. Currently the local simulator for AHS mode requries that all the driving fields have the same time-points for the input time series. This is not a restriction on QuEra's device which makes using the braket simulator to compare to Aquila a bit difficult. While merging the time points isn't really an issue for the simulator because there is no constraint on the the minimum time step in the time series, this is not the case on actual hardware. By merging the time points for each time series to fit the constraints of the simulator, you might create an invalid hardware task that violates the minimum time step constraint.

How would this feature be used? Please describe.
Instead of requiring the time series to have the same point, a simple solution would be to simply transform the AHS program to the valid form for the simulator. Here is a function that would be able to do this:

def merge_time_points(first_time_series: TimeSeries, second_time_series: TimeSeries) -> Tuple[TimeSeries, TimeSeries]:
    """Return new TimeSeries for the inputs by merging the time points from each series. 

    Args:
        first_time_series (TimeSeries): First time series to merge time points
        second_time_series (TimeSeries): Second time seroes to merge time points. 

    Returns:
        Tuple[TimeSeries, TimeSeries]: The new first and second time series with the merged time points respectively. 
        
    Note: This should be used with the Braket local simulator as it requires the time points for the driving fields to be the same. 
    """
    first_times = numpy.array(first_time_series.times(),dtype=object)
    second_times = numpy.array(second_time_series.times(),dtype=object)
    new_times = numpy.unique(numpy.hstack([first_times, second_times]))
    
    new_first_time_series = TimeSeries()
    new_second_time_series = TimeSeries()
    
    for time in new_times:
        new_first_time_series.put(time, get_time_series_value(first_time_series, time))
        new_second_time_series.put(time, get_time_series_value(second_time_series, time))  
        
    return new_first_time_series, new_second_time_series  

Describe alternatives you've considered
I have been using the above function to transform my AHS programs before submitting them to the local simulator.

NotImplementedError: Instruction targets=[0, 1] type=<Type.ecr: 'ecr'> not recognized

Describe the bug
The ECR gate does not work with LocalSimulator due to a NotImplementedError:

NotImplementedError: Instruction targets=[0, 1] type=<Type.ecr: 'ecr'> not recognized

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: amazon-braket-sdk==1.16.0
  • Amazon Braket Python Schemas version: amazon-braket-schemas==1.7.2
  • Amazon Braket Python Default Simulator version: amazon-braket-default-simulator==1.5.0
  • Python version: Python 3.9.7

Performance tests fail

Describe the bug
Performance Tests fail with the latest commit in main branch (commit 34c00c3)

To reproduce
Checkout latest commit 34c00c3 and run tox -e performance-tests: all tests fails

Expected behavior
On the other hand, older commit c723c8e passes all tests when you run tox -e performance-tests

Screenshots or logs

$ tox -e performance-tests
...
================================================================================================== FAILURES ==================================================================================================
____________________________________________________________________________________________ test_grcs_simulation ____________________________________________________________________________________________

benchmark = <pytest_benchmark.fixture.BenchmarkFixture object at 0x7f173dc6fdf0>
grcs_circuit_16 = Program(braketSchemaHeader=BraketSchemaHeader(name='braket.ir.jaqcd.program', version='1'), instructions=[H(target=0, ... type=<Type.h: 'h'>)], results=[StateVector(type=<Type.statevector: 'statevector'>)], basis_rotation_instructions=None)

    def test_grcs_simulation(benchmark, grcs_circuit_16):
        device = BaseLocalSimulator()
>       benchmark(device.run, grcs_circuit_16, 16, shots=0)

performance/test_performance.py:90: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../.tox/performance-tests/lib/python3.8/site-packages/pytest_benchmark/fixture.py:127: in __call__
    return self._raw(function_to_benchmark, *args, **kwargs)
../.tox/performance-tests/lib/python3.8/site-packages/pytest_benchmark/fixture.py:149: in _raw
    duration, iterations, loops_range = self._calibrate_timer(runner)
../.tox/performance-tests/lib/python3.8/site-packages/pytest_benchmark/fixture.py:277: in _calibrate_timer
    duration = runner(loops_range)
../.tox/performance-tests/lib/python3.8/site-packages/pytest_benchmark/fixture.py:92: in runner
    function_to_benchmark(*args, **kwargs)
../.tox/performance-tests/lib/python3.8/site-packages/braket/default_simulator/simulator.py:71: in run
    self._validate_ir_results_compatibility(circuit_ir)
../.tox/performance-tests/lib/python3.8/site-packages/braket/default_simulator/simulator.py:113: in _validate_ir_results_compatibility
    supported_result_types = self.properties.action[
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <braket.default_simulator.simulator.BaseLocalSimulator object at 0x7f173dc2d760>

    @property
    def properties(self) -> GateModelSimulatorDeviceCapabilities:
        """properties of simulator such as supported IR types, quantum operations,
        and result types.
        """
>       raise NotImplementedError("properties has not been implemented yet.")
E       NotImplementedError: properties has not been implemented yet.

../.tox/performance-tests/lib/python3.8/site-packages/braket/default_simulator/simulator.py:447: NotImplementedError
...
========================================================================================== short test summary info ===========================================================================================
FAILED performance/test_performance.py::test_grcs_simulation - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_qft[4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_qft[8] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_qft[12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_qft[16] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[2-4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[2-12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[2-20] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[6-4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[6-12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[6-20] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[10-4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[10-12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[10-20] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[14-4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[14-12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[14-20] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[18-4] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[18-12] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit[18-20] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit_result_types[results0] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit_result_types[results1] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit_result_types[results2] - NotImplementedError: properties has not been implemented yet.
FAILED performance/test_performance.py::test_layered_continuous_gates_circuit_result_types[results3] - NotImplementedError: properties has not been implemented yet.
============================================================================================= 24 failed in 3.44s =============================================================================================
ERROR: InvocationError for command /usr/bin/sh -c performance/compare_performance.sh (exited with code 1)
__________________________________________________________________________________________________ summary ___________________________________________________________________________________________________
ERROR:   performance-tests: commands failed

System information
A description of your system. Please provide:

  • Amazon Braket Python Default Simulator version: v1.2.1.dev0
  • Python version: 3.8.5

Using `rz` results in process being killed (OOM?)

Describe the bug
For a relatively low number of qubits, applying rz results in the process being killed. I can see from the source that rz has an exponential space requirement, but this seems too extreme; perhaps it's a symptom of something deeper.

To reproduce
NB I am running this on a macbook air with 8GB RAM - a beefier machine / different OS settings might breeze through 14 qubits.

from braket.circuits import Circuit
from braket.devices import LocalSimulator

device = LocalSimulator()
quantum_circuit = Circuit.from_ir('''
OPENQASM 3.0;
include "stdgates.inc";
qubit[14] r1;
rz(1) r1;
''')
quantum_circuit.probability()
res = device.run(quantum_circuit, 0)

Expected behavior
The program completes successfully.

Screenshots or logs
Here is the full output that I get:

This program uses OpenQASM language features that may not be supported on QPUs or on-demand simulators.
Killed

System information
A description of your system. Please provide:

  • Amazon Braket Python SDK version: v1.74.0
  • Amazon Braket Python Schemas version:
  • Amazon Braket Python Default Simulator version:
  • Python version: Python 3.10.12

Additional context
N/A

Numerical issue with the local AHS simulator

Describe the bug
Braket emulator crashes for a system of 10 atoms, with the error:
File "/usr/local/lib/python3.10/dist-packages/braket/analog_hamiltonian_simulator/rydberg/rydberg_simulator_helpers.py", line 566, in _apply_hamiltonian
output_register += (rabi_coef[index_time] / 2) * rabi_op.dot(input_register)
IndexError: index 400 is out of bounds for axis 0 with size 400

To Reproduce
execute attached demonstrator as-is.
https://bitbucket.org/balewski/quantummind/src/master/QuEra/python/issues/issue1_10atom_crash.py
It will crash in 5 seconds.

But if you reduce the number of atoms in line 74 to 9
nAtom=9
all works fine.

Expected behavior
program should simulate up to nAtom=16

System information (please complete the following information as applicable):
$ pip3 list |grep braket
amazon-braket-default-simulator 1.14.0
amazon-braket-schemas 1.17.0
amazon-braket-sdk 1.39.1

  • Working Environment: podman image running locally

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.