seed: 0
run_mode: 'finetune'
output_dir: './output' # path to save checkpoint/strategy
load_checkpoint: ""
src_strategy_path_or_dir: ''
auto_trans_ckpt: False
only_save_strategy: False
resume_training: False

# context
context:
  mode: 0 #0--Graph Mode; 1--Pynative Mode
  device_target: "Ascend"
  enable_graph_kernel: False
  graph_kernel_flags: "--disable_expand_ops=Softmax,Dropout --enable_parallel_fusion=true --reduce_fuse_depth=8 --enable_auto_tensor_inplace=true"
  max_call_depth: 10000
  max_device_memory: "59GB"
  save_graphs: False         # 存图命令,可以查看网络结构等
  save_graphs_path: "./graph"
  device_id: 6

# aicc
remote_save_url: "Please input obs url on AICC platform."

# runner
runner_config:
  epochs: 1
  batch_size: 1
  sink_mode: True
  sink_size: 2
runner_wrapper:
  type: MFTrainOneStepCell
  scale_sense:
    type: DynamicLossScaleUpdateCell
    loss_scale_value: 2048
    scale_factor: 2
    scale_window: 1000
  use_clip_grad: True

# parallel
use_parallel: False
parallel:
  parallel_mode: 1 # 0-data parallel, 1-semi-auto parallel, 2-auto parallel, 3-hybrid parallel
  gradients_mean: False
  loss_repeated_mean: True
  full_batch: True
  search_mode: "sharding_propagation"
  enable_parallel_optimizer: True
  strategy_ckpt_save_file: "./ckpt_strategy.ckpt"
parallel_config:
  data_parallel: 1
  model_parallel: 8
  pipeline_stage: 1
  optimizer_shard: True
  micro_batch_num: 1
  vocab_emb_dp: True            # 默认按mp切,设为True是按照dp切
  gradient_aggregation_group: 4
micro_batch_interleave_num: 1   # 多副本并行,设为2有效果

# moe
moe_config:
  expert_num: 1
  capacity_factor: 1.05
  aux_loss_factor: 0.05
  num_experts_chosen: 1

# recompute
recompute_config:
  recompute: True
  parallel_optimizer_comm_recompute: False
  mp_comm_recompute: True
  recompute_slice_activation: False

# autotune
auto_tune: True
filepath_prefix: './autotune'
autotune_per_step: 10

# profile
profile: False
profile_start_step: 1
profile_stop_step: 10
init_start_profile: True
profile_communication: True
profile_memory: True

# Trainer
trainer:
  type: CausalLanguageModelingTrainer
  model_name: 'wizardcoder'
# if True, do evaluate during the training process. if false, do nothing.
# note that the task trainer should support _evaluate_in_training function.
do_eval: False

# train dataset
train_dataset: &train_dataset
  data_loader:
    type: MindDataset
    dataset_dir: ""
    shuffle: True
  input_columns: ["input_ids", "labels"]
  num_parallel_workers: 8
  python_multiprocessing: False
  drop_remainder: True
  batch_size: 1
  repeat: 1
  numa_enable: False
  prefetch_size: 1
train_dataset_task:
  type: CausalLanguageModelDataset
  dataset_config: *train_dataset

# eval dataset
eval_dataset: &eval_dataset
  data_loader:
    type: MindDataset
    dataset_dir: ""
    shuffle: False
  input_columns: ["input_ids", "labels"]
  num_parallel_workers: 8
  python_multiprocessing: False
  drop_remainder: False
  repeat: 1
  numa_enable: False
  prefetch_size: 1
eval_dataset_task:
  type: CausalLanguageModelDataset
  dataset_config: *eval_dataset

# model
model:
  model_config:
    type: WizardCoderConfig
    seq_length: 2048
    n_position: 8192
    vocab_size: 49153
    hidden_size: 6144
    num_layers: 40
    num_heads: 48
    expand_ratio: 4
    hidden_act: "gelu"
    dropout_prob: 0.0
    hidden_dropout_prob: 0.1
    attention_probs_dropout_prob: 0.1
    initializer_range: 0.02
    eos_token: 0
    pad_token: 49152
    param_init_type: "float16"
    layernorm_dtype: "float32"
    softmax_dtype: "float16"
    compute_dtype: "float16"
    use_past: False
    use_seq_parallel: True
    use_select_recompute: True
    checkpoint_name_or_path: "wizardcoder.ckpt"
    eos_token_id: 0
    repetition_penalty: 1
    max_decode_length: 1024
    top_k: 5
    top_p: 1
    do_sample: True
    use_flash_attention: False
    batch_size: 1
  arch:
    type: WizardCoderLMHeadModel

# lr sechdule
lr_schedule:
  type: CosineWithWarmUpLR
  learning_rate: 0.000002
  lr_end: 0.0000005
  warmup_steps: 80
  total_steps: -1 # -1 means it will load the total steps of the dataset
layer_scale: False
layer_decay: 0.65

# optimizer
optimizer:
  type: FP32StateAdamWeightDecay
  beta1: 0.9
  beta2: 0.999
  eps: 0.00000001
  weight_decay: 0
lr_scale: False
lr_scale_factor: 256

# callbacks
callbacks:
  - type: MFLossMonitor
  - type: CheckpointMointor
    prefix: "wizardcoder"
    save_checkpoint_steps: 2000
    keep_checkpoint_max: 2
    integrated_save: False
    async_save: False
  - type: ObsMonitor
eval_callbacks:
  - type: ObsMonitor

# metric
metric:
  type: PerplexityMetric

# processor
processor:
  return_tensors: ms
  tokenizer:
    unk_token: '<|endoftext|>'
    bos_token: '<|endoftext|>'
    eos_token: '<|endoftext|>'
    pad_token: '[PAD]'
    vocab_file: 'vocab.json'
    merge_file: 'merges.txt'
    type: WizardCoderTokenizer
  type: WizardCoderProcessor