Sparse tensor not supported (Minkowski Engine)

Vinayak_Kunder: <h3>
<a name="sparsetensor-object-is-not-iterable-1" class="anchor" href="#sparsetensor-object-is-not-iterable-1"></a>SparseTensor’ object is not iterable</h3>
<ul>
<li>I have a pytorch model trained on Minkowski Engine  library and i want to deploy this model on torchserve.I am facing issues while converting ‘.pth’ model to the serialized ‘.pt’ model.</li>
<li>python enviornment -</li>
</ul>
<ol>
<li>python 3.7, pytorch 1.8, Minkowski Engine (0.4.3) [<a href="https://github.com/NVIDIA/MinkowskiEngine" class="inline-onebox" rel="noopener nofollow ugc">GitHub - NVIDIA/MinkowskiEngine: Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors</a>]</li>
<li>python 3.8, pythorch 1.10, Minkowski Engine 0.5.4<br>
Tried on both these enviornments, got same following issue.</li>
</ol>
<ul>
<li>
<p>preprocessing used in input file :<br>
<code>preprocessed_data = ME.SparseTensor(features, coordinates)</code></p>
</li>
<li>
<p>I used torch.jit functions to convert the model into serialized form, but i am getting errors due to sparse tensor class of minkowski engine dependency in model.</p>
</li>
</ul>
<h3>
<a name="error-logs-2" class="anchor" href="#error-logs-2"></a>Error logs</h3>
<p>I used various methods for converting ‘.pth’ model to ‘.pt’ serialized model.</p>
<ol>
<li>
<p>torch.jit.trace, got following error :<br>
<code>Traceback (most recent call last): File "model_pt_converter.py", line 65, in &lt;module&gt;  traced_script_module = torch.jit.trace(model, preprocessed_data) File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 750, in trace  _module_class, File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 941, in trace_module  example_inputs = make_tuple(example_inputs) File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 542, in make_tuple  return tuple(example_inputs) TypeError: 'SparseTensor' object is not iterable</code></p>
</li>
<li>
<p>using torch.jit.script,<br>
<code>torch.jit.frontend.UnsupportedNodeError: global variables aren't supported:</code><br>
<code>SparseTensor.__init__' is being compiled since it was called from '__torch__.SparseTensor.SparseTensor</code><br>
<code>__torch__.SparseTensor.SparseTensor' is being compiled since it was called from 'MinkowskiConvolution.forward</code></p>
</li>
<li>
<p>I also tried to serve the .pth model directly, the model is not getting loaded throwing following issues -<br>
<code> Load model failed: s2b-model, error: Worker died</code><br>
<code>error: unrecognized arguments: --sock-type unix --sock-name /tmp/.ts.sock.9002</code><br>
<code>java.lang.InterruptedException: null</code>I have a pytorch model trained on Minkowski Engine  library and i want to deploy this model on torchserve.I am facing issues while converting ‘.pth’ model to the serialized ‘.pt’ model.<br>
python enviornment -</p>
</li>
<li>
<p>python 3.7, pytorch 1.8, Minkowski Engine (0.4.3) [<a href="https://github.com/NVIDIA/MinkowskiEngine" class="inline-onebox" rel="noopener nofollow ugc">GitHub - NVIDIA/MinkowskiEngine: Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors</a>]</p>
</li>
<li>
<p>python 3.8, pythorch 1.10, Minkowski Engine 0.5.4<br>
Tried on both these enviornments, got same following issue.<br>
preprocessing used in input file :<br>
<code>preprocessed_data = ME.SparseTensor(features, coordinates)</code></p>
</li>
</ol>
<ul>
<li>I used various methods for converting ‘.pth’ model to ‘.pt’ serialized model.</li>
</ul>
<ol>
<li>
<p>torch.jit.trace, got following error :<br>
<code>Traceback (most recent call last): File "model_pt_converter.py", line 65, in &lt;module&gt;  traced_script_module = torch.jit.trace(model, preprocessed_data) File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 750, in trace  _module_class, File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 941, in trace_module  example_inputs = make_tuple(example_inputs) File "/home/vinayak/miniconda3/envs/serve/lib/python3.7/site-packages/torch/jit/_trace.py", line 542, in make_tuple  return tuple(example_inputs) TypeError: 'SparseTensor' object is not iterable</code></p>
</li>
<li>
<p>using torch.jit.script,<br>
<code>torch.jit.frontend.UnsupportedNodeError: global variables aren't supported:</code><br>
<code>SparseTensor.__init__' is being compiled since it was called from '__torch__.SparseTensor.SparseTensor</code><br>
<code>__torch__.SparseTensor.SparseTensor' is being compiled since it was called from 'MinkowskiConvolution.forward</code></p>
</li>
<li>
<p>I also tried to serve the .pth model directly, the model is not getting loaded throwing following issues -<br>
<code> Load model failed: s2b-model, error: Worker died</code><br>
<code>error: unrecognized arguments: --sock-type unix --sock-name /tmp/.ts.sock.9002</code><br>
<code>java.lang.InterruptedException: null</code></p>
</li>
</ol>
<h3>
<a name="installation-instructions-3" class="anchor" href="#installation-instructions-3"></a>Installation instructions</h3>
<ul>
<li>Installed torchserve using pip and pytorch using conda.</li>
<li>Didn’t used docker image.</li>
</ul>
<h3>
<a name="versions-4" class="anchor" href="#versions-4"></a>Versions</h3>
<hr>
<h2>
<a name="environment-headers-5" class="anchor" href="#environment-headers-5"></a>Environment headers</h2>
<p>Torchserve branch:</p>
<p>torchserve==0.7.0<br>
torch-model-archiver==0.7.0</p>
<p>Python version: 3.7 (64-bit runtime)<br>
Python executable: /home/vinayak/miniconda3/envs/serve/bin/python</p>
<p>Versions of relevant python libraries:<br>
future==0.18.2<br>
numpy==1.21.5<br>
nvgpu==0.9.0<br>
psutil==5.9.4<br>
requests==2.28.1<br>
torch==1.8.2<br>
torch-model-archiver==0.7.0<br>
torch-workflow-archiver==0.2.6<br>
torchaudio==0.8.2<br>
torchserve==0.7.0<br>
torchvision==0.13.1a0<br>
wheel==0.37.1<br>
torch==1.8.2<br>
**Warning: torchtext not present …<br>
torchvision==0.13.1a0<br>
torchaudio==0.8.2</p>
<p>Java Version:</p>
<p>OS: Pop!_OS 20.04 LTS<br>
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0<br>
Clang version: N/A<br>
CMake version: N/A</p>