quantum-showcase/main.ipynb
2024-08-13 16:58:29 +04:00

8.2 KiB
Raw Blame History

In [1]:
from spinqit import get_basic_simulator, get_compiler, Circuit, BasicSimulatorConfig
from spinqit import H, CX, Rx
from math import pi

# Write the program
circ = Circuit()
q = circ.allocateQubits(2)
circ << (Rx, q[0], pi)
circ << (H, q[1])
circ << (CX, (q[0], q[1]))

# Choose the compiler and backend
comp = get_compiler("native")
engine = get_basic_simulator()

# Compile
optimization_level = 0
exe = comp.compile(circ, optimization_level)

# Run
config = BasicSimulatorConfig()
config.configure_shots(1024)
result = engine.execute(exe, config)

print(result.counts)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from spinqit import get_basic_simulator, get_compiler, Circuit, BasicSimulatorConfig
      2 from spinqit import H, CX, Rx
      3 from math import pi

File C:\tmp\quantum-showcase\.venv\lib\site-packages\spinqit\__init__.py:16
      1 # Copyright 2021 SpinQ Technology Co., Ltd.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     15 from .model import *
---> 16 from .backend import *
     17 from .compiler import get_compiler
     18 from .primitive import *

File C:\tmp\quantum-showcase\.venv\lib\site-packages\spinqit\backend\__init__.py:15
      1 # Copyright 2021 SpinQ Technology Co., Ltd.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from .backend import *
     16 from .basic_simulator_backend import BasicSimulatorConfig
     17 from .nmr_backend import NMRConfig

File C:\tmp\quantum-showcase\.venv\lib\site-packages\spinqit\backend\backend.py:15
      1 # Copyright 2022 SpinQ Technology Co., Ltd.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 from spinqit.model.exceptions import InappropriateBackendError
---> 15 from .basic_simulator_backend import BasicSimulatorBackend
     16 from .nmr_backend import NMRBackend
     17 from .spinq_cloud_backend import SpinQCloudBackend

File C:\tmp\quantum-showcase\.venv\lib\site-packages\spinqit\backend\basic_simulator_backend.py:26
     24 from spinqit.model import Instruction
     25 from spinqit.model import I, H, X, Y, Z, Rx, Ry, Rz, T, Td, S, Sd, P, CX, CY, CZ, SWAP, CCX, U
---> 26 from spinqit.spinq_backends import BasicSimulator
     28 from spinqit.model.parameter import Parameter, LazyParameter
     29 from .basebackend import BaseBackend

ImportError: DLL load failed while importing spinq_backends: Не найден указанный модуль.
In [ ]: