flashinfer.comm._ulysses_lowp.finalize_stats¶
- flashinfer.comm._ulysses_lowp.finalize_stats(gathered: Tensor, ctx: StatsContext, k: Tensor, *, enable_pdl: bool | None = None) V2GStats¶
Turn the gathered statistics into final quantization inputs.
gatheredis the AllGather oflocal_statssends, rank-major ([world_size * N]or[world_size, N]fp32);kis the same local K shard passed tolocal_stats(protocol 2 computes its grouped amax here, after the global mean exists). The K mean divides by the LIVE row count (used_sequence): tail padding contributes exactly 0 to the gathered sum, so dividing by the padded length would bias the mean toward zero; with no padding the two are equal. Reductions run in fixed rank-major layout (sum(dim=0)/amax(dim=0)), so results are bit-identical on every rank.- Parameters:
gathered – AllGather output in group-rank order, FP32
[world_size, N]or flattened, where N is the local stats send size.ctx – Context returned by
local_statson this rank.k – The same local BF16/FP16 K shard used for
local_stats.enable_pdl – Whether to enable Programmatic Dependent Launch.
Noneselects according to device support.
- Returns:
V2GStatswith global mean, scales, finalized Q/K maxima and shard geometry.