-
Notifications
You must be signed in to change notification settings - Fork 590
Add Dynamic Model Import and ModelSpec Definition #814
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
df1bc6a
Update
fegin dfc1649
Update
fegin 720f12a
Update
fegin 225bfcc
Update
fegin 650152e
Update
fegin 687fda9
Update
fegin 6a51325
Update
fegin 5b33b65
Update
fegin 2e569d7
Update
fegin bab9bf5
Update
fegin 210707a
Update
fegin 6fb1d74
Update
fegin 02c87b2
Update
fegin 4234a26
Update
fegin a5491da
Update
fegin b5cd485
Update
fegin 078d4ad
Update
fegin caf5b97
Update
fegin c131309
Update
fegin 2f4d1ce
Update
fegin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
| # | ||
| # Copyright (c) Meta Platforms, Inc. All Rights Reserved. | ||
|
|
||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Callable, Dict, List, Protocol, Tuple, Type | ||
|
|
||
| import torch.nn as nn | ||
| from torch.distributed.pipelining.schedules import _PipelineSchedule | ||
|
|
||
|
|
||
| @dataclass | ||
| class BaseModelArgs: | ||
| _enforced: str = "This field is used to enforce all fields have defaults." | ||
|
|
||
|
|
||
| class ModelProtocol(Protocol): | ||
| def from_model_args(self, args: BaseModelArgs) -> nn.Module: | ||
| ... | ||
|
|
||
|
|
||
| @dataclass | ||
| class ModelSpec: | ||
fegin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: str | ||
| cls: Type[nn.Module] | ||
| config: Dict[str, BaseModelArgs] | ||
| # As for now, this is a string. So it will have to be built-in to the | ||
| # TorchTitan library. In the future, we can make this a defined class | ||
| # that can be extended like ModelSpec. | ||
| tokenizer: str | ||
fegin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| parallelize_fn: Callable[[nn.Module], None] | ||
| pipelining_fn: Callable[[nn.Module], Tuple[_PipelineSchedule, List[nn.Module]]] | ||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.