apply_to_collection
breaks named tuples (force casts to tuples)
#206
Labels
apply_to_collection
breaks named tuples (force casts to tuples)
#206
🐛 Bug
lightning_utilities.core.apply_func.apply_to_collection
breaks homogeneous named tuples, forcing conversion to simple tuples. This results in a forced conversion of NamedTuple-based batches from the dataloader to tuples in Lightning.To Reproduce
Reproducing the bug in Lightning requires creating model + dataloader with NamedTuple output.
Reproducing the problem in Lightning-Utilities is easier, see the snippet below:
Expected behavior
apply_to_collection
should return the NamedTuple (if input is of NamedTuple type) instead of force-casting it to simple tuple.Additional context
I think that the problem was introduced in #160
Lightning Utilities version
0.9.0
is fine, but0.10.0
breaks named tuples.I think that the behavior is incorrect in
utilities/src/lightning_utilities/core/apply_func.py
Line 68 in a00e114
Potential fix:
Environment details
conda
,pip
, source):The text was updated successfully, but these errors were encountered: