-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathtest_parametric_waveform.py
More file actions
59 lines (47 loc) · 1.91 KB
/
test_parametric_waveform.py
File metadata and controls
59 lines (47 loc) · 1.91 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
52
53
54
55
56
57
58
59
import sys
import os
# 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
import re
print("✅ TEST FILE LOADED")
set_token("xu1LTrkf0nP6sI8oh.bDPdk35RlOQZYy9hQPU6jK2J4d5AdINAOszCNPxTNGZ3-opBPhWcLcruYuSrvX8is1D9tKgw-O4Zg.Qf7fLp83AtSPP19jD6Na4piICkygomdfyxIjzhO6Zu-s5hgBu2709ZW=")
set_provider("tencent")
ds = list_devices()
print(ds)
def test_parametric_waveform():
qc = Circuit(2)
param0 = Param("a")
param1 = Param("b")
builder = qc.calibrate("my_gate", [param0, param1])
builder.new_frame("f0", param0)
builder.play("f0", waveforms.CosineDrag(10, 0.2, "0.5*PI", 0.01))
builder.new_frame("f1", param1)
builder.play("f1", waveforms.CosineDrag(20, 0.01, "0", 0))
builder.build()
tqasm_code = qc.to_tqasm()
tqasm_code = tqasm_code + '\nmygate q[0], q[1]'
print(tqasm_code)
assert "TQASM 0.2;" in tqasm_code
assert "defcal my_gate a, b" in tqasm_code
assert "frame f0 = newframe(a);" in tqasm_code
assert "play(f0, cosine_drag(10, 0.2, 0.5*PI, 0.01));" in tqasm_code
assert "frame f1 = newframe(b);" in tqasm_code
assert "play(f1, cosine_drag(20, 0.01, 0, 0));" in tqasm_code
assert re.search(r"defcal my_gate [^\)]* \s*\{", tqasm_code)
#tc.cloud.apis.set_token("xu1LTrkf0nP6sI8oh.bDPdk35RlOQZYy9hQPU6jK2J4d5AdINAOszCNPxTNGZ3-opBPhWcLcruYuSrvX8is1D9tKgw-O4Zg.Qf7fLp83AtSPP19jD6Na4piICkygomdfyxIjzhO6Zu-s5hgBu2709ZW=")
#tc.cloud.apis.set_provider("tencent")
device_name = "tianji_m2"
d = get_device(device_name)
t = submit_task(
circuit=qc,
shots=8192,
device=d,
enable_qos_gate_decomposition=False,
enable_qos_qubit_mapping=False,
)
rf = t.results()
print(rf)
test_parametric_waveform()