Skip to content

Reduce TabFM row embedding peak memory - #1331

Draft
akihironitta wants to merge 1 commit into
mainfrom
agent/tabfm-row-embedding-memory
Draft

akihironitta wants to merge 1 commit into
mainfrom
agent/tabfm-row-embedding-memory

Conversation

@akihironitta

@akihironitta akihironitta commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Build the TabFM row embedding's column-projection and row norms from sdm.nn.RMSNorm instead of torch.nn.RMSNorm. This cuts TabFM's peak GPU memory at 50k context rows by about 40%, with identical predictions.

Description of the change

Under CUDA autocast, torch.nn.RMSNorm runs in float32. So on the inference path, x.copy_(col_proj(x)) and x.copy_(row_norm(x)) in RowEmbedding create float32 copies of the whole embedding before writing it back. sdm.nn.RMSNorm, which the TabFM transformer blocks already use, writes the autocast dtype directly. It subclasses torch.nn.RMSNorm, so parameters and checkpoint keys are unchanged.

Validation

H100 PCIe 80GB, bf16 TabFM under bf16 autocast, 32 estimators, synthetic inputs. Main and this branch ran back to back on the same GPU. Peak is torch.cuda.max_memory_allocated(), including weights.

Context / query rows, features Task Peak, main (MiB) Peak, this PR (MiB)
50,000 / 10,000, 100 classification 22,989.5 13,472.6
50,000 / 10,000, 100 regression 22,997.5 13,480.6

Predictions are identical to main in all six cases measured: 1k, 10k and 50k context rows, for both classification and regression. At 1k and 10k rows, peak memory and latency are unchanged.

@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 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.

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.33%. Comparing base (c51bc37) to head (d92fac2).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1331   +/-   ##
=======================================
  Coverage   82.33%   82.33%           
=======================================
  Files         185      185           
  Lines       11794    11794           
=======================================
  Hits         9710     9710           
  Misses       2084     2084           

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

Build the column projection and row norms of the TabFM row embedding
from `sdm.nn.RMSNorm`, so that under autocast they write the autocast
dtype instead of float32 copies of the whole embedding.
@akihironitta
akihironitta force-pushed the agent/tabfm-row-embedding-memory branch from 3f98d06 to d92fac2 Compare November 3, 2026 08:07

This branch has not been deployed

No deployments
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