Skip to content

Commit 73278e6

Browse files
c00wpytorchmergebot
authored andcommitted
easy: sort dictionary keys for inductor config when publishing (pytorch#143307)
This means we should get consistent logging strings for the same config on different ranks Pull Request resolved: pytorch#143307 Approved by: https://github.com/xmfan
1 parent 84443bd commit 73278e6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

test/dynamo/test_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ def test_inductor_config_parsing_non_conforming_items(self, mocked_inductor_conf
412412
},
413413
}
414414
expected = (
415-
"""{"some": {"name": "Value is not JSON serializable", "some": true}, """
416-
""""data": {"name": "Value is not JSON serializable", "some": true}, """
415+
"""{"data": {"name": "Value is not JSON serializable", "some": true}, """
417416
""""list": [{"name": "Value is not JSON serializable", "some": true}, """
418417
"""{"name": "Value is not JSON serializable", "some": true}], """
419-
""""object": {"name": "Value is not JSON serializable", "some": true, """
420-
""""data": {"name": "Value is not JSON serializable", "some": true}}}"""
418+
""""object": {"data": {"name": "Value is not JSON serializable", "some": true}, """
419+
""""name": "Value is not JSON serializable", "some": true}, """
420+
""""some": {"name": "Value is not JSON serializable", "some": true}}"""
421421
)
422422
mocked_inductor_config.get_config_copy.return_value = test_mock_config
423423
inductor_config_json = utils._scrubbed_inductor_config_for_logging()

torch/_dynamo/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,10 @@ def default(self, o):
12411241
del inductor_config_copy[key]
12421242
# Stringify Inductor config
12431243
inductor_conf_str = json.dumps(
1244-
inductor_config_copy, cls=TypeSafeSerializer, skipkeys=True
1244+
inductor_config_copy,
1245+
cls=TypeSafeSerializer,
1246+
skipkeys=True,
1247+
sort_keys=True,
12451248
)
12461249
except Exception:
12471250
# Don't crash because of runtime logging errors

0 commit comments

Comments
 (0)