Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Graph][Dynamo Backend] Minor imperative run bug fix #383

Merged
merged 1 commit into from Nov 22, 2023

Conversation

Aalanli
Copy link
Collaborator

@Aalanli Aalanli commented Nov 21, 2023

No description provided.

@yaoyaoding
Copy link
Member

Hi @Aalanli, does this fix the bug?

@Aalanli
Copy link
Collaborator Author

Aalanli commented Nov 22, 2023

Yes, the following script now runs:

import os
import torch
import hidet
from transformers import AutoTokenizer, RobertaForSequenceClassification
from transformers import logging
import hidet

# This line causes compilation to fail
hidet.option.imperative(False)
# hidet.torch.dynamo_config.use_cuda_graph(False)

os.environ["TOKENIZERS_PARALLELISM"] = "false"
logging.set_verbosity_error()


if __name__ == "__main__":
    
    tokenizer = AutoTokenizer.from_pretrained("roberta-base")
    model = RobertaForSequenceClassification.from_pretrained("roberta-base", max_position_embeddings=8192, ignore_mismatched_sizes=True)
    model = model.eval().cuda()

    inputs = tokenizer("Hello, my dog is cute", padding='max_length', max_length=4096, return_tensors="pt")
    inputs = {'input_ids': inputs['input_ids']}

    with torch.no_grad(), torch.autocast("cuda", enabled=True):
        model = torch.compile(model, backend="hidet")

        torch_inputs = tuple(i.clone().cuda() for i in inputs.values())
        torch_out = model(*torch_inputs)

@yaoyaoding
Copy link
Member

Thanks @Aalanli !

@yaoyaoding yaoyaoding merged commit e349972 into hidet-org:main Nov 22, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants