[论文解读] TRT-ViT: TensorRT-oriented Vision Transformer
TRT-ViT 提出了一类经 TensorRT 优化的视觉变换器(Vision Transformers),通过在 TensorRT 上直接进行硬件感知的延迟测量,重新思考网络设计,实现了最先进的延迟-准确率权衡。通过推导出四项实用设计准则(如后期阶段的 Transformer 和早期的 CNN),其在分割和检测任务上的推理速度相比 SOTA 模型最快提升 4.4 倍,同时保持或提升了准确率。
We revisit the existing excellent Transformers from the perspective of practical application. Most of them are not even as efficient as the basic ResNets series and deviate from the realistic deployment scenario. It may be due to the current criterion to measure computation efficiency, such as FLOPs or parameters is one-sided, sub-optimal, and hardware-insensitive. Thus, this paper directly treats the TensorRT latency on the specific hardware as an efficiency metric, which provides more comprehensive feedback involving computational capacity, memory cost, and bandwidth. Based on a series of controlled experiments, this work derives four practical guidelines for TensorRT-oriented and deployment-friendly network design, e.g., early CNN and late Transformer at stage-level, early Transformer and late CNN at block-level. Accordingly, a family of TensortRT-oriented Transformers is presented, abbreviated as TRT-ViT. Extensive experiments demonstrate that TRT-ViT significantly outperforms existing ConvNets and vision Transformers with respect to the latency/accuracy trade-off across diverse visual tasks, e.g., image classification, object detection and semantic segmentation. For example, at 82.7% ImageNet-1k top-1 accuracy, TRT-ViT is 2.7$ imes$ faster than CSWin and 2.0$ imes$ faster than Twins. On the MS-COCO object detection task, TRT-ViT achieves comparable performance with Twins, while the inference speed is increased by 2.8$ imes$.
研究动机与目标
- 解决研究驱动的模型效率指标(如 FLOPs)与实际部署性能之间的日益扩大的差距。
- 识别为何最先进的 Transformer 模型尽管准确率高,但在实际应用中表现不佳,尤其是由于计算模式对硬件不友好。
- 为特定硬件上的 TensorRT 推理开发一种实用的、硬件感知的高效视觉模型设计框架。
- 通过构建混合架构,弥合 CNN(高效)与 Transformer(准确)之间的性能差距,实现在延迟-准确率权衡上与两者相当或更优。
提出的方法
- 以 T4 GPU 上批量大小为 8 的实际推理延迟作为主要效率指标,取代 FLOPs 或参数量等间接指标。
- 在多个视觉任务上进行受控的消融实验,推导出四项高效、适合部署的架构设计准则。
- 设计混合的 TRT-ViT 模块,以块级方式串行组合 CNN 和 Transformer 组件,解耦异构操作,提升信息流动性和内存效率。
- 实现层级级和块级的架构模式:后期阶段的 Transformer、浅层-深层阶段设计,以及全局-局部块设计,以平衡性能与速度。
- 引入 MixBlockC 模块,通过可学习的压缩比控制计算与内存成本,实现高效的权衡。
- 在相同的 TensorRT 部署设置下,对 TRT-ViT 进行图像分类(ImageNet-1k)、目标检测(MS-COCO)和语义分割(ADE20K)的训练与评估。
实验结果
研究问题
- RQ1为何最先进的 Transformer 模型尽管 FLOPs 较低,仍无法在实际中实现高效推理,即使其准确率很高?
- RQ2如何设计视觉模型,使其在真实硬件上实现高准确率与低推理延迟的双重优势,特别是在 TensorRT 部署场景下?
- RQ3在优化真实硬件延迟时,层级级或块级的架构模式中,哪种最能平衡性能与效率?
- RQ4在真实部署条件下,混合 CNN-Transformer 架构能否在延迟-准确率权衡上超越纯 Transformer 或纯 CNN 模型?
主要发现
- 在 ImageNet-1k 上达到 82.7% 的 top-1 准确率时,TRT-ViT 在 T4 GPU 上的推理速度比 CSWin 快 2.7 倍,比 Twins 快 2.0 倍(批量大小=8)。
- 在 MS-COCO 目标检测任务中,TRT-ViT-B 的 AP 与 Twins-SVT-S 相当(47.3 vs. 47.3),但推理速度快 2.8 倍。
- 在 ADE20K 语义分割任务中,TRT-ViT 比 Twins-SVT-S 快 4.4 倍,mIoU 达 45.46%,在相似延迟下比 ResNet 提升 6.6%。
- TRT-ViT-D 在 COCO 检测任务中达到 48.1 AP,推理速度比 Twins-SVT-B 快 2.7 倍,展示了在下游任务中的显著效率提升。
- 分类与检测之间的延迟差距显著缩小:TRT-ViT 在迁移至检测任务时保持了类似 ResNet 的效率,而像 Twins-SVT-B 这类 Transformer 模型则出现 32 倍的延迟增加。
- 所提出的 MixBlockC 模块在压缩比 R=0.5 时,延迟降低 40%,准确率仅轻微下降(80.8% → 81.2%),证明了可控计算控制的有效性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。