AttributeError: module 'torch.backends' has no attribute 'opt_einsum'

I updated my pytorch version from 2.0.1 to 2.1.0 today and noticed that torch.backends no longer has opt_einsum as an attribute. The error can be simply reproduced by running

torch.backends.opt_einsum

When I go into the source code of torch.backends, I found the following block of code

from torch.backends import (
    cpu as cpu,
    cuda as cuda,
    cudnn as cudnn,
    mkl as mkl,
    mkldnn as mkldnn,
    mps as mps,
    openmp as openmp,
    quantized as quantized,
)

which seems to suggest that opt_einsum has removed from the imports. However, the directory opt_einsum still exists in torch/backends.

I’m just curious if this change is intentional, and if so what is the reason?

As long as it exists in the torch/backends dir, shouldn’t it return you the still opt_einsum module?

Yes I think you’re right, it appears that

import torch.backends import opt_einsum

still works, and all the functions of opt_einsum can still be accessed normally.

I am still a bit curious if this is a sign of deprecation or some incoming refactoring. Couldn’t find anything in the release notes.

I am still a bit curious if this is a sign of deprecation or some incoming refactoring. Couldn’t find anything in the release notes.

That block of imports was actually added later, so opt_einsum was never actually included there.