Online Softmax: block calculation can still be unified
The long focus matrix occupies a large amount of intermediate storage.
Learning objectives and first steps2 objectives . 1 first fix
Try to do it after reading
- Explains online Softmax: block calculations can still maintain the same homogenization mechanism and premise
- Positioning the mechanism ' s fault limits with fixed examples
Suggested first
- Stable softmax with splits
Issues and mechanisms
The long focus matrix occupies a large amount of intermediate storage. Online softmax maintains the current maximum score, index and weighting values and allows data blocks to enter with the same result of reunification. It is an important arithmetic basis for understanding the IO perception of attention: the failure to preserve the complete fraction matrix does not mean that attention is turned into a close sample or local window.
Maintains maximum value m, scalded and l and value weights and u when a piece has been processed. When the maximum value of the new block is greater, the old l and u, multiplied by the old exp, are reduced by the maximum value and added to the scaling result of the new block. Final output u divided by l. The old state must be adjusted to the same public scale, otherwise different blocks use different index benchmarks, and the weighting after consolidation is wrong.
A concrete example
Synthesis of two fractions of zero and log II, one and three, respectively. The first one is only the first, m = 0, l = 1, u = 1. The second section converts the maximum value to log II, the old item is downsized to 0.5, the new item contributes one, obtained from l = 1.5, u = 0.5 plus 3 = 3.5, and the output is seven divided by about 2.3333333. The full re-entry weight is one third and two thirds, with the same result for direct weighting.
Borders and checks
The order of floating point execution may result in minor errors, and the mathematical equivalent is not equal to the alignment of each platform. The complete block requires a clear state of affairs, and the final legitimation of the line should still be rejected as a contract. Real efficient attention also involves the calculation of block size, memory layers and reverses, which cannot be repeated as GPU performance.
The same items may be treated in different blocks sizes when the block is checked and the final output shall be consistent within the tolerance; A single block comparison is not sufficient to detect a merger error.
A method of verification
The boundary and input order of blocks should also be changed, with the same legal items being used to compare eventual conclusion. After all fractions are added to the constant, the output shall be maintained within the margin; The output should be also scaled after the value vector is multiplied by a constant. These checks cover index scales and weighting molecules respectively. Where a piece is not legal, it should be maintained in an effective cumulative state without infinity of reduction; Only eventually the whole line is missing to enter the task definition of empty pool processing.
Check understanding
Why do you need to resize old aggregates when the maximum value of the new block becomes larger?
Old quantities are indexed using old maximum values, and new amounts are benchmarked using new maximum values. (b) The difference in the corresponding index is multiplied to the same scale; Otherwise it's a mistake to normalize.
The fragments obtained the same result. Does it indicate that the approximation Attention has been used?
No, it's not. The same precise focus can be calculated mathematically as long as all legal items are retained and correctly concluded; It's almost different in dimension.
Sources and reconciliations
Definitions, methods and interfaces are available.
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.