Skip to content

[Refactor] Split TensorDict helper functions#1683

Open
vmoens wants to merge 1 commit intopytorch:mainfrom
vmoens:split-td-helper-functions
Open

[Refactor] Split TensorDict helper functions#1683
vmoens wants to merge 1 commit intopytorch:mainfrom
vmoens:split-td-helper-functions

Conversation

@vmoens
Copy link
Copy Markdown
Collaborator

@vmoens vmoens commented Apr 29, 2026

Summary

  • move top-level tensordict._td helper functions into tensordict._td_functions
  • keep tensordict._td as the compatibility facade for these helpers
  • add import-identity coverage for the moved helpers and top-level tensordict exports

BC notes

  • existing imports from tensordict._td remain valid
  • top-level tensordict helper exports still resolve to the same function objects
  • moved helpers keep __module__ == "tensordict._td"

Test plan

  • python -m pytest test/test_compatibility.py::test_td_helper_import_paths_are_preserved -q
  • ulimit -n 4096 && python -m pytest test/test_tensordict.py -k "from_module or from_modules or from_pytree or from_consolidated or save_load_memmap or maybe_dense_stack" -q
  • python -m pytest test/test_compatibility.py -q -k "not redis and not StoreFromSchema and not Preallocation"
  • python -m compileall -q tensordict/_td.py tensordict/_td_functions.py

The local file descriptor limit is 256, so the memmap-heavy targeted test selection needs ulimit -n 4096 locally.

@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 Apr 29, 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: Split TensorDict helper functions

Supported Prefixes

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

Prefix Label Applied Example
[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] or [Dist] Distributed [Distributed] Add scatter collective
[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

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

@github-actions github-actions Bot added the Test label Apr 29, 2026
@vmoens vmoens force-pushed the split-td-helper-functions branch from 04704bb to 25365c8 Compare April 29, 2026 20:03
@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: Split TensorDict helper functions

Supported Prefixes

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

Prefix Label Applied Example
[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] or [Dist] Distributed [Distributed] Add scatter collective
[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

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

@vmoens vmoens changed the title Split TensorDict helper functions [Refactor] Split TensorDict helper functions Apr 30, 2026
@github-actions github-actions Bot added the Refactor Refactoring code - not a new feature label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Refactor Refactoring code - not a new feature Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant