Skip to content

Handle empty ragged selections during compilation - #1327

Merged
aw471 merged 1 commit into
mainfrom
compile/varlen-empty-compaction
Nov 2, 2026
Merged

aw471 merged 1 commit into
mainfrom
compile/varlen-empty-compaction

Conversation

@aw471

@aw471 aw471 commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Handle empty ragged selections without reading a tensor length into Python. This removes a full-graph compilation failure in KumoTabular query preprocessing.

Description of the change

Numerical-only table groups still contain an empty text block. Estimator expansion selects that block; returning empty offsets and indices directly avoids unnecessary compaction.

Before: torch._dynamo.exc.UserError: Could not extract specialized integer from data-dependent expression u0 (unhinted: u0). (Size-like symbols: none) on PyTorch 2.14.1.

Validation

The minimal CPU reproducer fails on main and passes with this patch using actual Inductor on PyTorch 2.14.1. Empty int32/int64 metadata checks and fitted eight-estimator preprocessing checks passed on CPU/CUDA.

Combined with the other three predict fixes: pretrained KumoTabular large, default recipe, 8 estimators, 10k context / 512 queries, RTX PRO 6000, PyTorch 2.14.1+cu130 and FP16 autocast. Main and #1275 each passed three actual-Inductor fullgraph=True predictions with one graph, zero breaks/recompiles, and max probability error 1.47e-4 versus eager; predicted classes matched. This is correctness validation, not a performance benchmark.

Minimal reproducer
import torch
from sdm import EnsembleTable, TableTensor

group = TableTensor(numerical=torch.ones(4, 3, 2))
table = EnsembleTable([group], [(0, i) for i in (0, 1, 2, 3, 0, 1, 2, 3)])
with torch.inference_mode():
    torch.compile(lambda t: t.expanded_group(0), fullgraph=True)(table)

@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@aw471

aw471 commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

The author requested and pre-approved a full review of this PR.

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between b5c3641 and 6a036fe.

Files selected for processing: 1
  • sdm/tensor/var_len.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Empty range inputs are now handled gracefully, producing no indices and a zero offset. This avoids unnecessary processing for empty inputs and provides consistent output for downstream operations.

_compact now returns zero offsets and an empty index tensor when start is empty. Nonempty inputs continue through the existing compaction logic.

Changes: Empty-input compaction

Layer / File(s) Summary
Handle empty start tensors
sdm/tensor/var_len.py
For an empty start tensor, _compact returns a one-element zero offset tensor and an empty index tensor.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: Minimal · up to 6a036

The change is ready to merge; no remaining material risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: handling empty ragged selections during compilation.
Description check Passed The description directly explains the compilation failure, the empty-selection fix, and the validation performed.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.39%. Comparing base (b5c3641) to head (6a036fe).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1327   +/-   ##
=======================================
  Coverage   82.39%   82.39%           
=======================================
  Files         185      185           
  Lines       11773    11775    +2     
=======================================
+ Hits         9700     9702    +2     
  Misses       2073     2073           

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

@aw471
aw471 marked this pull request as ready for review November 2, 2026 23:13
@aw471
aw471 merged commit f6e7d23 into main Nov 2, 2026
7 checks passed
@aw471
aw471 deleted the compile/varlen-empty-compaction branch November 2, 2026 23:18
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.

1 participant