A question regarding pytorch backend usage
I was looking in the tritonserver pytorch backend doccumentation, where I have seen the following:
> PyTorch 2.0 features are available. However, Triton’s PyTorch backend requires a serialized representation of the model in the form a model.pt file. The serialized representation of the model can be generated using PyTorch’s [torch.save()](https://docs.pytorch.org/tutorials/beginner/saving_loading_models.html#id1) function to generate the model.pt file.
I tried using this feature as advertised, in order to run a torch.compile() model in tritonserver, and got the following error:
```
failed to load 'model' version 1: Internal: failed to load model 'model': PytorchStreamReader failed locating file constants.pkl: file not found. This is an internal miniz error. If you are seeing this error, there is a high likelihood that your checkpoint file is corrupted. This can happen if the checkpoint was not saved properly, was transferred incorrectly, or the file was modified after saving
```
The issue suggests that the file I put in my model repository is not in the correct format.
After consulting the pytorch backend code, I found the following, under `model.py`:
```
if not _is_py_class_model(model_path):
self._logger.log_info("Loading '" + self._model_name + "' as TorchScript")
self._model = torch.jit.load(model_path)
self._device = _get_device(self._kind, self._device_id, self._model)
self._model.to(self._device)
self._model.eval()
return
```
This if statement suggests that only if my model is not a python model, the model will fallback on running the .pt file, which when using torch.save results in an error.
This implies that In order to let the backend to run my torch compile, i must save the model as a .py file, which goes against what the docs say.
When doing running with `backend: pytorch`, and setting `default_model_name: "model.py"` to the appropriate python file, I get the following error:
```
[libprotobuf ERROR /tmp/tritonbuild/tritonserver/build/_deps/repo-third-party-build/grpc-repo/src/grpc/third_party/protobuf/src/google/protobuf/text_format.cc:337] Error parsing text-format inference.ModelConfig: 3:19: Message type "inference.ModelConfig" has no field named "default_model_name".
E0311 14:35:59.343860 1 model_repository_manager.cc:1460] "Poll failed for model directory 'model': failed to read text proto from /models/model/config.pbtxt"
```
At this point I can simply run my model as a python backend model, but that beats the point of the feature.
So what's going on here? What exactly is this feature? How may one use it? Is it simply a documentation mistake? A bug of some sort? What the docs show seems promising but It's not what's happening, something is not adding up.
Thanks in advance!
2 条评论