Skip to content

fix(model): guard prediction against empty tiles#58

Open
EliHei2 wants to merge 1 commit into
mainfrom
bugfix/empty-tile-guards
Open

fix(model): guard prediction against empty tiles#58
EliHei2 wants to merge 1 commit into
mainfrom
bugfix/empty-tile-guards

Conversation

@EliHei2

@EliHei2 EliHei2 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Two robustness fixes that surface on sparse/empty tiles (common at scale, e.g. MERSCOPE):

  • LitISTEncoder.predict_step: scatter_max returns -1 for transcripts with no candidate boundary; main only checked max_idx < dst.shape[0] so a -1 was treated as valid and indexed wrongly. Add the max_idx >= 0 guard.
  • Positional2dEmbedder.forward: return zeros for empty pos/batch instead of crashing on min/max over an empty tensor; cast batch to long.

What to review: the one-line valid guard in lightning_model.py and the two empty-tensor early-returns in ist_encoder.py. No behavior change on non-empty input.

Two robustness fixes that surface on sparse/empty tiles (common at scale, e.g.
MERSCOPE):
- LitISTEncoder.predict_step: scatter_max returns -1 for transcripts with no
  candidate boundary; main only checked `max_idx < dst.shape[0]` so a -1 was
  treated as valid and indexed wrongly. Add the `max_idx >= 0` guard.
- Positional2dEmbedder.forward: return zeros for empty `pos`/`batch` instead of
  crashing on min/max over an empty tensor; cast batch to long.

What to review: the one-line `valid` guard in lightning_model.py and the two
empty-tensor early-returns in ist_encoder.py. No behavior change on non-empty input.
@Tobiaspk

Tobiaspk commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

I'm not too familiar with this part of the code base. Would loop in @andrewmoorman for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants