Global Phase#
from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register
from qualtran import QBit, QInt, QUInt, QAny
from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma
from typing import *
import numpy as np
import sympy
import cirq
GlobalPhase
#
Applies a global phase to the circuit as a whole.
The unitary effect is to multiply the state vector by the complex scalar
\(e^{i pi t}\) for exponent
\(t\).
The global phase of a state or circuit does not affect any observable quantity, but keeping track of it can be a useful bookkeeping mechanism for testing circuit identities. The global phase becomes important if the gate becomes controlled.
Parameters#
exponent
: the exponent \(t\) of the global phase \(e^{i pi t}\) to apply.eps
: precision
from qualtran.bloqs.basic_gates import GlobalPhase
Example Instances#
global_phase = GlobalPhase(exponent=0.5)
Graphical Signature#
from qualtran.drawing import show_bloqs
show_bloqs([global_phase],
['`global_phase`'])
Call Graph#
from qualtran.resource_counting.generalizers import ignore_split_join
global_phase_g, global_phase_sigma = global_phase.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(global_phase_g)
show_counts_sigma(global_phase_sigma)
Counts totals:
GPhase((6.123233995736766e-17+1j))
: 1
Tensors and Controlled#
The “tensor” of the global phase gate is just a number.
global_phase.tensor_contract()
/usr/local/google/home/mpharrigan/qualtran/conda-311/lib/python3.11/site-packages/cotengra/hyperoptimizers/hyper.py:57: UserWarning: Couldn't find `optuna`, `cmaes`, `baytune (btb)`, `chocolate`, or `nevergrad` so will use completely random sampling in place of hyper-optimization.
warnings.warn(
/usr/local/google/home/mpharrigan/qualtran/conda-311/lib/python3.11/site-packages/cotengra/hyperoptimizers/hyper.py:76: UserWarning: Couldn't find `optuna`, `cmaes`, `baytune (btb)`, `chocolate`, or `nevergrad` so will use completely random sampling in place of hyper-optimization.
warnings.warn(
(6.123233995736766e-17+1j)
When a global phase is controlled, it is equivalent to a ZPowGate
cgp = global_phase.controlled()
print(repr(cgp))
print(cgp.tensor_contract())
ZPowGate(exponent=0.5, global_shift=0.0, eps=1e-11)
[[1.+0.j 0.+0.j]
[0.+0.j 0.+1.j]]