Skip to content

Bandits are non-TorchScript-able in 3.10 #124

@tcleberg

Description

@tcleberg

Hello- applying a bandit from Pearl and I came across a torch.jit.save() issue for a bandit class in a python 3.10, torch 2.0.1 environment:

This is due to two issues:

  1. The more trivial one - the current type hints are not 3.10-compatible. We could very likely handle that by:
from __future__ import annotations
  1. Optimizers are attributes of the policy learner (and the corresponding PyTorch type hints are not compatible).

Externalizing the optimizer from the policy_learner might make sense in any case.

        self._optimizer: torch.optim.Optimizer = optim.AdamW(
            self.model.parameters(), lr=learning_rate, amsgrad=True
        )

I'm aware that this is quite a restricted environment and that the solve might be to pin Pearl at versions above that - but wanted to log the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions