已合并
[pytorch][fix]bug fix for ceval evauation #2844
AtomGit-Bot创建于 2025年6月18日
[pytorch][fix]bug fix for ceval evauation #2844
已合并
从refs/pull/2844/head合入到2.0.0
共 2 个文件变更+2-173
| @@ -124,12 +124,12 @@ class CEvalExam(DatasetEval): | |||
| 124 | chat_results, rank = chat.chat(instruction=instructions, history=[]) | 124 | chat_results, rank = chat.chat(instruction=instructions, history=[]) |
| 125 | if chat_results: | 125 | if chat_results: |
| 126 | for index, chat_result in enumerate(chat_results): | 126 | for index, chat_result in enumerate(chat_results): |
| 127 | - answer = chat_result[0].lstrip() | 127 | + answer = chat_result[0].lstrip().strip() |
| 128 | try: | 128 | try: |
| 129 | if rank == 0: | 129 | if rank == 0: |
| 130 | logger.info("correct: %s, AI: %s", answers[index], answer) | 130 | logger.info("correct: %s, AI: %s", answers[index], answer) |
| 131 | subject_result[str(idx - len(chat_results) + index + 1)] = answer | 131 | subject_result[str(idx - len(chat_results) + index + 1)] = answer |
| 132 | - if subject_result[str(idx - len(chat_results) + index + 1)] == answers[index]: | 132 | + if subject_result[str(idx - len(chat_results) + index + 1)].strip() == answers[index].strip(): |
| 133 | acc_n += 1 | 133 | acc_n += 1 |
| 134 | except Exception as e: | 134 | except Exception as e: |
| 135 | subject_result[str(idx - len(chat_results) + index + 1)] = str( | 135 | subject_result[str(idx - len(chat_results) + index + 1)] = str( |
| @@ -1,171 +0,0 @@ | |||
| 1 | -#!/bin/bash | ||
| 2 | -export CUDA_DEVICE_MAX_CONNECTIONS=1 | ||
| 3 | -export PYTORCH_NPU_ALLOC_CONF=expandable_segments:True | ||
| 4 | -export HCCL_CONNECT_TIMEOUT=3600 | ||
| 5 | - | ||
| 6 | -GPUS_PER_NODE=8 | ||
| 7 | -MASTER_ADDR=localhost | ||
| 8 | -MASTER_PORT=6000 | ||
| 9 | -NNODES=1 | ||
| 10 | -NODE_RANK=0 | ||
| 11 | -WORLD_SIZE=$(($GPUS_PER_NODE*$NNODES)) | ||
| 12 | - | ||
| 13 | -basepath=$(cd `dirname $0`; cd ../../../; pwd) | ||
| 14 | - | ||
| 15 | -DATA_PATH=/data/pretrain_dataset/alpaca_text_document | ||
| 16 | -TOKENIZER_PATH=/data/deepseek-v3-mcore-tp1-pp2-ep4-32experts | ||
| 17 | -CKPT_LOAD_DIR=/data/deepseek-v3-mcore-tp1-pp2-ep4-32experts | ||
| 18 | - | ||
| 19 | -TP=1 | ||
| 20 | -PP=2 | ||
| 21 | -EP=4 | ||
| 22 | -CP=1 | ||
| 23 | -CP_TYPE='ulysses_cp_algo' | ||
| 24 | -NUM_LAYERS=4 | ||
| 25 | -SEQ_LEN=4096 | ||
| 26 | -MBS=1 | ||
| 27 | -GBS=8 | ||
| 28 | - | ||
| 29 | -DISTRIBUTED_ARGS=" | ||
| 30 | - --nproc_per_node $GPUS_PER_NODE \ | ||
| 31 | - --nnodes $NNODES \ | ||
| 32 | - --node_rank $NODE_RANK \ | ||
| 33 | - --master_addr $MASTER_ADDR \ | ||
| 34 | - --master_port $MASTER_PORT | ||
| 35 | -" | ||
| 36 | - | ||
| 37 | -MLA_ARGS=" | ||
| 38 | - --multi-head-latent-attention \ | ||
| 39 | - --qk-rope-head-dim 64 \ | ||
| 40 | - --qk-nope-head-dim 128 \ | ||
| 41 | - --q-lora-rank 1536 \ | ||
| 42 | - --kv-lora-rank 512 \ | ||
| 43 | - --v-head-dim 128 \ | ||
| 44 | - --qk-layernorm | ||
| 45 | -" | ||
| 46 | - | ||
| 47 | -MOE_ARGS=" | ||
| 48 | - --n-group 4 \ | ||
| 49 | - --seq-aux \ | ||
| 50 | - --moe-alltoall-overlap-comm \ | ||
| 51 | - --moe-grouped-gemm \ | ||
| 52 | - --moe-permutation-async-comm \ | ||
| 53 | - --use-fused-moe-token-permute-and-unpermute \ | ||
| 54 | - --moe-token-dispatcher-type alltoall \ | ||
| 55 | - --first-k-dense-replace 1 \ | ||
| 56 | - --moe-layer-freq 1 \ | ||
| 57 | - --n-shared-experts 1 \ | ||
| 58 | - --num-experts 32 \ | ||
| 59 | - --moe-router-topk 8 \ | ||
| 60 | - --moe-intermediate-size 2048 \ | ||
| 61 | - --moe-router-load-balancing-type noaux_tc \ | ||
| 62 | - --topk-group 4 \ | ||
| 63 | - --routed-scaling-factor 2.5 \ | ||
| 64 | - --norm-topk-prob \ | ||
| 65 | - --moe-router-score-function sigmoid \ | ||
| 66 | - --moe-router-enable-expert-bias | ||
| 67 | -" | ||
| 68 | - | ||
| 69 | -MTP_ARGS=" | ||
| 70 | - --num-nextn-predict-layers 1 \ | ||
| 71 | - --share-mtp-embedding-and-output-weight \ | ||
| 72 | - --recompute-mtp-norm \ | ||
| 73 | - --recompute-mtp-layer | ||
| 74 | -" | ||
| 75 | - | ||
| 76 | -ROPE_ARGS=" | ||
| 77 | - --rope-scaling-beta-fast 32 \ | ||
| 78 | - --rope-scaling-beta-slow 1 \ | ||
| 79 | - --rope-scaling-factor 40 \ | ||
| 80 | - --rope-scaling-mscale 1.0 \ | ||
| 81 | - --rope-scaling-mscale-all-dim 1.0 \ | ||
| 82 | - --rope-scaling-original-max-position-embeddings 4096 \ | ||
| 83 | - --rope-scaling-type yarn | ||
| 84 | -" | ||
| 85 | - | ||
| 86 | -GPT_ARGS=" | ||
| 87 | - --finetune \ | ||
| 88 | - --spec mindspeed_llm.tasks.models.spec.deepseek_spec layer_spec \ | ||
| 89 | - --recompute-granularity full \ | ||
| 90 | - --recompute-method uniform \ | ||
| 91 | - --recompute-num-layers 1 \ | ||
| 92 | - --no-shared-storage \ | ||
| 93 | - --use-distributed-optimizer \ | ||
| 94 | - --reuse-fp32-param \ | ||
| 95 | - --use-flash-attn \ | ||
| 96 | - --shape-order BNSD \ | ||
| 97 | - --use-mcore-models \ | ||
| 98 | - --tensor-model-parallel-size ${TP} \ | ||
| 99 | - --pipeline-model-parallel-size ${PP} \ | ||
| 100 | - --expert-model-parallel-size ${EP} \ | ||
| 101 | - --sequence-parallel \ | ||
| 102 | - --context-parallel-size ${CP} \ | ||
| 103 | - --context-parallel-algo ${CP_TYPE} \ | ||
| 104 | - --num-layers ${NUM_LAYERS} \ | ||
| 105 | - --hidden-size 7168 \ | ||
| 106 | - --ffn-hidden-size 18432 \ | ||
| 107 | - --num-attention-heads 128 \ | ||
| 108 | - --tokenizer-type PretrainedFromHF \ | ||
| 109 | - --tokenizer-name-or-path ${TOKENIZER_PATH} \ | ||
| 110 | - --seq-length ${SEQ_LEN} \ | ||
| 111 | - --max-position-embeddings 163840 \ | ||
| 112 | - --micro-batch-size ${MBS} \ | ||
| 113 | - --global-batch-size ${GBS} \ | ||
| 114 | - --make-vocab-size-divisible-by 1 \ | ||
| 115 | - --lr 1.0e-5 \ | ||
| 116 | - --train-iters 15 \ | ||
| 117 | - --lr-decay-style cosine \ | ||
| 118 | - --untie-embeddings-and-output-weights \ | ||
| 119 | - --disable-bias-linear \ | ||
| 120 | - --attention-dropout 0.0 \ | ||
| 121 | - --init-method-std 0.02 \ | ||
| 122 | - --hidden-dropout 0.0 \ | ||
| 123 | - --position-embedding-type rope \ | ||
| 124 | - --normalization RMSNorm \ | ||
| 125 | - --use-fused-rotary-pos-emb \ | ||
| 126 | - --use-rotary-position-embeddings \ | ||
| 127 | - --use-fused-swiglu \ | ||
| 128 | - --use-fused-rmsnorm \ | ||
| 129 | - --swiglu \ | ||
| 130 | - --no-masked-softmax-fusion \ | ||
| 131 | - --attention-softmax-in-fp32 \ | ||
| 132 | - --min-lr 1.0e-7 \ | ||
| 133 | - --weight-decay 1e-2 \ | ||
| 134 | - --clip-grad 1.0 \ | ||
| 135 | - --adam-beta1 0.9 \ | ||
| 136 | - --adam-beta2 0.999 \ | ||
| 137 | - --initial-loss-scale 65536 \ | ||
| 138 | - --vocab-size 129280 \ | ||
| 139 | - --padded-vocab-size 129280 \ | ||
| 140 | - --rotary-base 10000 \ | ||
| 141 | - --norm-epsilon 1e-6 \ | ||
| 142 | - --no-load-optim \ | ||
| 143 | - --no-load-rng \ | ||
| 144 | - --bf16 | ||
| 145 | -" | ||
| 146 | - | ||
| 147 | -DATA_ARGS=" | ||
| 148 | - --data-path $DATA_PATH \ | ||
| 149 | - --split 100,0,0 | ||
| 150 | -" | ||
| 151 | - | ||
| 152 | -OUTPUT_ARGS=" | ||
| 153 | - --log-throughput \ | ||
| 154 | - --log-interval 1 \ | ||
| 155 | - --save-interval 2000 \ | ||
| 156 | - --eval-interval 2000 \ | ||
| 157 | - --eval-iters 0 \ | ||
| 158 | - --no-save-optim \ | ||
| 159 | - --no-save-rng | ||
| 160 | -" | ||
| 161 | - | ||
| 162 | -torchrun $DISTRIBUTED_ARGS $basepath/pretrain_gpt.py \ | ||
| 163 | - $GPT_ARGS \ | ||
| 164 | - $DATA_ARGS \ | ||
| 165 | - $OUTPUT_ARGS \ | ||
| 166 | - $MLA_ARGS \ | ||
| 167 | - $ROPE_ARGS \ | ||
| 168 | - $MOE_ARGS \ | ||
| 169 | - $MTP_ARGS \ | ||
| 170 | - --load $CKPT_LOAD_DIR \ | ||
| 171 | - --distributed-backend nccl | ||