From 7598769ac79dee6960f81bf03b30e68bfcfaeb12 Mon Sep 17 00:00:00 2001 From: digital-garbage <133010426+digital-garbage@users.noreply.github.com> Date: Sat, 19 Sep 2026 18:42:05 +0300 Subject: [PATCH] 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 --- samplers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samplers.py b/samplers.py index c63f27d3..2ac54c25 100644 --- a/samplers.py +++ b/samplers.py @@ -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)