
# ------------------------------------------------------------------------------------------------
# WARNING: HARDWARE REQUIREMENTS
# ------------------------------------------------------------------------------------------------
# This config targets Qwen3-30B-A3B (30B parameters).
# It requires at least 8 GPUs (e.g., 8x A100 80GB or 8x H100 80GB) to run,
# but you can potentially run it on less GPUs by reducing the local batch size.
# ------------------------------------------------------------------------------------------------

step_scheduler:
  global_batch_size: 1024
  local_batch_size: 128
  ckpt_every_steps: 100
  val_every_steps: 50
  num_epochs: 2
  max_steps: 1000

dist_env:
  backend: nccl
  timeout_minutes: 20

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

model:
  _target_: nemo_automodel.NeMoAutoModelForCausalLM.from_pretrained
  pretrained_model_name_or_path: Qwen/Qwen3-30B-A3B
  trust_remote_code: true
  torch_dtype: bfloat16
  backend:
    _target_: nemo_automodel.components.models.common.BackendConfig
    attn: te
    linear: torch
    rms_norm: te
    experts: te
    dispatcher: deepep
    fake_balanced_gate: false
    enable_hf_state_dict_adapter: true
    enable_fsdp_optimizations: true

peft:
  _target_: nemo_automodel.components._peft.lora.PeftConfig
  target_modules: ["*"]
  dim: 32
  alpha: 32
  dropout: 0.0

checkpoint:
  enabled: true
  checkpoint_dir: checkpoints/qwen3_moe_lora
  model_save_format: safetensors

distributed:
  strategy: fsdp2
  tp_size: 1
  cp_size: 1
  pp_size: 1
  ep_size: 8
  activation_checkpointing: true

  sequence_parallel: false
  activation_checkpointing: true

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

dataset:
  _target_: nemo_automodel.components.datasets.llm.hellaswag.HellaSwag
  path_or_dataset: rowan/hellaswag
  split: train

dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  collate_fn: nemo_automodel.components.datasets.utils.default_collater
  shuffle: true
  num_workers: 4

validation_dataset:
  _target_: nemo_automodel.components.datasets.llm.hellaswag.HellaSwag
  path_or_dataset: rowan/hellaswag
  split: validation
  num_samples_limit: 128

validation_dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  collate_fn: nemo_automodel.components.datasets.utils.default_collater
  num_workers: 4

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