JamesTheZ commented on issue #13664:
URL: https://github.com/apache/tvm/issues/13664#issuecomment-1365749841

   > It looks like amp is adding some dynamism, do you know why?
   > 
   > The following modified script that removed amp autocast works:
   > 
   > ```
   > from transformers import BertTokenizer, BertConfig, BertModel
   > import tvm
   > from tvm import relay
   > import torch
   > 
   > 
   > class AutoModelAMP(BertModel):
   >     def __init__(self, *args, **keyargs):
   >         super().__init__(*args, **keyargs)
   > 
   >     def forward(self, *args, **keyargs):
   >         return super().forward(*args, **keyargs)
   > 
   > 
   > config = BertConfig.from_pretrained("bert-large-uncased")
   > config.return_dict = False
   > config.torchscript = True
   > model = AutoModelAMP(config).eval()
   > 
   > batch = 1
   > seq_len = 128
   > input = torch.zeros([batch, seq_len], dtype=torch.int).long()
   > inputs = {
   >     "input_ids": input,
   >     "attention_mask": input,
   >     "token_type_ids": input,
   > }
   > input_list = []
   > for k, v in inputs.items():
   >     input_list.append(v)
   > 
   > shape_list = []
   > for k, v in inputs.items():
   >     shape_list.append((k, v.shape))
   > 
   > traced_model = torch.jit.trace(
   >     model, input_list, strict=False).eval()
   > mod, params = relay.frontend.from_pytorch(traced_model, shape_list)
   > ```
   
   Using the above script without autocast still results in the same error to 
me. The environment by executing `python -c 'import torch, tvm, transformers; 
print(f"torch version: {torch.__version__}, tvm version: {tvm.__version__}, 
transformers version: {transformers.__version__}");'` is:
   ```
   torch version: 1.12.0+cu113, tvm version: 0.11.dev0, transformers version: 
4.25.1
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to