Skip to content

Implementation for TensorRT #36

Closed
Closed

Description

@UdonDa

Hi,

I guess that a reverse diffusion process can be performed fastly if an UNet implementation in this library can infer with TensorRT.
Would you have the plan to implement for TensorRT?

Activity

  1. patrickvonplaten commented on Jun 28, 2022

    @patrickvonplaten
    Contributor

    Hey @UdonDa,

    That's a good question! I'm sadly not too familiar with TensorRT but diffusion processes indeed suffer from slow inference often. I'd be happy to allow integrations with TensorRT, do you have an idea of how to do so? Also cc @anton-l

  2. UdonDa commented on Jun 28, 2022

    @UdonDa
    Author

    Hi, @patrickvonplaten, @anton-l!

    Actually, it is easy to implement it using this library https://github.com/pytorch/TensorRT#python.
    The library provides a compiler so that we just compile our network instance.

    However, I have two concerns.
    (1) I do not know if the compiled network can estimate an accurate score function.
    (2) It's necessary to re-write an unet implementation to compile, which is just how to define networks such as resblocks. Now, although I try to use TensorRT, the implementation cannot adapt it. If the modification is applied, the pretrained weight uploaded on a huggingface may not be correctly loaded.

  3. patrickvonplaten commented on Aug 23, 2022

    @patrickvonplaten
    Contributor

    Hey,

    Hmm if it requires major code additions, it might be a bit too early to add to the library at this stage. Happy to help if you're interested in adding some code though!

  4. batrlatom commented on Sep 13, 2022

    @batrlatom

    This is the middle of the road, but it is necessary to be able to use tensorrt (through the torch_tensorrt library). Check out this implementation. Converting to torchscript and layer fusion increases the speed by 50%, which is pretty cool. Do you want to try adding it to the official library? https://github.com/cloneofsimo/sd-various-ideas/blob/main/create_jit.ipynb

  5. gadicc commented on Sep 16, 2022

    @gadicc

    PhotoRoom made an awesome blog post on exactly how do this: Making stable diffusion 25% faster using TensorRT. They explain exactly what's happening, give all the sample code, and even performance metrics between the two models. They also reference the recent ONNX work in #284. Hope this helps!

  6. patrickvonplaten commented on Sep 21, 2022

    @patrickvonplaten
    Contributor
  7. github-actions commented on Oct 15, 2022

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

    Please note that issues that do not follow the contributing guidelines are likely to be ignored.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions