Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.93k stars 1.09k forks source link

TRT support for MAISI #8153

Closed borisfom closed 2 weeks ago

borisfom commented 1 month ago

Description

Added trt_compile() support for Lists and Tuples in arguments for forward() - needed for MAISI. Did not add support for grouping return results yet - MAISI worked with explicit workaround unrolling the return results.

Notes

To successfully export MAISI, either latest Torch nightly is needed, or this patch needs to be applied to 24.09-based container:

--- /usr/local/lib/python3.10/dist-packages/torch/onnx/symbolic_opset14.bak     2024-10-09 01:38:04.920316673 +0000                                                   
+++ /usr/local/lib/python3.10/dist-packages/torch/onnx/symbolic_opset14.py      2024-10-09 01:38:25.228053951 +0000                                                   
@@ -148,7 +148,6 @@                                                                                                                                                   
         is_causal and symbolic_helper._is_none(attn_mask)                                                                                                            
     ), "is_causal and attn_mask cannot be set at the same time"                                                                                                      

-    scale = symbolic_helper._maybe_get_const(scale, "f")                                                                                                             
     if symbolic_helper._is_none(scale):                                                                                                                              
         scale = _attention_scale(g, query)                                                                                                                           

Types of changes

borisfom commented 1 month ago

Also, I did not do any results verification. If any results depend on Meta tensors operation, that part may be lost. Please check!

KumoLiu commented 1 month ago

Hi @binliunls, please also review the trt related parts in this PR, thanks.

KumoLiu commented 2 weeks ago

/build

KumoLiu commented 2 weeks ago

/build