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

Ggml exporter #1293

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Ggml exporter #1293

wants to merge 8 commits into from

Conversation

baskrahmer
Copy link
Contributor

@baskrahmer baskrahmer commented Aug 17, 2023

What does this PR do?

Export Hugging Face models to ggml format using a dedicated exporter. Right now I added the bloom and starcoder architectures, only for PyTorch and without quantization. In the current PR, adding a new architecture would look as follows:

  • Adding a cpp file: contains code for inference and loading of the weights (example)
  • Adding a Makefile target: used to create a main cpp binary from the cpp file (example)
  • Creating a ggml config: used to create a ggml cpp binary from the Hugging Face weights. Specify parameters like vocab size, hidden dim etc. and also for model-specific processing (e.g. map HF layers to cpp layers using state dict; reshape specific layers, etc) -- see optimum/exporters/ggml/model_configs.py in this PR

Now I am a bit overwhelmed by the diversity between only starcoder and bloom already. This makes me question whether a solution like this would be too complex to support a wide range of models, hence I am opening it early as a draft PR to gather some feedback early before polishing any further.

To try it yourself, see these testcases tests/exporters/ggml/test_ggml_export.py and make sure the ggml.cpp submodule is loaded correctly (I think you need to explicitly pull it for the source code to appear).

Related issue: #903 (cc @fxmarty @NouamaneTazi @sidistic)

Before submitting

  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

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

1 participant