Skip to content

[Feature] Add functorch integration tests for TensorDictModule - Fixes #154#3697

Open
ParamThakkar123 wants to merge 1 commit intopytorch:mainfrom
ParamThakkar123:functorch
Open

[Feature] Add functorch integration tests for TensorDictModule - Fixes #154#3697
ParamThakkar123 wants to merge 1 commit intopytorch:mainfrom
ParamThakkar123:functorch

Conversation

@ParamThakkar123
Copy link
Copy Markdown
Contributor

Summary

Adds a comprehensive test suite for functorch integration with TensorDictModule to address issue #154.

Tests Added

  • test_tdmodule_functional_params - Tests extracting functional params from a TDModule using TensorDict.from_module
  • test_vmap_on_tdmodule_with_params - Tests vmap on TensorDictModule with functional params expanded across batch dimension
  • test_nested_tdmodule_param_length - Tests nested TDModules (SafeProbabilisticTensorDictSequential) param extraction
  • test_nested_tdmodule_param_casting - Tests that params can be cast to different dtypes (e.g., float64)
  • test_tdsequence_vmap_params - Tests TDSequence param handling with vmap
  • test_vmap_multiple_inputs - Tests vmap with multiple input keys to module
  • test_vmap_module_class - Tests VmapModule class directly
  • test_tdsequence_vmap - Tests vmap on SafeSequential
  • test_tdmodule_functional_to_module - Tests the to_module context manager for functional params
  • test_nested_sequential_vmap - Tests vmap on nested TensorDictSequential modules

All tests cover the functionality requested in the issue.

Fixes #154

Adds comprehensive test suite for functorch integration with TensorDictModule
to address issue pytorch#154. Tests cover:

- Functional params extraction from TDModule using TensorDict.from_module
- vmap on TensorDictModule with functional params
- Nested TDModules (ProbabilisticTensorDictModule) param handling
- Param casting to different dtypes
- TDSequence param handling with vmap
- vmap with multiple input keys to module
- VmapModule class usage
- SafeSequential vmap
- to_module context manager for functional params
- Nested sequential vmap

Fixes pytorch#154
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 30, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3697

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 17 Awaiting Approval

As of commit 1d50328 with merge base c764978 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 30, 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 functorch integration tests for TensorDictModule - Fixes #154

Supported Prefixes (case-sensitive)

Your PR title must start with exactly one of these prefixes:

Prefix Label Applied Example
[BugFix] BugFix [BugFix] Fix memory leak in collector
[Feature] Feature [Feature] Add new optimizer
[Doc] or [Docs] Documentation [Doc] Update installation guide
[Refactor] Refactoring [Refactor] Clean up module imports
[CI] CI [CI] Fix workflow permissions
[Test] or [Tests] Tests [Tests] Add unit tests for buffer
[Environment] or [Environments] Environments [Environments] Add Gymnasium support
[Data] Data [Data] Fix replay buffer sampling
[Performance] or [Perf] Performance [Performance] Optimize tensor ops
[BC-Breaking] bc breaking [BC-Breaking] Remove deprecated API
[Deprecation] Deprecation [Deprecation] Mark old function
[Quality] Quality [Quality] Fix typos and add codespell

Note: Common variations like singular/plural are supported (e.g., [Doc] or [Docs]).

@ParamThakkar123 ParamThakkar123 changed the title Add functorch integration tests for TensorDictModule - Fixes #154 [Feature] Add functorch integration tests for TensorDictModule - Fixes #154 Apr 30, 2026
@github-actions github-actions Bot added the Feature 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. Feature New feature Modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Write tests for functorch integration

1 participant