From 83e77dc31c8bc413a4e4c263581eb6b520bb4dc9 Mon Sep 17 00:00:00 2001 From: tankya2 Date: Wed, 31 Jan 2024 17:34:15 +0800 Subject: [PATCH] Update sample code [skip CI] --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/README.md b/README.md index 4628c1c..a1fea8d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,58 @@ Qibotn is the tensor-network translation module for Qibo to support large-scale simulation of quantum circuits and acceleration. To get started, `python setup.py install` to install the tools and dependencies. + +# Sample Codes +## Single Node + +
+```
+import numpy as np
+from qibo import Circuit, gates
+import qibo
+
+'''
+computation_settings = {
+    'MPI_enabled': False,
+    'MPS_enabled': False,
+    'NCCL_enabled': False,
+    'expectation_enabled': {
+        'pauli_string_pattern': "IXZ"
+    }
+}
+'''
+
+computation_settings = {
+    'MPI_enabled': False,
+    'MPS_enabled': {
+                "qr_method": False,
+                "svd_method": {
+                    "partition": "UV",
+                    "abs_cutoff": 1e-12,
+                },
+            } ,
+    'NCCL_enabled': False,
+    'expectation_enabled': False
+}
+
+# computation_settings = {
+#     'MPI_enabled': False,
+#     'MPS_enabled': True,
+#     'NCCL_enabled': False,
+#     'expectation_enabled': False
+# }
+
+qibo.set_backend(backend="qibotn", runcard=computation_settings)
+
+# Construct the circuit
+c = Circuit(2)
+# Add some gates
+c.add(gates.H(0))
+c.add(gates.H(1))
+
+# Execute the circuit and obtain the final state
+result = c()
+
+print(result.state())
+```
+
\ No newline at end of file