Skip to content

The guider rescale's 'unbiased vs biased std' comment names an error that cannot exist: the (n-1) cancels in the ratio #1050

Description

@localai-bot

src/vllm/model_executor/models/ltx2_pipeline.cpp:505-506, inside
Ltx2MultiModalGuidance's rescale branch:

// :268-271. torch's `std` is the UNBIASED (N-1) estimator by default; the
// biased one would be a small, everywhere, resolution-dependent gain error.
auto unbiased_std = [count](const float* buffer) { ... sqrt(sum_sq / (count - 1)); };
const float factor_raw = unbiased_std(cond) / unbiased_std(pred.data());

The stated consequence is mathematically impossible. factor_raw divides two
stds taken over the same count, so whichever divisor the estimator uses
cancels exactly:

sqrt(ss_c / (n-1)) / sqrt(ss_p / (n-1))  ==  sqrt(ss_c / ss_p)
sqrt(ss_c /  n   ) / sqrt(ss_p /  n   )  ==  sqrt(ss_c / ss_p)

There is no gain error, small or otherwise, and nothing about it is
resolution-dependent. The two forms differ only by f32 rounding in the divide.

The header repeats the claim at
include/vllm/model_executor/models/ltx2_pipeline.h:319-322.

Why this is worth a record and not just a typo. The comment tells the next
reader that a gate is needed here, and it is not. The fresh review of #1039
mutated the estimator to the biased form and it survived — correctly, because it
is an identity — and a survivor at that site would otherwise read as a blind
instrument and cost another investigation. The comment is the thing that has to
change; the code is right as written and should stay unbiased_std, because the
name is what mirrors torch even where the ratio does not care.

Pre-existing from cefacd2d0 (#641). Found while repairing the fresh review of
#1039 on PR #1032; out of scope there under that review's explicit exclusions,
and listed under ## Owed in .agents/specs/ltx25-t2a-one-stage.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions