🐛 [Bug] Encountered bug for nn.LSTM with half dtype
Open
@bowang007 is already working on this.
Since Mar 4, 2024.
bug
story: LLM & Generative AI
- Dominant language
- Python
- Stars
- 3k
- Forks
- 410
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 78
Description
Bug Description
When running the compiled LSTM model for half dtype with torch-tensorrt, I get this errors:
RuntimeError: Input and parameter tensors are not the same dtype, found input tensor with Float and parameter tensor with Half
Here is the test code:
import torch
import torch.nn as nn
import torch_tensorrt
class Model(nn.Module):
def __init__(self):
super().__init__()
self.relu = nn.ReLU()
self.lstm = nn.LSTM(800, 800)
def forward(self, input_x):
x = self.relu(input_x)
x = self.lstm(x)[0]
return x
model = Model().eval().half().cuda()
x = torch.randn(50, 50, 800).half().cuda()
script_model = torch.jit.trace(model, x)
trt_ts_model = torch_tensorrt.compile(script_model, ir="torchscript", inputs=[x], enabled_precisions=[torch.half], truncate_long_and_double=True)
res = trt_ts_model(x)
Expected behavior
Environment
Build information about Torch-TensorRT can be found by turning on debug messages
- Torch-TensorRT Version (e.g. 1.0.0): v1.4.0
- PyTorch Version (e.g. 1.0): 2.0
- CPU Architecture:
- OS (e.g., Linux): Linux
- How you installed PyTorch (
conda,pip,libtorch, source): - Build command you used (if compiling from source):
- Are you using local sources or building from archives:
- Python version:
- CUDA version: 11.8
- GPU models and configuration: A100
- Any other relevant information:
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.