PCVL 1267 EMT - Dectector loss balancing - #772
Conversation
| ) | ||
| valid.warned = True | ||
| return res | ||
| valid.warned = False |
There was a problem hiding this comment.
Giving attributes to functions can be misleading and error-prone, you can use a bool defined outside this method
|
|
||
| def extend_computation(self, computation: Computation, noise: NoiseModel) -> list[Computation]: | ||
| comp = deepcopy(computation) | ||
| comp.command = "probs" |
| return math.prod([(1 / ratios[k.photon2mode(i)]) for i in range(k.n)], start = v) | ||
|
|
||
| res = copy(results[0]) # We are going to modify this to keep custom fields as much as we can | ||
| assert len(ratios) == computation.experiment.m, "Loss ratios do not match the distribution lengths." |
There was a problem hiding this comment.
Already done in self._validate_ratios()
|
|
||
| class DetectorBalancing(AbstractMitigation): | ||
|
|
||
| APPLY_MIN_PHOTONS = True |
There was a problem hiding this comment.
Since we don't remove the heralds, postselection and min_photons_filter, we can set these to False
| def test_recombination(): | ||
| expected, sub_results = prepare_test() | ||
| noise = NoiseModel() | ||
| noise.loss_ratios = [1., 1.] |
There was a problem hiding this comment.
We'll need to decide where to put this
| return math.prod([(1 / ratios[k.photon2mode(i)]) for i in range(k.n)], start = v) | ||
| ratios = noise.loss_ratios | ||
| if len(ratios) < computation.experiment.m: | ||
| warnings.warn( |
| if values: | ||
| valids = [math.isfinite(v) and v > 0. for v in values] | ||
| if not all(valids): | ||
| warnings.warn( |
| RuntimeWarning, | ||
| ) | ||
| self._loss_ratios = [ v if valid else 1. for v, valid in zip(values, valids) ] | ||
| #TODO: divide by max(valid_ratios) ? |
There was a problem hiding this comment.
Yes, but this should be done before replacing invalid values by 1
There was a problem hiding this comment.
We need precise specs on this.
Setting [ .1, .1 ], I'd imagined that modes 0 and 1 have 90% loss and other modes are perfect
The "median scaled to 100%" thing seems specific to perf <-> noise methods
There was a problem hiding this comment.
Yes, you're right
In that case, something here should ensure that the values are not greater than 1
| # Note: we do not know if it behaves correctly with Feef-Forward | ||
|
|
||
| APPLY_MIN_PHOTONS = False | ||
| APPLY_LOGICAL_SELECTION = True |
There was a problem hiding this comment.
Since we don't change the states, this can also be set to False
No description provided.