SlimGPT: Layer-wise Structured Pruning for Large Language Models

本文是LLM系列文章,针对《SlimGPT: Layer-wise Structured Pruning for Large Language Models》的翻译。

SlimGPT:大型语言模型的分层结构化修剪

摘要

大型语言模型(LLM)因其在各个领域的卓越能力而受到广泛关注,其巨大的参数规模为实际部署带来了挑战。结构化修剪是一种平衡模型性能和效率的有效方法,但在计算资源约束下的性能恢复是修剪LLM的主要挑战。因此,我们提出了一种基于Brain Surgeon框架的低成本、快速的LLM结构化修剪方法SlimGPT。我们提出了批量贪婪修剪,用于快速和接近最优的修剪,通过分组Cholesky分解提高了头部修剪误差估计的准确性,并通过动态组大小提高了FFN的修剪效率,从而在一小时内实现了近似的局部最优修剪结果。此外,我们从误差累积的角度探讨了分层修剪的局限性,并提出了增量修剪率,这是一种非均匀修剪策略,可以减少性能下降。LLaMA基准测试的实验结果表明,SlimGPT优于其他方法,并取得了最先进的结果。

1 引言

2 相关工作

3 前言

4 方法

5 实验

6 结论

在这项工作中,我们介绍了一种基于OBS框架的快速、结构化的修剪方法,用于资源受限场景中的大规模模型,称为SlimGPT。利用新的批处理贪婪修剪,我们提高了修剪误差估计的准确性,从而最大限度地减少了修剪造成的性能下降。此外,我们从误差累积的角度分析了分层修剪的局限性,并提出了一种名为增量修剪率的非均匀策略,有效地提高了修剪模型的性能。开源实验的证据证实了我们方法的有效性。
限制

注意力头剪枝与 GQA:从多头冗余到推理加速 KV cache 是解码阶段的显存与带宽杀手,公式是2LHkvdhsb⋅bytes2LHkv​dh​sb⋅bytes,7B 模型在 4k 上下文、batch 8 下就要 16 GiB。多头确实有冗余,但冗余不是均匀分布的:我的实验里 8 个头能安全删掉 4 个(准确率只掉 3.5 个点,KL 0.0336 → 0.2368),第 5 个就是断崖。按梯度×输出的重要性排序剪枝,比随机剪枝的 KL 好 5~9 倍。GQA 省的是 KV 字节,不是 FLOPs。 阅读详情

相关推荐

「文智助手」全场景办公AI助理AI+OPC全流程实践方案(大赛作品)

「文智助手」全场景办公AI助理AI+OPC全流程实践方案(大赛作品)

jks212454的博客 369

船载 OpenHarmony AIS 航海工作台:告警与防碰撞预警系统

船载OpenHarmony AIS航海工作台的告警与防碰撞系统,集成十余类告警(超速、偏航、会遇、SOS等),通过网格空间索引实现高效邻近判定,保障实时性。告警管理器统一调度规则、去重、通知与日志,支持悬浮球、语音、跑马灯、弹窗多渠道触达,确保航行安全。SOS紧急通道独立运行,避免干扰。系统设计强调性能优化与多场景适配,为航海安全提供核心支撑。

专注于计算机研发知识和资讯分享 303

从零开始搭建多旋翼无人机:飞控系统配置全攻略(含IMU校准技巧)

本文详细介绍了从零开始搭建多旋翼无人机的飞控系统配置全流程,重点解析了IMU校准技巧。涵盖飞控硬件选型、IMU校准(加速度计、陀螺仪、磁力计)、GPS与罗盘集成方案、飞行模式配置策略及实战故障排查手册,帮助DIY爱好者提升无人机飞行稳定性与安全性。

beta5的博客 799

VMware虚拟机安装MS-DOS 7.10教程

dos安装教程dos版本7.10附下载链接。

Minecraft_xiaole的博客 1万+

DTS中video-interfaces接口详解

视频数据管道通常由外部设备组成,例如通过I2C、SPI或UART总线控制的摄像机传感器,以及SoC内部IP块(包括视频DMA引擎和视频数据处理器)。 SoC内部块由DT节点描述,与其他SoC块放置方式类似。外部设备表示为它们各自总线控制器节点的子节点,例如I2C。 所有视频设备上的数据接口都由它们的子“port”节点描述。端口的配置取决于参与数据传输的其他设备,并由“endpoint”子节...

龙图腾的博客 9010

Mac新手必看:nvm安装全攻略(含常见错误解决方案)

本文为Mac开发者提供nvm安装与使用全攻略,涵盖环境准备、安装步骤、Shell配置优化及常见错误解决方案。详细讲解如何利用nvm管理多Node版本,提升开发效率,特别针对国内用户提供网络问题解决技巧,是Mac新手必备的Node版本管理指南。

weixin_28839699的博客 1619

5G NR切换测量事件解析:从A1到B2的实战应用指南

本文深入解析5G NR切换测量事件,从A1到B2的实战应用指南。详细介绍了系统内切换事件(A1-A6)和系统间切换事件(B1-B2)的触发条件与配置建议,帮助优化网络性能。通过实际案例分享,展示如何调整参数提升切换成功率和降低乒乓切换率,适用于5G网络优化工程师。

tcp8optimizer的博客 515

解决nfs挂载根文件系统报错:VFS: Unable to mount root fs via NFS, trying floppy.

解决nfs挂载根文件系统报错的问题:VFS: Unable to mount root fs via NFS, trying floppy.

汉尼拔勇闯天涯 4577

解锁RK1126与SC132GS摄像头适配密码:技术与代码全解析

本文详细介绍了瑞芯微RK1126芯片与SC132GS摄像头的适配方法。首先分析了RK1126的四核Cortex-A7处理器、Mali-T860 GPU等硬件特性,以及SC132GS的130万像素、全局快门等技术参数。重点阐述了基于MIPI CSI接口的硬件连接原理和基于V4L2框架的软件驱动设计,并提供了完整的初始化、数据采集和图像处理代码实现。针对常见连接和图像质量问题给出了解决方案,展现了该组合在智能安防、工业检测等领域的应用潜力,为开发者提供了实用的技术参考。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1506

华为 MetaERP · 本体论驱动的 PTP 全流程智能建模方案

华为MetaERP通过“本体+事件+图谱+Agent”四位一体架构,将传统ERP从“记录系统”升级为“智能执行系统”。基于OWL本体实现业务语义精准表达,融合LLM与元数据多租能力,构建可推理、可治理的PTP全流程智能模型,解决AI理解业务逻辑难题,实现三单匹配自动化、关账效率提升30%、成本降低50%,推动企业数字化迈向可信智能新范式。

金牌架构师 182

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: Improving Multi-Step Reasoning Abilities of Large Language Models with Direct Advantage
下一篇: M-Ped: Multi-Prompt Ensemble Decoding for Large Language Models
UnknownBody
博客等级 码龄16年 5601粉丝 4744原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UnknownBody

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值