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

Basic pixtral support, paving the way for vision models 🖼️ #153

Merged
merged 12 commits into from
Jan 29, 2025

Conversation

francoishernandez
Copy link
Member

@francoishernandez francoishernandez commented Nov 29, 2024

Conversion

Conversion is made to work with the mistral-community models, and was for now only tested with mistral-community/pixtral-12b.
The official mistralai models lack quite some information to be usable in our context. (HF checkpoints lack information as well, but it's more manageable.)

What works

The provided test_inference.py script in the pixtral recipe allows to run inference on a few examples (grabbed from the Pixtral blog post).
The configuration is using bitsandbytes quantization by default, to allow running on a 24G VRAM GPU (tested on 3090).
Some differences in a few methods (notably rope) lead to slight numerical differences with the HF implementation (as most of our models anyways).

What does not work (yet)

What might need to be improved (future work)

  • model definition (split out eole.models.model? allow for different adapter classes?)
  • configuration / documentation
  • proper configuration of specific image tokens
  • HF conversion script (not only related to this work)
  • dataloading is a bit hacky and might benefit some refactoring/simplification
  • support more Llava-like models?

@francoishernandez francoishernandez force-pushed the more_tokenizers branch 2 times, most recently from 11f0c4b to b13ac3f Compare November 29, 2024 15:23
@francoishernandez francoishernandez added the enhancement New feature or request label Dec 4, 2024
@francoishernandez francoishernandez changed the base branch from more_tokenizers to main January 12, 2025 14:51
@francoishernandez francoishernandez force-pushed the pixtral branch 2 times, most recently from 6a07c42 to 2212f16 Compare January 12, 2025 16:26
@francoishernandez
Copy link
Member Author

francoishernandez commented Jan 12, 2025

Recent changes (mostly #171) broke a few things here, I grabbed the changes and created a clean commit from there.

Also, "model-level rope" might not the best here because we have different kinds of rope for the vision encoder and the text decoder. So for now, the vision encoder rope is defined within the encoder code, while the "model-level rope" is the text decoder one.

@francoishernandez
Copy link
Member Author

The initial goal was to extend this PR with more llava-like vision architectures. This could have facilitated finetuning experiments with smaller models for instance.
But the various llava models are quite a mess with lots of vision encoder/adapter variants notably.
(For now, the finetuning codepath has only been tested "naïvely" by reducing the number of layers to fit in VRAM and making sure the code runs.)
So let's merge this, which allows to play with pixtral-12b inference, and address these topics (+ server support) in subsequent PRs.

@francoishernandez francoishernandez marked this pull request as ready for review January 29, 2025 08:47
@francoishernandez francoishernandez force-pushed the pixtral branch 2 times, most recently from 00348f7 to d3250a7 Compare January 29, 2025 10:45
@francoishernandez francoishernandez merged commit f6f9a95 into main Jan 29, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant