BufferUnweighter

class madspace.BufferUnweighter(self: madspace._madspace_py.BufferUnweighter, types: madspace._madspace_py.NamedTypes, quantile: SupportsFloat = 0.0)

Bases: FunctionGenerator

Partial unweighting of one batch, for the MadNIS replay buffer.

The maximum weight is the quantile quantile of |w| over the batch (so a fraction 1 - quantile of the events is over-weight). An event is kept with probability min(1, |w| / w_max) and gets the weight sign(w) * max(|w|, w_max): the sign of a negative weight (an interference) is kept, and the quantile is over |w| like the acceptance, so that a mostly negative batch is still unweighted. The adaptive_prob of a kept event, the density it was sampled with, is multiplied by its acceptance probability and by N / N_kept, so that training on the buffered events stays unbiased (Sec. 3.4.1 of [1]).

batch is the leading batch dimension.

Arguments

  • the tensors named in types (the first is the event weight, and one must be named adaptive_prob).

Returns

  • the tensors named in types, partially unweighted, with adaptive_prob rescaled.

References

Parameters:
  • types – The per-event tensors, the first being the weight.

  • quantile – Quantile of |w| taken as the maximum weight.