Skip to content

Pipeline Parallelism GPT2 Example #489

Closed

Description

@nitikasaran68

Hey I was trying to run the Megatron-LM code with your 3D parallelism. For pipeline parallelism, I unrolled the GPT-2 into an nn.Sequential like model and followed the AlexNet example to tweak the training script accordingly. But it keeps going out of memory for me even for a "train_micro_batch_size_per_gpu" of 1 in the 1.5bn model. I've disabled data & model parallelism and was running it on 8 GPUs with the partition method as "type:TransformerLayer".
I also see references to a "GPT2ModelPipe" in the code but I couldn't find it in the examples. Could you release this example for Megatron?

Activity

  1. added
    user-question
    on Oct 29, 2020
  2. ShadenSmith commented on Oct 29, 2020

    @ShadenSmith
    Contributor

    Hi @nitikasaran68, thank you for your interest in DeepSpeed! We're working on releasing a full example and tutorial. There have just been some initial tasks to address first, such as improved examples and some interface simplifications.

  3. nitikasaran68 commented on Nov 3, 2020

    @nitikasaran68
    Author

    Hey, can you help me reproduce your GPT-2 3D parallelism results here (figure 5)
    I'm unable to fit a batch size of even 1 with a single gradient accumulation step with the 4pp x 4dp setting on 16 V100s with 16GB memory. If I try 8pp and 2dp, a micro batch size of 1 fits for not more than 4 micro batches.
    Here's how I'm wrapping the gpt2 model:

    model = deepspeed.pipe.PipelineModule(layers=model.to_layers(),
    num_stages=args.pipeline_depth,
    loss_fn=loss_fn,
    partition_method="type:GPT2ParallelTransformerLayer",
    activation_checkpoint_interval=0)

    I've gone through a lot of your code and I don't think I'm passing anything incorrectly but perhaps you could help me out?

    I'm using this config:
    {
    "train_batch_size": 8,
    "train_micro_batch_size_per_gpu" : 1,
    "steps_per_print": 1,
    "zero_optimization": {
    "stage": 1,
    "reduce_bucket_size": 5000000,
    "allgather_bucket_size": 5000000
    },
    "zero_allow_untested_optimizer": true,
    "gradient_clipping": 1.0,
    "fp16": {
    "enabled": true,
    "loss_scale": 0,
    "loss_scale_window": 1000,
    "hysteresis": 2,
    "min_loss_scale": 1,
    "initial_scale_power": 13
    },
    "wall_clock_breakdown": false
    }

    gpt_options="
    --model-parallel-size 1
    --num-layers 48
    --hidden-size 1600
    --num-attention-heads 16
    --batch-size 1
    --seq-length 1024
    --max-position-embeddings 1024
    --train-iters 100000
    --resume-dataloader
    --train-data webtext
    --lazy-loader
    --tokenizer-type GPT2BPETokenizer
    --split 949,50,1
    --distributed-backend nccl
    --lr 0.00001
    --no-load-optim
    --lr-decay-style cosine
    --weight-decay 1e-2
    --log-interval 1
    --clip-grad 1.0
    --warmup .01
    --fp16

  4. ShadenSmith commented on Nov 3, 2020

    @ShadenSmith
    Contributor

    Hi @nitikasaran68, try setting activation_checkpoint_interval=1 when you wrap the module. Activation checkpointing is a big memory saver for these kinds of models.

  5. added a commit that references this issue on Apr 11, 2023
  6. self-assigned this
    on Sep 8, 2023
  7. xiexbing commented on Sep 14, 2023

    @xiexbing
    Contributor

    software issue has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

user-question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions