tyxonq 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. tyxonq/__init__.py +70 -0
  2. tyxonq/about.py +119 -0
  3. tyxonq/abstractcircuit.py +1286 -0
  4. tyxonq/applications/__init__.py +5 -0
  5. tyxonq/applications/ai/__init__.py +0 -0
  6. tyxonq/applications/ai/ensemble.py +163 -0
  7. tyxonq/applications/dqas.py +973 -0
  8. tyxonq/applications/finance/__init__.py +0 -0
  9. tyxonq/applications/finance/portfolio.py +89 -0
  10. tyxonq/applications/graphdata.py +481 -0
  11. tyxonq/applications/layers.py +519 -0
  12. tyxonq/applications/optimization.py +364 -0
  13. tyxonq/applications/physics/__init__.py +0 -0
  14. tyxonq/applications/physics/baseline.py +57 -0
  15. tyxonq/applications/physics/fss.py +110 -0
  16. tyxonq/applications/utils.py +443 -0
  17. tyxonq/applications/vags.py +1183 -0
  18. tyxonq/applications/van.py +404 -0
  19. tyxonq/applications/vqes.py +677 -0
  20. tyxonq/asciiart.py +267 -0
  21. tyxonq/backends/__init__.py +2 -0
  22. tyxonq/backends/abstract_backend.py +1767 -0
  23. tyxonq/backends/backend_factory.py +59 -0
  24. tyxonq/backends/cupy_backend.py +486 -0
  25. tyxonq/backends/jax_backend.py +783 -0
  26. tyxonq/backends/jax_ops.py +176 -0
  27. tyxonq/backends/numpy_backend.py +447 -0
  28. tyxonq/backends/pytorch_backend.py +711 -0
  29. tyxonq/backends/pytorch_ops.py +116 -0
  30. tyxonq/backends/tensorflow_backend.py +1014 -0
  31. tyxonq/backends/tf_ops.py +103 -0
  32. tyxonq/basecircuit.py +987 -0
  33. tyxonq/channels.py +996 -0
  34. tyxonq/circuit.py +1000 -0
  35. tyxonq/cloud/__init__.py +5 -0
  36. tyxonq/cloud/abstraction.py +472 -0
  37. tyxonq/cloud/apis.py +525 -0
  38. tyxonq/cloud/config.py +8 -0
  39. tyxonq/cloud/local.py +75 -0
  40. tyxonq/cloud/tyxonq_provider.py +405 -0
  41. tyxonq/cloud/utils.py +121 -0
  42. tyxonq/cloud/wrapper.py +321 -0
  43. tyxonq/compiler/__init__.py +8 -0
  44. tyxonq/compiler/composed_compiler.py +84 -0
  45. tyxonq/compiler/qiskit_compiler.py +191 -0
  46. tyxonq/compiler/simple_compiler.py +311 -0
  47. tyxonq/cons.py +900 -0
  48. tyxonq/densitymatrix.py +383 -0
  49. tyxonq/experimental.py +527 -0
  50. tyxonq/fgs.py +931 -0
  51. tyxonq/gates.py +985 -0
  52. tyxonq/interfaces/__init__.py +17 -0
  53. tyxonq/interfaces/jax.py +189 -0
  54. tyxonq/interfaces/numpy.py +61 -0
  55. tyxonq/interfaces/scipy.py +106 -0
  56. tyxonq/interfaces/tensorflow.py +126 -0
  57. tyxonq/interfaces/tensortrans.py +308 -0
  58. tyxonq/interfaces/torch.py +165 -0
  59. tyxonq/keras.py +291 -0
  60. tyxonq/mps_base.py +390 -0
  61. tyxonq/mpscircuit.py +982 -0
  62. tyxonq/noisemodel.py +356 -0
  63. tyxonq/quantum.py +2459 -0
  64. tyxonq/results/__init__.py +4 -0
  65. tyxonq/results/counts.py +124 -0
  66. tyxonq/results/qem/__init__.py +14 -0
  67. tyxonq/results/qem/benchmark_circuits.py +107 -0
  68. tyxonq/results/qem/qem_methods.py +383 -0
  69. tyxonq/results/readout_mitigation.py +836 -0
  70. tyxonq/shadows.py +485 -0
  71. tyxonq/simplify.py +283 -0
  72. tyxonq/templates/__init__.py +9 -0
  73. tyxonq/templates/ansatz.py +93 -0
  74. tyxonq/templates/blocks.py +203 -0
  75. tyxonq/templates/chems.py +7 -0
  76. tyxonq/templates/conversions.py +94 -0
  77. tyxonq/templates/dataset.py +71 -0
  78. tyxonq/templates/graphs.py +147 -0
  79. tyxonq/templates/measurements.py +335 -0
  80. tyxonq/torchnn.py +138 -0
  81. tyxonq/translation.py +778 -0
  82. tyxonq/utils.py +232 -0
  83. tyxonq/vis.py +337 -0
  84. tyxonq-0.1.1.dist-info/METADATA +312 -0
  85. tyxonq-0.1.1.dist-info/RECORD +88 -0
  86. tyxonq-0.1.1.dist-info/WHEEL +5 -0
  87. tyxonq-0.1.1.dist-info/licenses/LICENSE +61 -0
  88. tyxonq-0.1.1.dist-info/top_level.txt +1 -0
tyxonq/__init__.py ADDED
@@ -0,0 +1,70 @@
1
+ __version__ = "0.1.1"
2
+ __author__ = "TensorCircuit Authors"
3
+ __creator__ = "refraction-ray"
4
+
5
+ from .utils import gpu_memory_share
6
+
7
+ gpu_memory_share()
8
+
9
+ from .about import about
10
+ from .cons import (
11
+ backend,
12
+ set_backend,
13
+ set_dtype,
14
+ set_contractor,
15
+ get_backend,
16
+ get_dtype,
17
+ get_contractor,
18
+ set_function_backend,
19
+ set_function_dtype,
20
+ set_function_contractor,
21
+ runtime_backend,
22
+ runtime_dtype,
23
+ runtime_contractor,
24
+ ) # prerun of set hooks
25
+ from . import gates
26
+ from . import basecircuit
27
+ from .gates import Gate
28
+ from .circuit import Circuit, expectation
29
+ from .mpscircuit import MPSCircuit
30
+ from .densitymatrix import DMCircuit as DMCircuit_reference
31
+ from .densitymatrix import DMCircuit2
32
+
33
+ DMCircuit = DMCircuit2 # compatibility issue to still expose DMCircuit2
34
+ from .gates import num_to_tensor, array_to_tensor
35
+ from .vis import qir2tex, render_pdf
36
+ from . import interfaces
37
+ from . import templates
38
+ from . import results
39
+ from . import quantum
40
+ from .quantum import QuOperator, QuVector, QuAdjointVector, QuScalar
41
+ from . import compiler
42
+ from . import cloud
43
+ from . import fgs
44
+ from .fgs import FGSSimulator
45
+
46
+ try:
47
+ from . import keras
48
+ from .keras import KerasLayer, KerasHardwareLayer
49
+ except ModuleNotFoundError:
50
+ pass # in case tf is not installed
51
+
52
+ try:
53
+ from . import torchnn
54
+ from .torchnn import TorchLayer, TorchHardwareLayer
55
+ except ModuleNotFoundError:
56
+ pass # in case torch is not installed
57
+
58
+ try:
59
+ import qiskit
60
+
61
+ qiskit.QuantumCircuit.cnot = qiskit.QuantumCircuit.cx
62
+ qiskit.QuantumCircuit.toffoli = qiskit.QuantumCircuit.ccx
63
+ qiskit.QuantumCircuit.fredkin = qiskit.QuantumCircuit.cswap
64
+
65
+ # amazing qiskit 1.0 nonsense...
66
+ except ModuleNotFoundError:
67
+ pass
68
+
69
+ # just for fun
70
+ from .asciiart import set_ascii
tyxonq/about.py ADDED
@@ -0,0 +1,119 @@
1
+ """
2
+ Prints the information for tyxonq installation and environment.
3
+ """
4
+
5
+ import platform
6
+ import sys
7
+ import numpy
8
+
9
+
10
+ def about() -> None:
11
+ """
12
+ Prints the information for tyxonq installation and environment.
13
+ """
14
+ print(f"OS info: {platform.platform(aliased=True)}")
15
+ print(
16
+ f"Python version: {sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"
17
+ )
18
+ print(f"Numpy version: {numpy.__version__}")
19
+
20
+ try:
21
+ import scipy
22
+
23
+ print(f"Scipy version: {scipy.__version__}")
24
+ except ModuleNotFoundError:
25
+ print(f"Scipy is not installed")
26
+
27
+ try:
28
+ import pandas
29
+
30
+ print(f"Pandas version: {pandas.__version__}")
31
+ except ModuleNotFoundError:
32
+ print(f"Pandas is not installed")
33
+
34
+ try:
35
+ import tensornetwork as tn
36
+
37
+ print(f"TensorNetwork version: {tn.__version__}")
38
+ except ModuleNotFoundError:
39
+ print(f"TensorNetwork is not installed")
40
+
41
+ try:
42
+ import cotengra
43
+
44
+ try:
45
+ print(f"Cotengra version: {cotengra.__version__}")
46
+ except AttributeError:
47
+ print(f"Cotengra: installed")
48
+ except ModuleNotFoundError:
49
+ print(f"Cotengra is not installed")
50
+
51
+ try:
52
+ import tensorflow as tf
53
+
54
+ print(f"TensorFlow version: {tf.__version__}")
55
+ print(f"TensorFlow GPU: {tf.config.list_physical_devices('GPU')}")
56
+ print(f"TensorFlow CUDA infos: {dict(tf.sysconfig.get_build_info())}")
57
+ except ModuleNotFoundError:
58
+ print(f"TensorFlow is not installed")
59
+
60
+ try:
61
+ import jax
62
+
63
+ print(f"Jax version: {jax.__version__}")
64
+ try:
65
+ device = jax.devices("gpu")
66
+ print(f"Jax GPU: {device}")
67
+ except RuntimeError:
68
+ print(f"Jax installation doesn't support GPU")
69
+ except ModuleNotFoundError:
70
+ print(f"Jax is not installed")
71
+
72
+ try:
73
+ import jaxlib
74
+
75
+ print(f"JaxLib version: {jaxlib.__version__}")
76
+ except ModuleNotFoundError:
77
+ print(f"JaxLib is not installed")
78
+
79
+ try:
80
+ import torch
81
+
82
+ print(f"PyTorch version: {torch.__version__}")
83
+ print(f"PyTorch GPU support: {torch.cuda.is_available()}")
84
+ print(
85
+ f"PyTorch GPUs: {[torch.cuda.device(i) for i in range(torch.cuda.device_count())]}"
86
+ )
87
+ if torch.version.cuda is not None:
88
+ print(f"Pytorch cuda version: {torch.version.cuda}")
89
+ except ModuleNotFoundError:
90
+ print(f"PyTorch is not installed")
91
+
92
+ try:
93
+ import cupy
94
+
95
+ print(f"Cupy version: {cupy.__version__}")
96
+ except ModuleNotFoundError:
97
+ print(f"Cupy is not installed")
98
+
99
+ try:
100
+ import qiskit
101
+
102
+ print(f"Qiskit version: {qiskit.__version__}")
103
+ except ModuleNotFoundError:
104
+ print(f"Qiskit is not installed")
105
+
106
+ try:
107
+ import cirq
108
+
109
+ print(f"Cirq version: {cirq.__version__}")
110
+ except ModuleNotFoundError:
111
+ print(f"Cirq is not installed")
112
+
113
+ from tyxonq import __version__
114
+
115
+ print(f"tyxonq version {__version__}")
116
+
117
+
118
+ if __name__ == "__main__":
119
+ about()