Skip to content

Commit c6233ab

Browse files
committed
error docs
1 parent 1037e70 commit c6233ab

File tree

6 files changed

+16
-285
lines changed

6 files changed

+16
-285
lines changed

docs/source/quickstart.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ For the Monte Carlo trajectory noise simulator, the unitary Kraus channel can be
470470
nmc = 10000
471471
random = K.implicit_randu(nmc)
472472
valuemc = K.mean(K.numpy(noisec_vmap(random)))
473-
(0.931+0j)
473+
# (0.931+0j)
474474
475475
476476
**Density Matrix Simulator:**
@@ -491,7 +491,7 @@ Density matrix simulator ``tc.DMCircuit`` simulates the noise in a full form, bu
491491
K = tc.set_backend("tensorflow")
492492
noisec_jit = K.jit(noisecircuitdm)
493493
valuedm = noisec_jit()
494-
(0.931+0j)
494+
# (0.931+0j)
495495
496496
497497
**Experiment with quantum errors:**
@@ -521,7 +521,7 @@ Readout error can be added in experiments for sampling and expectation value cal
521521
c = tc.Circuit(3)
522522
c.X(0)
523523
readout_error = []
524-
readout_error.append([0.9, 0.75]) # readout error of qubit 0
524+
readout_error.append([0.9, 0.75]) # readout error of qubit 0 p0|0=0.9, p1|1=0.75
525525
readout_error.append([0.4, 0.7]) # readout error of qubit 1
526526
readout_error.append([0.7, 0.9]) # readout error of qubit 2
527527
value = c.sample_expectation_ps(z=[0, 1, 2], readout_error=readout_error)
@@ -531,13 +531,12 @@ Readout error can be added in experiments for sampling and expectation value cal
531531
allow_state=True,
532532
readout_error=readout_error,
533533
random_generator=tc.backend.get_random_state(42),
534+
format_="sample_bin"
534535
)
535-
#[(<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 0, 0], dtype=int32)>,
536-
# <tf.Tensor: shape=(), dtype=float32, numpy=0.21000001>),
537-
#(<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 0, 0], dtype=int32)>,
538-
# <tf.Tensor: shape=(), dtype=float32, numpy=0.21000001>),
539-
#(<tf.Tensor: shape=(3,), dtype=int32, numpy=array([1, 0, 1], dtype=int32)>,
540-
# <tf.Tensor: shape=(), dtype=float32, numpy=0.09>)]
536+
# tf.Tensor(
537+
# [[1 0 0]
538+
# [1 0 0]
539+
# [1 0 1]], shape=(3, 3), dtype=int32)
541540
542541
543542
MPS and MPO

examples/noise.py

Lines changed: 0 additions & 208 deletions
This file was deleted.

examples/noise_calibration.py

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def mitigate_readout(nqubit, circ, readout_error):
7575
for s in bs:
7676
calmatrix[int(s, 2)][i] = bs[s] / shots
7777

78-
key = K.get_random_state(42)
78+
key, subkey = tc.backend.random_split(key)
79+
key = subkey
7980
bs = circ.sample(
8081
batch=shots, allow_state=True, format_="count_dict_bin", random_generator=key
8182
)
@@ -226,66 +227,3 @@ def example_T2_cali():
226227
example_readout_mitigate()
227228
example_T1_cali()
228229
example_T2_cali()
229-
230-
231-
c = tc.Circuit(3)
232-
c.X(0)
233-
readout_error = []
234-
readout_error.append([0.9, 0.75]) # readout error of qubit 0
235-
readout_error.append([0.4, 0.7]) # readout error of qubit 1
236-
readout_error.append([0.7, 0.9]) # readout error of qubit 2
237-
value = c.sample_expectation_ps(z=[0, 1, 2], readout_error=readout_error)
238-
instance = c.sample(allow_state=True, readout_error=readout_error)
239-
instances = c.sample(
240-
batch=3,
241-
allow_state=True,
242-
readout_error=readout_error,
243-
random_generator=tc.backend.get_random_state(42),
244-
)
245-
246-
c = tc.Circuit(1)
247-
c.x(0)
248-
c.thermalrelaxation(
249-
0, t1=300, t2=400, time=1000, method="ByChoi", excitedstatepopulation=0
250-
)
251-
c.generaldepolarizing(0, p=0.01, num_qubits=1)
252-
c.phasedamping(0, gamma=0.2)
253-
c.amplitudedamping(0, gamma=0.25, p=0.2)
254-
c.reset(0)
255-
c.expectation_ps(z=[0])
256-
257-
258-
def noisecircuit(random):
259-
c = tc.Circuit(1)
260-
c.x(0)
261-
c.thermalrelaxation(
262-
0,
263-
t1=300,
264-
t2=400,
265-
time=1000,
266-
method="ByChoi",
267-
excitedstatepopulation=0,
268-
status=random,
269-
)
270-
return c.expectation_ps(z=[0])
271-
272-
273-
K = tc.set_backend("tensorflow")
274-
noisec_vmap = K.jit(K.vmap(noisecircuit, vectorized_argnums=0))
275-
nmc = 10000
276-
random = K.implicit_randu(nmc)
277-
valuemc = K.mean(K.numpy(noisec_vmap(random)))
278-
279-
280-
def noisecircuitdm():
281-
dmc = tc.DMCircuit(1)
282-
dmc.x(0)
283-
dmc.thermalrelaxation(
284-
0, t1=300, t2=400, time=1000, method="ByChoi", excitedstatepopulation=0
285-
)
286-
return dmc.expectation_ps(z=[0])
287-
288-
289-
K = tc.set_backend("tensorflow")
290-
noisec_jit = K.jit(noisecircuitdm)
291-
valuedm = noisec_jit()

mypy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
python_version = 3.8
33
ignore_missing_imports = True
44
strict = True
5-
warn_unused_ignores = True
5+
warn_unused_ignores = False
66
disallow_untyped_calls = False
77
local_partial_types = False
88
implicit_reexport = True
@@ -12,6 +12,7 @@ implicit_reexport = True
1212
;;only module level * works...
1313
ignore_errors = True
1414

15+
1516
[mypy-cirq.*]
1617
ignore_errors = True
1718

tensorcircuit/applications/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def color_svg(circuit: cirq.Circuit, *coords: Tuple[int, int]) -> Any:
352352
from cirq.contrib.svg import SVGCircuit
353353

354354
svg_str = SVGCircuit(circuit)._repr_svg_()
355-
DOMTree = xml.dom.minidom.parseString(svg_str)
355+
DOMTree = xml.dom.minidom.parseString(svg_str) # type: ignore
356356
xpos = []
357357
ypos = []
358358
for r in DOMTree.getElementsByTagName("rect"): # [0].setAttribute("fill", "gray")

tests/test_channels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ def mitigate_readout(nqubit, circ, readout_error):
323323
for s in bs:
324324
calmatrix[int(s, 2)][i] = bs[s] / shots
325325

326-
key = tc.backend.get_random_state(42)
326+
key, subkey = tc.backend.random_split(key)
327+
key = subkey
327328
bs = circ.sample(
328329
batch=shots, allow_state=True, format_="count_dict_bin", random_generator=key
329330
)
@@ -360,7 +361,7 @@ def test_readout_mitigate(backend):
360361
c.X(2)
361362

362363
readout_error = []
363-
readout_error.append([0.9, 0.75]) # readout error of qubit 0
364+
readout_error.append([0.9, 0.75]) # readout error of qubit 0, p0|0=0.9, p1|1=0.75
364365
readout_error.append([0.4, 0.7]) # readout error of qubit 1
365366
readout_error.append([0.7, 0.9]) # readout error of qubit 2
366367

0 commit comments

Comments
 (0)