# 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.

seed: 1234

step_scheduler:
  global_batch_size: 512
  local_batch_size: 4
  ckpt_every_steps: 1000
  val_every_steps: 1000
  num_epochs: 2

distributed:
  strategy: fsdp2
  tp_size: 1
  cp_size: 1
  pp_size: 2
  dp_replicate_size: 1
  ep_size: 32
  sequence_parallel: false

  pipeline:
    pp_schedule: interleaved1f1b
    pp_microbatch_size: 1
    round_virtual_stages_to_pp_multiple: down
    scale_grads_in_schedule: false
    patch_inner_model: false
    patch_causal_lm_model: false
    layers_per_stage: 2

  moe:
    reshard_after_forward: false
    wrap_outer_model: false

dist_env:
  backend: nccl
  timeout_minutes: 10

model:
  _target_: nemo_automodel.NeMoAutoModelForCausalLM.from_pretrained
  pretrained_model_name_or_path: MiniMaxAI/MiniMax-M2.1
  trust_remote_code: true
  backend:
    _target_: nemo_automodel.components.models.common.BackendConfig
    attn: te
    linear: te
    rms_norm: torch_fp32
    rope_fusion: true
    dispatcher: deepep
    experts: gmm
    fake_balanced_gate: false
    enable_hf_state_dict_adapter: true
    enable_fsdp_optimizations: true

checkpoint:
  enabled: false

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

# Data configuration from llama finetuning
dataset:
  _target_: nemo_automodel.components.datasets.llm.hellaswag.HellaSwag
  path_or_dataset: rowan/hellaswag
  split: train

packed_sequence:
  packed_sequence_size: 0

dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  collate_fn:
    _target_: nemo_automodel.components.datasets.utils.default_collater
    pad_seq_len_divisible: 160
  shuffle: true

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

validation_dataloader:
  _target_: torchdata.stateful_dataloader.StatefulDataLoader
  collate_fn:
    _target_: nemo_automodel.components.datasets.utils.default_collater
    pad_seq_len_divisible: 160
  shuffle: true
  drop_last: true

optimizer:
  _target_: torch.optim.Adam
  betas:
  - 0.9
  - 0.999
  eps: 1e-8
  lr: 1e-5
  weight_decay: 0

ci:
  nodes: 8
  time: "01:00:00"
