Repository navigation
Conversation
lkhphuc
commented
Apr 5, 2025
| class_type = self.__class__.__annotations__[k] | ||
| setattr(self, k, class_type(**v)) | ||
| else: | ||
| # Fallback to dynamic class creation for any new sections |
Contributor
Author
There was a problem hiding this comment.
Or we could remove this entirely and enforce all config are typed in a dataclass.
tianyu-l
reviewed
Apr 8, 2025
tianyu-l
left a comment
Contributor
There was a problem hiding this comment.
After a closer look at #767, it seems to me that using tyro gives a more elegant solution -- one only needs to define the args and their defaults once, in data classes, without using argparse at all. And it works nicely with toml dict and hierarchical configs.
My only ask is to make it easy to extend (#767). E.g. users should be allowed to define a new data class (e.g. in another module), and still be able to config via toml/cmdline.
Once we make it work nicely, I think it's ok to depend on tyro.
cc: @jaysonfrancis
Merged
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.
#767 seems to be getting stucked due to an extra dependency, so I made this PR to add typing and autocomplete to JobConfig with python native's dataclasses.
In term of typing enhancements, I think this is the most important aspect and improve developer experience the most.
My implementation uses explicit dataclass for typing and still relies on python's argparse for parse args, default values, help-string etc.
argparse.add_argumentand as an attribute in the corresponding dataclass. However I think this added work is minimal and worths the benefit.[training]tensor_parallel_degreeinstead of the new[parallelism]tensor_parallel_degree, now we will throws an error instead of silently uses the default value fromparallelismand ignore the specified value intrainingsection. (This has happened to me before).Before:

After:

Close #767 #753