-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy path01_test_gate.py
More file actions
51 lines (40 loc) · 1.08 KB
/
01_test_gate.py
File metadata and controls
51 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys
import os
import matplotlib.pyplot as plt
# Add the directory containing your module to Python's search path
module_path = ".."
sys.path.insert(0, module_path)
from tensorcircuit import Circuit, Param, gates, waveforms
from tensorcircuit.cloud.apis import submit_task, get_device, set_provider, set_token, list_devices, list_properties
import re
# from dotenv import load_dotenv
# load_dotenv()
shots_const = 1000
print("✅ TEST FILE LOADED")
set_token(os.getenv("TOKEN"))
set_provider("tencent")
ds = list_devices()
print(ds)
def gen_gate_circuit(t):
qc = Circuit(2)
qc.h(0)
qc.cnot(0, 1)
return qc
def run_circuit(qc):
device_name = "tianji_s2"
d = get_device(device_name)
t = submit_task(
circuit=qc,
shots=shots_const,
device=d,
enable_qos_gate_decomposition=False,
enable_qos_qubit_mapping=False,
)
# print(qc.to_tqasm())
# n = qc._nqubits
rf = t.results()
t.details(prettify=True)["backend"].draw(output="mpl")
return rf
qc = gen_gate_circuit(1.0)
result = run_circuit(qc)
print(result)