Skip to content

Commit 22d731e

Browse files
coderabbitai[bot]aaronzoaw471rusty1s
authored
Add behavioral tests for the NanoTabICL guide examples (#1237)
# Summary Add regression coverage for the executable NanoTabICL guide examples and their model components. # Description of the change Execute the guide's Python blocks directly to keep tests aligned with the published examples. Cover context and query isolation, permutation behavior, readout shapes, both context-label injection stages, invalid labels, empty queries, and feature-grouping offsets, wraparound, projection, and input dimensions. Parameterize forward checks across float32 and float64 with CPU and CUDA coverage, and initialize attention outputs so behavioral checks exercise attention. # Validation Validation was not run; changes were inspected only. [View coding task](https://app.coderabbit.ai/code/tasks/f72b503c-ee72-43be-8abd-658f82274d17?source=coding_agent_github_pr_description) --------- Co-authored-by: Aaron Zolnai-Lucas <azolnailucas@nvidia.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ard <88337265+aw471@users.noreply.github.com> Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
1 parent 01d13c9 commit 22d731e

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎docs/source/nanotabicl.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NanoTabICL in SDM
1+
# NanoTabICL
22

33
The [`sdm.nn`](api/nn) package provides reusable, GPU-accelerated building blocks for developing foundation models for structured data from scratch.
44
In this guide, we show how to build a minimal [TabICLv2](https://arxiv.org/abs/2602.11139)-inspired Tabular Foundation Model (TFM) with it.
@@ -268,9 +268,10 @@ The remaining rows are treated as query rows whose labels the model predicts.
268268
Categorical encoding, missing-value handling, and feature scaling are typically performed in a pre-processing stage before the model's {py:meth}`~torch.nn.Module.forward` call.
269269

270270
```python
271-
x = torch.randn(128, 32, device="cuda")
272-
y = torch.randint(0, 10, (64, ), device="cuda")
271+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
272+
x = torch.randn(128, 32, device=device)
273+
y = torch.randint(0, 10, (64, ), device=device)
273274

274-
model = NanoTabICL().cuda()
275+
model = NanoTabICL().to(device)
275276
out = model(x, y)
276277
```

‎test/docs/test_nanotabicl.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import re
5+
from pathlib import Path
6+
from typing import Any
7+
8+
9+
def test_nanotabicl() -> None:
10+
path = Path(__file__).parents[2] / "docs/source/nanotabicl.md"
11+
text = path.read_text()
12+
namespace: dict[str, Any] = {}
13+
14+
for match in re.finditer(r"^```python\n(.*?)^```", text, re.M | re.S):
15+
source = "\n" * text.count("\n", 0, match.start(1)) + match[1]
16+
exec(compile(source, str(path), "exec"), namespace)
17+
18+
out = namespace["out"]
19+
assert out.size() == (64, 10)
20+
assert out.isfinite().all()

0 commit comments

Comments
 (0)