Skip to content

fix(architectures): keep the distribution-parameter axis in ensemble LSS models - #457

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/ensemble-lss-param-axis
Open

fix(architectures): keep the distribution-parameter axis in ensemble LSS models#457
ChrisW09 wants to merge 1 commit into
mainfrom
fix/ensemble-lss-param-axis

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #447

Problem

TabM and Trompt unconditionally squeeze(-1) their ensemble output. That is right for
single-output regression and binary classification — the trailing axis has size 1 and the ensemble loss
expects (B, E). But in LSS mode the trailing axis is the distribution-parameter axis, and for a
family with exactly one parameter it also has size 1, so it was deleted.

compute_loss then does predictions[:, ensemble_member], yielding a 1-D tensor that the distribution
indexes with [:, idx]:

IndexError: too many indices for tensor of dimension 1
  deeptab/distributions/poisson.py:29  predictions[:, self.param_names.index("rate")]

Reproduced for TabMLSS and TromptLSS with family in {poisson, tweedie, dirichlet, categorical}.
Multi-parameter families were unaffected because the squeeze was a no-op for them.

Shape proof: Trompt(..., num_classes=1) returned (5, 6) where num_classes=2 returned (5, 6, 2).

Fix

Skip the squeeze in LSS mode (self.hparams.lss, already threaded into every architecture by
TaskModel). For the multi-parameter families that already worked this changes nothing, since the
squeeze was a no-op there.

Tests

New tests/test_ensemble_lss.py: TabMLSS fits and predicts finitely for both poisson (1 param) and
normal (2 params), plus a direct shape assertion that the LSS ensemble output keeps its parameter
axis while the non-LSS one still collapses. Verified 2 of the 3 fail on main. tests/test_models.py
and tests/test_lss_base.py pass unchanged.

🤖 Generated with Claude Code

…LSS models

TabM and Trompt unconditionally squeeze the trailing axis of their
ensemble output. That is correct for single-output regression and binary
classification, where the axis has size 1 and the loss expects (B, E) --
but in LSS mode the trailing axis is the distribution-parameter axis. For
a family with exactly one parameter it also has size 1, so it was
deleted, and compute_loss's predictions[:, member] then produced a 1-D
tensor that the distribution indexed with [:, idx]:

    IndexError: too many indices for tensor of dimension 1

raised from deeptab/distributions/poisson.py:29 for TabMLSS/TromptLSS
with family in {poisson, tweedie, dirichlet, categorical}. Multi-parameter
families were unaffected because the squeeze was a no-op for them.

The squeeze is now skipped in LSS mode, which is a no-op for the families
that already worked.

Fixes #447

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

[BUG] Ensemble LSS models (TabM, Trompt) crash for every single-parameter distribution family

1 participant