gpt-fast icon indicating copy to clipboard operation
gpt-fast copied to clipboard

[example] Added (hacky) Grok1 support

Open Chillee opened this issue 1 year ago • 3 comments

Downloading from https://huggingface.co/hpcai-tech/grok-1

git clone --branch grok1 [email protected]:pytorch-labs/gpt-fast.git && cd gpt-fast/mixtral-moe
export MODEL_REPO=hpcai-tech/grok-1
python scripts/download.py --repo_id $MODEL_REPO
python scripts/convert_hf_checkpoint.py --checkpoint_dir checkpoints/$MODEL_REPO
python quantize.py --checkpoint_path checkpoints/$MODEL_REPO/model.pth --mode int8
TOKENIZERS_PARALLELISM=false ENABLE_INTRA_NODE_COMM=1 time torchrun --standalone --nproc_per_node=8 generate.py  --checkpoint_path checkpoints/$MODEL_REPO/model_int8.pth   --compile --compile_prefill

Run on 8xA100 80GB

Time for inference 5: 2.73 sec total, 73.15 tokens/sec
Bandwidth achieved: 3057.61 GB/s
Average tokens/sec: 73.04

ms per output token: 13.67ms

Chillee avatar May 05 '24 21:05 Chillee

This is awesome! I found one small bug:

Grok uses gelu for the MLP block https://github.com/xai-org/grok-1/blob/7050ed204b8206bb8645c7b7bbef7252f79561b0/model.py#L374 But mixtral uses silu https://github.com/pytorch-labs/gpt-fast/blob/de06b53a4f95c72cd3abd0a8e9fa2d6913676c1a/mixtral-moe/model.py#L214

You should replace it with gelu. Otherwise, the model can generate meaningful text but its performance is significantly degraded.

merrymercy avatar May 24 '24 10:05 merrymercy

@merrymercy ah that would explain my results haha. Thanks!

Chillee avatar Jun 06 '24 04:06 Chillee

Hi @Chillee!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Feb 28 '25 03:02 facebook-github-bot