Fix MLflowTracker.store_init_configuration mutating the caller's config dict#4046
Open
ATOM00blue wants to merge 1 commit into
Open
Fix MLflowTracker.store_init_configuration mutating the caller's config dict#4046ATOM00blue wants to merge 1 commit into
ATOM00blue wants to merge 1 commit into
Conversation
`store_init_configuration` deleted over-long values from the `values` dict in place via `del values[name]`. Since `Accelerator.init_trackers` passes the same `config` object to every tracker, this removed the key from the user's dict and from all other trackers as well. Build a filtered list of in-range items instead of mutating the input, matching the approach already used in `MLflowTracker.log`. The warning and the dropping of over-long values are preserved. Adds a regression test that fails before this change.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds regression coverage and adjusts MLflow init-config logging to avoid mutating caller-provided configuration dictionaries.
Changes:
- Update
MLflowTracker.store_init_configuration()to filter over-long values without deleting keys from the input dict. - Add a regression test asserting the caller’s dict is not mutated while ensuring MLflow still drops over-long params.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_tracking.py | Adds regression test for non-mutating init configuration logging to MLflow. |
| src/accelerate/tracking.py | Avoids in-place deletion from values when filtering MLflow params. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+328
to
+332
| """`store_init_configuration` must not mutate the caller's dict when dropping over-long values. | ||
|
|
||
| The same `config` object is shared across all trackers in `Accelerator.init_trackers`, so deleting | ||
| keys in place removed them from the user's dict and from every other tracker too. | ||
| """ |
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.
What does this PR do?
MLflowTracker.store_init_configurationdrops config values that exceed MLflow'sMAX_PARAM_VAL_LENGTH, but it did so by deleting them from the input dict in place:Accelerator.init_trackerspasses the sameconfigobject to every tracker:So when MLflow drops an over-long value, that key is permanently removed from the
user's
configdict and is therefore missing from every other tracker (TensorBoard,WandB, etc.) that runs after MLflow, as well as from any later use of the dict by the
user. This is silent, order-dependent data loss.
Fix
Build a filtered list of in-range items instead of mutating the input, which is the
same approach already used in
MLflowTracker.log(it builds a separatemetricsdict).The warning and the dropping of over-long values from what gets logged to MLflow are
both preserved; only the in-place mutation of the caller's dict is removed.
Reproduction (before this PR)
After this PR,
configstill containslong_note; only the value sent to MLflow is dropped.Before submitting
A regression test (
MLflowTrackingTest::test_store_init_configuration_does_not_mutate_input)is added; it fails on
mainand passes with this change.Who can review?
@BenjaminBossan @SunMarc
Developed with AI coding assistance; reviewed and submitted by the author.