Lance Training Script Usage

June 17, 2026 · View on GitHub

This document explains the purpose and common usage of the following training scripts:

  • scripts/sft_lance_unified.sh
  • scripts/sft_lance_generation.sh
  • scripts/sft_lance_understand.sh

All three scripts ultimately launch train/unified_train.py via accelerate launch. The main differences are the default dataset config and the VISUAL_GEN switch.

1. Environment Setup

The training release adds extra dependencies on top of the inference-only setup. If you installed the environment before the fine-tuning code was released, reinstall the dependencies from the updated requirements.txt:

pip install -r requirements.txt

2. Data Preparation

Training reads local parquet files. Download example datasets from Hugging Face and place them under local ./datasets.

Expected local layout:

datasets/
├── image2image/
├── image2text/
├── text2image/
├── text2video/
├── video2text/
└── video2video/

The ready-to-use local configs live in config/train_local/, for example:

TaskConfig
t2iconfig/train_local/t2i_local.yaml
t2vconfig/train_local/t2v_local.yaml
i2iconfig/train_local/i2i_local.yaml
v2vconfig/train_local/v2v_local.yaml
i2tconfig/train_local/i2t_local.yaml
v2tconfig/train_local/v2t_local.yaml

For parquet schemas, supported task types, and custom dataset construction, see train_dataset.md.

3. Launch Patterns

After preparing the environment, model weights, and example datasets, launch one of the training scripts below.

By default, the scripts use all GPUs visible to nvidia-smi on the current machine. To run on fewer GPUs, set ARNOLD_WORKER_GPU before launching, for example ARNOLD_WORKER_GPU=1 bash scripts/sft_lance_unified.sh. For smaller local machines, you can also lower dataloader workers, for example NUM_WORKERS=2 ARNOLD_WORKER_GPU=1 bash scripts/sft_lance_unified.sh.

3.1 Unified mixed training

bash scripts/sft_lance_unified.sh

3.2 Generation-task training

bash scripts/sft_lance_generation.sh

For a local t2v run, override the dataset config and experiment name:

DATASET_CONFIG_FILE=config/train_local/t2v_local.yaml \
VAL_DATASET_CONFIG_FILE=config/train_local/t2v_local.yaml \
WANDB_NAME=t2v_local_debug \
bash scripts/sft_lance_generation.sh

3.3 Understanding-task training

bash scripts/sft_lance_understand.sh

For a local v2t run, override the dataset config and experiment name:

DATASET_CONFIG_FILE=config/train_local/v2t_local.yaml \
VAL_DATASET_CONFIG_FILE=config/train_local/v2t_local.yaml \
WANDB_NAME=v2t_local_debug \
bash scripts/sft_lance_understand.sh

NOTE: The scripts default to MODEL_PATH=./downloads/Lance_3B_Video, the unified video-capable checkpoint. For image-only fine-tuning, such as t2i, i2i, or i2t, you can switch MODEL_PATH to ./downloads/Lance_3B before launch.

4. Training Script Selection

These scripts expand shell variables into command-line arguments and pass them to train/unified_train.py. In practice, you should first decide which class of task you want to train.

ScriptDefault configDefault switchesSuitable scenariosCommon fields to modify
scripts/sft_lance_unified.shconfig/train_local/unified.yamlVISUAL_UND=True, VISUAL_GEN=TrueMixed understanding + generation trainingDATASET_CONFIG_FILE, VAL_DATASET_CONFIG_FILE, WANDB_NAME
scripts/sft_lance_generation.shconfig/train_local/multi_gen.yamlVISUAL_UND=True, VISUAL_GEN=TrueGeneration tasks such as t2i, t2v, i2i, v2vDATASET_CONFIG_FILE, VAL_DATASET_CONFIG_FILE, WANDB_NAME
scripts/sft_lance_understand.shconfig/train_local/multi_und.yamlVISUAL_UND=True, VISUAL_GEN=FalseUnderstanding tasks such as i2t, v2tDATASET_CONFIG_FILE, VAL_DATASET_CONFIG_FILE, WANDB_NAME

5. Key Parameters to Modify First

These are the parameters you should verify before most runs. Think of them as the first layer of knobs that usually need to be changed.

ParameterPurposeWhen to changeRecommendation
DATASET_CONFIG_FILESpecifies the training dataset yamlAlmost every runPoint it to the dataset config you actually want to train
VAL_DATASET_CONFIG_FILESpecifies the validation dataset yamlValidation is currently not supportedKeep the default value
WANDB_NAMENames the experimentAlmost every runInclude task name, dataset name, and date
VISUAL_UNDEnables the visual understanding branchUsually not changed oftenKeep True for understanding tasks and most generation tasks
VISUAL_GENEnables the visual generation branchMust be checked when switching between understanding and generationSet False for understanding tasks, True for generation tasks
SAVE_EVERYCheckpoint save intervalCommonly changed in both debug and formal runsSmaller for debugging, larger for long runs
CKPT_DEBUG_STEPSVery early debug checkpointCommonly changed during debuggingSet to -1 if you do not need early debug checkpoints
VALIDATION_STEPValidation intervalValidation is currently not supportedKeep -1; do not set it to a positive integer
NUM_SHARDNumber of FSDP shardsWhen changing the parallelism strategyTune together with GPU count and memory budget
NUM_REPLICATENumber of replicasUsually changes with NUM_SHARDComputed as TOTAL_RANK / NUM_SHARD

6. Two Switches That Are Easy to Misconfigure

6.1 VISUAL_GEN

VISUAL_GEN controls whether the visual generation branch is enabled, including the VAE latent / flow matching / MSE path.

  • Common settings for generation tasks:

    • VISUAL_UND=True
    • VISUAL_GEN=True
  • Common settings for understanding tasks:

    • VISUAL_UND=True
    • VISUAL_GEN=False

If you accidentally set VISUAL_GEN=True for an understanding task, but the batch does not contain the latent fields required by the generation branch, Lance.forward(...) may enter the wrong branch and fail.

6.2 VALIDATION_STEP

All three scripts default to:

VALIDATION_STEP=-1

This means:

  • no fixed validation dataset is prepared
  • validate_on_fixed_batch(...) is never triggered in the training loop

The validation logic in the training script has not been fully checked yet. Enabling validation with a positive value is currently not supported, so do not set values such as VALIDATION_STEP=100; keep it as -1.

7. Practical Recommendations

  1. Use sft_lance_understand.sh first for pure understanding tasks.
  2. Use sft_lance_generation.sh first for pure generation tasks.
  3. Use sft_lance_unified.sh when you really want mixed-task training.
  4. During debugging, prioritize changing:
    • DATASET_CONFIG_FILE
    • WANDB_NAME
    • VISUAL_GEN
    • SAVE_EVERY
    • CKPT_DEBUG_STEPS
    • VALIDATION_STEP
  5. For local parquet training, verify first:
    • the yaml really points to a local parquet file
    • the _local dataset class matches the parquet schema
    • understanding tasks do not accidentally run with VISUAL_GEN=True