# FFT config for Llama 3.3 70B.
# Some param values are inspired by the following recipe:
# https://github.com/pytorch/torchtune/blob/main/recipes/configs/llama3_3/70B_full.yaml
#
# Requirements:
#   - Log into WandB (`wandb login`) or disable `enable_wandb`
#   - Log into HF: `hf auth login`
#   - Request access to Llama 3.3: https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct
#
# Usage:
#   oumi train -c configs/recipes/llama3_3/sft/70b_full/train.yaml
#
# See Also:
#   - Documentation: https://oumi.ai/docs/en/latest/user_guides/train/train.html
#   - Config class: oumi.core.configs.TrainingConfig
#   - Config source: https://github.com/oumi-ai/oumi/blob/main/src/oumi/core/configs/training_config.py
#   - Other training configs: configs/**/*train.yaml

model:
  model_name: "meta-llama/Llama-3.3-70B-Instruct"
  model_max_length: 2048
  torch_dtype_str: "bfloat16"
  attn_implementation: "sdpa"
  chat_template: "llama3-instruct"
  load_pretrained_weights: True
  trust_remote_code: True

data:
  train:
    datasets:
      - dataset_name: "yahma/alpaca-cleaned"

training:
  trainer_type: "TRL_SFT"
  save_steps: 200
  num_train_epochs: 3
  per_device_train_batch_size: 2
  max_grad_norm: 0.0

  enable_gradient_checkpointing: True
  gradient_checkpointing_kwargs:
    use_reentrant: False
  ddp_find_unused_parameters: False
  optimizer: "adamw_torch_fused"
  learning_rate: 2.0e-05
  warmup_ratio: 0.02

  dataloader_num_workers: "auto"
  dataloader_prefetch_factor: 16

  logging_steps: 100
  log_model_summary: False
  empty_device_cache_steps: 50
  output_dir: "output/llama70b.fft"
  include_performance_metrics: True
  enable_wandb: True

fsdp:
  enable_fsdp: True
  cpu_offload: True
  forward_prefetch: True

  sharding_strategy: "FULL_SHARD"
  state_dict_type: "SHARDED_STATE_DICT"
  auto_wrap_policy: "TRANSFORMER_BASED_WRAP"
  transformer_layer_cls: "LlamaDecoderLayer"
