# Ray Megatron GKD — colocate mode (train + rollout share GPUs), colocated teacher.
rlhf_type: gkd

model: Qwen/Qwen3.5-2B
teacher_model: Qwen/Qwen3.5-4B
gkd_logits_topk: 64  # omit for full-vocab distillation

dataset:
  - 'AI-ModelScope/alpaca-gpt4-data-zh#2000'
  - 'AI-ModelScope/alpaca-gpt4-data-en#2000'
dataset_num_proc: 4
split_dataset_ratio: 0

micro_batch_size: 1
global_batch_size: 16
num_train_epochs: 1
logging_steps: 1
seed: 42
max_length: 8192
max_completion_length: 8192
padding_free: true
sequence_parallel: true
attention_backend: flash

lr: 1e-6
min_lr: 1e-6
lr_warmup_fraction: 0.0

temperature: 1.0
lmbda: 1
beta: 0.5
sft_alpha: 0.0

finetune: true
no_save_optim: true
no_save_rng: true
recompute_granularity: selective

use_vllm: true

colocate_groups: [[train, rollout]]
offload_model: true
offload_optimizer: true
offload_teacher_model: true
sleep_level: 1

train:
  gpus: 4
  tuner_type: lora
  lora_rank: 8
  lora_alpha: 32
  tensor_model_parallel_size: 2  # TP2 -> DP2 on 4 GPUs
  pipeline_model_parallel_size: 1
  expert_model_parallel_size: 1
  context_parallel_size: 1
  output_dir: megatron_output/gkd_rollout_colocate_teacher_colocate

rollout:
  gpus: 4
  vllm_tensor_parallel_size: 2
  vllm_gpu_memory_utilization: 0.4
  vllm_max_model_len: 16384
