Commit Graph
4 Commits
Author SHA1 Message Date
alisson-anjosandClaude Opus 5 0a25538692 Do the layout maths in float, not in the coordinate dtype (1.29.3)
ComfyUI's pixel coords are int64 -- latent corners multiplied by integer VAE scale factors --
while centring a reference on the target's height and taking a clip midpoint are half-pixel
operations. Adding a float shift into a Long tensor in place raises "result type Float can't
be cast to the desired output type Long", which is where the sidecar layout landed next.

_apply_tass_layout now promotes both coordinate tensors to float32 for the shift and rounds
back to the caller's dtype on the way out. Rounding matters: the caller casts the reference
coords to the target grid's dtype when concatenating, and a cast truncates where rounding is
what a half-pixel centre wants.

The earlier tests missed this because they built float tensors -- test_tass_layout now runs
every layout on int64 input and checks both the dtype and that the result stays within half
a pixel of the float placement.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGYHCVjHe6acihEpCRyn1K
2026-08-23 17:01:25 +00:00
alisson-anjosandClaude Opus 5 268f00c1a7 Place the sidecar reference correctly on 2.3 as well (1.29.2)
1.29.1 stopped the crash but only got the placement right on 2.5. The temporal span the
trainer writes -- bounds = (t_min, t_max) of the target clip -- is collapsed to one number
per token by the model, and the two LTX generations do it differently:

  use_middle_indices_grid=True   (2.5, and any checkpoint whose metadata declares it)
                                 -> (start + end) / 2, i.e. the middle of the clip
  use_middle_indices_grid=False  (2.3 checkpoints that predate the flag)
                                 -> the start bound alone, i.e. frame zero

So the same bounds mean "centre of the clip" on 2.5 and "pinned to frame 0" on 2.3 -- one
LoRA, two placements, and the 2.3 one is exactly the single-instant conditioning sidecar
exists to avoid. The layout now takes the model's own flag (read off the transformer in
_process_input) and writes the midpoint into both bounds when the model reads the start,
which lands the reference in the same place under either rule. Legacy [B, 3, N] coordinates
get the midpoint for the same reason.

Verified by collapsing the coordinates the way generate_freqs does and measuring the
reference against the target in the same frame: 2.5 is bit-identical to the trainer, and
2.3 matches to within half a patch (the coordinate convention's own offset, which applies
to the target's tokens equally).

tests/test_tass_layout.py covers both shapes, both collapse rules, the batch-1 reference vs
batch-2 target that crashed, the margin, and that patch spans are translated rather than
squeezed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGYHCVjHe6acihEpCRyn1K
2026-08-23 16:53:16 +00:00
alisson-anjos 3d4796684b Use standard zero reference offset by default 2026-08-14 10:48:37 +00:00
alisson-anjos 22d52d8e70 Add reference-only temporal offset controls 2026-08-14 10:41:06 +00:00