[Prototype] Support block-modular architecture#277
Closed
oleksost wants to merge 158 commits into
Closed
Conversation
…oleksiy/apriel-ssm
…to modular_hybrids
Collaborator
jlamypoirier
left a comment
There was a problem hiding this comment.
I had a quick look, will go deeped once updated with main
| # Should be handled in `from_dict`, but can fail if instantiating directly. | ||
| Assert.is_(self.__class__, expected_class) | ||
|
|
||
| # TODO: is this ok? i.e. we want the assigned class to be a subclass of the expected class, not neccessarily exactly the same class. |
Collaborator
There was a problem hiding this comment.
No, this is handled in from_dict. The expected class is not the same as the type hint.
|
|
||
|
|
||
| @config_class() | ||
| class BaseBlockConfig(BaseModelConfig): |
Collaborator
There was a problem hiding this comment.
This doesn't really belong in common. Maybe a base_block submodule?
|
|
||
| @config_class() | ||
| class LanguageModelBaseConfig(BaseModelConfig): | ||
| transformer: TransformerConfig = Field( |
| hint=FieldHint.feature, | ||
| valid=check_field(Assert.geq, 0), | ||
| ) | ||
| head_normalization: NormalizationConfig | None = Field( |
Collaborator
There was a problem hiding this comment.
Implicit convention: Put sub-configs on top. I don't think we want None in the type hint since it's not a valid value after validation.
| if self.embeddings_hidden_dropout is None: | ||
| self.embeddings_hidden_dropout = 0.0 | ||
| if self.head_normalization is None: | ||
| self.head_normalization = NormalizationConfig() |
Collaborator
There was a problem hiding this comment.
I'd rather keep the transformer normalization as the default.
| @@ -0,0 +1,55 @@ | |||
| import typing | |||
Collaborator
There was a problem hiding this comment.
Rename file to block for consistency
Collaborator
|
Handled in #362 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Description
This draft PR addresses #242 by introducing a flexible, modular configuration system for hybrid model architectures.
TODOs:
maininto this branchWhich will result in block layout like this: ["bob", "mamba_1", "mamba_2", "bob"], where bobs share weights and mamba do not share weights.
🔍 Type of change
Class hierarchy in the config system:
BaseBlockintoBaseBlockConfiginlayers/commonBaseBlockConfig, both holding functionality specific to their dedicated blocks (TransformerLayer, LlambaBlock)Block-specific hyperparameters & tensor space definition:
HybridBlockConfigs implemented undermodels/hybrid/configallowing block-specific hyperparameters definitionLayer freezing:
lr_scaleand component specific scales likenorm_lr_scale,mlp_lr_scaleetc.. If both are passed, the resulting scale for a component islr_scaleof the block multiplied by the component specific lr (see 'get_lr_scale' function.Select all that apply:
📝 Changes
✅ Checklist
Make sure the following tasks are completed before submitting the PR:
General
Dependencies and Configuration
Testing
Performance Impact