-
Notifications
You must be signed in to change notification settings - Fork 33
[Prototype] Generalize dynamic config classes #245
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
Draft
jlamypoirier
wants to merge
39
commits into
main
Choose a base branch
from
generalize_dynamic_classes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
4b606b0
Generalize config classes
jlamypoirier 4a67660
cli
jlamypoirier 531f67d
Merge branch 'main' into generalize_dynamic_classes
jlamypoirier 1823407
misc
jlamypoirier fe7acd9
stuff
jlamypoirier bee7a4b
Merge remote-tracking branch 'origin/main' into generalize_dynamic_clβ¦
jlamypoirier d41be60
stuff
jlamypoirier ec35a50
fixes
jlamypoirier 3005c8c
stuff
jlamypoirier 5735d21
fix
jlamypoirier a7e7362
Merge remote-tracking branch 'origin/main' into generalize_dynamic_clβ¦
jlamypoirier 6357365
stuff
jlamypoirier 207aef0
stuff
jlamypoirier 31579bd
Bring back default_factory
jlamypoirier f79ed27
fix
jlamypoirier 0a37209
Revert "fix"
jlamypoirier 897cc0f
Revert "Bring back default_factory"
jlamypoirier 8a49e0f
stuff
jlamypoirier 843a621
fix
jlamypoirier aa3bc0b
stuff
jlamypoirier 28d321e
stuff
jlamypoirier 1bbd7fb
stuff
jlamypoirier a426450
Merge branch 'misc' into generalize_dynamic_classes
jlamypoirier 87e11f0
stuff
jlamypoirier 60a656e
stuff
jlamypoirier 3595949
Minimalistic dynamic configs
jlamypoirier 39b1a04
stuff
jlamypoirier f29b3fc
Merge branch 'minimalistic_dynamic_classes' into generalize_dynamic_cβ¦
jlamypoirier 743edaa
Simplify cli
jlamypoirier 038106f
Simplify cli
jlamypoirier d0e86cb
Merge remote-tracking branch 'origin/main' into misc
jlamypoirier 3fa314c
Merge branch 'misc' into minimalistic_dynamic_classes
jlamypoirier 7bb6ee9
Merge remote-tracking branch 'origin/main' into minimalistic_dynamic_β¦
jlamypoirier a98a2ae
Merge branch 'minimalistic_dynamic_classes' into simplify_cli
jlamypoirier 85e02b8
Merge branch 'main' into simplify_cli
jlamypoirier 0fd49e4
Merge remote-tracking branch 'origin/main' into simplify_cli
jlamypoirier 0a010f3
Merge branch 'main' into generalize_dynamic_classes
jlamypoirier c415e32
Merge branch 'simplify_cli' into generalize_dynamic_classes
jlamypoirier e199d0a
fix
jlamypoirier 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
import sys | ||
import traceback | ||
|
||
from fast_llm.config import ValidationError | ||
from fast_llm.engine.config_utils.logging import configure_logging | ||
from fast_llm.engine.config_utils.run import log_main_rank | ||
from fast_llm.engine.config_utils.runnable import RunnableConfig | ||
|
||
# Import these submodules to ensure classes are added to the dynamic class registry. | ||
import fast_llm.data.auto # isort: skip | ||
import fast_llm.engine.checkpoint.convert # isort: skip | ||
import fast_llm.models.auto # isort: skip | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def fast_llm_main(args: list[str] | None = None): | ||
# TODO: Add hook to register model classes? (environment variable?) | ||
# (Pre-)configure logging | ||
configure_logging() | ||
try: | ||
RunnableConfig.parse_and_run(args) | ||
except Exception as e: | ||
if sys.gettrace(): | ||
raise | ||
if isinstance(e, ValidationError): | ||
log_main_rank(traceback.format_exc(), log_fn=logger.error) | ||
else: | ||
logger.critical(traceback.format_exc()) | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
fast_llm_main() |
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 |
---|---|---|
@@ -1,13 +1,5 @@ | ||
from fast_llm.data.preparator.config import DatasetPreparatorConfig | ||
from fast_llm.data.preparator.gpt_memmap.config import GPTMemmapDatasetPreparatorConfig | ||
from fast_llm.utils import Registry | ||
""" | ||
Import these submodules to ensure classes are added to the dynamic class registry. | ||
""" | ||
|
||
dataset_preparator_registry = Registry[str, DatasetPreparatorConfig]( | ||
"DatasetPreparator", | ||
{ | ||
dataset_preparator.preparator_name: dataset_preparator | ||
for dataset_preparator in [ | ||
GPTMemmapDatasetPreparatorConfig, | ||
] | ||
}, | ||
) | ||
from fast_llm.data.preparator.gpt_memmap.config import GPTMemmapDatasetPreparatorConfig # isort: skip |
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.
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.
@jlamypoirier shouldn't this be something like
Assert.custom(issubclass, expected_class, self.__class__)
instead?I.e. the dynamically inferred class (expected_class) should be a subclass of self.class, it should not necessarily match the class exactly?
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 value is overridden in
from_dict
. Anyway this PR isn't too relevant anymore, I broke it into pieces