Skip to content

[BugFix] Add TensorDictModuleBase repr - #1767

Merged
vmoens merged 2 commits into
pytorch:mainfrom
priba:priba/repr
Aug 21, 2026
Merged

[BugFix] Add TensorDictModuleBase repr#1767
vmoens merged 2 commits into
pytorch:mainfrom
priba:priba/repr

Conversation

@priba

@priba priba commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Moves __repr__ to TensorDictModuleBase so subclasses provide an informative representation of their child modules, input keys, and output keys. The representation does not report a device because a module may contain state on multiple devices.

Follow-up

#1770 deprecates the existing TensorDictModule.device property for removal in TensorDict 0.17. It was developed as a direct stack on this PR and rebased onto main after this PR merged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature which changes existing functionality)
  • Documentation

Checklist

  • I have read the contribution guide.
  • I have updated the tests accordingly.
  • My change requires documentation updates.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Title Label Error

PR title must start with a label prefix in brackets (e.g., [BugFix]).

Current title: Add TensorDictModuleBase repr and device

Supported Prefixes

Your PR title must start with exactly one of these prefixes (case-insensitive):

Prefix Label Applied Example
[BE] BE [BE] Improve internal plumbing
[BugFix] or [Fix] bug [BugFix] Fix memory leak in TensorDict
[Feature] Feature [Feature] Add new storage backend
[Doc] or [Docs] documentation [Doc] Update installation guide
[Refactor] Refactor [Refactor] Clean up module imports
[CI] CI [CI] Fix workflow permissions
[Test] or [Tests] Test [Test] Add unit tests for nn module
[Compile] Compile [Compile] Fix torch.compile issue
[Performance] or [Perf] Performance [Perf] Optimize tensor operations
[Deprecation] Deprecation [Deprecation] Mark old function
[Setup] setup [Setup] Update build configuration
[Distributed], [Dist], or [DTensor] Distributed [DTensor] Add cross-mesh transfer
[Benchmark] or [Bench] Benchmarks [Benchmark] Add compile benchmark
[Typing] or [Type] Typing [Typing] Add type stubs
[BC-breaking] or [BC] BC-breaking [BC-breaking] Remove deprecated API
[Formatting] or [Format] Formatting [Format] Fix code style
[Quality] Quality [Quality] Improve error messages
[Release] release [Release] Publish release artifacts
[Versioning] versioning [Versioning] Bump release version

Note: Matching is case-insensitive. Common variations (singular/plural) are supported.

@priba priba changed the title Add TensorDictModuleBase repr and device [BugFix] Add TensorDictModuleBase repr and device Aug 20, 2026
@github-actions github-actions Bot added the bug Something isn't working label Aug 20, 2026
@vmoens vmoens changed the title [BugFix] Add TensorDictModuleBase repr and device [BugFix] Add TensorDictModuleBase repr Aug 21, 2026

@vmoens vmoens left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM thanks!

@vmoens
vmoens merged commit abb3c47 into pytorch:main Aug 21, 2026
48 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. nn Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants