Update pyconfig to get config defaults from types.py instead of base.yml - #5096
Open
bvandermoon wants to merge 1 commit into
Open
Update pyconfig to get config defaults from types.py instead of base.yml#5096bvandermoon wants to merge 1 commit into
bvandermoon wants to merge 1 commit into
Conversation
bvandermoon
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
richjames0,
shralex,
shuningjin,
vipannalla and
xibinliu
as code owners
September 1, 2026 23:42
There was a problem hiding this comment.
Code Review
This pull request enables sparse configuration loading without a base.yml file and introduces dynamic environment variable overrides prefixed with M_. The reviewer identified several critical issues: a potential silent failure when a specified configuration file is missing, a logic bug in the tokenizer_path fallback for custom models, and a TypeError crash when attempting to override nested configuration fields via environment variables. Expanding the unit tests to cover nested overrides was also recommended.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bvandermoon
force-pushed
the
bvandermoon-configs
branch
2 times, most recently
from
September 2, 2026 00:19
e9145f4 to
8387f9e
Compare
bvandermoon
force-pushed
the
bvandermoon-configs
branch
from
September 2, 2026 21:18
8387f9e to
37fdee3
Compare
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 is Part 2 of the multi-step effort to establish
src/maxtext/configs/types.pyas the single source of truth for configuration schema and default values in MaxText.Previously,
pyconfig.pyrequired parsing a monolithic 1,400+ linebase.ymlbefore passing parameters to Pydantic. This PR updatespyconfig.pyso that defaults are provided directly bytypes.MaxTextConfig, and YAML files are treated as sparse override recipes layered on top of Python defaults.Key Changes
Backward-Compatible
base.ymlHandling:_load_config()now intercepts references tobase.yml(e.g.base_config: "base.yml"in existing child YAMLs) and safely treats them as a no-op returning{}with an informational log.base.ymlcontinue running without breaking.Sparse Recipe Loading on
types.pyDefaults:_initialize_pydantic()no longer assumes a full base YAML dictionary; it merges only the user-provided recipe/model YAML overrides and CLI flags directly intotypes.MaxTextConfig.Logical Axis Rules Parity:
logical_axis_rules,_initialize_pydantic()cleanly falls back totypes.DEFAULT_LOGICAL_AXIS_RULES.Dynamic
M_*Environment Variable Overrides:os.environfor any variable starting withM_(e.g.,M_STEPS=100,M_PER_DEVICE_BATCH_SIZE=8,M_GCS_METRICS=True) and maps it to any field inMaxTextConfig.model_fields.Automatic Tokenizer Path Resolution:
_prepare_for_pydantic()automatically infers default HuggingFace tokenizer paths whentokenizer_pathis omitted in sparse model configs.Unit Tests:
test_sparse_delta_loading_without_base_yml: Verifies loading sparse YAML recipes directly on top of Pydantic defaults.test_dynamic_env_var_overrides: Verifies arbitraryM_<PARAM>environment variable overrides against config fields.Next Steps
base_config: "base.yml"from all 22 child/recipe YAMLs.base.ymland legacypyconfig_deprecated.py.Tests
CI
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.