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
Copy link
Copy Markdown
Collaborator

@EliHei2 EliHei2 commented Jun 1, 2026

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.
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.

2 participants