Some checks failed
Build wheels / build (ubuntu-latest, 3.11) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.12) (push) Has been cancelled
Build wheels / build (ubuntu-latest, 3.13) (push) Has been cancelled
Tests / check (push) Has been cancelled
Tests / build (ubuntu-latest, 3.11) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.12) (push) Has been cancelled
Tests / build (ubuntu-latest, 3.13) (push) Has been cancelled
34 lines
1014 B
Python
34 lines
1014 B
Python
"""Example custom case for tools/run_tn_custom.py."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
|
|
import numpy as np
|
|
from qibo import Circuit, gates
|
|
|
|
|
|
def build_circuit(nqubits, nlayers, seed):
|
|
rng = np.random.default_rng(seed)
|
|
circuit = Circuit(nqubits)
|
|
for layer in range(nlayers):
|
|
for qubit in range(nqubits):
|
|
circuit.add(gates.RY(qubit, theta=rng.uniform(-math.pi, math.pi)))
|
|
circuit.add(gates.RZ(qubit, theta=rng.uniform(-math.pi, math.pi)))
|
|
for qubit in range(layer % 2, nqubits - 1, 2):
|
|
circuit.add(gates.RXX(qubit, qubit + 1, theta=rng.uniform(-0.7, 0.7)))
|
|
circuit.add(gates.RZZ(qubit, qubit + 1, theta=rng.uniform(-0.7, 0.7)))
|
|
return circuit
|
|
|
|
|
|
def build_observable(nqubits, seed):
|
|
return {
|
|
"terms": [
|
|
{
|
|
"coefficient": 1.0 / max(1, nqubits - 1),
|
|
"operators": [("Z", site), ("Z", site + 1)],
|
|
}
|
|
for site in range(nqubits - 1)
|
|
]
|
|
}
|