What's Changed
This new version of tensordict comes with a great deal of new features:
- You can now operate pointwise arithmetic operations on tensordict. For locked tensordicts and inplace operations such as `+=` or `data.mul_`, fused cuda kernels will be used which will drastically improve the runtime.
See
- [Feature] Pointwise arithmetic operations using foreach by vmoens in https://github.com/pytorch/tensordict/pull/722
- [Feature] Mean, std, var, prod, sum by vmoens in https://github.com/pytorch/tensordict/pull/751
- Casting tensordicts to device is now much faster out-of-the box as data will be cast asynchronously (and it's safe too!)
[BugFix,Feature] Optional non_blocking in set, to_module and update by vmoens in https://github.com/pytorch/tensordict/pull/718
[BugFix] consistent use of non_blocking in tensordict and torch.Tensor by vmoens in https://github.com/pytorch/tensordict/pull/734
[Feature] non_blocking=None by default by vmoens in https://github.com/pytorch/tensordict/pull/748
- The non-tensor data API has also been improved, see
[BugFix] Allow inplace modification of non-tensor data in locked tds by vmoens in https://github.com/pytorch/tensordict/pull/694
[BugFix] Fix inheritance from non-tensor by vmoens in https://github.com/pytorch/tensordict/pull/709
[Feature] Allow non-tensordata to be shared across processes + memmap by vmoens in https://github.com/pytorch/tensordict/pull/699
[Feature] Better detection of non-tensor data by vmoens in https://github.com/pytorch/tensordict/pull/685
- `tensorclass` now supports automatic type casting: annotating a value as a tensor or an int can ensure that the value will be cast to that type if the tensorclass decorator takes the `autocast=True` argument
[Feature] Type casting for tensorclass by vmoens in https://github.com/pytorch/tensordict/pull/735
- TensorDict.map now supports the "fork" start method. Preallocated outputs are also a possibility.
[Feature] mp_start_method in tensordict map by vmoens in https://github.com/pytorch/tensordict/pull/695
[Feature] map with preallocated output by vmoens in https://github.com/pytorch/tensordict/pull/667
- Miscellaneous performance improvements
[Performance] Faster flatten_keys by vmoens in https://github.com/pytorch/tensordict/pull/727
[Performance] Faster update_ by vmoens in https://github.com/pytorch/tensordict/pull/705
[Performance] Minor efficiency improvements by vmoens in https://github.com/pytorch/tensordict/pull/703
[Performance] Random speedups by albanD in https://github.com/pytorch/tensordict/pull/728
[Feature] Faster to(device) by vmoens in https://github.com/pytorch/tensordict/pull/740
- Finally, we have opened a discord channel for tensordict!
[Badge] Discord shield by vmoens in https://github.com/pytorch/tensordict/pull/736
- We cleaned up the API a bit, creating a `save` and a `load` methods, or adding some utils such as `fromkeys`. One can also check if a key belongs to a tensordict as it is done with a regular dictionary with `key in tensordict`!
[Feature] __contains__, clear and fromkeys by vmoens in https://github.com/pytorch/tensordict/pull/721
Thanks for all our contributors and community for the support!
Other PRs
* [Benchmark] Benchmark to_module by vmoens in https://github.com/pytorch/tensordict/pull/669
* [Benchmark] Benchmark update_ by vmoens in https://github.com/pytorch/tensordict/pull/704
* [BugFIx] FIx tc.update_ by vmoens in https://github.com/pytorch/tensordict/pull/750
* [BugFix, Feature] `pad_sequence` refactoring by dtsaras in https://github.com/pytorch/tensordict/pull/652
* [BugFix, Feature] tensorclass.to_dict and from_dict by vmoens in https://github.com/pytorch/tensordict/pull/707
* [BugFix, Performance] Fewer imports at root by vmoens in https://github.com/pytorch/tensordict/pull/682
* [BugFix, Refactor] More reliable Sequential.get_dist by vmoens in https://github.com/pytorch/tensordict/pull/678
* [BugFix,Feature] filter_empty in apply by vmoens in https://github.com/pytorch/tensordict/pull/661
* [BugFix] Allow device overriding with None in apply by vmoens in https://github.com/pytorch/tensordict/pull/720
* [BugFix] Avoid lazy stacks in stack if not asked explicitly by vmoens in https://github.com/pytorch/tensordict/pull/741
* [BugFix] Dense stack lazy tds defaults to dense_stack_tds by vmoens in https://github.com/pytorch/tensordict/pull/713
* [BugFix] Faster to_module by vmoens in https://github.com/pytorch/tensordict/pull/670
* [BugFix] Fix colab in tutos by vmoens in https://github.com/pytorch/tensordict/pull/757
* [BugFix] Fix dense stack usage in torch.stack by vmoens in https://github.com/pytorch/tensordict/pull/714
* [BugFix] Fix empty(recurse) call in _apply_nest by vmoens in https://github.com/pytorch/tensordict/pull/658
* [BugFix] Fix indexing (lazy stack and names) by vmoens in https://github.com/pytorch/tensordict/pull/657
* [BugFix] Fix keys for nested lazy stacks by vmoens in https://github.com/pytorch/tensordict/pull/745
* [BugFix] Fix lazy params init by vmoens in https://github.com/pytorch/tensordict/pull/681
* [BugFix] Fix lazy stack keys by vmoens in https://github.com/pytorch/tensordict/pull/744
* [BugFix] Fix load_state_dict for TensorDictParams by vmoens in https://github.com/pytorch/tensordict/pull/689
* [BugFix] Fix name gathering with tensor indices by vmoens in https://github.com/pytorch/tensordict/pull/690
* [BugFix] Fix singleton dims in expand_as_right by vmoens in https://github.com/pytorch/tensordict/pull/687
* [BugFix] Fix to_module `__exit__` update when td is locked by vmoens in https://github.com/pytorch/tensordict/pull/671
* [BugFix] Fix to_module batch-size mismatch by vmoens in https://github.com/pytorch/tensordict/pull/688
* [BugFix] Fix torch_function for uninit param by vmoens in https://github.com/pytorch/tensordict/pull/683
* [BugFix] Fix zipping in flatten_keys by vmoens in https://github.com/pytorch/tensordict/pull/729
* [BugFix] Improve update_ by vmoens in https://github.com/pytorch/tensordict/pull/655
* [BugFix] Keep dim names in transpose by vmoens in https://github.com/pytorch/tensordict/pull/662
* [BugFix] Loading phantom state-dicts by vmoens in https://github.com/pytorch/tensordict/pull/650
* [BugFix] Make functorch.dim optional by vmoens in https://github.com/pytorch/tensordict/pull/737
* [BugFix] Missing **kwargs in apply_ fallback by vmoens in https://github.com/pytorch/tensordict/pull/664
* [BugFix] Patch pad_sequence by vmoens in https://github.com/pytorch/tensordict/pull/742
* [BugFix] Remove monkey patching of uninit params by vmoens in https://github.com/pytorch/tensordict/pull/684
* [BugFix] Support empty tuple in lazy stack indexing by vmoens in https://github.com/pytorch/tensordict/pull/696
* [BugFix] Track sub-tds in memmap by vmoens in https://github.com/pytorch/tensordict/pull/719
* [BugFix] Unlock td during update in to_module by vmoens in https://github.com/pytorch/tensordict/pull/686
* [BugFix] module hook fixes by vmoens in https://github.com/pytorch/tensordict/pull/673
* [BugFix] tensorclass as a decorator by vmoens in https://github.com/pytorch/tensordict/pull/691
* [CI] Doc on release tag by vmoens in https://github.com/pytorch/tensordict/pull/761
* [CI] Fix wheels by vmoens in https://github.com/pytorch/tensordict/pull/763
* [CI] Pinning mpmath by vmoens in https://github.com/pytorch/tensordict/pull/697
* [CI] Remove OSX x86 jobs by vmoens in https://github.com/pytorch/tensordict/pull/753
* [CI] Remove all osx x86 workflows by vmoens in https://github.com/pytorch/tensordict/pull/760
* [CI] Remove snapshot from CI by vmoens in https://github.com/pytorch/tensordict/pull/701
* [CI] Schedule workflow for release branches by vmoens in https://github.com/pytorch/tensordict/pull/759
* [CI] Unpin mpmath by vmoens in https://github.com/pytorch/tensordict/pull/702
* [Doc,CI] Sanitize version by vmoens in https://github.com/pytorch/tensordict/pull/762
* [Doc] Fix EnsembleModule docstring by BY571 in https://github.com/pytorch/tensordict/pull/712
* [Doc] Fix probabilistic td module doc by vmoens in https://github.com/pytorch/tensordict/pull/756
* [Doc] Installation instructions in API ref by vmoens in https://github.com/pytorch/tensordict/pull/660
* [Doc] Per-release docs by vmoens in https://github.com/pytorch/tensordict/pull/758
* [Doc] fix typo by husisy in https://github.com/pytorch/tensordict/pull/724
* [Feature] Adds utils method isin by albertbou92 in https://github.com/pytorch/tensordict/pull/654
* [Feature] Adds utils method remove_duplicates by albertbou92 in https://github.com/pytorch/tensordict/pull/653
* [Feature] Inherit lock in shape / tensor ops by vmoens in https://github.com/pytorch/tensordict/pull/730
* [Feature] Store non tensor stacks in a single json by vmoens in https://github.com/pytorch/tensordict/pull/711
* [Feature] TensorDict logger by vmoens in https://github.com/pytorch/tensordict/pull/710
* [Feature] TensorDict.depth property by vmoens in https://github.com/pytorch/tensordict/pull/732
* [Feature] Use generator for map by vmoens in https://github.com/pytorch/tensordict/pull/672
* [Feature] Warn when `reset_parameters_recursive` is a no-op by matteobettini in https://github.com/pytorch/tensordict/pull/693
* [Feature] `from_modules` method for MOE / ensemble learning by vmoens in https://github.com/pytorch/tensordict/pull/677
* [Feature] td_flatten_with_keys by vmoens in https://github.com/pytorch/tensordict/pull/675
* [Feature] tensordict.to_padded_tensor by vmoens in https://github.com/pytorch/tensordict/pull/723
* [Feature] use return_mask as a string in pad_sequence by dtsaras in https://github.com/pytorch/tensordict/pull/739
* [Minor] Minor improvements to tensorclass by vmoens in https://github.com/pytorch/tensordict/pull/743
* [Minor] Remove double locks on data and grad by vmoens in https://github.com/pytorch/tensordict/pull/752
* [Refactor, Feature] Default to empty batch size by vmoens in https://github.com/pytorch/tensordict/pull/674
* [Refactor] Cleanup deprecation of empty td filtering in apply by vmoens in https://github.com/pytorch/tensordict/pull/665
* [Refactor] Refactor contiguous by vmoens in https://github.com/pytorch/tensordict/pull/716
* [Refactor] Set lazy_legacy to False by default by vmoens in https://github.com/pytorch/tensordict/pull/680
* [Test] Add proper tests for torch.stack with lazy stacks by vmoens in https://github.com/pytorch/tensordict/pull/715
* [Versioning] Remove deprecated features by vmoens in https://github.com/pytorch/tensordict/pull/747
* [Versioning] Torch version by vmoens in https://github.com/pytorch/tensordict/pull/749
* [Versioning] v0.4.0 by vmoens in https://github.com/pytorch/tensordict/pull/649
New Contributors
* dtsaras made their first contribution in https://github.com/pytorch/tensordict/pull/652
* BY571 made their first contribution in https://github.com/pytorch/tensordict/pull/712
* husisy made their first contribution in https://github.com/pytorch/tensordict/pull/724
* albanD made their first contribution in https://github.com/pytorch/tensordict/pull/728
**Full Changelog**: https://github.com/pytorch/tensordict/compare/v0.3.0...v0.4.0