Summary
Training on a MemmapDataset with a variant target (e.g. energy/pbe) fails at the first batch with:
invalid parameter: 'energy/pbe' is not a valid label name
The identical target definition trains fine when the data is read from an ASE-readable .xyz file. The issue should be isolated to MemmapDataset.__getitem__, which builds the metatensor property Labels from the raw target name and does not strip the /<variant> suffix.
Is this a wanted behaviour or a bug worth correcting?
Expected behavior
Training runs correctly with /<variant> suffix
Actual behavior
mtt stops with error
invalid parameter: 'energy/pbe' is not a valid label name
Version
2026.2.1
Steps to reproduce
from metatensor.torch import Labels
# What `MemmapDataset.__getitem__` currently does:
Labels.range("energy/pbeu".replace("mtt::", ""), 1)
-> RuntimeError: invalid parameter: 'energy/pbeu' is not a valid label name
# What `target_info.py` / the ASE reader do (works):
tk = "energy/pbeu"
Labels.range((tk.split("/")[0] if "/" in tk else tk).replace("mtt::", ""), 1) # OK -> "energy"
Further information, files, and links
Suggested fix:
properties=Labels.range(
- target_key.replace("mtt::", ""), target_array.shape[-1]
+ (target_key.split("/")[0] if "/" in target_key else target_key).replace(
+ "mtt::", ""
+ ),
+ target_array.shape[-1],
),
Summary
Training on a
MemmapDatasetwith a variant target (e.g.energy/pbe) fails at the first batch with:The identical target definition trains fine when the data is read from an ASE-readable
.xyzfile. The issue should be isolated toMemmapDataset.__getitem__, which builds the metatensor propertyLabelsfrom the raw target name and does not strip the/<variant>suffix.Is this a wanted behaviour or a bug worth correcting?
Expected behavior
Training runs correctly with
/<variant>suffixActual behavior
mtt stops with error
Version
2026.2.1
Steps to reproduce
Further information, files, and links
Suggested fix: