Nemotron 3.5 Super VL: Text-to-SQL with LoRA
Nemotron 3.5 Super VL: Text-to-SQL with LoRA
A step-by-step guide for LoRA fine-tuning Nemotron 3.5 Super VL (121B hybrid Mamba and Attention Mixture-of-Experts (MoE) VLM) on Spider, a cross-domain text-to-SQL dataset, using NeMo AutoModel. The whole run fits on a single node of 8 H100; inference and evaluation use the Spider validation split, whose databases never appear in training.
What is Nemotron 3.5 Super VL?
Nemotron 3.5 Super VL (nvidia/NVIDIA-Nemotron-3.5-Super-midtrain-67B-vision-pretrained, architecture
NemotronH_Omni_Reasoning_V3) is the 121B member of the Nemotron 3.5 family: a NemotronV3 hybrid backbone
(88 layers: 40 Mamba2, 8 attention, 40 MoE with 512 routed experts and top-22 routing) with a RADIO v2.5-H
vision encoder. This guide uses it as a text-only model: the vision tower is loaded but never receives an
image. See the model coverage page for the
architecture details and the other recipes.
Text-to-SQL on Spider
Spider contains 10,181 natural-language questions over 200 databases spanning 138 domains. The Hugging Face release ships the questions and gold SQL for 7,000 training questions (140 databases) and 1,034 validation questions (20 databases). The two sets of databases are disjoint, so the validation split measures how well the model writes SQL for schemas it has never seen.
The base model answers such a question with a paragraph of reasoning that might not end in a query. After fine-tuning, it outputs exactly one SQL query against the schema it is given.
Guide Overview
Hardware Requirements
- 1 node x 8 H100 80 GB (512 experts sharded with
ep_size=8;cp_size=1so the 8-question global batch is one question per data-parallel rank) - Memory: ~36 GiB per GPU. The frozen base weights need no fp32 master copy or optimizer state; only the 177M LoRA parameters carry fp32 master weights and Adam moments.
- Training time: ~15 min for 400 steps (3,200 of the 7,000 training questions), including four validation passes over the 1,034 validation questions and adapter-only checkpoints (~355 MB each)
Step 0 — Set Up the Environment
Nemotron 3.5 Super VL requires mamba_ssm and causal_conv1d (the cuda extra, pre-built in the
NeMo AutoModel container), Transformer Engine (attn: te, linear: te), and DeepEP for expert dispatch.
The checkpoint is ~232 GB in bf16 (63 safetensors shards); download it into $HF_HOME before launching
so that all 8 ranks read from the shared cache.
Step 1 — Explore Spider and Render the Database Schemas
The Spider rows carry only db_id, question, and query; the database schemas come from
richardr1126/spider-schema, one row per
database with its tables, columns, column types, primary keys, and foreign keys.
Expected output:
Schema as CREATE TABLE Statements
make_spider_dataset (in nemo_automodel.components.datasets.vlm.datasets) renders every database as
CREATE TABLE statements with primary and foreign keys (spider_schema_to_ddl), puts the schema and the
question into the user turn, and uses the gold query (whitespace collapsed) as the assistant turn:
A training sample is 371 tokens on average (95th percentile 904, maximum 1,839); the SQL answer is 30 tokens
on average. max_length: 2048 in the recipe therefore never truncates.
Step 2 — LoRA Training Configuration
Config file: examples/vlm_finetune/nemotron_3_5_super_vl/nemotron_3_5_super_vl_spider_peft.yaml
Rank-64 LoRA adapters are trained on 272 LLM linear projections (177M parameters, 0.15% of the model).
The targets include Mamba in_proj/out_proj; attention q_proj/k_proj/v_proj/o_proj; MoE latent
projections; and shared-expert MLPs. The vision tower, projector, and lm_head are excluded.
Collate Function
The collate function applies the chat template to each conversation (which adds the <think></think>
prefix for the assistant turn), tokenizes it, and masks everything but the assistant turn in the labels,
so the loss is computed on the SQL tokens only.
Step 3 — Launch Fine-Tuning
On one node with 8 GPUs:
You can also launch it on any 8-GPU machine with the automodel launcher: automodel examples/vlm_finetune/nemotron_3_5_super_vl/nemotron_3_5_super_vl_spider_peft.yaml --nproc-per-node 8.
W&B logging is opt-in: add --wandb.enable=true --wandb.entity=<entity> --wandb.project=<project>.
Training Log
The 400-step run takes about 15 min on 8 H100, including the four validation passes. Training loss keeps falling while validation loss on the unseen databases is lowest after the first 100 steps and then drifts up slightly. Step 5 shows that the later checkpoints nevertheless decode more queries correctly, so evaluate both.
Checkpoints Saved
A checkpoint is written every ckpt_every_steps (100) steps and at the final step; each holds only the
adapter weights, so the whole run needs about 1.5 GB of disk.
Step 4 — Run Inference and Evaluation
Load the base checkpoint across all visible GPUs (device_map="auto"; the bf16 weights need ~232 GB, so use
one node with 8x H100), fold the LoRA adapter into the base weights (W += (B @ A) * alpha / r), and greedy-decode
validation questions with the training prompt. Each prediction is scored against the gold query after
normalization (lower-cased, whitespace collapsed, trailing ; removed):
- exact match — normalized prediction identical to the normalized gold query
- similarity — normalized sequence similarity (difflib ratio; 1.0 = identical)
Spider’s validation split is ordered by database, so the snippet takes every 51st question to cover many databases in a small sample.
Skipping the merge block scores the un-tuned base model the same way.
Resources: One node with 8x H100 (bf16 weights spread over the GPUs). Runtime: About 2–4 min to load the base checkpoint, then about 3.4 s per question for the fine-tuned model (greedy, up to 256 new tokens). The un-tuned base model takes about 16 s per question because it writes a paragraph of reasoning before (or instead of) the query.
Step 5 — Results
Evaluation on 20 Spider Validation Questions (13 Unseen Databases)
The base model never returns a bare query: it reasons about the schema in prose (“We need to count the number of singers. The table singer has Singer_ID as primary key. So we can count distinct Singer_ID or just count rows…”) and, when it does write SQL, wraps it in a code fence. After LoRA fine-tuning, every prediction is a single SQL statement against the given schema.
Exact string match understates the fine-tuned model: of the 10 step-399 mismatches, 7 are semantically
equivalent queries (the two joined tables listed in the other order with aliases swapped, single instead of
double quotes, ORDER BY ... LIMIT 1 instead of a min() subquery, an explicit ASC, grouping by the id
column instead of the name column). The remaining 3 are genuine errors (a wrong column such as Maker for
Make, one extra selected column, and a mis-specified nested query). Spider’s official metric is execution
accuracy against the SQLite databases, which are not part of the Hugging Face release; the normalized exact
match and similarity above are a conservative proxy.