-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#17312: Fix type error when saving report config to json file #17350
Merged
smountenay-tt
merged 1 commit into
main
from
smountenay-tt/17312-report_config_typeerror
Jan 30, 2025
Merged
#17312: Fix type error when saving report config to json file #17350
smountenay-tt
merged 1 commit into
main
from
smountenay-tt/17312-report_config_typeerror
Jan 30, 2025
Conversation
This file contains 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
dmakoviichuk-tt
approved these changes
Jan 30, 2025
yieldthought
pushed a commit
that referenced
this pull request
Jan 31, 2025
### Ticket [#17312](#17312) ### Problem description Running pytest with the `TTNN_CONFIG_OVERRIDES` environment variable set to enable detailed buffer reports will fail with `TypeError: Object of type method is not JSON serializable` if a `config.json` file does not already exist in the report directory. Debugging the issue with pdb I determined that the cause of the problem was due to an unexpected `_pybind11_conduit_v1_` key in the `normalized_config` dict that is written to the `config.json` file in the `ttnn.save_config_to_json_file` function. There was logic in this function already to ignore dunder methods and attributes from the original `CONFIG` object, but the `if "__" in key:` check that matched regular Python special attributes didn't match the `_pybind11_conduit_v1_` attribute returned by `dir(CONFIG)`. I experienced this issue personally every time I deleted the reports directory, which I was doing frequently to ensure that each report only had data from a single run. Oddly, it would only fail on the first run after deleting the reports directory, and on subsequent runs of pytest it would work and write the `config.json` file fine. This leads me to believe that this `_pybind11_conduit_v1_` property did not always exist on the `CONFIG` object, but understanding why was outside the scope of my debugging to unblock me. The issue was also reported to us by another user. ### What's changed I have changed the logic in `ttnn.save_config_to_json_file` so that instead of ignoring any config attributes with `__` in their name, it instead ignores any config attributes that start and end with an underscore. This preserves the original intention of ignoring the standard Python special attributes, but also any other pseudo-special attributes like this one. This solution generalizes things a bit, without explicitly excluding the `_pybind11_conduit_v1_` attribute. Alternatively, we could be explicit about it by changing it to: ``` if "__" in key or key == "_pybind11_conduit_v1_": continue ``` I preferred the regex approach and think there's no performance implication since it's just writing a small config object once when a new report is created. ### Checklist - [X] Post commit CI passes - [ ] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [ ] **(For models and ops writers)** Full [new models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml) tests passes - [ ] New/Existing tests provide coverage for changes Co-authored-by: Scott Mountenay <[email protected]>
nikileshx
pushed a commit
to nikileshx/tt-metal
that referenced
this pull request
Feb 3, 2025
…ile (tenstorrent#17350) ### Ticket [tenstorrent#17312](tenstorrent#17312) ### Problem description Running pytest with the `TTNN_CONFIG_OVERRIDES` environment variable set to enable detailed buffer reports will fail with `TypeError: Object of type method is not JSON serializable` if a `config.json` file does not already exist in the report directory. Debugging the issue with pdb I determined that the cause of the problem was due to an unexpected `_pybind11_conduit_v1_` key in the `normalized_config` dict that is written to the `config.json` file in the `ttnn.save_config_to_json_file` function. There was logic in this function already to ignore dunder methods and attributes from the original `CONFIG` object, but the `if "__" in key:` check that matched regular Python special attributes didn't match the `_pybind11_conduit_v1_` attribute returned by `dir(CONFIG)`. I experienced this issue personally every time I deleted the reports directory, which I was doing frequently to ensure that each report only had data from a single run. Oddly, it would only fail on the first run after deleting the reports directory, and on subsequent runs of pytest it would work and write the `config.json` file fine. This leads me to believe that this `_pybind11_conduit_v1_` property did not always exist on the `CONFIG` object, but understanding why was outside the scope of my debugging to unblock me. The issue was also reported to us by another user. ### What's changed I have changed the logic in `ttnn.save_config_to_json_file` so that instead of ignoring any config attributes with `__` in their name, it instead ignores any config attributes that start and end with an underscore. This preserves the original intention of ignoring the standard Python special attributes, but also any other pseudo-special attributes like this one. This solution generalizes things a bit, without explicitly excluding the `_pybind11_conduit_v1_` attribute. Alternatively, we could be explicit about it by changing it to: ``` if "__" in key or key == "_pybind11_conduit_v1_": continue ``` I preferred the regex approach and think there's no performance implication since it's just writing a small config object once when a new report is created. ### Checklist - [X] Post commit CI passes - [ ] Blackhole Post commit (if applicable) - [ ] Model regression CI testing passes (if applicable) - [ ] Device performance regression CI testing passes (if applicable) - [ ] **(For models and ops writers)** Full [new models](https://github.com/tenstorrent/tt-metal/actions/workflows/full-new-models-suite.yaml) tests passes - [ ] New/Existing tests provide coverage for changes Co-authored-by: Scott Mountenay <[email protected]>
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.
Ticket
#17312
Problem description
Running pytest with the
TTNN_CONFIG_OVERRIDES
environment variable set to enable detailed buffer reports will fail withTypeError: Object of type method is not JSON serializable
if aconfig.json
file does not already exist in the report directory.Debugging the issue with pdb I determined that the cause of the problem was due to an unexpected
_pybind11_conduit_v1_
key in thenormalized_config
dict that is written to theconfig.json
file in thettnn.save_config_to_json_file
function.There was logic in this function already to ignore dunder methods and attributes from the original
CONFIG
object, but theif "__" in key:
check that matched regular Python special attributes didn't match the_pybind11_conduit_v1_
attribute returned bydir(CONFIG)
.I experienced this issue personally every time I deleted the reports directory, which I was doing frequently to ensure that each report only had data from a single run.
Oddly, it would only fail on the first run after deleting the reports directory, and on subsequent runs of pytest it would work and write the
config.json
file fine. This leads me to believe that this_pybind11_conduit_v1_
property did not always exist on theCONFIG
object, but understanding why was outside the scope of my debugging to unblock me.The issue was also reported to us by another user.
What's changed
I have changed the logic in
ttnn.save_config_to_json_file
so that instead of ignoring any config attributes with__
in their name, it instead ignores any config attributes that start and end with an underscore. This preserves the original intention of ignoring the standard Python special attributes, but also any other pseudo-special attributes like this one.This solution generalizes things a bit, without explicitly excluding the
_pybind11_conduit_v1_
attribute. Alternatively, we could be explicit about it by changing it to:I preferred the regex approach and think there's no performance implication since it's just writing a small config object once when a new report is created.
Checklist