tao-finetune-cosmos-reason
Original:🇺🇸 English
Translated
2 scriptsChecked / no sensitive code detected
Cosmos-Reason2-8B video QA supervised fine-tuning with FSDP parallelism. Use when training or evaluating video question-answering models, fine-tuning Cosmos-Reason2 with SFT, or working with Cosmos-RL. Trigger phrases include "fine-tune Cosmos-Reason", "Cosmos-RL SFT", "video QA fine-tune", "Cosmos-Reason2-8B training".
9installs
Sourcenvidia/skills
Added on
NPX Install
npx skill4agent add nvidia/skills tao-finetune-cosmos-reasonTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Cosmos-RL
Supervised fine-tuning (SFT) of nvidia/Cosmos-Reason2-8B on video reasoning tasks. Pretrained weights are sourced from HuggingFace, not NGC. This is a gated model — requires .
HF_TOKENUses FSDP-based parallelism with for GPU count and for node count (not the standard /).
dp_shard_sizedp_replicate_sizenum_gpusnum_nodesWhen to Use
Use this skill to train, evaluate, quantize, or run inference on Cosmos-Reason2-8B for video question-answering and video reasoning. The core workflow is: confirm gating, sample annotations for , load the spec template, apply the critical train overrides below, then launch through the platform skill (or AutoML when enabled).
HF_TOKENvideo_fpsDataclass Schemas
Generated TAO Core schemas are packaged in , with listing available actions. Each generated schema also emits from the schema top-level field. AutoML enablement is declared at the model layer in via . Runnable AutoML still requires and to exist and parse. Use the packaged train schema for , , defaults, min/max bounds, enums, option weights, math conditions, dependencies, and popular parameters. Do not expect at runtime; maintainers regenerate schemas/templates before packaging the skill bank.
schemas/<action>.schema.jsonschemas/manifest.jsonreferences/spec_template_<action>.yamldefaultreferences/skill_info.yamlautoml_enabledschemas/train.schema.jsonreferences/spec_template_train.yamlautoml_default_parametersautoml_disabled_parameters~/tao-coreTrain Action Policy
This model is AutoML-enabled at the model layer. Before handling any train-stage request, read and resolve the run override from either an explicit value or the user's workflow request. Treat phrases like "turn off AutoML", "disable AutoML", "no HPO", or "plain training" as for this run only; otherwise default to . When , , and both and are packaged, route the train action through by default with this model's . Preserve workflow/application overrides for datasets, specs, output directories, GPU/platform settings, parent checkpoints, and . Use direct model training only when or the packaged train schema/template is missing; in the missing-schema case, report that AutoML is enabled but not runnable for this model until schemas are generated.
references/skill_info.yamlautoml_policyautoml_policy: offautoautoml_policy: autoautoml_enabled: trueschemas/train.schema.jsonreferences/spec_template_train.yamltao-skill-bank:tao-run-automlskill_dirautoml_policyautoml_policy: offNon-train actions such as , , , and deploy flows stay in this model skill. The per-run override does not change model metadata.
evaluateinferenceexportautoml_policyCredentials
- HF_TOKEN (required): HuggingFace access token. The user must accept the model agreement at https://huggingface.co/nvidia/Cosmos-Reason2-8B and provide a token with read access. Passed to the container as a .
docker_env_var
Datasets
Dataset type is vlm in llava format; accepted intents are training, evaluation, and testing. Inputs may be dataset roots (root mode maps plus as the media path) or direct spec-key paths (when annotations and media live in different locations). Before launching train/AutoML/evaluate, sample the annotation JSON and require in each record — missing makes the Cosmos-RL SFT loader fail with after the job starts. Stop before runner generation if it is absent and ask the user to fix the annotation files; do not start AutoML to discover this inside torchrun.
<root>/annotations.json<root>video_fpsvideo_fpsError processing sample: 'video_fps'See for the full training requirements, the launch intake reminder (spec-key options, root-mode mapping, container-image confirmation, and the invocation), the Per-Action Dataset Requirements table, the mapping with direct-override examples, and the eval-dataset / auto-split policy.
references/datasets.mdcheck_tao_launch_preflight.pydata_sourcesSpec Construction
cosmos-rl is . Always start from (or for evaluate) — load it via and apply user overrides on top. The spec the model consumes is nested dicts, not flat dotted keys; the dotted override notation denotes paths into the nested spec, so walk the path and assign at the leaf. Data source overrides are mandatory for every action and must be built from the Per-Action Dataset Requirements table in .
mode: configreferences/spec_template_train.yamlspec_template_evaluate.yamlyaml.safe_load(...)references/datasets.mdSee for the load-template-then-override pattern and the full typical override blocks for train (including , /, and LoRA //), evaluate, quantize, and inference, plus the note that leaf keys are valid even when absent from the default spec object.
references/spec-construction.mdpolicy.model_max_length=81920dp_shard_sizedp_replicate_sizelora_alpharlora_dropoutcustom.val_datasetCritical Overrides (Train)
These are the keys whose template defaults are wrong or where omission flips the run into a different mode:
| Parameter | Template Default | Required Value | Why |
|---|---|---|---|
| | | The bare HF id makes cosmos-rl fetch from HF Hub at runtime; the |
| 40960 | Keep at 40960 or higher | Smaller than ~40k causes |
| 32 | Any multiple of | Mismatch raises an immediate AssertionError |
| | Keep as | If dropped during agent regeneration, cosmos-rl flips to RL mode → rollout replica allocated → multi-node attempted → hostname errors when |
Parameters
train.train_batch_per_replicatrain.train_policy.mini_batchpolicy.model_max_lengthpolicy.parallelism.dp_shard_sizedp_replicate_sizecustom.vision.fpscustom.vision.nframesSee for the complete parameter reference: training loop, model & policy, parallelism (including multi-node guidance and platform-skill pointers), optimization & data loading, vision encoders (fps vs nframes details and the decord/torchvision failure mode), checkpointing, validation, logging, and hardware.
references/parameters.mdEvaluate
The evaluator reads a flat TOML config with top-level keys , , , , , , , , , . Task type is (General Evaluator, auto-detects binary yes/no classification and computes TP/FP/TN/FN/accuracy/precision/recall/F1) or (left/right/straight; do NOT use for collision detection). The block in declares inputs and outputs; for SDK invocation see .
datasetmodeltaskevaluationvisiongenerationmetricsresultsnum_gpusresults_dir"""its_directionality"actions.evaluatereferences/skill_info.yamlskills/platform/tao-run-platform/SKILL.mdSee for the config-format detail, task-type notes, LoRA evaluation (checkpoint path via with / and adapter merge behavior), selective download ( partial media pull), and the results format and metrics.
references/evaluate.mdspec_overridesmodel.enable_loramodel.base_model_path{annotation, format, keys}Error Patterns
Common failures include CUDA OOM in train (reduce or raise ), OOM during LoRA evaluation, NaN loss, the shape mismatch (raise to 40960), not divisible by , larger than samples per rank (the 0-step crash), stale dataset cache after changing fps/total_pixels, and the gated-repo authentication loop.
mini_batchdp_shard_sizevision_embedsmodel_max_lengthtrain_batch_per_replicamini_batchtrain_batch_per_replica'NoneType' object has no attribute 'state_dict'See for the full diagnosis and fix for each error pattern.
references/troubleshooting.mdDEFT Support and Parent-Model Inference
Cosmos-RL implements the DEFT workflow contract for video QA tasks (see and ). Gap analysis via reads cosmos-rl , compares predictions by exact string match after , and emits a parquet of failure cases — so eval prompts must force short constrained answers. Model-specific parent-model inference mappings (evaluate/inference/quantize/train spec fields → inference functions, checkpoint metadata, and handling) live in the reference, not in .
config.jsonworkflow/deft/deft.mdscripts/analyze_gaps.pyresults.json.lower().strip()parent_job_idconfig.jsonSee for the gap-analysis detail and limitation, and the full parent-model inference mapping table.
references/deft-and-inference-mappings.md