Tensordict

Latest version: v0.7.2

Safety actively analyzes 722861 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 4

0.7.2

We are pleased to announce the release of tensordict v0.7.2, which includes several bug fixes and backend improvements.

Bug Fixes:
- Consolidated lazy stacks of non-tensors (1222, 1224)
- Passed type directly during reduction (1225)
- Fixed non-deterministic key order in stack (1230)
- Added _PASSTHROUGH_MEMO for passthrough tensorclass (1231)
- Improved performance and safety of non-tensor stack (1232)
- Fixed serialization of stacks of Tensorclasses (1236)
- Fixed compile during _check_keys (1239)

Backend Improvements:
Improved errors for TensorDictSequential (1227)

Documentation Updates:
Improved documentation for TensorDictModuleBase (1226)

**Full Changelog**: https://github.com/pytorch/tensordict/compare/v0.7.1...v0.7.2

0.7.1

We are pleased to announce the release of tensordict v0.7.1, which includes several bug fixes and a deprecation notice.

Bug Fixes
- Fixed get method for nested keys with default values in TensorClass (1211)
- Enforced zip(..., strict=True) in TDModules to prevent potential issues (1212)
- Properly handled auto-batch size for unbatched tensors (1213)
- Fixed indexing issues in TensorClass (1217)

Deprecation Notice

Softly deprecated extra-tensors with respect to out_keys (1215). We make sure a warning is raised when the number of output tensors and output keys do not match.


**Full Changelog**: https://github.com/pytorch/tensordict/compare/v0.7.0...v0.7.1

0.7.0

alive!


New Contributors

A special thanks to our new contributors (+ people interacting with us on the PyTorch forum, discord or via issues and
social platforms)!

* egaznep made their first contribution in https://github.com/pytorch/tensordict/pull/1056
* priba made their first contribution in https://github.com/pytorch/tensordict/pull/1065
* SamAdamDay made their first contribution in https://github.com/pytorch/tensordict/pull/1075
* emmanuel-ferdman made their first contribution in https://github.com/pytorch/tensordict/pull/1105
* bachdj-px made their first contribution in https://github.com/pytorch/tensordict/pull/1101
* jgrhab made their first contribution in https://github.com/pytorch/tensordict/pull/1130
* amdfaa made their first contribution in https://github.com/pytorch/tensordict/pull/1191


BC-breaking changes

- In 1180, we use the same object for `min` and `max` operations as we do with torch.Tensor.min. Previously, tensorclasses
were used, but that lead to some undefined behaviors when indexing (in PyTorch, `min` returns a namedtuple that can be
indexed to get the values or argmax, whereas indexing a tensorclass indexes it along the batch dimension).
- In 1166, we introduce broadcasting for pointwise operations between tensors and tensordicts. Now, the following two
operations on either sides of the `==` sign are exactly equivalent:
python
td = TensorDict(..., batch_size=[3, 5])
t = torch.randn(5)
td + t == td + t.expand(td.shape)


Announced API changes

CompositeDistribution

**TL;DR: We're changing the way log-probs and entropies are collected and written in `ProbabilisticTensorDictModule` and
in `CompositeDistribution`. The `"sample_log_prob"` default key will soon be `"<value>_log_prob` (or
`("path", "to", "<value>_log_prob")` for nested keys). For `CompositeDistribution`, a different log-prob will be
written for each leaf tensor in the distribution. This new behavior is controlled by the
`tensordict.nn.set_composite_lp_aggregate(mode: bool)` function or by the `COMPOSITE_LP_AGGREGATE` environment variable.
We *strongly* encourage users to adopt the new behavior by setting `tensordict.nn.set_composite_lp_aggregate(False).set()`
at the beginning of their training script.**

We've had multiple rounds of refactoring for `CompositeDistribution` which relied on some very specific assumptions and
resulted in a brittle and painful API. We now settled on the following API that will be enforced in v0.9, unless the
`tensordict.nn.set_composite_lp_aggregate(mode)` value is explicitly set to ``True`` (the current default).

The bulk of the problem was that log-probs were aggregated in a single tensor and registered in `td["sample_log_prob"]`.
This had the following problems:
- Summing the log-probs isn't a good idea, users should be entitled to user the log-probs as they please.
- `"sample_log_prob"` is a generic but inappropriate name (the data may not be a random `sample` but anything else.)
- Summing requires reduction (because log-probs may have different shapes), but sometimes we don't want to reduce to the
shape of the root tensordict (see https://github.com/pytorch/rl/pull/2756 for instance).

What's new

tensorclass

- Introduction of the `TensorClass` class to do simple inheritance-style coding, which is accompanied by a stub file
that encodes all the TensorDict op signatures (we ensure this in the CI). See 1067
- tensorclass shadow attributes: you can now do `tensorclass(shadow=True)` or `class T(TensorClass["shadow"]): ...`
and you will be able to use dedicated names like `get` or `values` as attribute names. This is slightly unsafe when you
nest the tensorclass, as we can't guarantee that the container won't be calling these methods directly on the
tensorclass.
- Similarly, `tensorclass(nocast=True)` and `TensorClass["nocast"]` will deactivate the auto-casting in tensorclasses.
The behavior is now:
- No value: tensorclass will cast things like TensorDict (ie, `int` or `np.arrays` will be cast to `torch.Tensor`
instances for example).
- `autocast=True` will cause `tensorclass` to go one step further and attempt to cast values to the type indicated
in the dataclass definition.
- `nocast=True` keeps values as they are. All non-tensor (or non-tensordict/tensorclass) values will be wrapped in
a `NonTensorData`.

NonTensorData

- It is not easier to build non-tensor stacks through a simple `NonTensorStack(*values)`.

See the full list of features here:
[Feature] Add `__abs__` docstrings, `__neg__`, `__rxor__`, `__ror__`, `__invert__`, `__and__`, `__rand__`, `__radd__`, `__rtruediv__`, `__rmul__`, `__rsub__`, `__rpow__`, `bitwise_and`, `logical_and` (1154) (d1363eb9) by vmoens ghstack-source-id: 97ce710b5a4b552d9477182e1836cf3777c2d756
[Feature] Add expln map to NormalParamExtractor (1204) (e900b24c) by vmoens ghstack-source-id: 9003ceafbe8ecb73c701ea1ce96c0a342d0679b0
[Feature] Add missing `__torch_function__` (1169) (bc6390c3) by vmoens ghstack-source-id: 3dbefb4f5322a944664bbc2d29af7f862cb92342
[Feature] Better list casting in TensorDict.from_any (1108) (1ffc4637) by vmoens ghstack-source-id: 427d19d5ef7c0d2779e064e64522fc0094a885af
[Feature] Better logs of key errors in assert_close (1082) (747c593b) by vmoens ghstack-source-id: 46cb41d0da34b17ccc248119c43ddba586d29d80
[Feature] COMPOSITE_LP_AGGREGATE env variable (1190) (9733d6e6) by vmoens ghstack-source-id: 16b07d0eac582cfd419612f87e38e1a7acffcfc0
[Feature] CompositeDistribution.from_distributions (1113) (a45c7e39) by vmoens ghstack-source-id: 04a62439b0fe60422fbc901172df46306e161cc5
[Feature] Ensure all dists work with DETERMINSTIC type without warning (1182) (8e63112f) by vmoens ghstack-source-id: 63117f9b3ac4125a2be4e3e55719cc718051fc10
[Feature] Expose WrapModule (1118) (d849756f) by vmoens ghstack-source-id: 55caa5d7c39e0f98c1e0558af2a076fee15f7984
[Feature] Fix type assertion in Seq build (1143) (eaafc18c) by vmoens ghstack-source-id: 83d3dcafe45568c366207395a22b22fb35f61de1
[Feature] Force log_prob to return a tensordict when kwargs are passed to ProbabilisticTensorDictSequential.log_prob (1146) (98c57eef) by vmoens ghstack-source-id: 326d0763c9bbb13b51daac91edca4f0e821adf62
[Feature] Make ProbabilisticTensorDictSequential account for more than one distribution (1114) (c7bd20c7) by vmoens ghstack-source-id: b62b81b5cfd49168b5875f7ba9b4f35b51cd2423
[Feature] NonTensorData(*sequence_of_any) (1160) (70d4ed17) by vmoens ghstack-source-id: 537f3d87b0677a1ae4992ca581a585420a10a284
[Feature] NonTensorStack.data (1132) (4404abe0) by vmoens ghstack-source-id: 86065377cc1cd7c7283ed0a468f5d5602d60526d
[Feature] NonTensorStack.from_list (1107) (f924afcd) by vmoens ghstack-source-id: e8f349cb06a72dcb69a639420b14406c9c08aa99
[Feature] Optional in_keys for WrapModule (1145) (2d37d92b) by vmoens ghstack-source-id: a18dd5dff39937b027243fcebc6ef449b547e0b0
[Feature] OrderedDict for TensorDictSequential (1142) (7df20626) by vmoens ghstack-source-id: a8aed1eaefe066dafaa974f5b96190860de2f8f1
[Feature] ProbabilisticTensorDictModule.num_samples (1117) (978d96cc) by vmoens ghstack-source-id: dc6b1c98cee5fefc891f0d65b66f0d17d10174ba
[Feature] ProbabilisticTensorDictSequential.default_interaction_type (1123) (68ce9c3b) by vmoens ghstack-source-id: 37d38df36263e8accd84d6cb895269d50354e537
[Feature] Subclass conservation in td ops (1186) (070ca618) by vmoens ghstack-source-id: 83e79abda6a4bb6839d99240052323380981855c
[Feature] TensorClass (1067) (a6a0dd61) by vmoens ghstack-source-id: c3d4e17599a3204d4ad06bceb45e4fdcd0fd1be5
[Feature] TensorClass shadow attributes (1159) (c744bcfa) by vmoens ghstack-source-id: b5cc7c7fea2d48394e63d289ee2d6f215c2333bc
[Feature] TensorDict.<reduction>(dim='feature') (1121) (ba431598) by vmoens ghstack-source-id: 68f21aca722895e8a240dbca66e97310c20a6b5d
[Feature] TensorDict.clamp (1165) (646683c6) by vmoens ghstack-source-id: 44f0937c195d969055de10709402af7c4473df32
[Feature] TensorDict.logsumexp (1162) (e564b3a6) by vmoens ghstack-source-id: 84148ad9c701029db6d02dfb84ddb0a9b26c9ab7
[Feature] TensorDict.separates (1120) (674f356d) by vmoens ghstack-source-id: be142a150bf4378a0806347257c3cf64c78e4eda
[Feature] TensorDict.softmax (1163) (c0c6c14f) by vmoens ghstack-source-id: a88bebc23e6aaa02ec297db72dbda68ec9628ce7
[Feature] TensorDictModule in_keys allowed as Dict[str, tuple | list] to enable multi use of a sample feature (1101) (e871b7df) by bachdj-px
[Feature] UnbatchedTensor (1170) (74cae098) by vmoens ghstack-source-id: fa25726d61e913a725a71f1579eb06b09455e7c8
[Feature] `intersection` for assert_close (1078) (84d31dba) by vmoens ghstack-source-id: 3ae83c4ef90a9377405aebbf1761ace1a39417b1
[Feature] allow tensorclass to be customized (1080) (31c73301) by vmoens ghstack-source-id: 0b65b0a2dfb0cd7b5113e245c9444d3a0b55d085
[Feature] broadcast pointwise ops for tensor/tensordict mixed inputs (1166) (aeff8376) by vmoens ghstack-source-id: bbefbb1a2e9841847c618bb9cf49160ff1a5c36a
[Feature] compatibility of consolidate with compile (quick version) (1061) (3cf52a0f) by vmoens ghstack-source-id: 1bf3ca550dfe5499b58f878f72c4f1687b0f247e
[Feature] dist_params_keys and dist_sample_keys (1179) (a728a4f7) by vmoens ghstack-source-id: d1e53e780132d04ddf37d613358b24467520230f
[Feature] flexible return type when indexing prob sequences (1189) (790bef60) by vmoens ghstack-source-id: 74d28ee84d965c11c527c60b20d9123ef30007f6
[Feature] from_any with UserDict (1106) (3485c2c8) by vmoens ghstack-source-id: 420464209cff29c3a1c58ec521fbf4ed69d1355f
[Feature] inplace to method (1066) (fbb71a4d) by vmoens ghstack-source-id: 21cbc9f21287d3041c95d31fe2e5259b4ed36a42
[Feature] min, amin, max, amax, cummin, cummax (1057) (e8c0087f) by vmoens ghstack-source-id: 9873c08f98e84b372c6f701a3326e900454dc1d0
[Feature] repeat and repeat_interleave (1115) (004f9796) by vmoens ghstack-source-id: d90a1a7bd87115c5f7af1a413788a30cbc2096ee
[Feature] super() calls within TensorClass subclasses (1133) (5349f2af) by vmoens ghstack-source-id: 060a89982413869c54e1fb4aa74f90e2b9cdaac4
[Feature] tensorclass nocast (1079) (5125217d) by vmoens ghstack-source-id: edaba79a8a3b42cb3dac19b9fc145c1ceca4c70f
[Doc,BugFix,Feature] Better doc for reductions (1122) (26110533) by vmoens ghstack-source-id: 575544e823f29031739dc49561bc2a71125071ca
[Feature,Refactor] More args in constructors, refactor free functions (1116) (b539bebe) by vmoens ghstack-source-id: 35e2444bb5d4bf92b78437063e2f5aec83651713
[Feature,Refactor] Refactor from_dict, add from_any, from_dataclass (1102) (c95a7039) by vmoens ghstack-source-id: eb25fe4b201fd7f27d60b140278820c0d5d51eb8


Bug Fixes

[BugFix] Add checks and to_module to tensorclass accepted methods (1124) (dd88950e) by vmoens ghstack-source-id: 5a1cd0d2ac9a0880111f503fc9cb12519d85ef42
[BugFix] Better comparison of tensorclasses (1137) (eb4a56ed) by vmoens ghstack-source-id: 8def6f01f2b6d09714319a56f96b166ac1fd49d5
[BugFix] Better deterministic sample for composite (1205) (5630fc82) by vmoens ghstack-source-id: 9dd872e39ed9b697412ac8618b870b4d94670293
[BugFix] Better handling of struct arrays (1193) (9b663389) by vmoens ghstack-source-id: 37aecd40226db2362515fd00826bb336607e8749
[BugFix] Better repr of lazy stacks (1076) (eaba7110) by vmoens ghstack-source-id: 7256b4c95b239bf9e6467c0ea687abe2c9179922
[BugFix] Better return_log_prob=True for tensordict outputs (1155) (aff4f4c1) by vmoens ghstack-source-id: 977af3880f39cb341c1c715f1b8c9d59b7c580a0
[BugFix] Cloning empty tensordicts (1119) (c38e256f) by vmoens ghstack-source-id: f3db930052a3ff8d7e75e0d238a578c79acd6bd7
[BugFix] Computation of log prob in composite distribution for TensorDict without batch size (1065) (e64a4c36) by priba Co-authored-by: priba <pau.ribahelsing.ai>
[BugFix] Consistent behavior for pad_sequence with one and many non-tensors (1172) (be44018b) by vmoens ghstack-source-id: c74edd95ed9846c14ffe26cb176d93c6e5e0dfbf
[BugFix] Do not unlock td if it's not locked in TDParams (for compile compat) (1125) (4949efa8) by vmoens ghstack-source-id: 9b6923f9c219e12af5560c97c1c6c58ed7870a8a
[BugFix] Ensure grads and noned when needed (1069) (082d5429) by vmoens ghstack-source-id: 5e9c5a974e5a5c73b033e5b85c3eb70c2f433512
[BugFix] Fix from_any tests (1110) (e2444ed9) by vmoens ghstack-source-id: 8c3b3d825555c727c7c18c7e8a87311f718a94b6
[BugFix] Fix grad tests (1070) (752e6dc4) by vmoens ghstack-source-id: 32c9ee0690db01b54de2e9cc0d83b595b87ac527
[BugFix] Fix mem leak when locking (1188) (259c9411) by vmoens ghstack-source-id: d6e44e1d9b9afc9903a0f45945c10a94dcf5a0ca
[BugFix] Fix none ref in during reduction (1090) (c11024e0) by vmoens
[BugFix] Fix typo in `OneHotCategorical` (1130) (d7506c49) by jgrhab
[BugFix] Fix unitary ops for tensorclass (1164) (148c8231) by vmoens ghstack-source-id: 2d117645769890b72f5856f68acbe1b48015cfbb
[BugFix] Fix update_ KeyError when a key from source is missing in dest (1150) (efb89a6f) by vmoens ghstack-source-id: 63013752ba61f05079cb6a60bb06312968b79ae9
[BugFix] Make min/max tensorclasses be interchangeable with PT equivalent (1180) (44734854) by vmoens
[BugFix] Proper masks for padding with custom pad value (1185) (bbf773be) by vmoens ghstack-source-id: 0580f89ce9bbaf5a13bab33f9c9b8f5a9e9df96f
[BugFix] Reference cycle in TensorDict._cast_reduction (1056) (3316bdcc) by egaznep
[BugFix] Same behaviour in compiled and non-compiled versions of _new_unsafe (1197) (64cfa585) by vmoens ghstack-source-id: 075f953ca7fbd7fc54d797e12437db59b44bde03
[BugFix] Use 'spawn' mp context in all tests (1111) (c8427308) by vmoens ghstack-source-id: a7d786fe77c2c12d5c8c85579123a64ef5c87cf2
[BugFix] Use correct default cuda device (1161) (ecb692e7) by vmoens ghstack-source-id: 9afb5b03ddf75afec357e9e54caadfc92ebf4ded
[BugFix] auto-batch-size in dipatch (1109) (2728dbf9) by vmoens ghstack-source-id: ca5b36195c28da65a20d42699346fbc06083181c
[BugFix] calling pad with immutable sequence (1075) (760c5374) by SamAdamDay
[BugFix] clear_refs_for_compile_() to clear weakrefs when compiling (1196) (ba135417) by vmoens ghstack-source-id: ecbad083704930313dcfdd5bf3f6bb6b984030e8
[BugFix] densify non tensor stack is a no-op (1194) (9a25b88f) by vmoens ghstack-source-id: edbc22ce562cd918ce5dd5c0441e47cdadf7d88a
[BugFix] fix inline TDParams kwargs for nontensordata (1094) (a5656cb0) by vmoens ghstack-source-id: afd50385b6b1e8bd8ccfaabfa387ca5611ca07e2
[BugFix] inline TDParams kwargs in prob modules (1093) (0b7ce938) by vmoens ghstack-source-id: 9fda35811b4656bd9939c9fb31cb253d7751b55c
[BugFix] select_out_keys for Prob sequential (1103) (df61d64a) by vmoens ghstack-source-id: a566ae225c54f07a680b4bf380b16d8e797f62ea
[BugFix] smarter check in set_interaction_type (1088) (db2b5e65) by vmoens ghstack-source-id: 1821309ad24827c22c40c41f3544e7a768325f72

Better engineering

[BE] Better warning for composite_lp_aggregate value (1201) (0fdaba7b) by vmoens ghstack-source-id: c0a801e4922878d65b0f81357afd7ecddc6943fb
[BE] Check ordering and exclusivity of tensorclass registers (1176) (b493178d) by vmoens ghstack-source-id: 3dc907f4dd3047238adb0bb309d9ae75d24c5085
[BE] No warning if user sets the log_prob_key explicitly and only one variable is sampled from the ProbTDMod (1209) (60e71796) by vmoens ghstack-source-id: ccc966d5e698a4fb394081a92bafc31649951ab7
[BE] TensorClass stub method check (1174) (22add568) by vmoens ghstack-source-id: 5d85310221eb18ca6d0b1c4a4a88557f3fe8819d
[BE] single dim check helper (1192) (52dfeb87) by vmoens ghstack-source-id: 6606e4b96061f73b98787b25129c29671a78dc1e
[BE] tensorclass method registration check (1175) (dedec043) by vmoens ghstack-source-id: fa5dff657d58a035a05a39dbca84e3f9795c7fee
[Quality] Avoid torch.distributed imports at root (1134) (0e9a8544) by vmoens ghstack-source-id: f773ed94d4b7ca13c603f32251f0735c751ebf94
[Quality] Better error message for incongruent lists of keys (1077) (78b78022) by vmoens ghstack-source-id: 34940a47d84bcf171bf4511187fcc82df88f801f
[Quality] Better use of StrEnum in set_interaction_type (1087) (79a33458) by vmoens ghstack-source-id: c91a7a6be513fb46be6914df0b3bde779fa5528f

Performance

[Performance] Faster _is_tensor_collection in eager mode (1060) (3963e51a) by vmoens ghstack-source-id: b81c1d243a7c72a9d5fd68bf8e65e97a934ae61c
[Performance] Faster copy of TDParams (1096) (bbfe8c7f) by vmoens
[Performance] Faster to (1073) (6272510f) by vmoens ghstack-source-id: 3dfb0b66fae82dc8cf5ef2a14eccb1bec5237ebb


Refactor

[Refactor] Add missing functions in tensorclass register (1153) (05881f39) by vmoens ghstack-source-id: 48311d7a98a9895b10e5552e5b4a4f13764607e0
[Refactor] Avoid TDParams parameters and buffers construction when obvious (1100) (df870ef8) by vmoens ghstack-source-id: bd701ecfaf68605801a215d3cd9d49268b888bb3
[Refactor] Avoid lambda functions in core functionality (1136) (1d93434a) by vmoens ghstack-source-id: bdd43bbcd353f1148b8b0da79f670e82c3b55c47
[Refactor] Better compile checks (1139) (2aea3dd5) by vmoens ghstack-source-id: c6a8d4587df45e374f0d6cb59fe1c982c7818276
[Refactor] Better handling of params and buffers in bytes (1059) (3d3ea24a) by vmoens ghstack-source-id: 87945c47b376d223bb3dc33bd6ec7cb9bb047455
[Refactor] Fix property handling in TC (1178) (c7505980) by vmoens ghstack-source-id: 8be779a7a85fdf45000181a9ea0f830822f19e37
[Refactor] Make CompositeDistribution a tensordict-exclusive class (1112) (b4b8b31f) by vmoens ghstack-source-id: 56c1dd2ad856a18613ec1a4c0ca70aedd28a52e3
[Refactor] Make _set_dispatch_td_nn_modules compatible with compile (1084) (853b7d98) by vmoens ghstack-source-id: 85a78cd6086233b414fcfe221dd8129e2e38f71c
[Refactor] Refactor context managers (1098) (270d7bab) by vmoens ghstack-source-id: c16baa83f6e41c4afd6637f3b3739d4e5cf25f1e
[Refactor] Refactor keys, items and values (1058) (9232c467) by vmoens ghstack-source-id: 9d5436c6bbc743e3c754d5fe5f6d87b005dde014
[Refactor] `__eq__` to identity check in non-tensor stacking (1083) (b39f0dbf) by vmoens ghstack-source-id: ccbe882e12370b4145d7d834012cc3cfa6376f6c
[Refactor] `composite_lp_aggregate` to handle log-probs aggregates globally (1181) (0013e38b) by vmoens

Doc

[Doc] Add doc on export with nested keys (1085) (3cb5855a) by vmoens ghstack-source-id: 9c95e2dba6751d93c20c66d0dba0d4219dc61c0b
[Doc] Add missing classes to doc (1203) (b4fd3804) by vmoens ghstack-source-id: 2e174577aa33cc8d69c0f423c90ea2e5ee0fdef6
[Doc] Better doc for non-tensor data handling (1173) (d3fba082) by vmoens ghstack-source-id: c25571282d7bb63a14cc7b4ba9fb217785060cc7
[Doc] Better docstring for to_module (1081) (9607cf09) by vmoens ghstack-source-id: 16cedee8c0d38da6f377a262d5d7478a66fce07f
[Doc] Update `distributed_replay_buffer.py` reference (1105) (d5fcace5) by emmanuel-ferdman Signed-off-by: emmanuel-ferdman <emmanuelferdmangmail.com>

CI

[CI] Add missing packages for smoke test (1149) (42ad0660) by vmoens ghstack-source-id: 1ae2795ee734baac4419b722d4e11d522051b112
[CI] Fix GLIBCXX_3.4.29 error (1207) (bae04ced) by vmoens
[CI] Fix failing CI runs for release (1206) (76e1810e) by vmoens
[CI] Fix linux_job_v2 after https://github.com/pytorch/test-infra/pull/6104 (#1191) (f6426cd9) by amdfaa
[CI] Fix nightly build (1148) (b19fc054) by vmoens ghstack-source-id: 46010c7ef465c2fdfe5422e094b5c227b67dbd4f
[CI] Fix smoke tests (1147) (24d8474a) by vmoens ghstack-source-id: d529689fe2b08bed90f55cb2edd0592571619d85
[CI] Update the download-artifacts version (1177) (a63e7f35) by vmoens
[CI] Upgrade CUDA to 12.4 (1198) (1f35ab47) by vmoens ghstack-source-id: 2d06089d4364d906581b60e9d5da1d65ecf01203
[CI] Upgrade to linux_job_v2 (1097) (f606f7b1) by vmoens ghstack-source-id: cf280238d4a241c02edb5d3e8ffb52c24fd228c9

Other

[FBCode] Deactivate vmap monkey-patching in FBCode (1135) (d394750c) by vmoens ghstack-source-id: 4f1ebfd0fd4ff5b7378c8692a064406e72fc68c0
[Minor] Fix wrong fbcode manual links (1064) (b06de95a) by vmoens ghstack-source-id: 8ff9fb4a98ba3cbfc7c90d12a963a8a1e950e95b
[Minor] print_directory_tree returns a string (1086) (2b19ef11) by vmoens ghstack-source-id: d57f19dd8efcef06676fca40a4d6f95367ff1d55
[Test] Ignore annoying jit_utils warning with device context manager (1151) (c671d8ce) by vmoens ghstack-source-id: 23fffb80e79bb839b34178cf5e20faea7a8115c5
[Test] fix inline TDParams kwargs for nontensordata (1095) (978eb6c0) by vmoens ghstack-source-id: da8b7f40d05715170a3e9f0b47763efe356afe5e
[Tests] Skip deprecation warning tests on FB fbcode (1128) (22da6791) by vmoens ghstack-source-id: fb0cc381a670377667194324f5b019076b8e762d
[Versioning] 0.6.2 (1089) (73b0fd71) by vmoens ghstack-source-id: 929ad7fb89e0bd6d25a70ed64b340ad7245fd693
[Versioning] python 3.8 compatibility fix (1127) (d7529ab5) by vmoens ghstack-source-id: ba7e9325c4125892522ee63253c148ed34adac7c
[Versioning] v0.6.1 (1072) (f12d31d1) by vmoens ghstack-source-id: a899c95c12a3b1b986ed429b6507711c4126189e
[Versioning] v0.7 version and deprecations (1202) (02339fd7) by vmoens ghstack-source-id: 6eea85522d8e55d3c1bbfd93ab8c551142de45c1

0.6.2

Minor bug fixes

[BugFix] Fix none ref in during reduction (1090) 88c86f83
[Versioning] v0.6.2 fix cdd5cb39
[BugFix] smarter check in set_interaction_type 0b3c7783
[Versioning] 0.6.2 b26bbe35
[Quality] Better use of StrEnum in set_interaction_type 477d85bc
[Minor] print_directory_tree returns a string 05c0fe7e
[Doc] Add doc on export with nested keys d64c33d8
[Feature] Better logs of key errors in assert_close 1ef1188d
[Refactor] Make _set_dispatch_td_nn_modules compatible with compile f24e3d84
[Doc] Better docstring for to_module 178dfd9d
[Feature] `intersection` for assert_close 85833929
[Quality] Better error message for incongruent lists of keys 866943c3
[BugFix] Better repr of lazy stacks e00965c8
[BugFix] calling pad with immutable sequence (1075) d3bcb6ef
[Performance] Faster to f031bf26

**Full Changelog**: https://github.com/pytorch/tensordict/compare/v0.6.1...v0.6.2

0.6.1

This release offers some minor bug fixes in bytes (1059), a better handling of edge cases in keys, values and items (1058), better caching of grads (1069) and a broken reference cycle in reductions during calls to export (1056).

0.6.0

allowing you to get rid of tensordict altogether when exporting your models:
python
from torch.export import export

model = Seq(
1. A small network for embedding
Mod(nn.Linear(3, 4), in_keys=["x"], out_keys=["hidden"]),
Mod(nn.ReLU(), in_keys=["hidden"], out_keys=["hidden"]),
Mod(nn.Linear(4, 4), in_keys=["hidden"], out_keys=["latent"]),
2. Extracting params
Mod(NormalParamExtractor(), in_keys=["latent"], out_keys=["loc", "scale"]),
3. Probabilistic module
Prob(
in_keys=["loc", "scale"],
out_keys=["sample"],
distribution_class=dists.Normal,
),
)

model_export = export(model, args=(), kwargs={"x": x})

See our [new tutorial](https://pytorch.org/tensordict/main/tutorials/export.html) to learn more about this feature.

The library integration with the PT2 stack is also further improved by the introduction of [`CudaGraphModule`](https://pytorch.org/tensordict/main/reference/generated/tensordict.nn.CudaGraphModule.html),
which can be used to speed-up model execution under a certain set of assumptions; mainly that the inputs and outputs
are non-differentiable, that they are all tensors or constant and that the whole graph can be executed on cuda with
buffers of constant shape (ie, dynamic shape is not allowed).

We also introduce a new tutorial on [streaming tensordicts](https://pytorch.org/tensordict/main/tutorials/streamed_tensordict.html).

*Note*: The `aarch64` binaries are attached to these release notes and not available in PyPI at the moment.

Deprecations
* [Deprecate] Make calls to make_functional error 1034 by vmoens
* [Deprecation] Act warned deprecations for v0.6 1001 by vmoens
* [Refactor] make TD.get default to None, like dict (948) by vmoens

Features
* [Feature] Allow to specify log_prob_key in CompositeDistribution (961) by albertbou92
* [Feature] Better typing for tensorclass 983 by vmoens
* [Feature] Cudagraphs (986) by vmoens
* [Feature] Densify lazy tensordicts 955 by vmoens
* [Feature] Frozen tensorclass 984 by vmoens
* [Feature] Make NonTensorData a callable (939) by vmoens
* [Feature] NJT with lengths 1021 by vmoens
* [Feature] Non-blocking for consolidated TD 1020 by vmoens
* [Feature] Propagate `existsok` in memmap* methods 990 by vmoens
* [Feature] TD+NJT to(device) support 1022 by vmoens
* [Feature] TensorDict.record_stream 1016 by vmoens
* [Feature] Unify composite dist method signatures with other dists (981) Co-authored-by: Vincent Moens <vincentmoensgmail.com>^M
* [Feature] _foreach_copy_ for update_ 1032 by vmoens
* [Feature] `data_ptr()` method 1024 by vmoens
* [Feature] `inplace` arg in TDM constructor 992 by vmoens
* [Feature] `selected_out_keys` arg in TDS constructor 993 by vmoens
* [Feature] better sync and instantiation of cudagraphs (1013) by vmoens
* [Feature] callables for merge_tensordicts 1033 by vmoens
* [Feature] cat and stack_from_tensordict 1018 by vmoens
* [Feature] cat_tensors and stack_tensors 1017 by vmoens
* [Feature] from_struct_array and to_struct_array (938) by vmoens
* [Feature] give a `__name__` to TDModules 1045 by vmoens
* [Feature] param_count 1046 by vmoens
* [Feature] sorted keys, values and items 965 by vmoens
* [Feature] str2td 953 by vmoens
* [Feature] torch.export and onnx compatibility 991 by vmoens

Code improvements
* [Quality] Better error for mismatching TDs (964) by vmoens
* [Quality] Better type hints for `__init__` (1014) by vmoens
* [Quality] Expose private classmethods (982) by vmoens
* [Quality] Fewer recompiles with tensordict (1015) by vmoens
* [Quality] Type checks 976 by vmoens
* [Refactor, Tests] Move TestCudagraphs by vmoens
* [Refactor, Tests] Move TestCudagraphs 1007 by vmoens
* [Refactor] Make tensorclass work properly with pyright (1042) by maxim
* [Refactor] Update nn inline_inbuilt check 1029 by vmoens
* [Refactor] Use IntEnum for interaction types (989) by vmoens
* [Refactor] better AddStateIndependentNormalScale 1028 by vmoens

Fixes
* [BugFix] Add nullbyte in memmap files to make fbcode happy (943) by vmoens
* [BugFix] Add sync to cudagraph module (1026) by vmoens
* [BugFix] Another compiler fix for older pytorch 980 by vmoens
* [BugFix] Compatibility with non-tensor inputs in CudaGraphModule 1039 by vmoens
* [BugFix] Deserializing a consolidated TD reproduces a consolidated TD 1019 by vmoens
* [BugFix] Fix _foreach_copy_ for older versions of PT 1035 by vmoens
* [BugFix] Fix buffer identity in Params._apply (1027) by vmoens
* [BugFix] Fix key errors catch in del_ and related (949) by vmoens
* [BugFix] Fix number check in array parsing (np>=2 compatibility) 999 by vmoens
* [BugFix] Fix pre 2.1 _apply compatibility 1050 by vmoens
* [BugFix] Fix select in tensorclass (936) by vmoens
* [BugFix] Fix td device sync when error is raised 988 by vmoens
* [BugFix] Fix tree_leaves import for older versions of PT 995 by vmoens
* [BugFix] Fix vmap monkey patching 1009 by vmoens
* [BugFix] Make probabilistic sequential modules compatible with compile 1030 by vmoens
* [BugFix] Other dynamo fixes 977 by vmoens
* [BugFix] Propagate maybe_dense_stack in _stack 1036 by vmoens
* [BugFix] Regular swap_tensor for to_module in dynamo (963) by vmoens
* [BugFix] Remove ForkingPickler to account for change of API in torch.mp 998 by vmoens
* [BugFix] Remove forkingpickler (1049) by bhack
* [BugFix] Resilient deterministic_sample for CompositeDist 1000 by vmoens
* [BugFix] Simple syncs (942) by vmoens
* [BugFix] Softly revert get changes (950) by vmoens
* [BugFix] TDParams.to(device) works as nn.Module, not TDParams contained TD 1025 by vmoens
* [BugFix] Use separate streams for cudagraph warmup 1010 by vmoens
* [BugFix] dynamo compat refactors 975 by vmoens
* [BugFix] resilient _exclude_td_from_pytree 1038 by vmoens
* [BugFix] restrict usage of Buffers to non-batched, non-tracked tensors 979 by vmoens

Doc
* [Doc] Broken links in GETTING_STARTED.md (945) by vmoens
* [Doc] Fail-on-warning in sphinx 1005 by vmoens
* [Doc] Fix tutorials 1002 by vmoens
* [Doc] Refactor README and add GETTING_STARTED.md (944) by vmoens
* [Doc] Streaming tensordicts 956 by vmoens
* [Doc] export tutorial, TDM tuto refactoring 994 by vmoens

Performance
* [Performance] Faster `__setitem__` (985) by vmoens
* [Performance] Faster clone 1043 by vmoens

Not user facing
* [Benchmark] Benchmark H2D transfer 1044 by vmoens
* [CI, BugFix] Fix nightly build (941) by vmoens
* [CI] Add aarch64-linux wheels (987) by vmoens
* [CI] Fix versioning of h2d tests 1053 by vmoens
* [CI] Fix windows wheels 1006 by vmoens
* [CI] Upgrade 3.8 workflows (967) by vmoens
* [Minor, Format] Fix fbcode lint (940) by vmoens
* [Minor] Refactor is_dynamo_compiling for older torch versions (978) by vmoens
* [Setup] Correct read_file encoding in setup (962) by vmoens
* [Test] Keep a tight control over warnings (951) by vmoens
* [Test] Make h5py tests optional if no h5py installed (947) by vmoens
* [Test] Mark MP tests as slow (946) by vmoens
* [Test] Rename duplicated test 997 by vmoens
* [Test] Skip compile tests that require 2.5 for stable 996 by vmoens
* [Versioning] Versions for 0.6 (1052) by vmoens

New Contributors
* Mxbonn made their first contribution in https://github.com/pytorch/tensordict/pull/1042
* bhack made their first contribution in https://github.com/pytorch/tensordict/pull/1049

**Full Changelog**: https://github.com/pytorch/tensordict/compare/v0.5.0...v0.6.0

Co-authored-by: Vincent Moens <vmoensmeta.com> by albertbou92

Page 1 of 4

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.