Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[example] Added (hacky) Grok1 support #171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[example] Added (hacky) Grok1 support #171

wants to merge 2 commits into from

Conversation

Chillee
Copy link
Contributor

@Chillee Chillee commented May 5, 2024

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 5, 2024
@Chillee Chillee changed the title Added (hacky) Grok1 support [example] Added (hacky) Grok1 support May 6, 2024
@merrymercy
Copy link

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

x1 = F.silu(torch.einsum('ti,taoi -> tao', x, w1_weights))

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

@Chillee
Copy link
Contributor Author

Chillee commented Jun 6, 2024

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

@facebook-github-bot
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants