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

Split encoders in non-concurrent context with a max ops per encoder #1085

Merged
merged 2 commits into from
May 9, 2024

Conversation

awni
Copy link
Member

@awni awni commented May 6, 2024

Speeds up generation and slightly training, some benchmarks:

Benchmarks on an M2 Ultra

LLM generation

python -m mlx_lm.generate --model mlx-community/NeuralBeagle14-7B-4bit-mlx --prompt "Write a story about Albert Einstein" --temp 0.0 --max-tokens 256

Pre:
Prompt: 222.239 tokens-per-sec
Generation: 107.239 tokens-per-sec

Post:
Prompt: 223.145 tokens-per-sec
Generation: 108.463 tokens-per-sec

MNIST

Pre: Test accuracy 0.936, Time 0.632 (s)
Post: Test accuracy 0.927, Time 0.625 (s)

LeNet

Pre: Test accuracy 0.981, Time 2.797 (s)
Post: Test accuracy 0.975, Time 2.757 (s)

ResNet

Pre: Throughput: 6462.77 samples/second, Peak memory 1.663 (GB)
Post: Throughput: 6474.81 samples/second, Peak memory 1.663 (GB)

Transformer training:

python main.py --gpu

Pre: Iter 40: Train loss 7.864, It/sec 5.881, Peak memory 5.534 (GB)
Post: Iter 40: Train loss 7.814, It/sec 5.902, Peak memory 5.534 (GB)

@awni awni requested review from jagrit06 and angeloskath May 6, 2024 19:58
@awni
Copy link
Member Author

awni commented May 6, 2024

The generation speed up is pretty nice. Running with a bigger command buffer (100 ops) gives even more speedup:

Generation: 114.676 tokens-per-sec

The main downside is introducing the additional dipatch* methods so that we can track dispatches on the command encoder. I'm not wedded to it..

Copy link
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great! 🚀🚀🚀

@awni awni merged commit 06375e6 into main May 9, 2024
3 checks passed
@awni awni deleted the split_encoders branch May 9, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants