fix: restore h3_repr_steering's clone -- out can alias the block loop's own tensor
Adversarial review round 1 caught this: out is not provably this hook's own private tensor. A chained h3_block_repeat span_loop passthrough returns args["img"] verbatim with no copy for non-head blocks in its span, and h3_repr_steering installs as the OUTER wrapper around it (_install_block_ influence then _install_h3_repr_steering in _sample_chunk) -- so `out` here can be the H3 model loop's own live `h`. Removing the clone entirely (as the previous commit did) reintroduced exactly the aliasing hazard block_repeat's own _repeat() explicitly guards against one function away. Restored the clone, kept unconditional (not gated behind the safe/unsafe branch) so it still doesn't need the host sync this fix exists to remove. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
f5729a96df
commit
7598769ac7
@@ -6943,6 +6943,14 @@ class FunPackLTXAVSceneChainSampler:
|
||||
bump = (direction.to(out.dtype).to(out.device)
|
||||
* _strength * row_norm.to(out.dtype))
|
||||
safe = torch.isfinite(row_norm) & (row_norm > 0)
|
||||
# Clone unconditionally (not gated behind the safe/unsafe check --
|
||||
# that would need the exact host sync this rewrite exists to avoid).
|
||||
# `out` is NOT provably this hook's own private tensor: a chained
|
||||
# span_loop passthrough (samplers.py's block-repeat span mode)
|
||||
# returns args["img"] verbatim with no copy, which can be the H3
|
||||
# model loop's own live `h` -- mutating it in place would corrupt
|
||||
# that loop's state for any block this hook shares with span_loop.
|
||||
out = out.clone()
|
||||
out[mask] = torch.where(safe, rows + bump.to(rows.dtype), rows)
|
||||
return {"img": out}
|
||||
return _tag_dit_hook(_hook, inner)
|
||||
|
||||
Reference in New Issue
Block a user