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

Experimental StableLM support #1719

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

Conversation

kazssym
Copy link

@kazssym kazssym commented Feb 25, 2024

What does this PR do?

This pull request tries to add support for the StableLM model. It is still incomplete.

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

This commit introduces two improvements:

 1. Support StableLM-Epoch for ONNX export:

    - A new class StableLMEpochOnnxConfig is added in optimum/exporters/onnx/model_configs.py to define the configuration for exporting StableLM-Epoch models to ONNX format.
    - This aligns with existing configs for other supported models.

 2. Enable StableLM-Epoch tasks in optimum/exporters/tasks.py:

    - The supported_tasks_mapping function now includes "stablelm-epoch" with supported tasks like "text-generation" and "text-classification".
    - This allows exporting StableLM-Epoch models for various tasks using the appropriate ONNX configuration.

These changes expand the capabilities of optimum by enabling ONNX export and task handling for StableLM-Epoch models.
This commit adds NormalizedTextConfig as the normalized configuration class for StableLM-Epoch models in optimum/utils/normalized_config.py.

This ensures consistency with other supported models and improves the overall compatibility and functionality of optimum when working with StableLM-Epoch models.
This commit updates MODEL_TYPES_REQUIRING_POSITION_IDS in optimum/exporters/onnx/utils.py to include "stablelm-epoch".

This ensures that position IDs are properly handled during ONNX export for StableLM-Epoch models, aligning with other models requiring this information.
  - Adds StableLmOnnxConfig for exporting StableLM models to ONNX.
  - Updates TasksManager to use StableLmOnnxConfig for "stablelm" task.
  - Updates NormalizedConfigManager to recognize "stablelm".
  - Requires Transformers version >= 4.37.99 for StableLM export.

This commit partially enables exporting StableLM models to ONNX, allowing them to be used in various inference pipelines.
  - Replaces "stablelm-epoch" with "stablelm" in MODEL_TYPES_REQUIRING_POSITION_IDS.

This commit reflects the updated model name "stablelm" for consistency with other parts of the codebase.
  - Adds "stablelm": "gpt2" mapping to ORTConfigManager.

This commit specifies that StableLM models should be treated similarly to GPT-2 models during ONNX Runtime inference for consistency and potentially improved optimization.
@fxmarty
Copy link
Collaborator

fxmarty commented Feb 29, 2024

@kazssym let me know if you'd like a review.

@xenova
Copy link
Contributor

xenova commented Mar 2, 2024

Can confirm that this PR works for transformers.js models 👍

@kazssym Just a reminder: you can add https://huggingface.co/hf-internal-testing/tiny-random-StableLmForCausalLM as a unit test.

This commit sets the default ONNX opset version to 13 for StableLM models exported with `optimum.onnx.export`.

This change ensures compatibility with a wider range of ONNX runtimes that might not support the latest opsets.
This commit adds the StableLM model `"hf-internal-testing/tiny-random-StableLmForCausalLM"` to the dictionaries of models for testing PyTorch ONNX export:

  * `PYTORCH_EXPORT_MODELS_TINY`
  * `PYTORCH_EXPORT_MODELS_LARGE`

This allows for including StableLM in regression tests to ensure compatibility with the updated ONNX exporter.
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

4 participants