量化被疯狂地作为模型压缩技术,该技术通过将神经网络中的浮点重量和激活转换为低位整数来获得有效的模型。量化已被证明可以很好地在卷积神经网络和基于变压器的模型上运行。尽管这些模型具有符合性的典型性,但最近的工作表明,基于MLP的模型能够在从计算机视觉,NLP到3D点云等各种任务上取得可比的结果,同时由于并行性和网络简单性,可以实现更高的吞吐量。但是,正如我们在论文中所显示的那样,将量化直接应用于基于MLP的模型将导致明显的准确性降解。基于我们的分析,两个主要问题说明了准确性差距:1)基于MLP的模型中的激活范围可能太大而无法量化,而2)基于MLP的模型中的特定组件对量化很敏感。因此,我们建议1)应用分层以控制激活的量化范围,2)使用有界的激活功能,3)在激活上应用百分位量化,4)使用我们的改进的模块,称为多个令牌混合MLP,5)应用线性态度敏感操作的不对称量化器。我们的Q-MLP模型配备了上述技术,可以使用8位均匀量化(型号30 MB)和78.47%的Imagenet获得79.68%的精度,而4位量化(15 MB)。
translated by 谷歌翻译
网络量化显着降低了模型推理复杂性,并且已广泛用于现实世界部署。然而,大多数现有量化方法已经开发并主要测试并测试卷积神经网络(CNN),并且当应用于基于变压器的架构时遭受严重的降级。在这项工作中,我们提出了一种系统方法,以降低量化变压器的性能下降和推理复杂性。特别是,我们提出了两种规模(PTS)的权力以以硬件友好的方式处理LAbernorm输入的严重频道间变化。此外,我们提出了可以维持注意力映射的极端不均匀分布的log-int-softmax(LIS),同时通过使用4位量化和比特速度操作员简化推断。关于各种变压器的架构和基准测试的综合实验表明,我们的方法在使用Leference Maps中使用甚至更低的位宽度时,我们的方法始终以前的性能。例如,我们在Imagenet上达到85.17%的高精度,51.4地图与Coco上的级联面罩R-CNN(Swin-S)。据我们所知,我们是第一个在完全量化的视觉变压器上实现可比准确性降级(〜1%)的最初。代码可在https://github.com/linyang-zhh/fq-vit使用。
translated by 谷歌翻译
量化是压缩神经网络最有效的方法之一,这在卷积神经网络(CNNS)上取得了巨大的成功。最近,视觉变压器在计算机视觉中表现出很大的潜力。然而,先前的训练后量化方法在视觉变压器上不良好地执行,即使在8位量化中也导致高精度下降超过1%。因此,我们分析视觉变压器的量化问题。我们观察Softmax和Gelu功能与高斯分布完全不同的激活值的分布。我们还观察到,诸如MSE和余弦距离之类的常见量化度量是不准确的以确定最佳缩放因子。在本文中,我们提出了双均匀的量化方法来减少这些激活值上的量化误差。我们建议使用Hessian的指导指标来评估不同的缩放因子,这提高了校准的准确性,成本小。为了实现Vision变形金刚的快速量化,我们开发了一个有效的框架PTQ4VIT。实验表明,量化的视觉变压器在想象集分类任务上实现了近无损预测准确度(在8位量化的8%量值下降0.5%)。
translated by 谷歌翻译
在设计高性能变压器方面有兴趣爆发。虽然变形金刚提供了显着的性能改进,但由于存储在背部经历期间梯度计算所需的所有中间激活,尤其是长序列,虽然变形金刚提供了显着的性能改进,但培训这种网络非常内存。为此,我们展示了MESA,一个用于变压器的节省记忆资源有效的训练框架。具体而言,MESA在转发过程中使用精确的激活,同时存储低精度版本的激活,以减少训练期间的内存消耗。然后在返回传播期间对低精度激活进行拆分以计算梯度。此外,为了解决多头自我注意层中的异构激活分布,我们提出了一种头脑激活量化策略,其基于每个头的统计量来量化激活,以最小化近似误差。为了进一步提高训练效率,我们通过运行估计来学习量化参数。更重要的是,通过在采用更大的批量大小或缩放模型尺寸时重新投资所保存的内存,我们可以进一步提高受约束的计算资源下的性能。关于Imagenet的广泛实验,CiFar-100和ADE20K表明,MESA可以在训练期间减少一半的内存足迹,同时实现可比或更好的性能。代码在https://github.com/zhuang-group/mesa获得
translated by 谷歌翻译
在本文中,我们提出了一种称为Q-Vit的视觉变压器(VIT)的完全可区分的量化方法,其中两个量化标度和位宽度都是可学习的参数。具体而言,根据我们的观察,即VIT显示出不同的量化鲁棒性,我们利用头部宽度的位宽度来挤压Q-Vit的大小,同时保持性能。此外,我们提出了一种名为“可切换量表”的新技术,以解决量级和位宽度的联合训练中的收敛问题。这样,Q-Vit将VIT量化的限制推向了3位,而不会降低性能。此外,我们分析了VIT的每个体系结构成分的量化鲁棒性,并表明多头自我注意力(MSA)和高斯误差线性单元(GELU)是VIT量化的关键方面。这项研究提供了一些有关VIT量化的进一步研究的见解。在不同的VIT模型(例如DEIT和SWIN Transformer)上进行的广泛实验显示了我们量化方法的有效性。特别是,我们的方法优于最先进的统一量化方法,而Deit微型的量化方法则优于1.5%。
translated by 谷歌翻译
Post-training quantization (PTQ), which only requires a tiny dataset for calibration without end-to-end retraining, is a light and practical model compression technique. Recently, several PTQ schemes for vision transformers (ViTs) have been presented; unfortunately, they typically suffer from non-trivial accuracy degradation, especially in low-bit cases. In this paper, we propose RepQ-ViT, a novel PTQ framework for ViTs based on quantization scale reparameterization, to address the above issues. RepQ-ViT decouples the quantization and inference processes, where the former employs complex quantizers and the latter employs scale-reparameterized simplified quantizers. This ensures both accurate quantization and efficient inference, which distinguishes it from existing approaches that sacrifice quantization performance to meet the target hardware. More specifically, we focus on two components with extreme distributions: post-LayerNorm activations with severe inter-channel variation and post-Softmax activations with power-law features, and initially apply channel-wise quantization and log$\sqrt{2}$ quantization, respectively. Then, we reparameterize the scales to hardware-friendly layer-wise quantization and log2 quantization for inference, with only slight accuracy or computational costs. Extensive experiments are conducted on multiple vision tasks with different model variants, proving that RepQ-ViT, without hyperparameters and expensive reconstruction procedures, can outperform existing strong baselines and encouragingly improve the accuracy of 4-bit PTQ of ViTs to a usable level.
translated by 谷歌翻译
由于神经网络变得更加强大,因此在现实世界中部署它们的愿望是一个上升的愿望;然而,神经网络的功率和准确性主要是由于它们的深度和复杂性,使得它们难以部署,尤其是在资源受限的设备中。最近出现了神经网络量化,以满足这种需求通过降低网络的精度来降低神经网络的大小和复杂性。具有较小和更简单的网络,可以在目标硬件的约束中运行神经网络。本文调查了在过去十年中开发的许多神经网络量化技术。基于该调查和神经网络量化技术的比较,我们提出了该地区的未来研究方向。
translated by 谷歌翻译
模型量化已成为加速深度学习推理的不可或缺的技术。虽然研究人员继续推动量化算法的前沿,但是现有量化工作通常是不可否认的和不可推销的。这是因为研究人员不选择一致的训练管道并忽略硬件部署的要求。在这项工作中,我们提出了模型量化基准(MQBench),首次尝试评估,分析和基准模型量化算法的再现性和部署性。我们为实际部署选择多个不同的平台,包括CPU,GPU,ASIC,DSP,并在统一培训管道下评估广泛的最新量化算法。 MQBENCK就像一个连接算法和硬件的桥梁。我们进行全面的分析,并找到相当大的直观或反向直观的见解。通过对齐训练设置,我们发现现有的算法在传统的学术轨道上具有大致相同的性能。虽然用于硬件可部署量化,但有一个巨大的精度差距,仍然不稳定。令人惊讶的是,没有现有的算法在MQBench中赢得每一项挑战,我们希望这项工作能够激发未来的研究方向。
translated by 谷歌翻译
视觉变压器(VIT)正在出现,并且在计算机视觉任务中的准确性显着提高。但是,它们的复杂架构和巨大的计算/存储需求对新硬件加速器设计方法施加了紧迫的需求。这项工作提出了基于提议的混合速度量化的FPGA感知自动VIT加速框架。据我们所知,这是探索模型量化的第一个基于FPGA的VIT加速框架。与最先进的VIT量化工作(仅无硬件加速的算法方法)相比,我们的量化在相同的位宽度下可实现0.47%至1.36%的TOP-1精度。与32位浮点基线FPGA加速器相比,我们的加速器在框架速率上的提高约为5.6倍(即56.8 fps vs. 10.0 fps),对于DeitBase的ImagEnet数据集,精度下降了0.71%。
translated by 谷歌翻译
深神经网络(DNN)的庞大计算和记忆成本通常排除了它们在资源约束设备中的使用。将参数和操作量化为较低的位精确,为神经网络推断提供了可观的记忆和能量节省,从而促进了在边缘计算平台上使用DNN。量化DNN的最新努力采用了一系列技术,包括渐进式量化,步进尺寸的适应性和梯度缩放。本文提出了一种针对边缘计算的混合精度卷积神经网络(CNN)的新量化方法。我们的方法在模型准确性和内存足迹上建立了一个新的Pareto前沿,展示了一系列量化模型,可提供低于4.3 MB的权重(WGTS。)和激活(ACTS。)。我们的主要贡献是:(i)用张量学的学习精度,(ii)WGTS的靶向梯度修饰,(i)硬件感知的异质可区分量化。和行为。为了减轻量化错误,以及(iii)多相学习时间表,以解决从更新到学习的量化器和模型参数引起的学习不稳定性。我们证明了我们的技术在Imagenet数据集上的有效性,包括高效网络lite0(例如,WGTS。的4.14MB和ACTS。以67.66%的精度)和MobilenEtV2(例如3.51MB WGTS。 % 准确性)。
translated by 谷歌翻译
卷积神经网络(CNN)是用于计算机视觉的主要的深神经网络(DNN)架构。最近,变压器和多层的Perceptron(MLP)的基础型号,如视觉变压器和MLP-MILER,开始引领新的趋势,因为它们在想象成分类任务中显示出了有希望的结果。在本文中,我们对这些DNN结构进行了实证研究,并试图了解他们各自的利弊。为了确保公平的比较,我们首先开发一个名为SPACH的统一框架,可以采用单独的空间和通道处理模块。我们在SPACH框架下的实验表明,所有结构都可以以适度的规模实现竞争性能。但是,当网络大小缩放时,它们展示了独特的行为。根据我们的调查结果,我们建议使用卷积和变压器模块的混合模型。由此产生的Hybrid-MS-S +模型实现了83.9%的前1个精度,63米参数和12.3g拖薄。它已与具有复杂设计的SOTA模型相提并论。代码和模型在https://github.com/microsoft/spach上公开使用。
translated by 谷歌翻译
Large language models (LLMs) show excellent performance but are compute- and memory-intensive. Quantization can reduce memory and accelerate inference. However, for LLMs beyond 100 billion parameters, existing methods cannot maintain accuracy or do not run efficiently on hardware. We propose SmoothQuant, a training-free, accuracy-preserving, and general-purpose post-training quantization (PTQ) solution to enable 8-bit weight, 8-bit activation (W8A8) quantization for LLMs that can be implemented efficiently. We observe that systematic outliers appear at fixed activation channels. Based on the fact that weights are easy to quantize while activations are not, SmoothQuant smooths the activation outliers by offline migrating the quantization difficulty from activations to weights with a mathematically equivalent transformation. SmoothQuant enables an INT8 quantization of both weights and activations for all the GEMMs in LLMs, including OPT-175B, BLOOM-176B, and GLM-130B. SmoothQuant has better hardware efficiency than existing techniques using mixed-precision activation quantization or weight-only quantization. We demonstrate up to 1.56x speedup and 2x memory reduction for LLMs with negligible loss in accuracy. Thanks to the hardware-friendly design, we integrate SmoothQuant into FasterTransformer, a state-of-the-art LLM serving framework, and achieve faster inference speed with half the number of GPUs compared to FP16. Our work offers a turn-key solution that reduces hardware costs and democratizes LLMs. Code is available at: https://github.com/mit-han-lab/smoothquant.
translated by 谷歌翻译
The rising popularity of intelligent mobile devices and the daunting computational cost of deep learning-based models call for efficient and accurate on-device inference schemes. We propose a quantization scheme that allows inference to be carried out using integer-only arithmetic, which can be implemented more efficiently than floating point inference on commonly available integer-only hardware. We also co-design a training procedure to preserve end-to-end model accuracy post quantization. As a result, the proposed quantization scheme improves the tradeoff between accuracy and on-device latency. The improvements are significant even on MobileNets, a model family known for run-time efficiency, and are demonstrated in ImageNet classification and COCO detection on popular CPUs.
translated by 谷歌翻译
量化图像超分辨率的深卷积神经网络大大降低了它们的计算成本。然而,现有的作品既不患有4个或低位宽度的超低精度的严重性能下降,或者需要沉重的微调过程以恢复性能。据我们所知,这种对低精度的漏洞依赖于特征映射值的两个统计观察。首先,特征贴图值的分布每个通道和每个输入图像都变化显着变化。其次,特征映射具有可以主导量化错误的异常值。基于这些观察,我们提出了一种新颖的分布感知量化方案(DAQ),其促进了超低精度的准确训练量化。 DAQ的简单功能确定了具有低计算负担的特征图和权重的动态范围。此外,我们的方法通过计算每个通道的相对灵敏度来实现混合精度量化,而无需涉及任何培训过程。尽管如此,量化感知培训也适用于辅助性能增益。我们的新方法优于最近的培训甚至基于培训的量化方法,以超低精度为最先进的图像超分辨率网络。
translated by 谷歌翻译
与变压器架构相关的自我监督学习的最新进展使自然语言处理(NLP)表现出极低的困惑。如此强大的模型需要越来越多的模型大小,因此需要大量的计算和内存足迹。在本文中,我们为大规模生成语言模型提出了一个有效的推理框架。作为减少模型大小的关键,我们通过不均匀的量化方法量化权重。然后,我们提出的称为NUQMM的量化矩阵乘法加速了,该内核可以在压缩比和准确性之间进行广泛的权衡。我们提出的NUQMM不仅减少了每个GPU的延迟,还减少了大LMS的全部推断,因为高压缩比(通过低位量化)减轻了最小所需的GPU数量。我们证明NUQMM可以将GPT-3(175b)模型的推理速度加速约14.4倍,并将能源消耗降低93%。
translated by 谷歌翻译
现有的二进制神经网络(BNN)主要在具有二进制功能的局部卷积上运作。但是,这种简单的位操作缺乏建模上下文依赖性的能力,这对于学习视觉模型中的歧视性深度表示至关重要。在这项工作中,我们通过介绍二进制神经模块的新设计来解决这个问题,这使BNN能够学习有效的上下文依赖性。首先,我们建议二进制多层感知器(MLP)块作为二进制卷积块的替代方案,以直接建模上下文依赖性。短距离和远程特征依赖性均由二进制MLP建模,其中前者提供局部电感偏置,后者在二元卷积中有限的接受场有限。其次,为了提高具有上下文依赖性的二进制模型的鲁棒性,我们计算上下文动态嵌入,以确定一般二进制卷积块中的二进化阈值。用我们的二进制MLP块和改进的二进制卷积,我们用明确的上下文依赖性建模构建了BNN,称为BCDNET。在标准Imagenet-1K分类基准上,BCDNET可实现72.3%的TOP-1准确性,并且优于领先的二进制方法的差距很大。尤其是,提出的BCDNET超过了最新的ReactNet-A,具有相似操作的2.9%TOP-1准确性。我们的代码可从https://github.com/sense-gvt/bcdn获得
translated by 谷歌翻译
This paper studies the problem of designing compact binary architectures for vision multi-layer perceptrons (MLPs). We provide extensive analysis on the difficulty of binarizing vision MLPs and find that previous binarization methods perform poorly due to limited capacity of binary MLPs. In contrast with the traditional CNNs that utilizing convolutional operations with large kernel size, fully-connected (FC) layers in MLPs can be treated as convolutional layers with kernel size $1\times1$. Thus, the representation ability of the FC layers will be limited when being binarized, and places restrictions on the capability of spatial mixing and channel mixing on the intermediate features. To this end, we propose to improve the performance of binary MLP (BiMLP) model by enriching the representation ability of binary FC layers. We design a novel binary block that contains multiple branches to merge a series of outputs from the same stage, and also a universal shortcut connection that encourages the information flow from the previous stage. The downsampling layers are also carefully designed to reduce the computational complexity while maintaining the classification performance. Experimental results on benchmark dataset ImageNet-1k demonstrate the effectiveness of the proposed BiMLP models, which achieve state-of-the-art accuracy compared to prior binary CNNs. The MindSpore code is available at \url{https://gitee.com/mindspore/models/tree/master/research/cv/BiMLP}.
translated by 谷歌翻译
Top-1 ImageNet优化促进了可能在推理设置中不切实际的网络。二元神经网络(BNN)具有显着降低计算强度,但现有模型的质量低。为了克服这种缺陷,我们提出了PokeConv,一个二进制卷积块,这是通过添加多个剩余路径的技术提高BNN的质量,并调整激活函数。我们将其应用于Reset-50并优化Reset的初始卷积层,这很难二向化。我们命名由此产生的网络系列POKBNN。选择这些技术以产生最高1精度和网络成本的良好改进。为了使成本的联合优化以及准确性,我们定义算术计算工作(ACE),用于量化和二值化网络的硬件和能量启发成本度量。我们还确定需要优化控制二值化梯度近似的探索过的超参数。我们在高精度上建立了一种新的,强大的最先进(SOTA),以及常用的CPU64成本,ACE成本和网络大小指标。 ReactNET-ADAM是BNN中的先前SOTA,实现了7.9 ACE的70.5%的前1个精度。一小块的炭达到70.5%的前1个,成本降低超过3倍;一个较大的POKBNN以7.8 ACE获得75.6%的顶级1,在不增加成本的情况下,准确性提高超过5%以上。 JAX /亚麻和再现说明中的POKEBNN实现是开放的。
translated by 谷歌翻译
Convolutional Neural Networks (CNNs) are the go-to model for computer vision. Recently, attention-based networks, such as the Vision Transformer, have also become popular. In this paper we show that while convolutions and attention are both sufficient for good performance, neither of them are necessary. We present MLP-Mixer, an architecture based exclusively on multi-layer perceptrons (MLPs). MLP-Mixer contains two types of layers: one with MLPs applied independently to image patches (i.e. "mixing" the per-location features), and one with MLPs applied across patches (i.e. "mixing" spatial information). When trained on large datasets, or with modern regularization schemes, MLP-Mixer attains competitive scores on image classification benchmarks, with pre-training and inference cost comparable to state-of-the-art models. We hope that these results spark further research beyond the realms of well established CNNs and Transformers. 1
translated by 谷歌翻译
The complicated architecture and high training cost of vision transformers urge the exploration of post-training quantization. However, the heavy-tailed distribution of vision transformer activations hinders the effectiveness of previous post-training quantization methods, even with advanced quantizer designs. Instead of tuning the quantizer to better fit the complicated activation distribution, this paper proposes NoisyQuant, a quantizer-agnostic enhancement for the post-training activation quantization performance of vision transformers. We make a surprising theoretical discovery that for a given quantizer, adding a fixed Uniform noisy bias to the values being quantized can significantly reduce the quantization error under provable conditions. Building on the theoretical insight, NoisyQuant achieves the first success on actively altering the heavy-tailed activation distribution with additive noisy bias to fit a given quantizer. Extensive experiments show NoisyQuant largely improves the post-training quantization performance of vision transformer with minimal computation overhead. For instance, on linear uniform 6-bit activation quantization, NoisyQuant improves SOTA top-1 accuracy on ImageNet by up to 1.7%, 1.1% and 0.5% for ViT, DeiT, and Swin Transformer respectively, achieving on-par or even higher performance than previous nonlinear, mixed-precision quantization.
translated by 谷歌翻译