Keep the elasticity batch overrides out of the caller's config dict - #8329
Open
alanhuangyoo wants to merge 1 commit into
Open
Keep the elasticity batch overrides out of the caller's config dict#8329alanhuangyoo wants to merge 1 commit into
alanhuangyoo wants to merge 1 commit into
Conversation
DeepSpeedConfig stores the dict it is handed by reference, and deepspeedai#8289 established that parsing must not write back into it -- the caller owns that dict and may reuse it afterwards. The elasticity branch still does, two lines above the comment that says otherwise: it assigns train_batch_size, train_micro_batch_size_per_gpu and gradient_accumulation_steps into self._param_dict before the copy is taken. A caller that passes a config with elasticity enabled gets three keys back that it never set, and print_user_config() then reports them as though the user had. Collect the overrides and apply them to the copy instead. All three are top-level keys, so the existing shallow copy is enough to keep them off the caller's dict, and the parsed values are unchanged. Signed-off-by: alanhuangyoo <alanhuangyoo@gmail.com>
alanhuangyoo
requested review from
loadams,
tjruwase and
tohtana
as code owners
August 27, 2026 08:24
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.
DeepSpeedConfigkeeps the dict it is handed by reference:#8289 established that parsing must not write back into it — the caller owns that dict and may reuse it after initialization.
The elasticity branch still does, two lines above the comment that says otherwise:
A caller that enables elasticity gets three keys back that it never set.
print_user_config()dumpsself._param_dict, so it then reports them as though the user had written them.The elasticity path also forbids those keys in the input unless
ignore_non_elastic_batch_infois set:so a config that was rejected on the first pass would be accepted on a re-parse of the same dict, since the second time around the keys are there.
The fix
Collect the overrides and apply them to the copy. All three are top-level keys, so the existing shallow copy keeps them off the caller's dict.
Test
before
after
Same parsed values, so this only removes the write-back.
Added
test_elasticity_leaves_caller_config_untouchednext to #8289'stest_max_grad_norm_leaves_caller_config_untouched. It fails on master withand passes with the fix.