Skip to content

Support multi-batch inputs in TFTExplainer - #3182

Open
mahimn01 wants to merge 1 commit into
unit8co:masterfrom
mahimn01:feature/tft-explainer-multi-batch
Open

mahimn01 wants to merge 1 commit into
unit8co:masterfrom
mahimn01:feature/tft-explainer-multi-batch

Conversation

@mahimn01

Copy link
Copy Markdown
Contributor

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #3171.

Summary

TFTExplainer.explain() can now handle more series than model.batch_size with one model.predict() call.

A temporary prediction callback collects the raw attention and variable selection tensors from each batch. The explainer combines them in prediction order before building the existing six outputs. Existing callbacks are preserved, and the temporary collector is removed and cleared on both success and failure.

Distributed prediction is rejected clearly because callback state is process local and cannot safely reconstruct globally ordered results without explicit cross-rank gathering.

Tests cover single and multiple batches, exact batch boundaries, a final partial batch, aligned covariates, the no static covariates case, callback coexistence and failure cleanup, incomplete prediction output, input ordering, and distributed rejection.

Other Information

Validated with all 58 TFT explainer tests and the full 172-test explainability suite under Python 3.11. Pre-commit also passes.

@mahimn01
mahimn01 requested a review from dennisbader as a code owner August 18, 2026 15:59
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.04%. Comparing base (3d4c9e7) to head (6a725d1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3182      +/-   ##
==========================================
- Coverage   97.11%   97.04%   -0.08%     
==========================================
  Files         167      167              
  Lines       18429    18477      +48     
==========================================
+ Hits        17898    17931      +33     
- Misses        531      546      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mahimn01

Copy link
Copy Markdown
Contributor Author

Hi Dennis, just following up on this when you have a chance. It implements the callback approach we discussed in #3171, and all the current checks are passing.

@mahimn01
mahimn01 force-pushed the feature/tft-explainer-multi-batch branch from 7793091 to 6a725d1 Compare September 5, 2026 00:58
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.

Allow TFTExplainer to explain more series than the model batch size

1 participant