Productionizing native torch extensions

Hi, I work on the Torch-MLIR project and we are currently trying to figure out how to productionize our python packaging situation. The biggest problem appears to be how to address version skew / binary compatibility across PyTorch versions vs our native code that links against libtorch. One of my goals here is for pip install torch-mlir (with no additional flags or version requirements) to automatically install a binary-compatible torch-mlir+torch combo.

What are the best practices for handling that?

For example, we are playing with statically linking libtorch which removes some degrees of ABI incompatibility surface area but opens up other ones.

2 Likes

Hi,

I think the simplest version will be to pin a specific version of PyTorch as the dependency for your package so that the right now comes with your package.
The way we do this for domain libraries that have the same issue is:

  • Releases are pinned against last torch package release
  • Nighly binaries are pinned to the latest nightly version of pytorch

This way, both pip install torchvision and pip install --pre torchvision --extra-index-url https://download.pytorch.org/whl/nightly/cpu work as expected.

2 Likes

Thanks, that seems like a good approach!