Disclosure of Invention
Aiming at the defects and improvement demands of the prior art, the invention provides a memristor-based memory and calculation integrated system and an online deep learning method, and aims to improve the effect of wear balance in the memristor-based memory and calculation integrated system so as to prolong the overall service life of the system.
In order to achieve the above object, according to one aspect of the present invention, there is provided a memristor-based memory integrated system, including a memory module and a controller;
the storage module comprises a plurality of interconnected tiles, wherein each Tile comprises a plurality of interconnected PE, each PE comprises N memristor arrays, the mapping relation from the logic ID to the physical ID of each PE is recorded in a mapping table, N is a positive integer, and N is more than or equal to 1;
The controller is used for executing an inter-array wear balancing strategy based on a mapping table, and comprises the following steps:
Dividing each M times of writing into a wear leveling period, wherein M is a preset positive integer, maintaining metadata TWC and IWC for each PE, respectively recording the total writing times of the PE and the writing times in the current wear leveling period, and executing the following steps in each wear leveling period:
(S1) setting IWC of each PE to 0;
(S2) cumulatively recording the writing times of the memristor array in the PE in the operation stage to the corresponding IWC until the current wear balancing period is finished;
(S3) accumulating IWCs of the PEs to the corresponding TWCs;
(S4) rebuilding the mapping table such that the larger the IWC is, the smaller the TWC corresponding to the physical ID mapped by the corresponding logical ID is;
(S5) exchanging data stored in the PE based on the current mapping table.
Further, n=1.
Further, the IWCs of each PE are stored in registers internal to their memristor array.
Further, the plurality of tiles in the memory module are interconnected by Torus routing.
Further, one or more memristor arrays in the storage module are divided into dedicated metadata storage areas;
The TWC of each PE is stored in the metadata storage area.
According to another aspect of the invention, an online deep learning method based on the memristor-based memory and calculation integrated system is provided, wherein the memristor-based memory and calculation integrated system is used for accelerating online deep learning;
The online deep learning method comprises the following steps:
In the back propagation process, if the contribution rate α k of any kth hidden layer is smaller than a preset threshold epsilon and the number of data instances spaced from the last update of the hidden layer weight W k is smaller than a preset value gamma, the weight W k of the hidden layer is not updated, otherwise, the weight W k of the hidden layer is updated.
Further, the online deep learning method provided by the invention further comprises the step of updating the hidden layer weight and the step (S5) are executed simultaneously.
Further, γ=2.
Further, the memristor-based memory and calculation integrated system further comprises an auxiliary calculation unit, a vector calculation unit and a calculation unit, wherein the auxiliary calculation unit is used for executing vector operation;
and, in the process of back propagation of the online deep learning method, the calculation of the weight gradient is completed by an auxiliary calculation unit.
Further, the memristor-based memory and calculation integrated system further comprises a global cache;
in addition, in the back propagation process of the online deep learning method, intermediate data required by weight gradient calculation are stored in a global cache.
In general, through the above technical solutions conceived by the present invention, the following beneficial effects can be obtained:
(1) The memristor-based storage and calculation integrated system adopts an inter-array wear balancing strategy based on a mapping table, wherein the strategy maintains metadata TWC and IWC for each PE, the TWC is used for recording total write-in times of PE and reflecting total wear degree of the array in the whole life cycle, the IWC is used for recording write-in times of the current wear balancing cycle and reflecting short-term write-in heat of the array, and the mapping table is rebuilt when each wear balancing cycle is finished, so that the bigger the IWC is, the smaller the TWC corresponding to the physical ID mapped by the corresponding logic ID is, the thermal logic array is remapped to the physical array with less wear, the wear balancing among the arrays is realized, and compared with the existing wear balancing method in the arrays, the wear balancing effect can be improved, and finally the whole service life of the system is improved.
The inter-array wear balance strategy based on the mapping table is orthogonal to the existing intra-array wear balance strategy, can be used in combination with the existing intra-array wear balance strategy, realizes intra-array wear balance on the basis of realizing inter-array wear balance, and further improves the wear balance effect.
In addition, the inter-array wear balancing strategy based on the mapping table may enable the physical arrays belonging to the same logic matrix to be distributed in a plurality of tiles after the mapping table is reconstructed, so that the calculation tasks are distributed in the plurality of tiles, and bandwidth contention in the tiles is relieved.
(2) According to the memristor-based storage and calculation integrated system, in the preferred scheme, each PE only comprises a single memristor array, namely PE layers in the original three-level (Tile/PE/Crossbar) architecture are removed, the system architecture is simplified from the three-level (Tile/PE/Crossbar) architecture to the two-level (Tile/Crossbar) architecture, so that unnecessary communication expenditure can be reduced, the calculation speed is increased, and the overall performance of the system is further improved.
(3) In the invention, the IWC is temporary metadata and is frequently updated, and in the preferred scheme of the invention, the IWC is stored in a register inside the memristor array under a two-level hierarchical architecture, so that frequent writing to the memristor array due to IWC updating is avoided.
(4) In the preferred scheme of the invention, under the two-level hierarchical architecture, a plurality of tiles in the storage module are interconnected through the Torus route, so that the communication overhead can be further reduced.
(5) In the invention, TWC is important metadata which records the total number of unit writing in the life cycle of the memristor array, and in the preferred scheme of the invention, the metadata TWC of each PE is intensively stored in the special memristor array, thereby realizing nonvolatile storage of the metadata TWC and ensuring the storage safety of the metadata TWC.
(6) According to the online deep learning method provided by the invention, the memristor-based memory calculation integrated system is utilized to realize a deep learning network, only the hidden layer weight with higher contribution rate is updated in the back propagation process, the weight of a non-key hidden layer is not updated, the hidden layer weight is forcedly updated by gamma data examples, and the number of times of updating the hidden layer weight is effectively reduced under the condition of ensuring the deep learning effect, so that the writing of an array in the memory calculation integrated system is reduced, the energy consumption expense is reduced, and the service life of the system is prolonged.
(7) In the online deep learning method provided by the invention, in the preferred scheme, the hidden layer weight is updated while the data exchange operation in the inter-array wear balance strategy based on the mapping table is executed, and the additional writing introduced by the data exchange is reduced by overlapping the data exchange and the weight update because the data exchange is hidden in the weight update.
(8) According to the online deep learning method, in the preferred scheme, the number of data instances spaced by forced weight updating is set to be gamma=2, so that the maximum balance between the deep learning effect and the memristor array service life improving effect can be achieved.
(9) The data on which the online deep learning depends are large-scale streaming data, in the back propagation process, matrix operation of gradient calculation is degraded into vector operation, and in the preferred scheme of the invention, calculation of weight gradient is transferred from the memristor array to an auxiliary calculation unit, so that writing of the memristor array can be reduced, energy expenditure is reduced, service life is prolonged, and meanwhile, space waste is avoided.
(10) In deep learning, intermediate data is needed for calculation of weight gradients as input, and in online deep learning, the intermediate data storage requirement is smaller, and in the preferred scheme of the invention, the storage position of the intermediate data needed for calculation of weight gradients is transferred from the memristor array to the global cache, so that space waste can be avoided.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. In addition, the technical features of the embodiments of the present invention described below may be combined with each other as long as they do not collide with each other.
In the present invention, the terms "first," "second," and the like in the description and in the drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order.
In order to solve the technical problem that an existing in-array wear balancing method is poor in effect of improving the overall service life of a system in a memristor-based memory-calculation integrated system, the invention provides the memristor-based memory-calculation integrated system, and the overall thought of the memristor-based memory-calculation integrated system is that a wear balancing algorithm is improved, and a 'hot' logic array is periodically remapped to a physical array with less wear so as to realize wear balancing among the arrays, so that the overall service life of the system is finally improved. On the basis, the online deep learning method is provided, and the whole thought is that writing of the memristor array is reduced on the basis of not affecting the online deep learning effect, so that the defects of low service life of the system caused by frequent weight updating and writing and unbalanced writing in a memory and calculation integrated system based on the memristor in the online deep learning are overcome.
The following are examples.
Example 1:
A memristor-based memory and calculation integrated system is shown in fig. 3, and comprises a memory module and a controller.
The storage module comprises a plurality of interconnected tiles, each Tile comprises a plurality of interconnected PE, each PE comprises N memristor arrays, the mapping relation from the logic ID of each PE to the physical ID is recorded in a mapping table, the logic ID is a virtual reference distributed to an upper application by a system and is used for accessing the physical array, and the physical ID uniquely represents the PE in the storage and calculation integrated system.
As shown in fig. 3, in this embodiment, each PE contains only a single memristor array, i.e., n=1. Therefore, the memristor-based memory and calculation integrated system provided by the embodiment is equivalent to removing the PE level in the original three-level (Tile/PE/Crossbar) architecture, simplifying the system architecture from the traditional three-level (Tile/PE/Crossbar) architecture to the two-level (Tile/Crossbar) architecture, thereby reducing unnecessary communication overhead and accelerating the calculation speed. In this embodiment, a plurality of tiles are interconnected by Torus routing, and it should be noted that, here, the interconnection method of the tiles is only a preferred embodiment, and is not to be construed as a unique limitation of the present invention, and other interconnection methods, such as Mesh, may be used in the present invention.
As shown in FIG. 3, in this embodiment, each Tile is composed of a plurality of memristor arrays and Tile-level input/output buffers, and is interconnected by an H-Tree.
As shown in FIG. 3, the memristor cells in each memristor array are connected by a Crossbar, i.e., a cross-point array, and optionally, in this embodiment, in order to mitigate the effects of write disturbance and sneak current, the memristor cells in the memristor array are 1T1R cells.
In this embodiment, the controller is configured to execute a mapping table-based inter-array wear-leveling (TIWL) strategy, where the strategy includes:
dividing each M times of writing into a wear balancing period, wherein M is a preset positive integer and can be correspondingly determined according to actual requirements, maintaining metadata TWC and IWC for each PE, and respectively recording the total writing times of the PE and the writing times in the current wear balancing period;
as shown in fig. 4 and 5, TIWL performs the following steps at each wear leveling cycle:
(S1) setting IWC of each PE to 0;
(S2) cumulatively recording the writing times of the memristor array in the PE in the operation stage to the corresponding IWC until the current wear balancing period is finished;
(S3) accumulating IWCs of the PEs to the corresponding TWCs;
(S4) rebuilding the mapping table such that the larger the IWC is, the smaller the TWC corresponding to the physical ID mapped by the corresponding logical ID is;
likewise, each PE contains only 1 memristor array, and the logical ID and physical ID of the PE are the logical ID and physical ID of the memristor array, respectively;
The IWC reflects short-term writing heat of the memristor array, the TWC reflects total abrasion degree in the life cycle of the memristor array, and the embodiment realizes abrasion balance of a system level, namely abrasion balance among arrays by re-mapping the hot logic array to a physical array with less abrasion through rebuilding a mapping table, and compared with the existing abrasion balance in the array, the abrasion balance effect is better, and the service life of the whole system can be effectively prolonged;
(S5) exchanging data stored in the PE based on the current mapping table;
In the process of reconstructing the mapping table, the mapping relationship between the logical ID and the physical ID may change, and for the physical ID whose mapping relationship has changed, data stored in the corresponding memristor array needs to be exchanged to ensure the correctness of the mapping relationship.
The IWC is temporary metadata and frequently updated, in order to avoid introducing frequent writing to the memristor array due to IWC updating, as a preferred implementation, the present embodiment records the IWC into a register inside each memristor array, i.e. "wear counter" in fig. 3; TWCs are important metadata, recording the total number of cell writes in the memristor array lifecycle, requiring nonvolatile storage media for storage, in order to ensure the storage security of the TWC, in this embodiment, one or more memristor arrays in the storage module are divided into dedicated metadata storage areas;
The TWC of each PE is stored in the metadata storage area.
In contrast to the in-array wear leveling method TIWL, there is no need to record the aging state of each word line or bit line, nor to acquire the temperature of the cell. Thus, storage and computation overhead is reduced. The relevant overhead is briefly analyzed as follows:
Assuming that the IWC and TWC are respectively 32-bit and 64-bit, a memristor-based memory integrated system with the capacity of 4GB is constructed by using an array with the size of 128 multiplied by 128, the abrasion metadata occupies 24MB (accounting for 0.59 percent of 4 GB), the mapping table occupies 16MB (accounting for 0.15 percent of 4 GB), the memory overhead is in an acceptable range, when the array size is increased to 512 multiplied by 512, the memory overhead of the abrasion metadata and the mapping table is respectively reduced to 1.14MB (accounting for 0.03 percent of 4 GB) and 1.5MB (accounting for 0.04 percent of 4 GB), and the metadata of the array is fixed to 96-bit which is far smaller than the existing in-array abrasion balance strategy, namely, the row switching strategy (N multiplied by T, wherein N represents the row number and T is the bit width of a register).
In general, the memristor-based memory and calculation integrated system provided by the embodiment adopts the mapping table-based inter-array wear balancing strategy (TIWL) which can remap the hot logic array to the physical array with less wear, so that the wear balancing among the arrays is realized, and compared with the existing intra-array wear balancing method, the wear balancing effect can be improved, and finally the overall service life of the system is prolonged. In addition, the inter-array wear balance strategy of the mapping table provided by the embodiment is orthogonal to the existing intra-array wear balance strategy, can be used in combination with the existing intra-array wear balance strategy, realizes intra-array wear balance on the basis of realizing inter-array wear balance, further improves the wear balance effect, and can enable physical arrays belonging to one logic matrix to be distributed in a plurality of tiles after the mapping table is reconstructed based on the inter-array wear balance strategy of the mapping table, so that calculation tasks are dispersed in the plurality of tiles, and bandwidth contention in the tiles is relieved.
It should be noted that, according to the inter-array wear balancing strategy (TIWL) based on the mapping table provided in this embodiment, while the wear balancing effect is improved, since the calculation tasks are dispersed into multiple tiles, additional communication overhead is introduced, but the communication overhead is within an acceptable range. In addition, the communication overhead caused by TIWL can be effectively relieved by optimizing the system architecture and the Tile interconnection mode. In general, the present embodiments can obtain greater benefits with a small amount of overhead for improving the overall lifetime of memristor-based computational integration systems.
It will be readily appreciated that the above two-level (Tile/Crossbar) hierarchy architecture is merely a preferred embodiment of the present invention and should not be construed as the only limitation of the present invention. TIWL can obtain a friendly balance between mapping overhead and mapping income by adjusting scheduling granularity (namely PE size), when the number of memristor arrays contained in the PE is greater than 1, the implementation of TIWL in the integrated architecture is similar to the process, and the difference is that after the mapping relation between the logic ID and the physical ID of the PE is determined by the reconstruction mapping table, the remapping of the logic ID to the physical ID of the memristor arrays is completed according to the sequence of the memristor arrays in the PE, and in addition, metadata IWC of the PE is shared by a plurality of memristor arrays therein and is required to be stored in a register corresponding to the PE.
It is also easy to understand that in this embodiment, the implementation of TIWL does not depend on the specific structure inside the Tile, and when the internal structure of the Tile changes, for example, when the memristor unit changes, the overall life of the memristor-based integrated storage and calculation system provided by the present invention can still be effectively improved.
Example 2:
the online deep learning method based on the memristor-based memory integrated system provided in the embodiment 1, wherein the memristor-based memory integrated system is used for accelerating online deep learning.
Before explaining the technical scheme of the embodiment in detail, the following brief description is made on the existing online deep learning method:
The online deep learning can learn streaming data, keep model continuous training evolution, and can learn in streaming data scenes better than offline batch training. Fig. 6 shows a schematic diagram of a classical HBP online deep learning network structure, wherein (a) is a forward propagation process and (b) is a backward propagation process. The online deep learning network structure consists of two parts, namely a hidden layer h, wherein the hidden layer is propagated layer by layer from the first layer as in the traditional offline learning deep neural network, and the other part is an output layer o, and each output layer is connected with a Softmax classifier and is used for evaluating the learning condition of the current hidden layer. In the figure, alpha n represents the contribution weight ratio of the nth layer in all hidden layers, o k represents the Softmax output of the output layer of the kth layer classifier, and h k represents the output of the kth layer after the activation of the hidden layer.
Assuming that the number of hidden layers of a deep neural network is N, the final output of the online deep learning HBP model can be expressed by the following formula:
Wherein the method comprises the steps of
h0=x
The HBP model requires 3 parameters to learn, Θ k,Wk and α k respectively.
Where Θ k represents the parameter weight of the k-th output layer, W k represents the parameter weight of the k-th hidden layer, α k controls the contribution weight duty ratio of each layer to the output, and the classifier output of each layer obtains the final output result after weighted summation. The loss function of the model can be defined as: i.e. the classifier loss functions of each layer are weighted summed.
The contribution weight ratio α k for each layer is initialized to be uniformly distributed: In each iteration process, the output of each layer of classifier is o k, the loss function calculation is carried out through the sum of the real results, and the contribution weight ratio alpha k of each layer is updated through the following formula: Wherein t represents iteration round, beta epsilon (0, 1) is attenuation coefficient, and the contribution weight of each layer is attenuated according to the loss function after each iteration with the proportion alpha (l) After updating all contribution weight proportion, it will be standardized to make it conform to
As for the weight Θ k of the output layer, the weight is updated by the online gradient descent method, and the update process of the weight Θ k is as follows, as in the conventional offline learning:
For the update of hidden layer weights W k, unlike the conventional back propagation method, the error bias is back propagated by all output layers (i.e., each classifier o k), so its update process is expressed using the following formula:
Wherein the method comprises the steps of Is obtained by each classifier through error back propagation. It should be noted that the weight update of the k-th hidden layer requires weighted accumulation of the error bias of all the hidden layers behind itObtained.
Since the HBP optimization method reduces the weight ratio α k of the deep network to be very small, in order to limit the influence of the deep network on learning, a smoothing parameter s (s e (0, 1)) is used to control the update of α k, and the deep network is modified after the weight is updated each time: preventing deep networks from being unable to participate in the back propagation process.
On-line deep learning involves a large number of matrix operations, and memristor arrays can accelerate matrix vector multiplication operations, whereas deep learning applications involve a large number of matrix vector multiplication operations, so that acceleration can be performed by using memristor arrays, specifically, network weights W are stored in arrays, the arrays are input as vectors, and the arrays are output as calculation results.
Currently, online deep learning acceleration is still challenged with memristor-based memory and computation integration systems. Firstly, online deep learning is carried out on large-scale streaming data, the number of weight updating times (generally more than million levels) is far greater than that of traditional offline batch training, which can cause frequent writing of a memristor array and is a great challenge for the limited service life of the memristor array, secondly, the writing imbalance of the array during weight updating can lead to rapid reduction of the service life of a system, the short plate effect is prominent, and the problem of writing imbalance is more prominent due to large-scale continuous training in an online deep learning scene.
According to the online deep learning method provided by the embodiment, the memristor-based memory-calculation integrated system provided by the embodiment 1 is utilized to realize a deep learning network, and because the memory-calculation integrated system adopts an inter-array wear balancing strategy based on a mapping table, the influence of weight update of the online deep learning method on the service life of the system can be relieved under the condition that the array writing is unbalanced due to weight update, and the effective realization of the online deep learning method is ensured.
Considering that the contribution rate α of the shallow network gradually decreases and the contribution rate of the deep network gradually increases with the input of training data, the training of the online deep learning network such as HBP starts training from the shallow neurons and then gradually trains the neurons of the deep network. The final network result is obtained by weighted summation of all layers of classifiers according to the contribution rate alpha, and the network layers with low alpha have less influence on the output of the network. Based on the consideration, the embodiment improves the weight updating mode in the back propagation process of the online deep learning method, and proposes a write-optimization weight updating strategy (write-optimized parameter update, WARP) which dynamically controls the weight updating of the hidden layer according to the weight proportion of the network layer, avoids unnecessary weight writing and reduces the array abrasion.
More specifically, if α k of the hidden layer of the k-th layer is smaller than the threshold epsilon (a set constant, preferably 1/N) at each training iteration, then the contribution of that layer to the final output result of the network is also smaller, thus reducing the updating of the hidden layer weight W k. Meanwhile, considering that if the hidden layer weight is not updated continuously, the network convergence is too slow, in order to control the degree of reducing the weight update, the hidden layer weight is forcedly updated every other gamma data examples, and the weight update process can be expressed as follows:
Based on the weight updating mode, the embodiment effectively reduces the number of times of updating the weight of the hidden layer under the condition of ensuring the deep learning effect, thereby reducing the writing of an array in the integrated system, reducing the energy consumption expense and prolonging the service life of the system. As a preferred embodiment, in this embodiment, γ=2, and experiments show that setting the number of data instances spaced by the forced weight update in this way can achieve the greatest balance between the deep learning effect and the memristor array lifetime enhancement effect.
As a preferred implementation manner, the embodiment further comprises that the updating of the hidden layer weight is performed simultaneously with the step (S5), namely, the data exchange operation in TIWL is performed in the memristor-based memory-integrated system, and the embodiment reduces the extra writing introduced by the data exchange by overlapping the data exchange and the weight update because the data exchange is hidden in the weight update, thereby further reducing the energy consumption and improving the service life of the system.
In the online deep learning method, weight gradientRequires intermediate data x as input: the forward phase requires x to be stored. In the existing memristor-based memory calculation integrated system on-line deep learning method, main calculation and storage are completed by a memristor array, and weight gradient is calculated by using the memristor Two problems can exist, namely (1) frequent rewriting of the memristor array can introduce energy expenditure and shorten service life, and matrix operation of gradient calculation is degraded into vector operation in online deep learning based on large-scale streaming data, vector data is stored by directly utilizing the memristor array, and space waste of the memristor array can be caused. (2) Storing striped intermediate data in the memristor array wastes space, exacerbating wear imbalance. The intermediate data store for online deep learning is small compared to offline batch training, e.g., for training a 16-layer network (hidden layer size 100) using HBP, only about 9KB of intermediate data is needed.
Therefore, as shown in fig. 3, in this embodiment, an auxiliary computing unit (Auxiliarycomputeunit, ACU) is further disposed in the memristor-based memory-integrated system to perform vector operations, and in this embodiment, the calculation of the weight gradient is completed by the auxiliary computing unit during the back propagation of the online deep learning method, by transferring the calculation of the weight gradient from the memristor array to the auxiliary computing unit, writing of the memristor array can be reduced, energy overhead can be reduced, lifetime can be prolonged, and space can be avoided, and based on the same consideration, in this embodiment, the auxiliary computing unit is further used to complete processing of array results from different tiles, including ReLU activation, pooling pooling, cumulative summation, and the like, as an alternative implementation.
In addition, in the embodiment, a global cache is further arranged in the memristor-based memory and calculation integrated system, as shown in fig. 3, and in the embodiment, intermediate data required by weight gradient calculation is stored in the global cache, and in the embodiment, space waste can be avoided by transferring the storage position of the intermediate data from the memristor array to the global cache.
In general, the memristor-based memory integrated system provided in the embodiment 1 realizes an online deep learning method, and by further improvement, the defects of low service life of the system caused by frequent weight update and write and unbalanced write in the memristor-based memory integrated architecture of the online deep learning can be overcome.
It will be readily appreciated by those skilled in the art that the foregoing description is merely a preferred embodiment of the invention and is not intended to limit the invention, but any modifications, equivalents, improvements or alternatives falling within the spirit and principles of the invention are intended to be included within the scope of the invention.