qwen math training code (#435)

* qwen math training code

* pre-commit
This commit is contained in:
Zafir Stojanovski 2025-05-16 13:19:19 +02:00 committed by GitHub
parent 47303211b3
commit 0cda6b1205
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 155089 additions and 0 deletions

View file

@ -0,0 +1,20 @@
#!/bin/bash
MAMBA_ENV="tina"
eval "$(mamba shell hook --shell bash)" && mamba activate "${MAMBA_ENV}"
echo "START TIME: $(date)"
echo "PYTHON ENV: $(which python)"
source "./scripts/set/set_vars.sh"
PY_SCRIPT="./scripts/set/run_download_model.py"
echo ""
echo "Running script: ${PY_SCRIPT}"
echo ""
python "${PY_SCRIPT}"
echo "END TIME: $(date)"
echo "DONE"

View file

@ -0,0 +1,9 @@
import os
from huggingface_hub import snapshot_download
if __name__ == "__main__":
CKPT_DIR = os.environ["CKPT_DIR"]
print("Downloading model ...")
snapshot_download(repo_id="Qwen/Qwen2.5-3B-Instruct", local_dir=f"{CKPT_DIR}/models/Qwen2.5-3B-Instruct/base")

View file

@ -0,0 +1,39 @@
#!/bin/bash
# python 3.10 + cuda 11.8.0
# the execution order the following commands matter
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export OMP_NUM_THREADS=1
conda clean -a -y
mamba clean -a -y
pip install --upgrade pip
pip cache purge
# cuda, gcc/g++, torch
# mamba install cuda -c nvidia/label/cuda-11.8.0 -y
# mamba install gcc gxx -c conda-forge -y
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
# xformers
pip install xformers==0.0.28.post3 --index-url https://download.pytorch.org/whl/cu118
# vLLM pre-compiled with CUDA 11.8
pip install https://github.com/vllm-project/vllm/releases/download/v0.7.2/vllm-0.7.2+cu118-cp38-abi3-manylinux1_x86_64.whl
pip install deepspeed
pip install flash-attn==2.7.3 --no-build-isolation
pip install peft
pip install "trl==0.15.2"
pip install latex2sympy2_extended
pip install "math_verify==0.5.2"
pip install word2number
pip install scipy
pip install wandb
pip install plotly
pip install matplotlib
pip install seaborn

View file

@ -0,0 +1,46 @@
#!/bin/bash
# python 3.11 & cuda 11.8
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export OMP_NUM_THREADS=1
conda clean -a -y
mamba clean -a -y
pip install --upgrade pip
pip cache purge
# mamba install cuda -c nvidia/label/cuda-11.8.0 -y
# mamba install gcc gxx -c conda-forge -y
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install xformers --index-url https://download.pytorch.org/whl/cu118
pip install vllm
pip install flash-attn --no-build-isolation
pip install accelerate
pip install datasets
pip install deepspeed
pip install distilabel[vllm,ray,openai]
pip install e2b-code-interpreter
pip install einops
pip install flake8
pip install huggingface_hub
pip install hf_transfer
pip install isort
pip install langdetect
pip install latex2sympy2_extended
pip install liger_kernel
pip install "math_verify==0.5.2"
pip install packaging
pip install parameterized
pip install peft
pip install pytest
pip install python-dotenv
pip install ruff
pip install safetensors
pip install sentencepiece
pip install transformers
pip install trl@git+https://github.com/huggingface/trl.git
pip install wandb

View file

@ -0,0 +1,53 @@
#!/bin/bash
export CUDA_LAUNCH_BLOCKING=1
export DS_LOG_LEVEL=error
export TOKENIZERS_PARALLELISM=false
export NCCL_P2P_DISABLE=1
export NCCL_SHM_DISABLE=1
export NCCL_IB_DISABLE=1
export MKL_THREADING_LAYER=GNU
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export OMP_NUM_THREADS=1
## basic setup for the env
export PROJECT_PREFIX="/root/projects" # e.g. /home/username/projects
export SCRATCH_PREFIX="/root/scratch" # e.g. /home/username/scratch
mkdir -p "${PROJECT_PREFIX}" "${SCRATCH_PREFIX}"
export PROJECT_NAME="rg-math"
export CORE_POSTFIX="tina"
export PROJECT_DIR="${PROJECT_PREFIX}/${PROJECT_NAME}"
export PYTHONPATH="${PROJECT_DIR}":$PYTHONPATH
export PYTHONPATH="${PROJECT_DIR}/${CORE_POSTFIX}":$PYTHONPATH
mkdir -p "${PROJECT_PREFIX}/${PROJECT_NAME}"
export CKPT_DIR="${PROJECT_DIR}/ckpts"
export DATA_DIR="${PROJECT_DIR}/datasets"
export OUTPUT_DIR="${PROJECT_DIR}/outputs"
export LOGGING_DIR="${PROJECT_DIR}/logs"
mkdir -p "${CKPT_DIR}" "${DATA_DIR}" "${OUTPUT_DIR}" "${LOGGING_DIR}"
## wandb setup
# export WANDB_API_KEY="TODO"
export WANDB_PROJECT="${PROJECT_NAME}"
export WANDB_DIR="${OUTPUT_DIR}"
wandb login $WANDB_API_KEY
export CACHE_DIR="${PROJECT_DIR}/.cache"
export WANDB_CACHE_DIR="${CACHE_DIR}"
export TRITON_CACHE_DIR="${CACHE_DIR}/triton_cache"
## huggingface setup
# export HF_TOKEN="TODO"
git config --global credential.helper store
huggingface-cli login --token $HF_TOKEN --add-to-git-credential
export HF_HOME="${CACHE_DIR}/huggingface"
export HUGGINGFACE_HUB_CACHE="${HF_HOME}/hub"
export HF_DATASETS_CACHE="${HF_HOME}/datasets"