Git Product home page Git Product logo

colossalai-bert's Introduction

Bert Benchmark

Bert Benchmark with Colossal-AI.

Setup

  1. Install dependencies if you do not have them.
pip install -r requirement.txt
  1. Install Colossal-AI
git clone https://github.com/hpcaitech/ColossalAI.git

cd ColossalAI

pip install --no-cache-dir .

  1. Prepare dataset from JSON file.
# install nltk
pip install --upgrade --no-cache-dir nltk

python -c "import nltk; nltk.download('punkt')"

python process_data.py \
    --data-path /PATH/TO/JSON/FILE \
    --vocab-file /PATH/TO/VOCAB/FILE \
    --output-path /PATH/TO/OUTPUT/DATASET/ \
    --seq-len 512

Colossal-AI Usage

  1. Run benchmark
torchrun --nproc_per_node=NUM_GPUS \
    run.py \
    --config configs/bert_config_tp1d.json \
    --data-path /PATH/TO/DATASET/ \
    --vocab-file /PATH/TO/VOCAB/FILE

Baseline Usage

git clone https://github.com/NVIDIA/Megatron-LM.git

cd Megatron-LM

torchrun --nproc_per_node=NUM_GPUS \
    pretrain_bert.py \
    --tensor-model-parallel-size 2 \
    --pipeline-model-parallel-size 1 \
    --num-layers 36 \
    --hidden-size 2048 \
    --ffn-hidden-size 4096 \
    --num-attention-heads 32 \
    --micro-batch-size 8 \
    --global-batch-size 5120 \
    --seq-length 512 \
    --max-position-embeddings 512 \
    --train-iters 20 \
    --iter-per-epoch 10 \
    --data-path /PATH/TO/DATASET/my-bert_text_sentence \
    --vocab-file /PATH/TO/VOCAB/FILE \
    --data-impl mmap \
    --split 949,50,1 \
    --distributed-backend nccl \
    --lr 0.0001 \
    --lr-decay-style linear \
    --min-lr 1.0e-5 \
    --lr-decay-iters 16 \
    --weight-decay 1e-2 \
    --clip-grad 1.0 \
    --lr-warmup-iters 4 \
    --log-interval 2 \
    --eval-iters 1 \
    --fp16

colossalai-bert's People

Contributors

kurisusnowdeng avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.