FasterTransformer icon indicating copy to clipboard operation
FasterTransformer copied to clipboard

line 106, in run_vitnv_op vit = torch.classes.VisionTransformerClass(vit_weights.weights, TypeError: '_ClassNamespace' object is not callable

Open lucasjinreal opened this issue 3 years ago • 7 comments

Description

python3.10/site-packages/torch/include/ATen/core/ivalue_inl.h":123, please report a bug to PyTorch. Expected Object but got PyObject
Traceback (most recent call last):
  File "/home/infer_vit_op.py", line 92, in run_vitnv_op
    vit = torch.classes.VisionTransformer.Class(vit_weights.weights, 
RuntimeError: isObject()INTERNAL ASSERT FAILED at "/home/.local/lib/python3.10/site-packages/torch/include/ATen/core/ivalue_inl.h":123, please report a bug to PyTorch. Expected Object but got PyObject



### Reproduced Steps

```shell
python infer_visiontransformer_op.py \                                                                                                                1 ↵
    --model_type=ViT-B_16  \
    --img_size 384 \
    --batch-size=32 \
    --th-path ../../ft/build/lib/libpyt_vit.so \
    --quant-mode ft2
classifier: token
hidden_size: 768
patches:
  size: !!python/tuple
  - 16
  - 16
representation_size: null
transformer:
  attention_dropout_rate: 0.0
  dropout_rate: 0.1
  mlp_dim: 3072
  num_heads: 12
  num_layers: 12

[FT][INFO] img_size: 384, patch_size:16
batch_size:32, chn_num  : 3
embed_dim: 768, is_fp16  : 0
head_num  :12, head_dim : 64
inter_size:3072, num_layer: 12

[WARNING] gemm_config.in is not found; using default GEMM algo

lucasjinreal avatar Sep 20 '22 07:09 lucasjinreal

@byshiue hi, do u know why got this error?

lucasjinreal avatar Sep 21 '22 03:09 lucasjinreal

I have no idea. From the bug message, It looks like a bug of PyTorch.

please report a bug to PyTorch. Expected Object but got PyObject

byshiue avatar Sep 21 '22 03:09 byshiue

@byshiue Maybe, but seems the calling way torch.classes.VisionTrasnformerClass is not fully correct? Your c++ implementation has a namespace before this class....

Do u know how to correctly calling this c++ pytorch op? (I ddin't change anything of code)

lucasjinreal avatar Sep 21 '22 04:09 lucasjinreal

@byshiue I have posted a bug to pytorch. can u please help me try on more decent pytorch to see if it can run on your side?

lucasjinreal avatar Sep 21 '22 04:09 lucasjinreal

@byshiue I have posted a bug to pytorch. can u please help me try on more decent pytorch to see if it can run on your side?

We have verified PyTorch 1.09 ~ 1.13 by the pytorch docker images on NGC, like nvcr.io/nvidia/ptyroch:22.07-py3.

byshiue avatar Sep 22 '22 01:09 byshiue

@byshiue It's weired, I swithched to pytorch 1.12 seems not problem.

lucasjinreal avatar Sep 22 '22 03:09 lucasjinreal

We don't have ideas for such bugs about pytorch.

byshiue avatar Oct 10 '22 06:10 byshiue