記憶體內運算感知的模型適配研究
The Study of Computing-In-Memory Aware Model Adaption
摘要
卷積神經網絡(CNN)在深度學習中的表現十分出色,但隨著任務複雜度的增加,
計算需求呈指數級增長,導致存儲與計算單元之間的數據傳輸頻繁。這不僅加劇了馮·
諾依曼瓶頸問題,還導致功耗顯著增加。為了解決這一問題,記憶體內運算(CIM)通
過將存儲和計算功能集成在同一設備中,顯著減少了數據移動的需求。這種架構利用
高度並行的計算,不僅提升了能效,還大大減輕了數據傳輸的負擔。
然而,對於有限的記憶體空間,大型模型會導致頻繁的記憶體讀寫以獲取模型權
重,從而增加暫存記憶體的額外開銷,並在推理過程中形成速度瓶頸,限制了這些模
型在邊緣設備上的應用。為解決此問題,我們提出了兩階段的模型適應過程。第一階
段的目標是去除冗餘權重,並將模型壓縮到能適應有限大小的 CIM 陣列中。通過反覆
的壓縮和擴展,模型逐步調整以適應 CIM 陣列的大小。與直接剪枝相比,這種方法更
為優越,因為在擴展階段可以根據模型中各卷積層的重要性重新分配有限的資源,從
而優化資源利用效率和性能,彌補剪枝帶來的準確度損失。
第二階段的目標是對模型進行量化,通過量化感知訓練使模型適應量化誤差,避免
在實際推理中因量化誤差突然增加而導致準確度大幅下降。在這一過程中,我們為模
型權重引入了自動學習的量化步長,並通過梯度下降減少這些誤差。最後,結合 ADC
感知訓練,模型在訓練過程中模擬 ADC 量化的過程,從而適應並降低 ADC 量化誤差
的影響。
這一兩階段的模型適應過程帶來了顯著的優勢。首先,ADC 感知訓練減少了 ADC
量化誤差的影響,使得可以同時使用更多的 wordlines,同時通過 DAC 使用 4 位並行輸
入,顯著提升了 CIM 的計算速度,實現了相較 E-UPQ 高達 64 倍的並行度提升。其次,
通過直接剪枝低效的權重並保留對準確度有益的權重,達到了高達 90% 的 CIM 陣列利
用率,最大限度地利用了可用資源,減少了頻繁加載權重的需求。最後,在剪枝後通
過擴展進一步調整模型結構,實現了 90% 以上的壓縮率,同時保持了與其他方法相似
的準確度損失,從而使得模型在性能保持相近的情況下,達到了高度壓縮。
計算需求呈指數級增長,導致存儲與計算單元之間的數據傳輸頻繁。這不僅加劇了馮·
諾依曼瓶頸問題,還導致功耗顯著增加。為了解決這一問題,記憶體內運算(CIM)通
過將存儲和計算功能集成在同一設備中,顯著減少了數據移動的需求。這種架構利用
高度並行的計算,不僅提升了能效,還大大減輕了數據傳輸的負擔。
然而,對於有限的記憶體空間,大型模型會導致頻繁的記憶體讀寫以獲取模型權
重,從而增加暫存記憶體的額外開銷,並在推理過程中形成速度瓶頸,限制了這些模
型在邊緣設備上的應用。為解決此問題,我們提出了兩階段的模型適應過程。第一階
段的目標是去除冗餘權重,並將模型壓縮到能適應有限大小的 CIM 陣列中。通過反覆
的壓縮和擴展,模型逐步調整以適應 CIM 陣列的大小。與直接剪枝相比,這種方法更
為優越,因為在擴展階段可以根據模型中各卷積層的重要性重新分配有限的資源,從
而優化資源利用效率和性能,彌補剪枝帶來的準確度損失。
第二階段的目標是對模型進行量化,通過量化感知訓練使模型適應量化誤差,避免
在實際推理中因量化誤差突然增加而導致準確度大幅下降。在這一過程中,我們為模
型權重引入了自動學習的量化步長,並通過梯度下降減少這些誤差。最後,結合 ADC
感知訓練,模型在訓練過程中模擬 ADC 量化的過程,從而適應並降低 ADC 量化誤差
的影響。
這一兩階段的模型適應過程帶來了顯著的優勢。首先,ADC 感知訓練減少了 ADC
量化誤差的影響,使得可以同時使用更多的 wordlines,同時通過 DAC 使用 4 位並行輸
入,顯著提升了 CIM 的計算速度,實現了相較 E-UPQ 高達 64 倍的並行度提升。其次,
通過直接剪枝低效的權重並保留對準確度有益的權重,達到了高達 90% 的 CIM 陣列利
用率,最大限度地利用了可用資源,減少了頻繁加載權重的需求。最後,在剪枝後通
過擴展進一步調整模型結構,實現了 90% 以上的壓縮率,同時保持了與其他方法相似
的準確度損失,從而使得模型在性能保持相近的情況下,達到了高度壓縮。
Convolutional Neural Networks (CNNs) have demonstrated exceptional performance in
deep learning applications. However, as task complexity increases, the computational demands
grow exponentially, leading to frequent data transfers between storage and computational units.
This exacerbates the Von Neumann bottleneck and significantly increases power consumption.
To address this issue, Computing-in-Memory (CIM) integrates storage and computation within
the same device, drastically reducing the need for data movement. This architecture leverages
highly parallel computation, not only enhancing energy efficiency but also significantly reducing
the burden of data transfer.
Nevertheless, in the context of limited memory space, large models can lead to frequent
memory read-write operations to retrieve model weights, which increases the overhead of
temporary memory and creates a bottleneck during inference, restricting the deployment of
these models on edge devices. To solve this problem, we propose a two-stage model adaptation
process. The goal of the first stage is to remove redundant weights and compress the model to
fit within the limited size of the CIM array. Through iterative compression and expansion, the
model is gradually adjusted to fit the CIM array’s size. Compared to direct pruning, this method
is superior because, during the expansion phase, limited resources can be redistributed according
to the importance of each convolutional layer, optimizing resource utilization and performance,
and compensating for the accuracy loss caused by pruning.
The goal of the second stage is to quantize the model, making it resilient to quantization
errors through quantization-aware training, thereby avoiding a significant drop in accuracy
during actual inference due to sudden increases in quantization errors. In this process, we
introduce an automatically learned quantization step size for the model weights and use gradient
descent to minimize these errors. Finally, combined with ADC aware training, the model
simulates the ADC quantization process during training, thus adapting to and reducing the
impact of ADC quantization errors.
This two-stage model adaptation process offers considerable benefits. First, ADC-aware
training mitigates the impact of ADC quantization errors, enabling the simultaneous use of
more wordlines. Additionally, using 4-bit parallel inputs via DAC significantly accelerates
CIM computation, achieving a 64-fold increase in parallelism compared to E-UPQ. Second, by
directly pruning inefficient weights while retaining those that contribute to accuracy, we achieve
up to 90% utilization of the CIM array, optimizing resource use and reducing the frequency
of weight loading. Finally, post-pruning structural adjustments through expansion enable a
compression rate exceeding 90%, with accuracy loss comparable to other methods, allowing
the model to remain highly compressed while preserving similar performance.
deep learning applications. However, as task complexity increases, the computational demands
grow exponentially, leading to frequent data transfers between storage and computational units.
This exacerbates the Von Neumann bottleneck and significantly increases power consumption.
To address this issue, Computing-in-Memory (CIM) integrates storage and computation within
the same device, drastically reducing the need for data movement. This architecture leverages
highly parallel computation, not only enhancing energy efficiency but also significantly reducing
the burden of data transfer.
Nevertheless, in the context of limited memory space, large models can lead to frequent
memory read-write operations to retrieve model weights, which increases the overhead of
temporary memory and creates a bottleneck during inference, restricting the deployment of
these models on edge devices. To solve this problem, we propose a two-stage model adaptation
process. The goal of the first stage is to remove redundant weights and compress the model to
fit within the limited size of the CIM array. Through iterative compression and expansion, the
model is gradually adjusted to fit the CIM array’s size. Compared to direct pruning, this method
is superior because, during the expansion phase, limited resources can be redistributed according
to the importance of each convolutional layer, optimizing resource utilization and performance,
and compensating for the accuracy loss caused by pruning.
The goal of the second stage is to quantize the model, making it resilient to quantization
errors through quantization-aware training, thereby avoiding a significant drop in accuracy
during actual inference due to sudden increases in quantization errors. In this process, we
introduce an automatically learned quantization step size for the model weights and use gradient
descent to minimize these errors. Finally, combined with ADC aware training, the model
simulates the ADC quantization process during training, thus adapting to and reducing the
impact of ADC quantization errors.
This two-stage model adaptation process offers considerable benefits. First, ADC-aware
training mitigates the impact of ADC quantization errors, enabling the simultaneous use of
more wordlines. Additionally, using 4-bit parallel inputs via DAC significantly accelerates
CIM computation, achieving a 64-fold increase in parallelism compared to E-UPQ. Second, by
directly pruning inefficient weights while retaining those that contribute to accuracy, we achieve
up to 90% utilization of the CIM array, optimizing resource use and reducing the frequency
of weight loading. Finally, post-pruning structural adjustments through expansion enable a
compression rate exceeding 90%, with accuracy loss comparable to other methods, allowing
the model to remain highly compressed while preserving similar performance.