Skip to content
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

PyTorchFileRecord print debug option #1425

Merged
merged 5 commits into from
Mar 6, 2024

Conversation

antimora
Copy link
Collaborator

@antimora antimora commented Mar 6, 2024

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

Fixes #1416

Changes

  1. Added .with_debug_print() to PyTorchRecorder args
  2. Prints debug information when debug is on
  3. Updated the docs.

Testing

Added to the unit test and checked the output:

Debug information of keys and tensor shapes:
---
Original Key: conv.conv1.bias
Remapped Key: conv1.bias
Shape: [2]
Dtype: F32
---
Original Key: conv.conv1.weight
Remapped Key: conv1.weight
Shape: [2, 2, 2, 2]
Dtype: F32
---
Original Key: conv.conv2.weight
Remapped Key: conv2.weight
Shape: [2, 2, 2, 2]
Dtype: F32
---

@antimora antimora changed the title Pytorch recorder debug fixes PyTorchFileRecord print debug option Mar 6, 2024
@antimora antimora requested a review from laggui March 6, 2024 18:29
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 85.67%. Comparing base (b429cc3) to head (11f8d18).

Files Patch % Lines
crates/burn-import/src/pytorch/reader.rs 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1425      +/-   ##
==========================================
- Coverage   85.67%   85.67%   -0.01%     
==========================================
  Files         637      637              
  Lines       70286    70320      +34     
==========================================
+ Hits        60219    60248      +29     
- Misses      10067    10072       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@laggui laggui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful feature! Would have helped when porting the resnet weights 😄

Overall LGTM! Just one minor request and two comments/questions.

println!("Dtype: {dtype:?}");
println!("---");
}
println!("End of debug information.");
Copy link
Member

@laggui laggui Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to indicate the end of the debug info with a sentence. The separators should be enough, no? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it. It was mostly to signal there are no keys. I guess we can imply it here.

crates/burn-import/src/pytorch/reader.rs Show resolved Hide resolved
@@ -135,6 +140,12 @@ impl LoadArgs {
self.top_level_key = Some(key.into());
self
}

/// Sets printing debug information on.
pub fn with_debug_on(mut self) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_debug_on sounds weird. What do you think of with_debug_info instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`with_print_debug' maybe?

@antimora antimora requested a review from laggui March 6, 2024 21:51
@antimora antimora merged commit 545444c into tracel-ai:main Mar 6, 2024
14 checks passed
@antimora antimora deleted the pytorch-recorder-debug-fixes branch March 6, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to print tensor keys (before and after remap) for PyTorchFileRecorder
2 participants