# Copyright (c) 2025, NVIDIA CORPORATION.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# torchrun --nproc-per-node=8 examples/vlm_finetune/finetune.py -c examples/vlm_finetune/qwen3_5/qwen3_5_9b.yaml


recipe: FinetuneRecipeForVLM

step_scheduler:
  global_batch_size: 16
  local_batch_size: 2
  ckpt_every_steps: 100
  val_every_steps: 100
  num_epochs: 3
  max_steps: 100

dist_env:
  backend: nccl
  timeout_minutes: 10

rng:
  _target_: nemo_automodel.components.training.rng.StatefulRNG
  seed: 1234
  ranked: true

model:
  _target_: nemo_automodel.NeMoAutoModelForImageTextToText.from_pretrained
  pretrained_model_name_or_path: Qwen/Qwen3.5-9B
  attn_implementation: sdpa


processor:
  _target_: transformers.AutoProcessor.from_pretrained
  pretrained_model_name_or_path: Qwen/Qwen3.5-9B

checkpoint:
  enabled: true
  checkpoint_dir: /tmp/checkpoints/qwen3_5_9b/
  model_save_format: safetensors
  save_consolidated: true

distributed:
  _target_: nemo_automodel.components.distributed.fsdp2.FSDP2Manager
  tp_size: 1
  cp_size: 1
  pp_size: 1
  dp_replicate_size: 1
  ep_size: 1
  sequence_parallel: false

freeze_config:
  freeze_vision_tower: false
  freeze_audio_tower: true
  freeze_language_model: false

loss_fn:
  _target_: nemo_automodel.components.loss.masked_ce.MaskedCrossEntropy

dataset:
  _target_: nemo_automodel.components.datasets.vlm.datasets.make_medpix_dataset
  path_or_dataset: mmoukouba/MedPix-VQA
  split: train

dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  num_workers: 0
  collate_fn:
    _target_: nemo_automodel.components.datasets.vlm.collate_fns.default_collate_fn

validation_dataset:
  _target_: nemo_automodel.components.datasets.vlm.datasets.make_medpix_dataset
  path_or_dataset: mmoukouba/MedPix-VQA
  split: validation

validation_dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  num_workers: 0
  collate_fn:
    _target_: nemo_automodel.components.datasets.vlm.collate_fns.default_collate_fn

optimizer:
  _target_: torch.optim.AdamW
  betas: [0.9, 0.95]
  eps: 1e-8
  lr: 1.0e-5
  weight_decay: 0.1

ci:
  recipe_owner: HuiyingLi
  time: "00:30:00"

# wandb:
#   project: <your_wandb_project>
#   entity: <your_wandb_entity>
#   name: <your_wandb_name>
