-
Notifications
You must be signed in to change notification settings - Fork 19
[WIP] feat: add model architecture configuration #111
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @aftersnow, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a significant enhancement to the modelpack specification by adding an optional, detailed model architecture configuration. The primary goal is to provide explicit structural information about models, starting with decoder-type transformers, which is currently missing from the modelpack. This new configuration will enable model runtimes to seamlessly execute models by understanding their internal components and parameters, thereby improving interoperability and reducing the need for hardcoded details.
Highlights
- New Model Architecture Specification: I've added a comprehensive new document,
docs/architecture.md, which defines an optional configuration for model architectures. This is a crucial step towards bridging the gap between model images and model runtimes by providing detailed structural information. - Detailed Transformer Architecture Configuration: The new specification currently focuses on decoder-type transformer architectures, outlining detailed properties for components like tokenizers, embeddings (positional and token), transformer layers (attention, MLP, MoE), and normalization. It supports both uniform and mixed layer configurations, providing a granular way to describe model structure.
- Integration with Modelpack Configuration: I've updated
docs/config.mdto include an optionalarchitecture_configfield. This allows modelpack users to associate a detailed architectural description with their models, enhancing the existing specification and enabling better interoperability with model runtimes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces a new architecture_config field to the model configuration and a detailed specification for it in docs/architecture.md. This is a great addition that will improve model interoperability.
I've left a few comments on the documentation for clarity and consistency. The most important feedback is about a broken link in docs/config.md.
Additionally, it seems that the corresponding Go structs and JSON schema have not been updated to reflect these changes. The following files appear to be missing updates:
specs-go/v1/config.goschema/config-schema.json
Keeping the specification documents, Go types, and JSON schema in sync is crucial for consumers of this spec. Please consider adding the necessary changes to these files in this PR.
| - **mlp_layers** _array_, REQUIRED | ||
|
|
||
| Layers that use MLP. If empty, moe_frequency determines sparsity. The default is `[]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interaction between mlp_layers and moe_frequency is unclear.
- Both are marked as
REQUIRED, which seems contradictory if they are alternative ways of defining layer types. - The description for
mlp_layerssays "If empty, moe_frequency determines sparsity", which suggests they might be mutually exclusive in some way.
Could you please clarify the logic? For example:
- Are both fields always required? If so, how do they work together?
- Should the user provide one or the other? If so, they should probably be
OPTIONALand a constraint likeoneOfshould be defined on the parentmixed_layersobject.
The documentation should be updated to clearly explain how to configure mixed MLP and MoE layers. Also, note that mlp_layers is marked as REQUIRED but has a default value, which is inconsistent as mentioned in another comment.
|
Please take a look. More development, testing, and validation are needed. Recently, I have been busy with production environments and haven't had enough time. Everyone is welcome to contribute! |
This commit introduces a new document detailing the model architecture configuration, including support for transformer architectures and their components. It outlines terminology, properties, and provides an example configuration for better understanding and implementation. Signed-off-by: Zhao Chen <[email protected]>
ab3474c to
a1258dd
Compare
|
This PR is stale because it has been open 40 days with no activity. |
This commit introduces a new document detailing the model architecture configuration, including support for transformer architectures and their components. It outlines terminology, properties, and provides an example configuration for better understanding and implementation.
Description
Add an optional architecture configuration that describes the detailed structure and components of the model. Currently, only decoder-type transformer architectures are supported.
Motivation and Context
The current modelpack can serve as a standard for building, distributing, and managing AI models. Using this specification, we can:
However, it lacks the architectural and runtime interfaces to run the model. For example, it lacks crucial architectural details such as:
This creates a gap between the model image and the model runtime. Without this additional information, the model runtime cannot execute the model seamlessly (only if the model runtime has pre-built specific support). To address these limitations, we are defining the model architecture configuration as the first step.
This PR adds an optional architecture configuration that describes the detailed structure and components of the model.
Use Cases
Details
The transformer is the most popular architecture for LLMs. It consists of a stack of structured layers, where each layer contains a self-attention block and a feed-forward network, with normalization layers and residual connections. The complete architecture includes a tokenizer, input embedding layer, position embedding layer, transformer layers, and output embedding layer. The transformer architecture has remained relatively stable since Attention is all you need. As shown in the table below, current open-weight model architectures are converging, making it feasible to define a common abstraction.
Note: Each model represents the largest variant within its respective series.
Next Steps
Acknowledgement
This PR is inspired by transformers, vllm, ollama, onnx, tgi, sglang, lmdeploy, curated-transformers, triton-inference-server, transformer-engine, ggml.