A sparse neural network CSR field hierarchical protection method and system
By configuring the CSR field and its start and end endpoints, the consequences of single-bit faults are analyzed, the protection range is determined, and SECDED codewords are used to correct errors. This solves the problem that the impact of field errors in sparse neural network CSR storage is difficult to reflect, and improves the accuracy and stability of inference.
Patent Information
- Application Number
- CN202611461616.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-20
- Publication Date
- 2026-11-17
AI Technical Summary
In the CSR format storage of sparse neural networks, existing technologies have difficulty in effectively distinguishing and handling the impact of errors in different fields on inference execution, resulting in the error impact not being fully reflected in the calculation results.
By configuring the CSR field and its start and end endpoints, the consequences of a single bit failure in the field are analyzed, and the field protection scope and codeword organization are determined. SECDED codewords are used for protection, and errors are corrected during reading to ensure the legality of column indexes and boundaries.
It achieves targeted protection against errors in different fields, reduces error propagation, and improves the inference accuracy and stability of sparse neural networks.
Smart Images

Figure CN123114849A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to neural network storage fault tolerance and sparse computing technology, specifically to a method and system for hierarchical protection of CSR fields in sparse neural networks. Background Technology
[0002] When sparse neural networks store static weights using the Compressed Sparse Row (CSR) format, non-zero weights are stored in `values`, the column indices corresponding to the non-zero weights are stored in `col_indices`, and the start and end boundaries of non-zero entries in each output row are stored in `row_ptr`. Inference execution relies on row boundaries to determine the range of entries, accesses input activations based on column indices, and performs multiplication and addition of weights and activations. Weight quantization reduces the bit width of numerical storage, but column indices and row boundaries still need to represent the corresponding positions and ranges; therefore, metadata is also an important component of CSR storage.
[0003] Storage bit errors can alter the value of non-zero weights, the activation address pointed to by a column index, or the output row assignment of non-zero entries, thus affecting inference results or inference execution. Existing storage protection methods include data redundancy, error-correcting coding, and selective protection that allocates protection scope based on data nature or importance. For example, Single-Error Correction and Double-Error Detection (SECDED) corrects single-bit errors and detects double-bit errors by adding a parity bit; selective protection can configure redundancy for numerical, positional data, or data bits of different importance.
[0004] When only weight values are protected, errors in column indexes and row boundaries can still affect activation addressing and entry attribution. Expanding the protection scope can cover more fields, but it also requires additional verification capacity and corresponding read decoding processing; the specific cost depends on the coverage and codeword organization. For CSR storage, numerical perturbations, address errors, and row attribution changes involve different execution locations. Treating location data as a whole or evaluating the impact of errors solely based on accuracy changes fails to fully reflect the different roles of each field in inference executability and computation results.
[0005] Therefore, in neural networks that use CSR format to store static weights, it is necessary to determine the appropriate protection range based on the impact of errors in different fields on inference execution, while taking into account additional storage capacity and read processing overhead. Summary of the Invention
[0006] This invention provides a method and system for hierarchical protection of CSR fields in sparse neural networks, which solves the problem of lacking separate judgment and corresponding protection configuration for the numerical, address and structural consequences of errors in different fields in static weighted CSR storage, so that the field protection range, codeword organization and read correction position correspond to each other.
[0007] The method includes the following steps.
[0008] Step 1: Configure CSR fields and start / endpoints. Represent the static weights of the target network layer as values, col_indices, and row_ptr, and determine the logical bit width and data type of each field. Values and col_indices are matched one-to-one with non-zero entries. The total number of non-zero weights at the start and end points of row_ptr for each layer is used as a configuration constant. The remaining internal boundaries of values, col_indices, and row_ptr are included in the storage fault analysis object, and their protection scope will be determined in subsequent steps.
[0009] Step 2: Analyze the consequences of a single-bit field failure. After verifying that the fault-free CSR inference matches the reference calculation, determine the failure cases according to network layer, field, element, and logical bit. Save the original value of the target element and flip one of its logical bits. Determine the validity of the column index based on the current layer's input range, and determine the validity of the boundary based on the value range and non-decreasing relationship of the complete row boundary sequence. For out-of-bounds column index records, the address becomes invalid; for illegal boundary records, the structure becomes invalid; for executable cases, complete the CSR inference and calculate the decreased accuracy; restore the original value after each case.
[0010] Step 3: Determine the field protection scope and codeword organization. Based on the field execution function, the fault consequences recorded in Step 2, and the protection objectives, select either the first protection configuration that protects only the internal boundary of row_ptr, the second protection configuration that protects both the internal boundary of row_ptr and col_indices, or the third protection configuration that protects values, col_indices, and the internal boundary of row_ptr respectively, and determine the corresponding encoding unit and decoding branch.
[0011] Step 4: Encode storage during static loading. Based on the selected protection configuration, generate SECDED codewords for protected fields during the model loading or storage write phase, and store the codewords and unprotected field data according to CSR entries and boundary relationships.
[0012] Step 5: Read and decode the codewords. In the steady-state inference reading path, perform syndrome calculation, error location, and data correction on the protected codewords, and send the decoded data to the execution path corresponding to that field; unprotected fields are read according to their data representation.
[0013] Step 6: Perform CSR sparse inference. The range of entries in the current output row is determined using the read internal boundaries and configuration endpoints. Input activations are accessed using the read column indices, and the read weights are multiplied and accumulated item by item with the activations to obtain the inference results for the current row and subsequent network layers. Protected fields undergo decoding correction as described in Step 5 before being used by the corresponding pathways.
[0014] Furthermore, under full-field protection, the values accessed synchronously in the same non-zero entry are combined with col_indices to form a joint data unit and generate a SECDED codeword. The internal boundaries of row_ptr are kept independently encoded, forming a joint codeword configuration. This configuration has the same field coverage as the third protection configuration, but the codeword organization is different.
[0015] Furthermore, the encoding unit is either a field element or a fixed-width storage word. Element-level organization encodes individual field elements, while union codeword configuration encodes the weight and column index of the same non-zero entry. 64-bit storage word-level organization groups the data streams of each field separately and aligns them to the tail, while union codeword configuration first forms a tuple stream of weights and column indices, and then groups them into 64-bit groups.
[0016] Furthermore, decoding branches for different fields are set up in parallel; when decoding 64-bit data using a pipelined approach, new codewords are received cycle by cycle after the pipeline is full. Encoding operations are performed in the model loading or storage write path, while decoding and correction are performed in the inference read path.
[0017] Furthermore, the fault analysis calculates the fault-free accuracy and post-fault accuracy using a fixed evaluation sample, and statistically analyzes the proportion of address or structural failures within the corresponding field based on the total number of cases. When comparing different protection ranges, the number of failures is counted using the same original data bit fault space, and the accuracy decrease is statistically analyzed using the same set of executable cases under the unprotected baseline. For cases where multiple entries point to the same column index, the product of each entry is accumulated separately; for cases where adjacent row boundaries are equal, the corresponding output row is interpreted as a blank row.
[0018] This invention also provides a corresponding CSR field hierarchical protection system, including a CSR configuration module, a fault analysis module, a protection configuration module, an encoding writing module, a CSR storage module, a decoding reading module, and a CSR inference module. The CSR configuration module provides consistent field organization and endpoint configuration for the fault analysis module and the encoding writing module; the fault analysis module generates field consequence records for use by the protection configuration module; the protection configuration module determines encoding coverage and codeword boundaries; the encoding writing module generates codewords according to this configuration and writes them to the CSR storage module; the decoding reading module connects the CSR storage module and the CSR inference module, outputting correction data before the corresponding field enters row boundary control, activation address generation, and multiply-accumulate paths.
[0019] The beneficial effects of this invention are as follows: It distinguishes between address failures and structural failures by using column index ranges and boundary validity; it separately measures accuracy changes for executable failures, enabling the protected target to correspond to specific fields and their usage locations; and it progressively expands field coverage, configuring additional storage and decoding branches to the fields requiring protection. Under the condition of at most one bit error per codeword and no ECC logic fault, the protected internal boundary is restored before row partitioning, the protected column index is restored before active addressing, and the protected weight is restored before multiplication and addition, thereby suppressing the propagation of errors in the corresponding fields. When full field coverage is achieved, independent and combined codewords provide different data organization options; parallel read branch settings and wide codeword pipelined decoding provide corresponding implementation methods for specific storage organization. Attached Figure Description
[0020] Figure 1 A schematic diagram of the module relationships in a sparse neural network CSR field hierarchical protection system.
[0021] Figure 2 A schematic diagram of the overall process for the graded protection method of CSR fields.
[0022] Figure 3 This diagram illustrates the execution path and the consequences of a single bit flip for the three storage fields of the CSR.
[0023] Figure 4 A schematic diagram of the evaluation process for a single-bit failure case in a CSR storage field.
[0024] Figure 5 This is a diagram showing the address failure distribution of single-bit flips in col_indices in LeNet-5.
[0025] Figure 6 This is a structural failure distribution diagram of single-bit flipping of the internal boundary of row_ptr in LeNet-5.
[0026] Figure 7 Additional storage overhead and failure impact diagram for different CSR storage protection configurations. Detailed Implementation
[0027] The present invention will be further described in detail below with reference to the accompanying drawings.
[0028] Example 1
[0029] Reference Figure 1The CSR field-based hierarchical protection system comprises a CSR configuration module, a fault analysis module, a protection configuration module, an encoding and writing module, a CSR storage module, a decoding and reading module, and a CSR inference module. The system sequentially completes three processing stages: pre-deployment analysis, static weight loading, and inference reading. Before deployment, the CSR configuration module determines the field organization and provides it to the fault analysis module. The fault analysis module generates field consequence records, which the protection configuration module uses in conjunction with the protection objectives to determine the protection scope and codeword organization. During static loading, the encoding and writing module receives field data and protection configuration, and writes the codewords and unprotected data into the CSR storage module. During inference reading, the decoding and reading module reads data from the CSR storage module and connects to the CSR inference module, completing corrections before the fields are used by the corresponding paths.
[0030] Pre-deployment analysis is performed by analysis tools executed by the processor, and the read / decode path is implemented using synthesizable logic. Both use the same field definitions, field bit widths, endpoint conventions, and codeword organization to ensure that the analyzed object corresponds to the actual protected data. The protection configuration is determined before model loading; after static loading is completed, steady-state inference performs read, decode, and calculation, without repeating the pre-deployment fault case analysis.
[0031] Each non-zero CSR entry contains a weight and its column index. `row_ptr` divides consecutive entries into output rows. The total number of weights with zero start and non-zero end points is a configuration constant for each layer. `values`, `col_indices`, and the internal boundary of `row_ptr` together constitute the storage fault analysis object. The encoding protection range is determined by the protection configuration module. The CSR storage module stores field data or codewords and their correspondence with network layers, fields, non-zero entries, and internal boundaries. This correspondence is maintained whether fields are stored separately or packaged according to interface width. The weights and column indices in the combined codewords come from the same non-zero entry.
[0032] Example 2
[0033] like Figure 2 As shown, steps one through three complete the pre-deployment configuration, step four completes the static loading, and steps five and six are executed in conjunction during the inference and reading process. The steps utilize the following field representations, fault determination methods, and encoding conditions.
[0034] S1, Configure CSR fields and start / endpoints
[0035] The CSR configuration module converts the static weights of the target network layer into values, col_indices, and row_ptr, maintaining a one-to-one correspondence between values and col_indices in the order of non-zero entries, and generating row_ptr for each output row. For convolutional layers, the convolutional kernels and the input feature map sliding window are expanded in the same order, with column indices corresponding to the activation positions within the expanded window. The module determines the logical bit width and data type of each field and provides the field organization to the fault analysis module and the encoding / writing module.
[0036] Representing CSR constraints using a single target layer, let the number of output rows be... The input dimension is Representing CSR constraints with a single target layer, let the number of output rows be... The input dimension is The number of non-zero weights is ; For row boundary index, For non-zero entries in the index, For the first row in row_ptr A boundary, For the first The column index of each entry. The array length, column index, and complete row boundary sequence satisfy:
[0037]
[0038] In the formula, both array length and boundary offset are counted per entry. The first endpoint of each layer... Zero, tail endpoint This represents the total number of non-zero weights in the current layer; both are stored as configuration constants. The remaining internal boundaries of values, col_indices, and row_ptr are included in the storage fault analysis object, and the actual protected fields are determined by step three. During initialization, the array length, index range, boundary range, and non-decreasing constraints of the above formula are checked. When adjacent boundaries are equal, a blank row is corresponding to the condition; when multiple entries point to the same column index, each entry is retained and multiplied and added separately.
[0039] Under the implementation condition of using symmetric INT8 weights, `values` stores quantized integers, `col_indices` and `row_ptr` are encoded using unsigned integers, and activation, bias, and accumulation use FP32. Let... For the target layer index, For the complete weight tensor of this layer, the scale is quantized layer by layer. for:
[0040]
[0041] The maximum absolute value in the formula is obtained on the complete weight tensor of the corresponding layer; the quantization zero is 0, and the original model's quantization integer range is −127 to 127. Indicates the first value in values A quantized integer for each entry, used to calculate the weights for multiplication and addition. for:
[0042]
[0043] The stored integers correspond to the values calculated during inference. Rows with all-zero weights are represented by equal adjacent row boundaries, and the convolution unrolling, repeated column entry accumulation, and bias processing are consistent with the reference network.
[0044] S2, Analyze the consequences of a single-bit fault in the field.
[0045] like Figure 4 As shown, the fault analysis module first verifies the consistency between the fault-free CSR inference and the reference calculation, and then determines a fault case according to the target network layer, field, element position, and logical bit position. Let... Identify the values, col_indices, or row_ptr fields. Fixed-width binary mode for selected elements. This is the flipped bit pattern. (Index here) This indicates the position of the element in the list to be evaluated for this field; This indicates the LSB0 logic bits, numbered starting from the least significant bit 0. For the first Layer fields The logical bit width is in bits. After saving the original value, perform a single XOR operation on the target bit:
[0046]
[0047] In the above formula This indicates a bitwise XOR operation, where only one predetermined logical bit is flipped in each case. The flipped values are interpreted as signed two's complement, while col_indices and row_ptr are interpreted as unsigned numbers. For the flipped indexes, the value range is checked based on the actual input dimension of the current layer; for internal boundaries, they are placed back into the complete row_ptr sequence, with the first and last endpoints continuing to take their original configuration values, and the boundary value range and non-decreasing relationship are checked. The processing branches for each field are shown in Table 1.
[0048] Table 1. CSR Field Faults and Their Judgment Rules Injection Field Consequence type Judgment conditions Should we proceed with the reasoning? values Numerical perturbation Weight encoding changes, but indexes and boundaries remain valid. yes col_indices Error connection The index remains within the valid range of the current layer after flipping. yes col_indices Address invalid After flipping, the index exceeds the input range of the current layer. no row_ptr Error boundary The complete boundary sequence still satisfies the CSR legality constraint. yes row_ptr Structural failure Internal boundaries exceeding the range or violating non-decreasing relationships no
[0049] like Figure 3As shown, in a 3×8 sparse weighted matrix example, there are 10 non-zero weights, and the complete row_ptr is [0,3,7,10]. The value 23 becomes 22 after bit 0 is flipped, only changing the multiply-accumulate operands; when column index 5 becomes 7, it is still within the input range of 0 to 7, forming an incorrect connection; when it becomes 13, it causes address invalidation; when row_ptr changes from [0,3,7,10] to [0,2,7,10], it can still be parsed, but the ownership of entries in adjacent rows changes, becoming [0,3,15,10], simultaneously exceeding the boundary and disrupting the non-decreasing relationship. This example corresponds to three usage locations: multiply-accumulate data, active addressing, and row boundary control.
[0050] Cases experiencing address or structural failures are stopped during inference, and the type is recorded. For executable cases, inference is performed on the target layer and subsequent networks, and accuracy is calculated on the same fixed evaluation picture and order as the fault-free model. Let... This is the executable failure case number. To fix the fault-free accuracy of the evaluation sample, For the first Accuracy decreased after failure in each case. for:
[0051]
[0052] In the above formula, accuracy is expressed as a percentage, with the difference unit being percentage points (pp), and the sign of negative values is retained. Address failures and structural failures do not yield valid inference results and are not included in the accuracy reduction calculation. After each case, the original value of the flipped element is restored before processing the next case, maintaining the independence between cases.
[0053] set up For the target layer set, For the first Layer fields Number of elements included in the analysis, fields logical bit fault space The number of cases is:
[0054]
[0055] In the above formula, row_ptr Only internal boundaries are considered. For full traversal, a fault case is established for each logical bit in the definition space; for stratified quota sampling, quota field elements are selected on a target network layer basis, and all logical bits are traversed for the selected elements. Results are summarized by field, target layer, and logical bit; the full traversal results correspond to the definition space, and the stratified sampling results correspond to the selected samples.
[0056] The proportion of field-level address failures is calculated using the number of `col_indices` cases as the denominator, while the proportion of field-level structure failures is calculated using the number of `row_ptr` cases as the denominator. When comparing different protection configurations, the same original CSR data bits are used to construct the fault space, and the accuracy decreases when comparing the same set of executable cases under the no-protection configuration. Changes in cases that were originally unexecutable under the no-protection condition are reflected through address and structure failure indicators. Newly added ECC check bits are not included in the fault space of this original data bit. The fault analysis module provides the aforementioned consequence types and accuracy statistics to the protection configuration module.
[0057] S3, Determine the field protection scope and codeword organization
[0058] The protection configuration module, combining the field execution function, the fault consequences recorded in step two, and the protection target, determines the range of fields that need to be protected. Let P0 be the unprotected comparison baseline, and P1, P2, and P3 be the first, second, and third protection configurations, respectively. When the CSR structure can be resolved as the protection target, P1 only covers the internal boundary of row_ptr; simultaneously, when a valid activation address is required, P2 adds protection for col_indices; further, when weight value perturbations are covered, P3 protects values, col_indices, and the internal boundary of row_ptr respectively. All configurations use the same SECDED error correction condition; the difference lies in the field coverage range and its corresponding decoding branch.
[0059] When determining the configuration, the encoding unit, additional storage, and read module resources are compared simultaneously. Let... , , These are the logical bit widths of values, col_indices, and row_ptr, respectively, in bits; they are related to the aforementioned weight tensor. These represent different objects. The standard software CSR logical storage size, including the complete row_ptr, is [not specified]. for:
[0060]
[0061] The unit in the above formula is bits, and the superscript std indicates the standard software CSR storage caliber including the complete row_ptr. The fault and protection data space is configured in step one, minus the two start and end endpoints at each level; when using storage word-level grouping, alignment padding is additionally included in the corresponding unprotected storage baseline. Additional overhead is calculated based on the baseline of the selected organization, ensuring that endpoint processing, data grouping, and the number of parity bits correspond.
[0062] Before model loading, the protection configuration module outputs the protected fields, encoded data units, and codeword group boundaries, and determines the required decoding branches for the read path. Each protected field is encoded independently using field-independent organization; when full field coverage is achieved and the weights and indexes of the same non-zero entry are accessed synchronously, a combined codeword organization from the following codeword organization variants can be selected. This selection changes the codeword organization but does not change the full field coverage target.
[0063] S4, encoded and stored during static loading.
[0064] The encoding and writing module receives field data from the CSR configuration module and the encoding range from the protection configuration module, and generates a SECDED checksum for the protected data during the model loading or storage writing phase. Let... The number of bits in the codeword. The number of Hamming check bits, both in bits, satisfy the following:
[0065]
[0066] After selecting the number of Hamming parity bits according to the above formula, add 1 global even parity bit, and the total codeword length is... For 8-bit data, 4 Hamming check bits are used to form a 13-bit codeword; for 16-bit data, 5 Hamming check bits are used to form a 22-bit codeword; and for 64-bit data, 7 Hamming check bits are used to form a 72-bit codeword.
[0067] At the element level, P1 encodes the internal row boundaries, P2 encodes the internal boundaries and column indices separately, and P3 encodes the three fields separately. In 8 / 8 / 16-bit field configurations, the protected 8-bit weights or column indices form 13-bit codewords, and the 16-bit internal boundaries form 22-bit codewords. When using storage word-level organization, the field data stream is grouped according to a specified width; see the codeword organization variants below for specific 64-bit grouping and union organization.
[0068] The encoding and writing module stores the codewords and unprotected field data into the CSR storage module, maintaining their correspondence with the original fields, non-zero entries, and internal boundaries. Unprotected fields retain their original data representation; the beginning and end configuration constants continue to be used for the complete boundary sequence. Encoding operations are located in the load or write path, and steady-state inference reads the pre-generated codewords.
[0069] S5, read codewords and decode / correct them.
[0070] The decoding and reading module connects between the CSR storage module and the CSR inference module, performing verification, syndrome calculation, error location, and correction selection on the read protected codewords. It outputs the original data when there are no erroneous codewords; it outputs the recovered data under single-bit correction conditions; and flipping a single parity bit does not change the content of the decoded field. The module also provides a two-bit error detection status. The protection effects described below are based on the condition that there is at most one error per codeword and the ECC logic is fault-free.
[0071] P1 sets up an internal boundary decoding branch, P2 adds a column index decoding branch, and P3 adds a weight decoding branch. Decoding branches for different fields are connected in parallel to the common interface, outputting field data to row boundary control, activation address generation, and multiply-accumulate data paths respectively; unprotected fields directly output their stored data. Decoding branches are located before the position where the corresponding field is used, and their combined delays are not serially added along the same path. The decoding data allocation and 64-bit pipeline implementation of the joint codeword are set according to the following codeword organization variant and read implementation settings.
[0072] S6, Perform CSR sparse inference
[0073] The CSR inference module uses the read internal boundaries and start / end configuration constants to determine the range of entries in the current output line. For each non-zero entry within this range, it accesses the input activation using the read column index and performs multiplication and addition line by line with corresponding weights. Indicates the output row index. This indicates the index of the non-zero entry in that row. This indicates that input read by column index is active. Indicates the first The sparse multiply-add result of the row is:
[0074]
[0075] In the above formula and This represents the start and end boundaries of the current line entry. The summation is obtained from the quantized integers read using the aforementioned formula. When adjacent boundaries are equal, the summation is performed as an empty sum; when multiple entries point to the same column index, their products are accumulated separately without overwriting the previous entry or pre-merging them in the low-bit-width weight representation. The original network bias is used as originally set and is not included in the sparse multiply-accumulate term of this formula.
[0076] The protected internal boundaries, column indices, and weights undergo decoding correction in step five before entering row boundary control, activation address generation, and the multiply-accumulate path, respectively; unprotected fields are used according to the original execution rules. After each output row is completed, subsequent network layers continue to form the inference result. P2 corrects the internal boundaries and column indices, while values remain unprotected, and errors in these values may still alter numerical calculations; P3 corrects all three fields before their corresponding usage positions. The impact of different protection ranges is compared using the same original data bit space and a fixed set of executable cases determined in step two.
[0077] Example 3
[0078] 1. Field-independent and combined codewords under full field coverage
[0079] When the protected target contains weight value perturbations, either the P3 field is organized independently or the PT is combined. Both protect the internal boundaries of values, col_indices, and row_ptr. PT combines weights and column indices accessed synchronously in the same non-zero entry into a combined data unit, with the internal boundaries maintained by independent encoding. This organization is determined before static loading and maintains the same codeword boundaries during encoding, writing, and decoding.
[0080] For 8 / 8 / 16-bit field configurations, the 8-bit weights and 8-bit column indices in P3 each form 13-bit codewords, with two codewords corresponding to each non-zero entry; PT combines these two into 16-bit data, forming a 22-bit joint codeword. The 16-bit internal boundaries of both organizations form independent 22-bit codewords. The P3 read module uses two 8-bit decoding branches and one 16-bit decoding branch; PT uses one 16-bit joint decoding branch and one 16-bit internal boundary decoding branch. After joint decoding, the weights and indices are sent to the multiply-accumulate and address locations, respectively. The two fields in PT share codeword boundaries, and its organization does not retain the granularity of P2, which only protects `col_indices`.
[0081] 2. 64-bit storage word-level organization
[0082] When using 64-bit storage word-level encoding, field-independent organization groups each field's data stream by 64-bit boundaries, padding any data streams ending with less than one storage word. Union organization first forms a tuple stream from the weights and column indices of the same non-zero entry, then groups it by 64-bit boundaries, with the row_ptr's internal boundary data streams grouped independently. In 8 / 8 / 16-bit configurations, each weight and column index tuple contains 16 bits of data.
[0083] Each protected 64-bit data word is converted into a 72-bit SECDED codeword according to the parameters in step four. During writing, the correspondence between the grouped data and the original field elements is preserved. After reading, the decoded data is sent to the field execution path according to the same organization. At this granularity, both P3 and PT add 8 parity bits to the 64-bit protected data; the capacity difference under the same unprotected data baseline is calculated based on their respective grouping and alignment results.
[0084] 3. Read branch and pipeline decoding
[0085] The decoding branches, whether independent or jointly organized, are configured in parallel. The longest internal path of a module is determined by the slowest branch and the actual layout and routing. When codewords are mapped to block memory, the number of resource blocks required is jointly determined by the field depth, data bit width, codeword width, and device storage resources. The read path includes the corresponding storage output and decoding logic.
[0086] For 64-bit protected data, a pipelined SECDED decoding core can be used to process its 72-bit codewords. This core has a scheduling delay of three clock cycles, a startup interval of one clock cycle, and receives new codewords cycle by cycle after the pipeline is full. Encoding is still completed during static loading or storage write; the decoding result is output before the corresponding CSR field is used. Element-level encapsulation, representative block memory read paths, and the 64-bit decoding core are verified using independent configurations as described in the specific application and performance verification sections below.
[0087] Example 4
[0088] 1. Field Analysis and Protection Effects of LeNet-5
[0089] This application uses a LeNet-5 network trained from random initialization and the MNIST dataset. After network training, layer-by-layer unstructured pruning and fine-tuning are performed. Symmetric INT8 quantization is applied to the complete weight tensors of each target layer to obtain five CSR target layers: conv1, conv2, fc1, fc2, and fc3. The original weights totaled 44,190, with 13,973 non-zero weights retained, resulting in a sparsity of 68.38%. Values and col_indices are 8 bits, and row_ptr is 16 bits; activation, bias, and accumulation are FP32.
[0090] The CSR configuration module stores 241 complete row_ptr boundaries, of which 10 start and end endpoints across 5 layers are processed as configuration constants, and 231 internal boundaries are included in analysis and protection. The standard software CSR storage size is 227,424 bits; after deducting fault and protection data from start and end endpoints, it is 227,264 bits; the data stream, aligned to 64-bit boundaries, is 227,328 bits. The standard software CSR accounts for 64.33% of the dense INT8 weighted capacity, with column indexes and row boundaries accounting for 50.85% of the standard software CSR capacity. The complete array storage, the original data bit space after deducting configuration endpoints, and the 64-bit aligned storage each adopt the corresponding baselines mentioned above.
[0091] In baseline validation, the sparse FP32 model and the INT8-weighted CSR model achieved accuracies of 99.07% and 99.05%, respectively, on the full MNIST test set, with a prediction consistency rate of 99.97%. Single-bit fault assessment used a fixed set of 1000 randomly selected MNIST test images, achieving a CSR baseline accuracy of 99.10%; the same images and order were used for all fault cases. Table 2 lists the model configurations for the LeNet-5 application in this section and the VGG16-assisted analysis described later.
[0092] Table 2 Experimental Model, CSR Scale, and Fault Injection Configuration Model Dataset CSR target level Non-zero weights values / col_indices / row_ptr bit width Three-field assessment case count Way Full test set CSR accuracy LeNet-5 MNIST 5 13973 8 / 8 / 16 bit 111784 / 111784 / 3696 Full traversal 99.05% VGG16 CIFAR-10 16 3005459 8 / 16 / 32 bit 4096 / 16384 / 30944 Stratified quota sampling 94.02%
[0093] The fault analysis module traverses all 227,264 data bit cases. `values` and `col_indices` each correspond to 8 bits of 13,973 elements, totaling 111,784 cases; `row_ptr` corresponds to 16 bits of 231 internal boundaries, totaling 3,696 cases. Table 3 shows the field-level results for the two models. The address and structure ratios are calculated with the number of cases for the current field as the denominator. Accuracy statistics only use executable cases.
[0094] Table 3 CSR field-level fault results for LeNet-5 and VGG16 Model Fields Number of cases Executable Number of invalid addresses (percentage) Number of structural failures (proportion) Average accuracy decreased / pp Maximum accuracy decrease / pp LeNet-5 values 111784 111784 0(0%) 0(0%) 0.0065 0.70 LeNet-5 col_indices 111784 105269 6515(5.83%) 0(0%) 0.0078 0.60 LeNet-5 row_ptr 3696 1434 0(0%) 2262(61.20%) 0.12 10.50 VGG16 values 4096 4096 0(0%) 0(0%) 0.02 2.70 VGG16 col_indices 16384 10340 6044(36.89%) 0(0%) 0.0091 0.90 VGG16 row_ptr 30944 7691 0(0%) 23253(75.15%) 0.12 82.60
[0095] All values cases in LeNet-5 are executable, demonstrating that weight flipping does not alter the array structure or activation addresses under this execution rule. 6515 cases in `col_indices` are out of bounds, and 2262 cases in `row_ptr` violate legal boundaries; these cases enter the stop inference branch in Table 1. The maximum accuracy for still executable internal boundary errors drops to 10.50 pp, corresponding to the effect that a boundary can reallocate multiple consecutive non-zero entries. Field-level results are used to set resolvable structure and valid addresses as the protection targets for P2.
[0096] Figure 5 and Figure 6 The bit-level and hierarchical distributions of address and structure failures are given respectively. Figure 5 In this study, the overall address failure rate for column index bit 7 is 31.52%, causing 4404 address failures, accounting for 67.60% of all address failures. For conv1, the valid column indices are 0 to 24; flipping bits 5 to 7 results in out-of-bounds errors. For fc1, the input dimension is 256, and all 8-bit unsigned index values are valid; flipping any bit in this layer does not cause address failures. This comparison illustrates that the valid input range must be determined according to the current network layer.
[0097] Figure 6 In the row_ptr, flipping bits 0 to 3 did not violate structural constraints, while bits 8 to 15 all resulted in structural failures. The last eight higher bits caused 1848 structural failures, accounting for 81.70% of the 2262 failures. The starting bit for structural failures is also related to the network layer, as internal boundaries are constrained by both the total number of non-zero entries in the current layer and the spacing between adjacent boundaries. The absence of structural failures in the lower bits only indicates that the CSR is resolvable; the task of evaluating the impact of changes in entry attribution still needs to be performed.
[0098] After selecting P2 for the protection configuration module, the encoding and writing module generates a 13-bit codeword for the 8-bit column index and a 22-bit codeword for the 16-bit internal boundary, while keeping 8 bits of data in the values. During reading, the two decoding branches provide correction values to the active address generation and row boundary control, respectively, and the values directly enter the multiply-accumulate path. Under the condition that there is at most one error per codeword and no fault in the ECC logic, the original address and structural failure cases are both 0 after protection; the unprotected weights can still change the numerical calculation, and the maximum accuracy decrease in the fixed executable set remains at 0.70 pp. This completes the encoding, reading, and fault effect verification of the second protection configuration.
[0099] Table 4 shows the additional capacity for element-level and 64-bit word-level organization, respectively. The percentages are relative to the corresponding unprotected data baseline and do not include the data itself being counted as redundant again.
[0100] Table 4. Protection Scope, Codeword Organization, and Additional Storage Overhead Configuration Protected objects and codeword organizations Element-level additional overhead 64-bit storage word-level overhead P0 Unprotected baseline 0 0 P1 The internal boundaries of row_ptr are encoded independently. 0.61% 0.20% P2 The internal boundaries of col_indices and row_ptr are encoded respectively. 31.35% 6.35% P3 The three fields are encoded separately. 62.09% 12.50% PT values are associated with col_indices; row_ptr has independent internal boundaries. 37.50% 12.50%
[0101] Under the condition that there is at most one error per codeword and the ECC logic is fault-free, the failure consequences of each configuration are shown in Table 5. The address and structure ratio is calculated using the same 227,264 original data bit cases as the denominator; the decrease in average accuracy is calculated using the fixed set of 218,487 executable cases under P0 as the denominator, and the change in non-executable cases under P0 after protection is reflected by the failure count index. The newly added ECC check bit is not included in this fault space.
[0102] Table 5. Address, structure, and accuracy results under different protection ranges. Configuration Number of invalid addresses (uniform space ratio) Number of structural failures (uniform spatial proportion) Average accuracy decrease for fixed executable sets / pp Maximum accuracy decrease / pp P0 6515(2.87%) 2262(1.00%) 0.0079 10.50 P1 6515(2.87%) 0(0%) 0.0071 0.70 P2 0(0%) 0(0%) 0.0033 0.70 P3 0(0%) 0(0%) 0 0 PT 0(0%) 0(0%) 0 0
[0103] Figure 7 The subgraphs are (a) additional storage overhead, (b) address and structure failure ratio, and (c) decrease in average accuracy. P2 has eliminated both types of non-executable consequences, while P3 and PT continue to restore the baseline accuracy of the fixed executable set. When using 64-bit grouping, both P3 and PT add 8 parity bits to the 64-bit data, resulting in the same capacity overhead; tuple union only changes the data arrangement and does not produce any additional capacity advantage at this level.
[0104] 2. Larger Network-Auxiliary Analysis of VGG16
[0105] Larger-scale auxiliary analyses used VGG16 / CIFAR-10. The network contains 13 convolutional layers and 3 fully connected layers, trained from random initialization without using pre-trained parameters; it employs the same layer-by-layer unstructured pruning and symmetric INT8 quantization as LeNet-5. The original weights are 15,239,872, with 3,005,459 non-zero weights, a sparsity of 80.28%, 5,242 row_ptr internal boundaries, and field widths of 8 / 16 / 32 bits. The standard software CSR capacity is 72,299,784 bits, accounting for 59.30% of the dense INT8 weight capacity, while the index and boundaries account for 66.74% of the standard software CSR capacity.
[0106] This auxiliary analysis used stratified quota samples for 16 target layers, and the number of evaluation cases is shown in Table 2; all logical bits of each selected field element participated in the flipping. On the complete CIFAR-10 test set, the sparse FP32, pseudo-quantized INT8, and CSR models achieved 94.05%, 94.02%, and 94.02%, respectively. Fault assessment used the first 1000 images of the test set, with a CSR baseline of 94.60%, and all cases reused the same images and order. In Table 3, the address failure rate of 36.89% and the structural failure rate of 75.15% only represent the proportions in the corresponding stratified quota samples.
[0107] In VGG16, an executable internal boundary case changes the boundary of the first convolutional layer from 16 to 24, causing eight consecutive non-zero entries to be moved to adjacent output rows. The complete boundary sequence remains valid, and the case enters the erroneous boundary inference branch; accuracy drops from 94.60% to 12.00%, a decrease of 82.60 percentage points (pp). This example illustrates that validity checks must be retained in conjunction with executable task evaluation to simultaneously identify both "cannot be parsed" and "can be parsed but entry attribution changed" consequences. VGG16 analysis assists in examining the existence of consequences for the same field under larger CSR scales and wider metadata conditions; the reported proportions correspond to the selected stratified quota sample.
[0108] 3. Verification of the implementation of the read path and decoding module
[0109] This group verified the implementation of element-level read packages, representative block memory read paths, and 64-bit decoding primitives. The tools used were Vivado HLS 2019.2 and Vivado 2019.2, the target device was a Xilinx XC7Z020 (xc7z020clg484-1), and the reference period was 10 ns. HLS generated the decoding core RTL, followed by module-level independent placement and routing. 6238 test vectors were applied to the combinational core and pipeline core, forming 12476 C / RTL co-simulation transactions, covering error-free, single-bit correction, and double-bit detection states. The results were consistent with the independent bit-level reference model.
[0110] The resources and timing of each element-level encapsulation module are shown in Table 6. P0 to PT use the same input / output register boundaries; the 72 FFs of P0 are used as interface registers. The data path refers to the path between registers within the encapsulation module, and WNS is the worst-case negative margin report value for this module.
[0111] Table 6. OOC Resources and Timing Results for 8 / 16-bit Element-Level SECDED Read Path Encapsulation Configuration Parallel decoding branch LUT FF Longest internal data path / ns Internal WNS / ns P0 none 0 72 1.11 8.77 P1 1×16 bit 72 78 6.71 3.22 P2 1×8 bit + 1×16 bit 119 83 6.50 3.44 P3 2×8 bits + 1×16 bits 166 88 6.82 3.20 PT 2×16 bit 147 84 6.86 3.11
[0112] Compared to P3, P1 and P2 reduce the number of LUTs by 94 and 47 respectively, and the number of FFs by 10 and 5 respectively; the PT with the same full field coverage reduces the number of LUTs by 19 and the number of FFs by 4. The longest internal path of each protected module is 6.50 to 6.86 ns, which meets the setup time constraint under a 10 ns reference period. The longest path of P2 can still be less than that of P1 after adding an 8-bit tributary because the tributaries run in parallel, and the actual path is determined by the slowest tributary and the layout and routing.
[0113] In a representative BRAM path, 13,973 8-bit values are mapped to 4 RAMB36 blocks without protection, resulting in a BRAM data path of 3.16 ns. Using 13-bit codewords, they are mapped to 6 RAMB36 blocks and 1 RAMB18 block, with an additional 32 LUTs for decoding logic. The BRAM data path length is 7.81 ns, and the WNS is 1.92 ns. 231 internal boundaries can be mapped to 1 RAMB18 block in both 16-bit data and 22-bit codeword scenarios. With protection, the decoding logic becomes 72 LUTs, increasing the BRAM data path length from 3.27 ns to 8.65 ns, while the WNS is 1.25 ns. The conversion from capacity ratio to resource block number is determined by both storage depth and mapping.
[0114] In the independent 64-bit decoding primitives, the pass-through baseline has no LUT, 132 FFs, and a longest internal path of 1.08 ns; the combinational decoding has 218 LUTs, 140 FFs, and 9.38 ns; and the pipelined decoding has 199 LUTs, 379 FFs, and 6.49 ns. Pipelined decoding reduces the logic depth from 12 levels to 8 levels, increases the WNS from 0.49 ns to 3.21 ns, and shortens the longest internal data path by approximately 30.8%. Its HLS scheduling verification yields a delay of 3 cycles and a start interval of 1, corresponding to the aforementioned pipelined read organization.
[0115] The three implementations correspond to the element-level protection branch, the specific BRAM mapping read path, and the wide codeword pipeline core, respectively. The 64-bit capacity in Table 4, the element-level encapsulation resources in Table 6, and the timing of the 64-bit primitives in this section each have independent configurations, serving as verification criteria for different design choices. The above hardware results represent the resource and timing results of the decoding core and read path module in their respective independent configurations.
[0116] 4. Technical effects and comparison of protective tissues
[0117] Table 7 shows the protected objects, fault conditions, selection criteria, and codeword organization of different storage ECC methods. NN-ECC is a method that embeds weights into the code using training constraints; PoP-ECC is a two-level coding method oriented towards multi-bit flipping; and Stegano-ECC is a method oriented towards weighted important bits and embedding check information in low-importance bits. Table 7 compares these methods with this implementation method according to the protected objects, fault conditions, and codeword organization.
[0118] Table 7 Technical Comparison of This Embodiment with Representative Neural Network Storage ECC Methods method Protected object Main Failure Conditions Scope of protection and selection criteria ECC or codeword organization Full-field SECDED baseline P3 CSR three fields Single-bit flip Unified coverage of all fields Field-independent SECDED codeword NN-ECC Weight parameters Weight storage failure Training constraints Linear block code embedding weights PoP-ECC Accelerator storage data Multi-bit flip Multi-bit error mode Two-level ECC Stegano-ECC Weighting importance Weighting error Bit position and data type Important bits use SEC, and check information is embedded in less important bits. This implementation method includes P1 to P3 and PT. CSR three fields Single-bit flip Field Functions and Fault Consequences Fields P1 through P3 are independent; PT combines values and col_indices.
[0119] This implementation determines the coverage based on the CSR field's execution function and failure consequences, while preserving different protection granularities for internal boundaries, column indexes, and weights. Fields P1 to P3 are configured independently, while PT corresponds to the joint codeword configuration under full field coverage; the codeword boundaries, static encoding objects, and read branches required for both are set according to the aforementioned six-step implementation process and corresponding organizational variants.
Claims
1. A hierarchical protection method for CSR fields in sparse neural networks, characterized in that, Includes the following steps: Step 1: Configure CSR fields and start and end endpoints. Represent the static sparse weights of the target network layer as non-zero weight field values, column index field col_indices, and row boundary field row_ptr. Determine the logical bit width of each field. Use the total number of zero weights at the start endpoint and non-zero weights at the end endpoint of row_ptr for each layer as a configuration constant. Include values, col_indices, and the internal boundary of row_ptr in the storage fault analysis object. Step 2: Analyze the consequences of single-bit field failures. For each case of field element in the storage failure analysis object, flip one logical bit. Determine whether the column index is valid based on the current layer input range. Determine whether the complete row boundary sequence is valid based on the boundary value range and non-decreasing relationship. Record address failures and structural failures respectively. For executable cases, perform inference and calculate the accuracy reduction relative to the fault-free baseline according to CSR entries. After recovering the flipped element, process the next case. Step 3: Determine the field protection scope and codeword organization. Based on the consequences of a single bit failure in the field and the protection objectives, select one of the following configurations: protect only the internal boundary of row_ptr, protect the internal boundary of row_ptr and col_indices, and protect the aforementioned internal boundary, col_indices, and values. This corresponds to the protection objectives of structure parsing, structure parsing and address validity, and further coverage of weight value perturbations. The field composition and grouping boundaries of the SECDED codeword are then determined for the selected configuration. Step 4: During static loading, the protected data is encoded and stored. According to the selected field protection range and codeword organization, the protected data is generated with SECDED check bits, and the corresponding codewords and unprotected field data are stored in the CSR storage module. Step 5: Read the codeword and decode and correct it. Perform comprehensive calculation, error location and single-bit error correction on the protected codeword in the inference reading path, output the decoded field data, and output the stored data for the unprotected fields. Step 6: Perform CSR sparse inference, determine the range of entries in the output row using the read internal boundaries and the configuration constants, generate the input activation access address using the read column index, and multiply and accumulate the read non-zero weights with the accessed activations one by one. The protected fields complete the decoding correction before being controlled by the corresponding row boundaries, generated activation addresses, or used by the multiply-accumulate path.
2. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, The first endpoint of the complete row boundary sequence is zero, and the last endpoint is the total number of non-zero weights in the current layer. Each boundary is between zero and the total number of non-zero weights. Adjacent boundaries satisfy a non-decreasing relationship. When two adjacent boundaries are equal, there is a blank row. Each column index is within the range of zero to the current layer input dimension minus one. The number of elements in values and col_indices is equal to the total number of non-zero weights, and the number of elements in row_ptr is equal to the number of output rows plus one.
3. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, In step two, fault cases are uniquely identified by network layer, field, element position, and logical bit position, with logical bits numbered starting from the least significant bit zero; target bit XOR flipping is performed on the fixed-width binary bit pattern, the bit pattern of values is interpreted according to signed two's complement, and the bit patterns of col_indices and row_ptr are interpreted as unsigned integers; cases with invalid column indices are recorded as address failures, and cases with invalid row boundary sequences are recorded as structural failures. Inference is stopped and the fault type is recorded when either an address failure or a structural failure occurs.
4. The sparse neural network CSR field hierarchical protection method as described in claim 3, characterized in that, In step two, cases where the values bit is flipped and the executable condition is maintained are recorded with numerical perturbations; cases where the col_indices bit is flipped and the index is valid are recorded with incorrect connections; and cases where the row_ptr inner boundary bit is flipped and the complete sequence is valid are recorded with incorrect boundaries. The baseline and fault reasoning use the same evaluation images and order. The accuracy decrease is obtained by subtracting the fault accuracy from the baseline accuracy, and the sign of the difference is retained.
5. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, Step two employs either a full traversal or stratified quota sampling based on the target network layer. Full traversal establishes fault cases for all logical bits of each target field element, and hierarchical quota sampling establishes fault cases for all logical bits of the selected field elements in each target layer. When comparing different protection configurations, the same original CSR data bits are used to construct the fault space, and the accuracy of comparison on the same fault case set that can be executed under no protection configuration decreases.
6. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, When the configuration for protecting the internal boundary of row_ptr and col_indices is selected, independent SECDED codewords are constructed for the internal boundary and column index respectively, while the values remain unprotected. The internal boundary decoding branch and the column index decoding branch of the read path are set in parallel, and the decoded data is provided to the row boundary control path and the active address generation path respectively.
7. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, When selecting the configuration to protect the internal boundary of row_ptr, col_indices, and values, the organization of SECDED codewords can be constructed using the three fields respectively, or, under the condition that values and col_indices are accessed in pairs synchronously, the organization can be formed by encoding the weights and column indices of the same non-zero entry into a combined data unit, and the internal boundary of row_ptr can be encoded independently; the weights and column indices in the combined data unit are used together as protected data.
8. The sparse neural network CSR field hierarchical protection method as described in claim 7, characterized in that, When using field-independent element-level encoding, the 8-bit weight data and the 8-bit column index data each form a 13-bit codeword, and the 16-bit internal boundary data forms a 22-bit codeword; when using the combined data unit, the 8-bit weight and the corresponding 8-bit column index are combined into 16-bit data and form a 22-bit combined codeword.
9. The sparse neural network CSR field hierarchical protection method as described in claim 7, characterized in that, When using 64-bit storage word-level encoding, the data streams of each field in the field-independent organization are grouped according to 64-bit boundaries, and the tail of the data stream is aligned and padded; for the union organization, the weight and column index tuple streams of the same non-zero entry are first formed, and then grouped according to 64-bit boundaries, with the data streams of the row_ptr internal boundary grouped independently; each protected 64-bit data word forms a 72-bit SECDED codeword.
10. The sparse neural network CSR field hierarchical protection method as described in claim 9, characterized in that, The read path uses a pipelined 64-bit SECDED decoder core. The scheduling delay of the decoder core is three clock cycles, the start interval is one clock cycle, and new codewords are received cycle by cycle after the pipeline is full.
11. The sparse neural network CSR field hierarchical protection method as described in claim 1, characterized in that, The values store integers obtained by performing symmetric INT8 quantization on the complete weight tensors of each target layer. The quantization scale of each layer is obtained by dividing the maximum absolute value of the complete weight tensor of that layer by 127. The quantization zero point is zero, and the activation, bias, and accumulation are kept at FP32. The convolution kernel and the input sliding window are expanded in the same order. When multiple non-zero entries point to the same column index, the product of each entry is accumulated.
12. A sparse neural network CSR field hierarchical protection system, characterized in that, It includes a CSR configuration module, a fault analysis module, a protection configuration module, an encoding writing module, a CSR storage module, a decoding reading module, and a CSR inference module; The CSR configuration module is used to determine the values, col_indices, and row_ptr of the target network layer and their logical bit widths. The total number of zero weights at the beginning and non-zero weights at the end of each row_ptr is used as a configuration constant. The internal boundaries of values, col_indices, and row_ptr are included in the storage fault analysis object. The fault analysis module is connected to the CSR configuration module and is used to perform single-bit flipping of fields on a case-by-case basis. Based on the current layer input range and the range of the complete row boundary sequence and non-decreasing constraints, address failure and structural failure are recorded respectively. CSR inference is performed on executable cases and the accuracy decrease is calculated. The flipped elements are restored after each case. The protection configuration module is connected to the fault analysis module and is used to select the field protection range from the configurations of protecting only the internal boundary of row_ptr, further protecting col_indices, and further protecting values, based on the field fault consequences and protection objectives, and to determine the field composition and grouping boundaries of the corresponding SECDED codeword. The encoding writing module is connected to the CSR configuration module, the protection configuration module and the CSR storage module, and is used to generate SECDED codewords according to the selected configuration when loading or writing static weights. The CSR storage module is used to store the codewords and unprotected field data. The decoding and reading module is connected between the CSR storage module and the CSR inference module. It is used to calculate the syndrome of the protected codeword according to the protection configuration, locate and correct single-bit errors, and output the decoded field data and unprotected field data to the CSR inference module. The CSR inference module is used to perform row boundary control based on the read internal boundary and configuration constants, generate an activation address based on the read column index, and perform row-by-row multiplication and addition based on the read weight and activation. The correction of protected fields by the decoding and reading module precedes the use of the corresponding fields in the above path.
