Skip to content

🐛 [Bug] perf gap reduce on BERT #3702

Closed

Description

@zewenli98

Bug Description

Compare the perf of Torch-TRT against ONNX-TRT.

In fp32:

  1. Skipping constant folding of embedding layers can reduce engine size. It doesn't affect latency or precision
  2. Disabling linear decomposition + adding linear converter doesn't affect latency
  3. opt_level=3 or 5 get almost same latency
  4. onnx-trt takes much longer in compile time
  5. torch-trt is ~2.5% slower than onnx-trt

In fp16:

  1. Skipping constant folding of embedding layers can reduce engine size. It doesn't affect latency or precision
  2. Disabling linear decomposition + adding linear converter reduces ~18% latency
  3. opt_level=3 or 5 get almost same latency
  4. onnx-trt takes much longer in compile time
  5. torch-trt is ~11% slower than onnx-trt

To Reproduce

run perf_run.py script

Activity

  1. self-assigned this
    on Jul 22, 2025
  2. zewenli98 commented on Jul 22, 2025

    @zewenli98
    CollaboratorAuthor

    linear converter PR + fixing broadcast PR can eliminate perf gap on BERT in both fp32 and fp16

  3. zewenli98 commented on Jul 24, 2025

    @zewenli98
    CollaboratorAuthor

    When embedding layer is constant folded, the engine size will become larger and larger as inputs increase, while the latency is not affected though. Currently, I only observed the issue on BERT but not on other models.

  4. zewenli98 commented on Jul 28, 2025

    @zewenli98
    CollaboratorAuthor

    engine size issue will follow up in #3710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions