Module contents
Stage 9 of 9Research 120 min

A small vision-language-action model

Finish at the frontier with policies receiving a natural-language instruction. Fine-tune a small open-weight VLA designed for consumer GPUs on simulated language-conditioned tasks within an 8 GB budget, and evaluate by instruction, held-out paraphrases, and unseen compositions against Diffusion Policy conditioned on an instruction embedding.

After this lesson you can

  • Prepare a simulated task dataset with language instructions and demonstrations.
  • Fine-tune a small VLA with memory-saving techniques within 8 GB.
  • Evaluate by instruction, paraphrases, and unseen compositions.
  • Compare with a Diffusion Policy conditioned on text embeddings.

Before you start

One scene, two commands

If an image contains a T and two targets, a policy without an instruction does not know which to choose. Language adds a task variable: “push the T to the blue target” or “to the orange target.” To test whether the text matters, keep the scene fixed and change only the instruction. If both image and target change, a policy could ignore text and succeed using only the image.

A vision-language-action (VLA) model combines a multimodal model with a control output. Some architectures encode actions as discrete tokens; others generate continuous actions with a diffusion or flow head. SmolVLA uses a vision-language model and an action expert trained via flow matching. The checkpoint card presents it as a starting point for adaptation to a specific task, not a universal policy already adapted to any robot.

In the LeRobot 0.3.3 implementation, if A\mat{A} is a demonstrated chunk and ϵ\mat{\epsilon} is Gaussian noise of the same shape, an intermediate training point is Xt=tϵ+(1−t)A\mat{X}_t=t\mat{\epsilon}+(1-t)\mat{A}. Its velocity as tt increases is ϵ−A\mat{\epsilon}-\mat{A}. The action expert receives Xt\mat{X}_t, time, and multimodal conditioning, and learns to predict that velocity with squared error. At inference it starts in noise at t=1t=1 and moves toward t=0t=0 with negative Euler steps. This time convention matters: reversing endpoints also changes velocity’s sign.

Conditioning may include the image, state, and instruction tokens. The model does not receive the clean demonstrated action during deployment; it generates a chunk from noise and the current observation. Flow loss and physical success are different measurements: a well-fitted velocity on training samples does not guarantee the chunk is useful after unexpected contact. Chunk normalization and units must match the interface executing it.

Language representation provides a useful hypothesis for new commands: two different phrases can produce similar conditioning if they express the same goal. However, good phrase representations do not guarantee that the action head learned to use the difference. A policy could always select the nearest target and succeed on some scenes. Opposing commands on the same observation test precisely that possibility. The outcome is still behavioral: it indicates whether the decision changed under this protocol, not what internal reasoning produced it.

Create data that require reading the instruction

In this project both targets appear simultaneously. language_tasks.py builds the simulator from the first lesson’s Push-T; collect_language.py records scripted demonstrations for each target. The success condition uses the selected target, and the expert knows the exact goal: the expert is privileged, not a person or the VLA. With the same seed, the simulator uses the same initial state for both instructions, rejects scenes starting too close to either target, and retains both markers in the image.

To generate a dataset, also download p13_pusht.py and p13_collector.py into the same directory. Training and test seeds are separated before generation:

python collect_language.py --goal azul --out datos_azul --count 100 --seed 50000
python collect_language.py --goal naranja --out datos_naranja --count 100 --seed 50000

Each dataset retains the first 80 episodes for training and 20 for validation. Also hold out independent seeds, for example 70000 through 70099, for final rollout. Save failed attempts: discarding recording failures without recording their count would hide the expert’s success rate. Actions are absolute targets in millimeters for a 2D pusher; they are not the six robot joints in SmolVLA’s original data. A shape adapter does not prove semantic compatibility.

Split by complete episode, not frame. Two consecutive images in a trajectory are usually almost identical; placing one in training and another in validation would give an overly optimistic measure of generalization to new scenes. Pairing colors has a different purpose: for each seed it permits comparing commands on the same initial layout. Both properties must be preserved: both commands for one scene belong to the same split, and no test scene is used to fit statistics or choose the checkpoint.

Besides the success label, record the requested target, seed, simulator version, step limit, and executed actions after denormalization and clipping. An action outside the table can yield an apparently valid trajectory if silently clipped; the clipped fraction helps distinguish a poorly calibrated interface from a planning failure. For a sequence, also record when each target was reached. Final position alone cannot reconstruct the order.

Fine-tune while keeping memory in view

VLA fine-tuning adapts published weights to your own observations, actions, and instructions. Before training, fix camera names, dimensions, units, frequency, normalization, and step order. SmolVLA pads state and action to a maximum dimension, but a 2D pushing action remains different from a six-joint command. Changing tensor size and getting an output does not prove the robot understands the task.

In the adapter we will study, only the first two dimensions correspond to physical action. Reducing loss to those two avoids counting padded coordinates as targets, but the flow process still generates noise in all 32 dimensions before a learned projection. The other 30 coordinates can influence prediction through that projection: a loss mask does not make them nonexistent inputs. This adaptation therefore retains an internal 32-dimensional representation and is not equivalent to training an architecture designed from scratch for 2D actions.

LoRA replaces a dense update of a matrix W∈Rdout×din\mat{W}\in\R^{d_{\mathrm{out}}\times d_{\mathrm{in}}} with ΔW=BA\Delta\mat{W}=\mat{B}\mat{A}, where A∈Rr×din\mat{A}\in\R^{r\times d_{\mathrm{in}}} and B∈Rdout×r\mat{B}\in\R^{d_{\mathrm{out}}\times r}. It adds r(din+dout)r(d_{\mathrm{in}}+d_{\mathrm{out}}) trainable parameters to that matrix. Freezing base weights reduces gradients and optimizer states, but does not eliminate memory for those weights or all activations needed to compute adapter gradients. Recomputation trades activation memory for compute; mixed precision also requires checking stability and hardware compatibility.

InteractiveHow much does LoRA add?
  • Adapter size relative to a dense matrix
8
100
Adapter parameters1,638,400
Fraction of dense matrix1.56 %
Weights, gradients and moments19.66 MB
Base and adapters0.857 GiB
Hypothetical accounting for 1024 × 1024 matrices and a base of 450 million bf16 parameters. Count 2 bytes of weight, 2 of gradient, and 8 of moments per adapted parameter. Activations, master copies, and fragmentation are excluded; this is not a measured GPU peak.

The curve shows adapter size relative to a dense matrix; increasing the number of matrices does not change that ratio, but does change total parameters and memory. Greater rank expands the family of possible updates and their cost. The count is a storage bound under the figure’s assumptions, not a training-memory measurement.

A common initialization leaves B=0\mat{B}=0 and assigns nonzero values to A\mat{A}, so the model function initially matches the frozen base. On the first step, A\mat{A}‘s gradient is zero because it depends on B\mat{B}; B\mat{B}‘s gradient can be nonzero, allowing both matrices to learn afterward. Thus inspect which tensors changed as well as checking loss is finite. A nonzero gradient does not guarantee success in the environment either.

A hypothetical model with 450 million parameters stored entirely in bf16 occupies 450⋅106⋅2=900⋅106450\cdot10^6\cdot2=900\cdot10^6 bytes, about 0.838 GiB, for those weights alone. The actual peak includes adapters, optimizer, images, activations, buffers, and fragmentation. Measure maximum allocated and reserved GPU memory during a real step with the chosen batch size; adding up weights does not show complete fine-tuning fits in 8 GB.

An interface check begins before optimization. The base checkpoint contains architecture weights, but in the LeRobot version used, normalization statistics are supplied separately. For this task, position and action means and standard deviations are computed only from each target’s 80 training episodes. Position and action are expressed in millimeters in the table frame, while the RGB image is transformed from integers to values between 0 and 1 before visual preprocessing. After generating a chunk, its actions are denormalized and the clipping needed for each to remain on the table is recorded.

The action queue is also part of the interface. A 16-action chunk executing 8 before replanning does not use the same observation frequency as one executing all 16. Complete 16-step windows are chosen in demonstrations: positions too close to the end are excluded from this objective. This avoids treating temporal padding that could affect attention as real steps, but changes the window distribution and the base checkpoint’s horizon of 50. Declare both decisions when interpreting a comparison.

To explore the code, download train_smolvla_lora.py, smolvla_adapter.py, smolvla_loss.py, lora_utils.py, lora_resume.py, window_data.py, training_resume.py, language_tasks.py, and p13_pusht.py. You also need the open checkpoint and tokenizer identified by revision, LeRobot, and its dependencies. The program freezes the base, inserts LoRA into the expert’s query and value projections, and keeps state and action heads trainable. The output checkpoint saves adapters, heads, statistics, and base-model hash; loading it requires the same base.

Our CPU check completed one update using a simulator-recorded image, LoRA rank 8, and recomputation: 1 957 712 parameters were trainable and all 32 initially zero B\mat{B} matrices changed. The process reached about 3.21 GB peak working set and 4.71 GB committed memory. The model was then reconstructed and one finite action executed in the simulator. These checks verified computation, saving, and one action, but do not measure a trained policy’s success.

One diagnostic update on an RTX 3060, with microbatch 1, accumulation of 4, recomputation, and bf16 autocast, reached its own GPU reserved peak of 1 417 674 752 bytes, approximately 1.32 GiB. Allocated peak was 1 338 173 440 bytes; the process’s maximum host committed memory was 4 711 706 624 bytes. The downloadable measurement retains configuration and hashes. That particular step stayed below 8 GiB reserved on GPU, but does not alone demonstrate that a prolonged campaign finishes or that the policy solves the task. Weight size alone also does not represent total process memory.

With that same configuration, fine-tuning of 2 000 updates was subsequently completed, with four windows per update and 160 training episodes across the two targets. PyTorch’s maximum GPU reservation during that run was 1 419 771 904 bytes. Final weights matched the resumable state saved at completion, and statistics and data and model hashes were verified. This result demonstrates that fine-tuning run executed within the measured budget; training loss does not replace rollout evaluation of literal and held-out commands.

The adapter and fine-tuned heads are distributed alongside their metadata and statistics, the loader, and base-model attribution. The weights file has SHA-256 55d0ad47b80f07c6628358c687dce4917931607206db57a1c79cd5845cb6512c; it needs the base and tokenizer at the indicated revisions. The evaluator reconstructed that portable resource and executed 24 steps in each of four diagnostic scenes outside the reserved test, with finite actions. This checks loading and control, not a success rate or before/after comparison.

With local data, weights, and tokenizer directories prepared, this command reproduces the scale of one diagnostic update. Replace paths with your own; base_smolvla must contain config.json and model.safetensors, and tokenizador_smolvlm2 the configuration and tokenization files:

python train_smolvla_lora.py --blue datos_azul --orange datos_naranja \
  --base base_smolvla --backbone tokenizador_smolvlm2 \
  --out prueba_lora.pt --device cpu --steps 1 --batch 1 --accumulate 1

To repeat the GPU profile, use the same paths and replace the final options with --out perfil_lora.pt --device cuda --steps 1 --batch 1 --accumulate 4. Output shows the reserved peak and the checkpoint also saves maximum allocated. The test depends on your GPU and installation supporting bf16; the preceding figures correspond to the stated hardware and are not a memory promise for every device.

The experiment used the lerobot/smolvla_base checkpoint at revision 5e8d12a6e2975b0e5e5fce7c8caf47c371d257b6 and the HuggingFaceTB/SmolVLM2-500M-Video-Instruct configuration at revision 4cde9d208e19519c36917aa170fffc7e381aa0ad. Pinning revisions makes the dependency verifiable; changing a library, configuration, or data can change the result. For a longer campaign, the resume file retains optimizer, random state, and contract; that contract must be preserved on resumption. One update detects shape and gradient errors, not learning.

Evaluate language and composition

Language-conditioned evaluation separates literal training instructions, held-out paraphrases, and unseen combinations. A paraphrase preserves the goal, for example “take the T to the blue target”; a composition such as “first blue and then orange” requires a temporal definition of success, not merely ending at orange. For each instruction pair, evaluate the same scene seed and save whether the ordered goal was achieved, not only textual similarity.

Contrast a specialized policy conditioned on a text embedding with the VLA using the same scene, observation, frequency, actions, and rollout count. Compare the VLA before and after fine-tuning with the same episodes. If paraphrases or compositions do not appear in training, they must also stay outside checkpoint selection. Improved literal instructions alongside reduced compositional performance may indicate overspecialization, but without additional experiments does not by itself identify the cause.

This lab’s comparator combines the previous lesson’s diffusion policy with a frozen sentence encoder. text_diffusion_model.py computes a 384-component representation and incorporates it into network conditioning; text_diffusion_experiment.py trains on the two literal instructions and permits evaluating another phrase without refitting the encoder. This comparator also sees image and state, predicts 16 actions, and executes 8 before observing again. Actions are converted from training scale to millimeters before being sent to the simulator.

The portable comparator copy contains our network fine-tuned for 10 000 updates and its statistics; its metadata retain dataset and original checkpoint hashes without local paths. The copy has SHA-256 affab91a95a1398560a12898c966635feed2c287d46c88341a97ce68e9f86115; its 48 tensors, statistics, and reference embeddings match the original. In a CPU diagnostic scene, both produced the same first action and state, an interface check that does not measure success. The exporter creates that copy from a trusted checkpoint of your own. The all-MiniLM-L6-v2 encoder is obtained separately; its card states an Apache-2.0 license and the experiment pins revision 1110a243fdf4706b3f48f1d95db1a4f5529b4d41. The resource attribution distinguishes its weights from the external encoder.

The comparison does not by itself isolate the effect of pretraining: besides text, visual architecture and action generation change. Attributing a difference to language would require an ablation with the same policy and an alternative condition, such as a swapped instruction or target identifier, and a design holding data and training budget constant. Keeping image and scene fixed while swapping the phrase answers a narrower question: whether that policy changes behavior in response to different commands.

A paired evaluation retains one row per scene and command. For scene ii, write Yi,aY_{i,a} and Yi,bY_{i,b} as one if the requested goal was reached and zero otherwise. Difference Di=Yi,a−Yi,bD_i=Y_{i,a}-Y_{i,b} compares commands in the same scene; the mean of DiD_i shows the success difference between them. Reporting that difference alone is insufficient: both commands could always fail and yield zero difference. Also report both rates, scene count, and how many pairs succeeded on both, just one, or neither. The same principle applies before and after fine-tuning, keeping seeds and rollout protocol fixed.

The suite fixes groups of up to four independent scenes in advance for both actors. Each scene has its own environment, action queue, and noise generator; the protocol fixes seeds, instructions, precision, horizons, and hashes, and the evaluator saves each complete group to allow resumption. In a diagnostic with identical observations and noise, scalar and batch outputs differed by up to 1.2001 mm in one action component. Permuting scenes or replacing their companions kept batch outputs equal in that test. Both actor comparisons therefore use the same batch method; that diagnostic does not show scalar trajectories are identical or guarantee speedup on another machine.

If a scene finishes early, later group queries can contain fewer than four scenes. The same rule applies to both actors, but effective batch size can differ if their episodes end at different times. Given the observed numerical sensitivity to size, that detail is part of interpreting trajectories.

The diffusion comparator executes scenes one at a time, although it uses the same family of seeds, physical horizon, and device specified for the suite. Comparison with it also mixes effective inference size and architecture; it is not numerically repeating the same policy with another instruction.

To run a condition on your installation, the batched evaluator accepts the same data and weights. Without --checkpoint it evaluates the base; add --checkpoint smolvla_lora_2000.safetensors for the fine-tuned version. For other commands, change the phrase and, for a sequence, add --second-goal with the second target. The campaign orchestrator adds a comparison against a reference diagnostic trace and requires exact hashes; that check is specific to that run. Outputs include the protocol hash and support phase, clipping, and success checks with audit_vla_condition.py.

python smolvla_batched_eval.py --blue datos_azul --orange datos_naranja \
  --base base_smolvla --backbone tokenizador_smolvlm2 --goal azul \
  --instruction 'Empuja la T hasta la meta azul' --batch 4 --device cuda \
  --episodes 100 --eval-seed 70000 --out resultado_base.json

For example, if a policy succeeds on both commands in 30 of 100 scenes, only blue in 20, only orange in 10, and neither in 40, its rates are 50/100 and 40/100. The difference is ten points, but does not itself describe the 40 pairs where both fail. A Wilson interval for each rate quantifies episode uncertainty under chosen sampling; for the paired difference, the whole scene can be resampled with its two rows kept together. Those 100 scenes are not 100 independent training runs: independent training seeds are also needed to measure learning variation.

Composition needs a state machine agreed before evaluation: first wait for sufficient coverage of the first target; only then enable the second. If the second is reached before the first, the episode does not count as sequence success. A complete compound phrase can remain throughout the episode; if it is replaced with a new instruction on reaching the first target, the experiment evaluates following successive instructions, not necessarily understanding a single compound command. Record which protocol was used. In the diffusion comparator prepared for this lab, the complete phrase embedding remains fixed throughout the episode and, if the first target is reached halfway through a chunk, pending actions are finished before replanning. That delay is part of the protocol and must be retained in comparisons.

What happened in the held-out scenes

The executed suite contains three policies: base SmolVLA, the same model after LoRA, and specialized textual diffusion. Six instructions and 100 scenes per condition were evaluated, 1 800 rollouts total. Every combination achieved 0 successes out of 100; each 95% Wilson interval ranges from 0% to approximately 3.70%. In the two compositions, none of the three policies even reached the first target in those scenes. Failures are this experiment’s results, not a general property of the architecture.

Mean final coverage offers an additional signal when all rates are zero. In a composition it refers to the target still active at the end. Coverage is not equivalent to success and does not alone measure linguistic understanding:

CommandBase VLAVLA with LoRATextual diffusion
Literal blue4.23%1.23%2.40%
Literal orange4.79%0.47%3.43%
Blue paraphrase3.99%0.14%2.94%
Orange paraphrase4.07%1.19%3.84%
Blue → orange4.92%2.10%3.77%
Orange → blue4.96%0.47%4.14%
InteractiveGive commands to the robot

Loading recorded rollouts…

Recorded trajectories: fix one of three example scenes and change the command or policy. Rate and Wilson interval refer to 100 scenes per condition; the drawing shows a single episode, not a live simulation.

The figure records include three example scenes per condition, success for each of 100 seeds, and result hashes. The paired analysis, generated with paired_language_analysis.py, retains 24 contrasts. All contain 100 unsuccessful pairs and empirical scene bootstrap gives [0,0][0,0] for the rate difference. That degenerate interval does not prove true probabilities are equal; it simply reflects that this sample contains no discordances.

Evaluation used CUDA and float32 without autocast; both VLA policies shared normalization, seeds, and the rule of groups of up to four. Diffusion was evaluated scene by scene. The LoRA network was fine-tuned for 2 000 updates and one seed, and diffusion for 10 000 updates and one seed; architectures, training precision, and inference size differ. The 100 scenes quantify these policies’ results on this distribution, but do not replace independent training replicas or isolate a cause for coverage differences. They also do not directly compare this simulator with the published checkpoint’s robot or data.

Exercises

Numeric
Assuming 450 million parameters, all frozen and stored in bf16, how many bytes do their weights occupy?
Numeric
A frozen base model has 450 million bf16 parameters. Rank-8 LoRA adapters are added to 100 matrices of 1024 × 1024. Each adapter parameter uses 2 bytes for weight, 2 for gradient, and 8 for two float32 Adam moments. Under these assumptions, how many bytes do base and adapters occupy together, excluding activations and other buffers?
Quiz
Why might a pretrained VLA respond to a paraphrase unseen during fine-tuning better than a policy receiving only an integer task identifier?
Quiz
After fine-tuning, success improves on seen instructions and falls on unseen compositions. What interpretation is valid?
Code
Implement instrucciones(colores), where colores is a list of distinct names. Return two lists: for each color, the atomic Spanish paraphrases 'Lleva la T al objetivo COLOR' and 'Empuja la T hacia la meta COLOR'; and for each distinct color pair, the ordered composition 'Primero COLOR1 y después COLOR2'. Preserve input order, placing both paraphrases for each color together, and do not include pairs with the same color.
def instrucciones(colores):
  pass
Shift+Enter to run
Key idea

A VLA needs an explicit physical interface and rollout evaluation. Text should change the action when the command changes while the scene stays fixed; held-out paraphrases and compositions test different aspects of generalization. Weight memory is only part of the fine-tuning budget.