Skip to content

TRT engine caching for text gen models#55

Merged
IlyasMoutawwakil merged 5 commits into
mainfrom
trt-engine
Sep 15, 2023
Merged

TRT engine caching for text gen models#55
IlyasMoutawwakil merged 5 commits into
mainfrom
trt-engine

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Sep 11, 2023

Copy link
Copy Markdown
Member

builds two trt engines for causal models

@IlyasMoutawwakil

Copy link
Copy Markdown
Member Author

Using trt dynamic shapes instead of building two engines.
example:

provider_options = {
    "trt_engine_cache_enable": True,
    "trt_engine_cache_path": "tmp/trt_cache_gpt2_example",
    "trt_profile_min_shapes": "input_ids:1x16,attention_mask:1x16",
    "trt_profile_max_shapes": "input_ids:1x64,attention_mask:1x64",
    "trt_profile_opt_shapes": "input_ids:1x64,attention_mask:1x64",
}

ort_model = ORTModelForCausalLM.from_pretrained(
    "gpt2",
    export=True,
    use_cache=False,
    provider="TensorrtExecutionProvider",
    provider_options=provider_options,
)

ort_model.generate(
    input_ids=torch.tensor([[1] * 16]).to("cuda"),
    max_new_tokens=64-16,
    min_new_tokens=64-16,
    pad_token_id=0,
    eos_token_id=0,
)

but still very slow to build 😕

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.

1 participant