Qualtran
Qualtran copied to clipboard
Use rotation `eps` in `GateCounts`
fixes #1250
- Maintain a frequency table of
epsilonsfor rotation bloqs. - Epsilon is converted to a string (the dictionary key) using
np.format_float_scientific, with a default precision of10digits. - T-costs:
- Direct synthesis:
1.149 * log2(1.0 / eps) + 9.2from https://arxiv.org/abs/1404.5320 - Beverland et. al. model: passes the number of rotations, ignoring their epsilons.
- Direct synthesis:
we had discussed binning by ceil(log(eps)) -- can you comment on that
@tanujkhattar's comment:
It's better to store frequency of
epsby assuming we can represent floatepsas a fractionx / 2^{precision}and store frequencies ofx; withprecisionas a configurable parameter in the constructor ofQECGateCountclass. It's also fine to store frequency ofepsdirectly for now and make this change as a future improvement. I'd advice against storing frequency ofceil(log2(1/eps))since it's a very aggressive approximation.
Binning by the above integer approximation can be implemented.
My bigger concern is the various epsilons floating around:
bloq.epsfor rotation bloqserror_budgetin the surface code costing functions
Should we remove this error_budget and only use bloq.eps? I am not familiar enough with the surface_code implementation to decide if this is correct.
Certain physical cost functions make certain assumptions, and we've tried to implement them as described in the literature. The coupling between the logical costs and the physical cost models is done -- in this case -- via the methods on GateCounts. So, since the beverland physical cost model just counts "rotations" and gives one third of the total error budget to synthesizing them, the get_beverland_counts method should just return the number of rotations in the appropriate field. The gidney-fowler models consume get_total_t_and_ccz_counts, which can use the per-gate epsilon values to turn it into t and ccz counts
@mpharrigan ptal!
taking a look now. Can you update the original PR description with a summary of changes in this pr
The code snippet I was trying to use (which works with this PR):
import sympy
from qualtran.bloqs.basic_gates import ZPowGate
from qualtran.resource_counting import get_cost_value, QECGatesCost
t, eps = sympy.symbols(r"t \epsilon")
bloq = ZPowGate(exponent=t, eps=eps)
costs = get_cost_value(bloq, QECGatesCost())
costs.total_t_count()
Thinking more about this, I think we'll need a special data container for the binned rotations that enforces the invariants we want to enforce. It's too dangerous to have our public data member be a dictionary whose keys are supposed to be strings crafted in a very particular way. (There's a secondary issue that a dictionary is mutable and therefore not compatible with the frozen GateCounts class)