Mixtral offloading:10GB显存跑mixtral moe模型

火山方舟向量数据库大模型

        
          
https://github.com/dvmazur/mixtral-offloading  
https://arxiv.org/abs/2312.17238  
https://colab.research.google.com/github/dvmazur/mixtral-offloading/blob/master/notebooks/demo.ipynb  

      

picture.image

随着大型语言模型(LLMs)的广泛采用,许多深度学习从业者正在寻找更高效地运行这些模型的策略。其中一种策略是使用稀疏的专家混合模型(MoE)-这是一种模型架构类型,其中对于任何给定的输入,只有部分模型层是活跃的。这种特性使得基于MoE的语言模型比其密集对应物更快地生成标记,但也由于拥有多个专家而增加了模型大小。不幸的是,这使得最先进的MoE语言模型难以在没有高端GPU的情况下运行。

在这项工作中,我们研究了在具有有限显存上运行大型MoE语言模型的问题。我们基于参数卸载算法,并提出了一种利用MoE LLM固有属性加速卸载的新策略。使用这种策略,我们可以在桌面硬件和免费的Google Colab实例上运行具有混合量化的Mixtral-8x7B。

原理
  • Mixed quantization with HQQ. 我们为注意力层和专家应用单独的量化方案,以将模型适配到结合的GPU和CPU内存中。
  • MoE offloading strategy. 每个层的专家都单独卸载,并且只在需要时重新放回GPU。我们将活跃的专家存储在LRU缓存中,以减少在计算相邻标记的激活时的GPU-RAM通信。
测试步骤
  1. install conda/mamba
  2. conda create --name mixtral python=3.10
  3. conda activate mixtral
  4. conda install jupyterlab
  5. git clone https://github.com/dvmazur/mixtral-offloading
  6. cd mixtral-offloading
  7. mv notebooks/demo.ipynb to demo.ipynb
  8. open jupyter lab
  9. open the demo.ipynb notebook and change the first cell of code to the following:

        
          
 # fix numpy in colab  
 !pip install numpy  
 !pip install ipywidgets  
 import numpy  
 from IPython.display import clear_output  
 !pip install -q -r requirements.txt  

      
  1. in the thrid code cell, you can change the offload value:

        
          
 # 16 GB VRAM  
 # offload\_per\_layer = 4  
 # 12 GB VRAM  
 # offload\_per\_layer = 5  
 # approx. 10 GB VRAM  
 offload_per_layer = 6  

      

You can also run it with 4, so the new Nvidia Driver will simply use RAM in place of VRAM instead of OOM-ing, but it will be slow too.

Then execute the rest of the cells...

0
0
0
0
关于作者
关于作者

文章

0

获赞

0

收藏

0

相关资源
VikingDB:大规模云原生向量数据库的前沿实践与应用
本次演讲将重点介绍 VikingDB 解决各类应用中极限性能、规模、精度问题上的探索实践,并通过落地的案例向听众介绍如何在多模态信息检索、RAG 与知识库等领域进行合理的技术选型和规划。
相关产品
评论
未登录
看完啦,登录分享一下感受吧~
暂无评论