TabFM constructor accepts zero/negative dimensions; col_num_blocks=0 builds a model with no attention blocks

Open Beginner friendly
#92 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, pytorch

Research direction

Start at the TabFM constructor (init) and reproduce the reported zero and negative dimension cases in a clean container. Check how the dimensional parameters reach PyTorch and ModuleList construction; done means non-positive inputs produce one clear tabfm validation error rather than building empty attention blocks or failing with an unrelated tensor-shape message.

Written by the indexing model from the issue text.

Description

Separate from #91 (which is about config.json keys being merged in unvalidated) — this is about the constructor itself, and it affects anyone calling TabFM(...) directly in Python.

I tested every dimensional parameter at 0 and -1 on b15593e4c1111ddb5f4f30dd2957df2edbaa04ca, in a clean container. Ten of thirteen accept 0 and build a model with no error. Three accept -1 as well.

param                 value  outcome
------------------------------------------------------------------------
embed_dim                 0  BUILT OK  (no validation)
embed_dim                -1  RuntimeError: Trying to create tensor with negative di
max_classes               0  BUILT OK  (no validation)
max_classes              -1  RuntimeError: Trying to create tensor with negative di
col_num_blocks            0  BUILT OK  (no validation)
col_num_blocks           -1  BUILT OK  (no validation)
col_nhead                 0  ZeroDivisionError
col_nhead                -1  RuntimeError: Trying to create tensor with negative di
col_num_inds              0  BUILT OK  (no validation)
col_num_inds             -1  RuntimeError: zeros: Dimension size must be non-negati
row_num_blocks            0  BUILT OK  (no validation)
row_num_blocks           -1  BUILT OK  (no validation)
row_nhead                 0  ZeroDivisionError
row_nhead                -1  RuntimeError: upper bound and lower bound inconsistent
row_num_cls               0  BUILT OK  (no validation)
row_num_cls              -1  RuntimeError: zeros: Dimension size must be non-negati
icl_num_blocks            0  BUILT OK  (no validation)
icl_num_blocks           -1  BUILT OK  (no validation)
icl_nhead                 0  ZeroDivisionError
icl_nhead                -1  RuntimeError: Trying to create tensor with negative di
ff_factor                 0  BUILT OK  (no validation)
ff_factor                -1  RuntimeError: Trying to create tensor with negative di
feature_group_size        0  BUILT OK  (no validation)
feature_group_size       -1  RuntimeError: zeros: Dimension size must be non-negati
num_freq                  0  BUILT OK  (no validation)
num_freq                 -1  RuntimeError: zeros: Dimension size must be non-negati

The one I would draw your attention to is *_num_blocks. Passing 0 or -1 makes range(...) empty, so the ModuleList is empty and the model is built with no attention blocks at all. It still runs and still returns predictions. Nothing warns. That is a worse outcome than the crashes elsewhere in the table, because a crash is at least honest about what happened.

Where errors do occur they come from PyTorch rather than from tabfm, so the message describes a tensor shape rather than the parameter the caller actually got wrong — Trying to create tensor with negative dimension does not tell someone that ff_factor was the problem.

A small guard at the top of __init__ rejecting non-positive values for these parameters would turn all twenty-six rows into one clear message. I am happy to send that PR if you would like it — I did not want to presume which parameters you consider legitimately zero-able (decoder_hidden is already None-able, so there may be others by design).

Disclosure: I used an AI assistant to help find this. I ran the matrix myself.

Dominant language
Python
Stars
2.7k
Forks
275
Avg merge
1d 7h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google-research/tabfm

All issues in google-research/tabfm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.