AI inference chip precision maintenance and verification method and device, equipment and medium
By restoring the numerical semantic model and performing counterfactual verification during the compilation phase, the necessary constraints are identified and reproduced in on-chip memory, and a numerical error certificate is generated. This solves the problem of balancing numerical semantics and fusion benefits in low-bit operator fusion, and achieves numerical correctness and performance optimization during the runtime phase.
Patent Information
- Application Number
- CN202611646199.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-23
- Publication Date
- 2026-11-20
AI Technical Summary
Existing technologies cannot balance numerical semantic consistency and fusion benefits in low-bit operator fusion, resulting in the loss of off-chip memory access meaning or the destruction of calibrated numerical behavior during the optimization process.
By restoring the numerical semantic model of precision constraint events during the compilation phase, performing counterfactual verification, determining the boundaries that need to be retained, reproducing the necessary constraints in on-chip memory, and generating machine-readable numerical error certificates, the numerical correctness and performance optimization during the runtime phase are ensured.
It improves the controllability of the numerical behavior of low-bit fusion operators, breaks the contradiction between preserving numerical semantics and optimizing fusion performance in traditional schemes, and maximizes inference performance without sacrificing security.
Smart Images

Figure CN123140106A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence compilers and numerical computation, and in particular to a method, apparatus, device and medium for maintaining and verifying the accuracy of AI inference chips. Background Technology
[0002] In large-scale cloud inference scenarios, low-bit quantization and operator fusion are key technologies for improving computational efficiency. Maximizing the benefits of fusion while maintaining numerical accuracy has become a hot topic of ongoing research in this field. Existing technologies have developed various solutions, such as inserting pseudo-quantized nodes into the model graph through quantization-aware training to simulate hardware behavior, constructing hierarchical error propagation graphs to guide quantization parameter selection, and performing operator fusion based on algebraic equivalence to reduce memory access overhead. These solutions have, to some extent, optimized the deployment or fusion performance of quantized models.
[0003] However, the above scheme has a contradiction in low-bit fusion optimization scenarios: it cannot balance numerical semantic consistency and fusion benefits. If all intermediate quantization boundaries are mechanically retained, the meaning of reducing off-chip memory access is lost. If the boundaries are directly eliminated, the calibrated numerical behavior may be destroyed. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for maintaining and verifying the accuracy of AI inference chips, which can solve the problem in existing technologies where it is difficult to simultaneously maintain numerical semantics and achieve fusion benefits in low-bit operator fusion. The technical solution is as follows: On the one hand, a method for maintaining and verifying the accuracy of AI inference chips is provided, including: Step S1: Obtain the operator subgraph to be fused and its associated numerical precision configuration, wherein the operator subgraph contains multiple computing nodes in AI inference; recover the numerical semantic model based on the operator subgraph, wherein the numerical semantic model contains the precision constraint events corresponding to each computing node and the correlation between the precision constraint events; Step S2: When performing fusion optimization on the operator subgraph, determine the target boundary that needs to be retained after fusion from the precision constraint boundaries that are eliminated during the fusion process; Step S3: Establish counterfactual verification for the target boundary, construct a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics, perform numerical comparison on the two paths under the same input conditions, and determine whether the corresponding boundary is allowed to be omitted after fusion based on the comparison result; for target boundaries that are not allowed to be omitted, determine at least one candidate reproduction method. Step S4: Under the preset error constraints, security constraints, and hardware resource constraints of the target AI inference chip, the candidate reproduction methods of each target boundary that cannot be omitted are combined and optimized to determine the retained subset and its corresponding reproduction method; for the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets, and the precision constraint behavior of the corresponding boundary is reproduced in each variant using numerical operations in the non-main memory storage resources of the target chip. Step S5: Generate a machine-readable numerical error certificate for the generated fusion operator variant; the numerical error certificate contains the input application domain of the fusion operator variant and the corresponding error evidence, used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario; if not, adjust the constraints of the combinatorial optimization solution and re-execute steps S4 and S5 until the deployment requirements are met; Step S6: During the runtime phase, based on the runtime information of the current inference request and the input applicable domain of the numerical error certificate, select the target variant from the verified fusion operator variants to perform inference computation; when there is no input applicable domain covering the verified fusion operator variant of the current inference request, execute the conservative fallback path specified by the certificate or pre-verified.
[0005] On the other hand, an AI inference chip accuracy maintenance and verification device is provided, including: The semantic recovery module is configured to acquire the operator subgraph to be fused and its associated numerical precision configuration, wherein the operator subgraph contains multiple computing nodes in AI inference; and to recover the numerical semantic model based on the operator subgraph, wherein the numerical semantic model contains the precision constraint events corresponding to each computing node and the correlation between the precision constraint events. The boundary determination module is configured to determine the target boundary that needs to be retained after fusion from the precision constraint boundaries that are eliminated during the fusion process when performing fusion optimization on the operator subgraph. The counterfactual verification module is configured to establish counterfactual verification for the target boundary, construct a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics, perform numerical comparison on the two paths under the same input conditions, and determine whether the corresponding boundary is allowed to be omitted after fusion based on the comparison result; for target boundaries that are not allowed to be omitted, at least one candidate reproduction method is determined. The combinatorial optimization module is configured to perform combinatorial optimization on the candidate reproduction methods of each target boundary that cannot be omitted, under preset error constraints, security constraints and hardware resource constraints of the target AI inference chip, so as to determine the retained subset and its corresponding reproduction method; for the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets, and the precision constraint behavior of the corresponding boundary is reproduced in each variant using numerical operations in the non-main memory storage resources of the target chip; The certificate generation module is configured to generate a machine-readable numerical error certificate for the generated fusion operator variant. The numerical error certificate contains the input application domain of the fusion operator variant and the corresponding error evidence, which is used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario. If it does not meet the requirements, the module returns to the combinatorial optimization module. After adjusting the constraints of the combinatorial optimization solution, the combinatorial optimization solution and the generation of the numerical error certificate are re-executed until the deployment requirements are met. The runtime scheduling module is configured to select a target variant from verified fusion operator variants to perform inference computation based on the runtime information of the current inference request and the input applicable domain of the numerical error certificate during the runtime phase.
[0006] On the other hand, an AI inference chip compilation device is provided, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the AI inference chip accuracy maintenance and verification method described above.
[0007] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, the steps of the AI inference chip accuracy maintenance and verification method described above are implemented.
[0008] The technical solution provided by this invention can bring at least the following beneficial effects: This application effectively improves the controllability of the numerical behavior of low-bit fusion operators by restoring the numerical semantic model containing precision-constrained events during the compilation stage and performing counterfactual verification on the boundary of fusion elimination. More importantly, this solution transforms the boundary preservation decision into a combinatorial optimization problem under error, security, and resource constraints, and reproduces the necessary constraints in on-chip memory using numerical operations, thereby breaking the inherent contradiction between numerical semantic preservation and fusion performance optimization in traditional solutions. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 This is a flowchart of an AI inference chip accuracy maintenance and verification method provided in an embodiment of the present invention; Figure 2 This is a flowchart of a method for recovering a numerical semantic model provided in an embodiment of the present invention; Figure 3This is a flowchart of parallel numerical execution path comparison according to an embodiment of the present invention; Figure 4 This is a flowchart of generating error evidence according to an embodiment of the present invention; Figure 5 This is a structural diagram of the numerical error certificate binding relationship according to an embodiment of the present invention; Figure 6 This is a flowchart of the certificate domain scheduling process during the runtime phase of an embodiment of the present invention; Figure 7 This is a structural diagram of an AI inference chip accuracy maintenance and verification device according to an embodiment of the present invention; Figure 8 This is a hardware architecture diagram of an AI inference chip compilation device provided in an embodiment of the present invention. Detailed Implementation
[0011] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0012] As mentioned earlier, the fundamental reason for the contradictions faced by existing solutions in low-bit fusion optimization lies in the fact that existing solutions treat numerical accuracy as a static attribute or a post-verification indicator. However, the accuracy constraint boundaries eliminated during the actual fusion process themselves carry dynamic numerical semantic constraints—including quantization parameters, rounding strategies, and saturation behaviors established by the calibration process. Static, pre-defined quantization strategies cannot accurately determine at the compilation stage which boundaries can be reproduced at the register level through equivalent operations and which must be retained to maintain numerical correctness, resulting in a lack of verifiable numerical basis for fusion optimization decisions. Therefore, this application proposes a method to perform counterfactual determination of accuracy constraint boundaries at the compilation stage, reproduce necessary constraints on demand in on-chip resources, and generate numerical error evidence that can be verified at runtime, fundamentally breaking the deadlock between accuracy and performance.
[0013] Example 1 The following describes the specific implementation of the above concept.
[0014] like Figure 1 As shown in the figure, this application provides a method for maintaining and verifying the accuracy of AI inference chips. This method constructs a complete closed-loop process from semantic recovery in the compilation stage to safe scheduling in the runtime stage. Specifically, the method includes the following steps: Step S1 involves obtaining the operator subgraph to be fused and its associated numerical precision configuration. The operator subgraph contains multiple computation nodes in AI inference. A numerical semantic model is then recovered from the operator subgraph. This model includes precision constraint events corresponding to each computation node and the relationships between these events. Specifically, the numerical precision configuration includes not only data type definitions but also metadata such as quantization strategies, calibration parameters, and hardware numerical behavior descriptions. The recovered numerical event graph (NEG) differs from traditional pure computational data flow graphs. It explicitly models numerical events such as format conversion, quantization / dequantization, rounding, saturation pruning, and accumulated precision as first-class objects and records the causal relationships between these events before and after compilation transformation. Through this step, the compiler can accurately grasp all potential numerical constraint points in the operator subgraph before optimization begins, providing a complete semantic foundation for subsequent fusion decisions and avoiding precision misjudgments due to missing information.
[0015] Step S2 involves determining the target boundaries to be retained after fusion from the precision constraint boundaries eliminated during the fusion process, during which operator subgraphs undergo fusion optimization. During operator fusion, intermediate tensor write-back and overload operations that originally existed between independent kernels are eliminated, and the numerical boundaries attached to these operations also disappear. This step does not perform indiscriminate verification of all eliminated boundaries, but rather uses a pre-classification mechanism to filter out the target boundaries that truly require decision-making. For example, mandatory boundaries that would inevitably violate quantization semantics after deletion are directly retained; redundant boundaries that are equivalent to all valid inputs after deletion are directly eliminated; and only conditional boundaries whose deletion depends on the input domain range, error propagation characteristics, or hardware resource conditions are identified as target boundaries. This filtering mechanism effectively avoids wasting subsequent verification resources, allowing the compiler to focus on the key decision points that truly affect the trade-off between numerical correctness and performance.
[0016] Step S3 involves establishing counterfactual verification for the target boundary, constructing a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics. Under the same input conditions, the two paths are compared numerically, and the comparison results determine whether the corresponding boundary can be omitted after fusion. For target boundaries that cannot be omitted, at least one candidate reproduction method is determined. Counterfactual verification is an offline analysis process completed during the compilation phase, not during runtime. The reference execution path strictly follows the original quantization semantics or quantization-aware Golden semantics, preserving all original precision constraint operations; the candidate execution path simulates the actual numerical behavior after fusion, skipping some or all of the eliminated boundaries. By comparing the local errors, saturation behavior, and event set differences of the two paths on the same intermediate input domain, the compiler can quantitatively assess the impact of omitting a boundary on the final numerical result. If the comparison results show that the error is within an acceptable range and there is no safety risk, the boundary can be safely omitted; otherwise, the compiler needs to determine a candidate reproduction method for the boundary, such as performing an equivalent requant-dequant operation in a register or inserting a virtual quantization checkpoint in on-chip memory, thereby maintaining the necessary numerical semantics without writing back to main memory.
[0017] Step S4 involves combining and optimizing candidate reproduction methods for each target boundary that cannot be omitted, under preset error and safety constraints and the hardware resource constraints of the target AI inference chip, to determine the retained subset and its corresponding reproduction method. For the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets. In each variant, the precision constraint behavior of the corresponding boundary is reproduced using numerical operations in the non-main memory storage resources of the target chip. The goal of the combinatorial optimization is to minimize additional overhead while satisfying numerical correctness. This overhead includes additional instruction count, register usage, on-chip storage usage, format conversion latency, and pipeline congestion. Error constraints ensure that the upper bound of local error propagation in each computing node does not exceed the preset budget, safety constraints prevent anomalies such as NaN, Infinity, and overflow, and hardware resource constraints ensure that the implementation scheme is feasible within the physical limitations of the target chip. Based on the optimization results, the compiler generates multiple fusion operator variants, each corresponding to a specific boundary preservation strategy. The key is that all the precision constraints that are preserved are reproduced through numerical operations in non-main memory storage resources (such as register files or on-chip SRAM), thus preserving the core benefit of fusion optimization in reducing off-chip memory accesses while maintaining numerical semantics.
[0018] Step S5 involves generating a machine-readable Numerical Error Certificate (NEC) for the generated fusion operator variant. The NEC contains the input domain of the fusion operator variant and corresponding error evidence, used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario. If not, the constraints of the combinatorial optimization solution are adjusted, and steps S4 and S5 are re-executed until the deployment requirements are met. Furthermore, the NEC is bound to the code implementation of the fusion operator variant. When the code implementation of the fusion operator variant changes, the NEC becomes invalid, and step S5 must be re-executed to generate a new NEC. The NEC serves as a verifiable contract connecting the compilation-stage optimization with the runtime deployment. Its recorded input domain clarifies the input condition boundaries for the safe operation of the variant (such as tensor shape range, activation value amplitude, quantization scaling factor range, etc.), while the error evidence provides quantization proof that the numerical behavior within this domain conforms to expectations. This mechanism forms a self-verification closed loop during the compilation phase: if the certificate generated by the current optimization scheme cannot cover the actual deployment scenario or the accuracy is insufficient, the system will automatically adjust the constraints of the combined optimization solution and iterate the optimization and verification process again until a certificate that meets the requirements is generated. At the same time, the certificate is strongly bound to the specific code implementation; any code change will cause the original certificate to become invalid, fundamentally eliminating the risk of inconsistency between the verification object and the deployment object.
[0019] Step S6: During the runtime phase, based on the runtime information of the current inference request and the input applicability domain of the numerical error certificate, a target variant is selected from the verified fusion operator variants for inference computation. When no verified fusion operator variant for the current inference request has an input applicability domain covering it, a conservative fallback path specified in the certificate or pre-verified is executed. The runtime scheduling module extracts lightweight statistical information (such as quantization scaling factor, maximum absolute value, etc.) from the current inference request and determines whether it falls within the input applicability domain of a verified certificate with minimal overhead. If it does, a lightweight variant with fewer conditionally reserved boundaries in the reserved subset is selected for execution to achieve optimal performance; if it does not, it automatically switches to a full variant that retains more boundaries or uses higher precision accumulation to ensure numerical safety. This certificate-based deterministic scheduling mechanism enables the system to maximize inference performance for normal inputs without sacrificing safety, and automatically degrade to ensure correctness under abnormal inputs, achieving a dynamic balance between accuracy, performance, and safety.
[0020] In one specific embodiment, this embodiment further details the specific implementation of restoring the numerical semantic model based on the operator subgraph in step S1, and the classification logic for determining the target boundary in step S2.
[0021] like Figure 2 As shown, the recovery of the numerical semantic model is not based on a single information source, but rather on constructing a complete numerical semantic tracing link by fusing multi-level data. Specifically, step S1, which involves recovering the numerical semantic model based on the operator subgraph, includes the following sub-steps: Step S11: Obtain the quantization strategy, weight scaling factor (scale), and calibration parameters from the numerical precision configuration as model-level sources. Model-level sources represent the algorithm designer's original intent regarding numerical behavior. For example, the quantization strategy defines whether per-tensor or per-channel quantization is used, and the calibration parameters record the statistical distribution range of the activation values. This information constitutes the top-level constraints of numerical semantics, determining the precision benchmark that all subsequent computation nodes should follow. Without this level of information, the compiler will be unable to distinguish whether a floating-point multiplication is a high-precision computation or a quantized simulation computation.
[0022] Step S12 involves obtaining the operator-level source from the input-output precision contract, internal accumulation precision, and reduction order of each computation node in the operator subgraph. The operator-level source describes the numerical behavior specification of the operator at an abstract level. For example, for a matrix multiplication operator, its precision contract might stipulate that the output must be an INT32 accumulation result; for the Softmax operator, its reduction order might affect the associative law result of floating-point addition. This hierarchical information fills the semantic gap between model configuration and specific implementation, ensuring that the numerical behavior within the operator conforms to the framework definition.
[0023] Step S13 involves extracting the instruction sequence, vectorization method, register residency, and device math functions from the compilation artifacts corresponding to the operator subgraph as kernel-level sources. Kernel-level sources reflect the physical numerical behavior after code generation. Due to limitations or optimizations in the hardware instruction set, the actual numerical operations performed may differ from the abstract definitions. For example, the rsqrt implementation in the device math function library may use an approximation algorithm, and vectorized instructions may alter the accumulation order. By parsing the compilation artifacts, the numerical semantic model can capture these actual numerical events introduced by hardware characteristics, preventing the verification benchmark from becoming disconnected from actual execution.
[0024] Step S14 involves obtaining fusion, reassociation, common subexpression elimination, layout transformation, and mixed-precision compilation passes from the compilation optimization process corresponding to the operator subgraph as compilation-level sources. These compilation-level sources record the dynamic modifications to numerical semantics caused by optimization transformations. Each compilation pass may introduce, remove, or rearrange numerical events. For example, a fusion pass eliminates write-back and overloading of intermediate tensors, as well as implicit truncation or rounding events attached to that operation; a reassociation pass may change the associativity order of floating-point operations for parallelization. This hierarchical information is crucial for establishing cross-level causal relationships, enabling the compiler to trace the source of changes to a low-level numerical event.
[0025] After acquiring information from multiple sources, step S15 is executed to map the precision constraint events from each source to the numerical semantic model. Each precision constraint event records its original identifier and its target identifier after downgrading, forming a cross-level causal relationship. Specifically, each node in the numerical semantic model not only includes the event type (such as format conversion CAST, quantization QUANTIZE, rounding ROUND, saturation CLIP, etc.) and its attributes (such as scaling factor granularity, rounding mode, overflow strategy), but also points to its original definition in the model IR or operator family IR through origin_id, and points to its actual implementation position in the Kernel IR or instruction sequence through lowered_id. This bidirectional mapping mechanism allows the compiler to trace back the high-level numerical semantic intent it carries when facing low-level code; at the same time, when analyzing high-level graph transformations, it can also predict their specific impact on low-level numerical behavior. Through this mechanism, the numerical semantic model is no longer a static annotation, but a dynamic semantic carrier that runs through the entire compilation process, providing a traceable and verifiable data foundation for subsequent boundary determination and counterfactual verification.
[0026] Furthermore, when performing fusion optimization on the operator subgraph, to avoid wasting resources by indiscriminately verifying all eliminated boundaries, step S2 determines the target boundaries that need to be retained after fusion using a three-state classification logic, specifically including the following sub-steps: Step S21: Among the eliminated precision constraint boundaries, those boundaries that, upon deletion, would necessarily alter the defined quantization semantics, overflow strategies, or integer equivalence relations are identified as mandatory retention boundaries after fusion; these boundaries are marked as mandatory retention boundaries. For example, the requant operation from the INT32 accumulator to the INT8 output in the INT8 quantization path, if deleted, would directly violate the numerical definition of the quantization model; similarly, the saturation pruning operation to prevent the propagation of non-N (NaN) or infinite (Inf), if deleted, might lead to undefined behavior in subsequent calculations. For MANDATORY boundaries, the compiler does not need to perform counterfactual verification; it directly retains them in the fusion operator or reproduces them in an equivalent manner, thereby ensuring that the bottom line of numerical safety is not breached.
[0027] Step S22 identifies boundaries that, after removal, maintain the same numerical semantics across all allowed input domains and do not exhibit subsequent amplification as removable boundaries after fusion; these boundaries are marked as removable boundaries. Examples include two redundant format conversions performed consecutively under the same data type and scaling factor, or mathematically provable identities in pack / unpack operations. Since removing these boundaries does not introduce additional errors or alter numerical results under any valid input, the compiler can directly eliminate them without consuming verification resources. This step effectively reduces the size of the problem to be verified, allowing optimization to focus on truly uncertain decision points.
[0028] Step S23 identifies boundaries whose deletion is permissible based on the input domain range, error propagation characteristics, or hardware resource conditions as conditional boundaries requiring further judgment. These boundaries are marked as conditional boundaries and are the core objects of counterfactual verification in this application. For example, the requant boundary in the middle of the FP8 fusion operator: when the input value is in the linear region of the dynamic range, skipping this boundary may only introduce a small error without overflow; however, when the input value is close to the saturation region, skipping this boundary may lead to serious precision loss or numerical anomalies. Similarly, the safety of intermediate cast boundaries after certain reduction operations depends on the sensitivity of subsequent operators and the current error accumulation state. By identifying these boundaries as target boundaries, the compiler can initiate a targeted counterfactual verification process, accurately determining their retention or rejection under specific input domains and error budgets, thereby maximizing fusion benefits while ensuring numerical correctness. This three-state classification mechanism is essentially a hierarchical filtering strategy that separates deterministic problems from uncertain problems, avoiding the extreme "full retention" or "full deletion" strategies adopted in traditional schemes due to the inability to distinguish boundary properties, thus laying the foundation for refined numerical semantic preservation.
[0029] After determining the target boundary that needs to be retained after fusion in the above embodiments, this embodiment further describes in detail the specific construction method of counterfactual verification in step S3, and the objective function and constraint system of combinatorial optimization solution in step S4.
[0030] like Figure 3 As shown, the core of establishing counterfactual verification of the target boundary in step S3 lies in constructing two parallel numerical execution paths and completing the comparison offline during the compilation phase, rather than performing dynamic branching judgments during the runtime phase. Specifically, a reference execution path is constructed, which executes the original quantization semantics or quantization-aware Golden semantics, while retaining all numerical operations of the original precision constraint boundary. Here, the reference execution path does not refer to the original high-precision floating-point model during training, but rather to a quantization-aware Golden model that accurately simulates the low-bit hardware numerical behavior of the target. For example, for the FP8 fusion operator, the reference path will explicitly insert scaling factors consistent with the target hardware in the FP32 computing environment, including scaling, rounding, clipping, and requantizing operations, thereby establishing a benchmark that has both high precision and debuggability and strictly follows the low-bit numerical definition. This design ensures that the benchmark for subsequent comparisons is "correct low-bit behavior" rather than "ideal high-precision behavior," avoiding misjudging the model's own quantization loss as an implementation error introduced by fusion.
[0031] Simultaneously, candidate execution paths are constructed to execute the fused numerical semantics and skip some or all precision constraint boundaries. These candidate execution paths reflect the actual numerical behavior of the fused kernels that the compiler attempts to generate. In these paths, intermediate quantization boundaries that originally existed between independent kernels are removed, and intermediate tensors may be directly passed in registers at higher precision (e.g., BF16 or FP32). Numerical comparisons are performed by comparing local errors, saturation behavior, and event set differences between the reference and candidate execution paths using the same intermediate input domain. Specifically, the compiler selects a set of typical intermediate activation values covering the applicable domain of the reference input as test stimuli and injects them into both paths. The comparison of local errors focuses not only on the absolute or relative difference of the output values but also on the distribution characteristics of the errors; the comparison of saturation behavior is used to detect whether the candidate path generates outliers that should have been truncated in subsequent calculations due to skipping clip boundaries; and the comparison of event set differences is used to verify whether the candidate path has omitted key numerical semantic operations (such as specific rounding mode switching). Only when all three comparison results indicate that the candidate path is numerically equivalent to the reference path or the error is controllable within the given input domain, is the corresponding target boundary deemed acceptable for omission. This dual-path counterfactual verification mechanism allows the compiler to quantitatively and accurately predict the impact of fusion operations on numerical behavior without actually deploying code, providing solid data support for subsequent optimization decisions.
[0032] For target boundaries that are determined by counterfactual verification to be non-negotiable, step S4 incorporates them into the combinatorial optimization solution framework. It is important to emphasize that this combinatorial optimization solution is performed offline during the compilation phase, not in real-time during runtime. Its purpose is to determine the optimal boundary preservation strategy before generating the final kernel code. Specifically, the objective function of the combinatorial optimization solution is to minimize the additional overhead of the preserved subset. This additional overhead includes at least one of the following: additional instructions, register usage, on-chip memory usage, format conversion latency, and pipeline congestion. This means that the optimizer does not simply preserve all necessary boundaries, but rather seeks the combination with the lowest cost among various feasible reproduction methods (such as in-register requantization, on-chip SRAM temporary storage, virtual quantization checkpoints, etc.). For example, for a certain FP8 requant boundary that must be preserved, using the in-register immediate requant-dequantization method, while eliminating on-chip memory access overhead, increases the number of instructions and pipeline pressure; using on-chip SRAM temporary storage reduces the number of instructions but increases memory access latency. The optimizer quantizes and evaluates the combined overhead of each method based on the target chip's microarchitecture model, thereby selecting the globally optimal solution.
[0033] While minimizing overhead, combinatorial optimization solutions are subject to strict constraints to ensure that the generated variants are numerically safe and correct. These constraints include error constraints, safety constraints, and hardware resource constraints. The error constraint ensures that the upper bound of local error propagation at each computation node in the fusion operator variant does not exceed a preset error budget. This upper bound is determined by the input error, quantization error, rounding error, accumulation error, and the local amplification factor of the corresponding computation node within the applicable input domain. Specifically, for each computation segment in the fusion operator, the compiler calculates its error propagation upper bound based on a numerical semantic model. This upper bound includes not only the quantization, rounding, and accumulation errors introduced by the segment itself but also the amplified component of the input error from previous stages. The local amplification factor can be obtained through operator analytical upper bounds, interval analysis, or offline sampling statistics. For example, for highly sensitive operators such as Softmax, the gradient is extremely large when the input value is close to zero, and the local amplification factor is significantly higher than in the linear region. Therefore, the optimizer allocates a tighter error budget or forces the preservation of more boundaries when processing such operators to prevent error explosion. This refined error constraint based on local propagation characteristics avoids the problems of over-conservatism or local loss of control caused by using a globally uniform error threshold in traditional schemes.
[0034] Safety constraints prevent the generation of non-NaN, infinity (Inf), numerical overflow, or saturation exceeding device limits. This is a hard constraint with higher priority than performance optimization. During the solution process, any boundary-preserving subsets that might lead to numerical anomalies will be pruned directly. For example, if a candidate path generates infinity (Inf) by skipping saturation boundaries in a specific input domain, it will be deemed infeasible even if it has the lowest performance overhead. Hardware resource constraints ensure that register usage and on-chip memory usage do not exceed the upper limit of the target chip. This constraint ensures the physical feasibility of the optimization results. Since fusion operators are typically designed to maximize data locality, their register and on-chip memory requirements often approach hardware limits. The optimizer must monitor resource usage in real time while searching for reserved subsets to prevent register overflows or on-chip memory bandwidth bottlenecks caused by inserting too many VQC operations. Through the combined effect of the objective function and the three types of constraints, combinatorial optimization transforms the precision preservation problem into a formally solvable resource scheduling problem. This allows the compiler to automatically search for the optimal fusion operator implementation while ensuring numerical safety and correctness, thus breaking the traditional trade-off between precision and performance.
[0035] After completing the combinatorial optimization solution and generating the fusion operator variant in the above embodiments, this embodiment further describes in detail the evidence structure, binding mechanism and input application domain of the numerical error certificate generated in step S5.
[0036] like Figure 4As shown, generating error evidence involves acquiring two independent types of error data through a first reference path and a second reference path. Specifically, through the first reference path, the actual output of the fusion operator variant is compared with the high-precision computational output of the quantization simulation under the same input to obtain implementation error evidence. Here, the first reference path refers to the quantization-aware Golden model that accurately simulates the numerical behavior of the target low-bit hardware (such as the scaling factors of FP8, such as scale, round, and clip), and its function is to verify whether the fusion operator variant correctly implements the predetermined low-bit numerical semantics. Simultaneously, through the second reference path, the output of the low-bit model is compared with the output of the high-precision model before quantization under the same input to obtain quantization deviation evidence. Here, the second reference path refers to the original FP32 or BF16 high-precision model, and its function is to observe the inherent accuracy loss of the low-bit model itself relative to the high-precision benchmark. Implementation error evidence is used to characterize the implementation deviation of the fusion operator variant relative to the predetermined finite-precision numerical semantics, and quantization deviation evidence is used to characterize the inherent deviation of the finite-precision model relative to the high-precision model before quantization. Implementation error evidence and quantization deviation evidence together constitute error evidence, and the two are recorded independently. The technical significance of this separate recording mechanism lies in its clear distinction between "implementation errors introduced by the compiler" and "inherent deviations caused by model quantization." In traditional verification schemes, if only the difference between the final output and the high-precision model is compared, the compiler may mistakenly attribute the model's own quantization loss to implementation defects in the fusion operator, leading to unnecessary boundary preservation or incorrect certificate issuance. Through independent recording, the system can accurately determine whether the fusion operation is correctly executed within the allowable error range of the quantization model, avoiding overly conservative optimization or incorrect release due to attribution confusion. The aforementioned implementation error evidence and quantization deviation evidence, after separate recording, constitute the error evidence for the numerical error certificate within the applicable input domain; this, along with the strong identity identifier generated from the binding information, forms a complete numerical error certificate, such as... Figure 5 As shown.
[0037] Furthermore, such as Figure 5 As shown, the numerical error certificate consists of two parts: first, a strong identity identifier generated from the binding information, ensuring the certificate's uniqueness and version locking; and second, error evidence characterizing the numerical error boundary within the applicable input domain. Figure 4 The two reference paths are generated. At least one of the binding information includes: model hash, computation graph hash, intermediate representation hash, compilation pass sequence hash, kernel binary hash, quantization configuration version, reference implementation version, and device numerical behavior configuration version. For example... Figure 5As shown, this binding information constitutes a strong identity identifier for the certificate. Specifically, the model hash ensures that the certificate is only applicable to a specific version of the model weight and structure; the compilation pass sequence hash and kernel binary hash lock the specific compilation path and code implementation that generated the certificate; and the device numerical behavior configuration version ensures that the certificate is only valid on hardware firmware with the same numerical operation characteristics. The numerical error certificate also includes signature information for machine-readable verification, preventing the certificate content from being tampered with. When any of the above binding information changes, the original numerical error certificate becomes invalid and triggers regeneration. This invalidation chain mechanism is the core technical means of this application to ensure deployment security. In actual engineering iterations, model fine-tuning, compiler upgrades, or firmware updates may all lead to subtle changes in numerical behavior. If the old certificate is used, there may be a risk of evidence drift, such as "verifying code A but deploying code B". By including all critical artifacts in the binding scope and establishing an automatic invalidation mechanism, the system forces the verification process to be re-executed after any element changes, thereby ensuring that the certificate used during the runtime phase is always strictly consistent with the currently executed code and environment, fundamentally eliminating numerical security incidents caused by version mismatch.
[0038] In addition, such as Figure 5As shown, the input applicability domain is jointly defined by at least one of the following: tensor shape range, activation value amplitude statistics, quantization scaling factor range, and finite number preconditions. The input applicability domain defines the safe operating space guaranteed by the certificate; error evidence in the certificate (including the aforementioned implementation error evidence and quantization deviation evidence) is considered valid only when the input during the runtime falls within this domain. Specifically, the tensor shape range limits the dimensional boundaries of the operator processing; activation value amplitude statistics (such as maximum absolute value amax or percentiles) constrain the dynamic range of the input data, preventing saturation or overflow due to exceeding the calibration interval; the quantization scaling factor range ensures the validity of the quantization parameters; and the finite number preconditions exclude interference from abnormal inputs such as non-NaN or infinite Inf. For special architectures in large model inference, the input applicability domain is also specifically extended. When the operator subgraph corresponds to a hybrid expert model, the input applicability domain also includes the number of expert tokens or the route distribution range. This is because the activation frequencies and workloads of different experts in the MoE (Mixture of Experts) model vary greatly. Global statistics alone cannot accurately characterize the numerical behavior of a single expert; routing-level constraints must be introduced to ensure the validity of certificates in sparse activation scenarios. When the operator subgraph corresponds to a long-context attention mechanism, the input domain also includes sequence length or KVCache statistics. In long-context scenarios, the numerical distribution of attention scores changes significantly with sequence length, and the cumulative error of KVCache may amplify with increasing length. Therefore, the sequence dimension must be included in the domain definition to avoid misusing lightweight variants applicable only to short texts during inference with extremely long texts. Through this multi-dimensional construction of the input domain, numerical error certificates can accurately adapt to complex and ever-changing real-world deployment scenarios, providing fine-grained judgment criteria for runtime security scheduling.
[0039] Based on the numerical error certificate generated in the above embodiments, this embodiment further details the error budget allocation mechanism within the fusion operator family, the specialized processing strategies for different low-bit data types, and the runtime variant selection logic based on the certificate.
[0040] When a fusion operator variant covers multiple logic operators, it also includes defining a total error budget for each logic operator within the fusion operator variant. This total error budget is then weighted and allocated to each logic operator stage based on at least one of subsequent output sensitivity, reduction amplification factor, or calibration statistics. During combinatorial optimization, the error budget allocated to each stage is used as part of the error constraints. Specifically, fusion operators are typically composed of multiple heterogeneous computational units connected in series, such as matrix multiplication followed by bias addition and activation functions. Since different computational units have significantly different sensitivities to numerical errors, applying a uniform error threshold across the entire chain during combinatorial optimization often leads to overly lenient constraints on sensitive stages, causing accuracy collapse, or overly strict constraints on insensitive stages, sacrificing unnecessary performance. By introducing a weighted allocation mechanism, the compiler can dynamically adjust the error tolerance of each stage according to the data flow. For example, in subsequent computation stages involving high gradient-sensitive operators such as Softmax or RMSnorm, due to their large local amplification factors, the system allocates a tighter error budget, forcing the retention of more precision constraint boundaries or employing higher-precision reproduction methods. Conversely, for subsequent stages involving only linear transformations or those within the error-masking region, the budget can be appropriately relaxed, allowing the omission of some non-critical boundaries. This semantically sensitive, refined budget allocation enables combinatorial optimization to maximize the performance potential of fusion operators while ensuring overall accuracy safety, avoiding the suboptimal solution problem caused by traditional globally unified constraints.
[0041] Numerical precision configuration includes at least one of the following data types, each corresponding to different precision constraint events and candidate reproduction methods. Due to the fundamental differences in the physical representation and numerical behavior of different low-bit data types, general precision preservation strategies cannot be directly adapted to all scenarios. Therefore, this application establishes a customized event modeling and reproduction system for mainstream low-bit types. For the FP4 data type, precision constraint events include group scaling factor (scale), narrow dynamic range saturation, and pack / unpack events. The corresponding candidate reproduction methods include virtual quantization of the group scaling factor (scale) and on-chip pack semantic preservation. The FP4 format has an extremely narrow dynamic range and extremely high compression ratio, and its numerical correctness highly depends on fine-grained group-level scaling factors. Simply eliminating the group scaling factor (scale) boundary during the fusion process can easily lead to numerical overflow or underflow. Therefore, the candidate reproduction method specifically designs a virtual quantization operation for the group scaling factor (scale), which simulates group scaling and truncation behavior within the register while maintaining the bit-level semantics of pack / unpack, ensuring that the unique numerical distribution characteristics of FP4 are maintained without writing back to main memory. For FP8 data types, precision constraint events include E4M3 or E5M2 format conversion, per-tensor or per-channel scaling, rounding, and saturation events. Corresponding candidate reproduction methods include in-register requant-dequant operations. FP8 inference often involves dynamic conversion between multiple formats and fine-grained channel-level quantization. To avoid writing intermediate results to disk, the system directly inserts equivalent requant-dequant instruction sequences into the register file, utilizing hardware-native low-latency weighting instructions to reproduce the original rounding and saturation behavior, thereby eliminating HBM memory access while ensuring strict equivalence of FP8 numerical semantics. For INT8 data types, precision constraint events include zeropoint, INT32 accumulation, and requant events. Corresponding candidate reproduction methods include INT32 to FP32 or INT8 requant semantic preservation. The core challenge of INT8 quantization lies in zero-point offset handling in asymmetric quantization and accumulator bit width management. The candidate reproduction method explicitly requires that the INT32 accumulation process be fully preserved in the on-chip resources, and that a requant operation including zero-point compensation be strictly performed before conversion to the output format to prevent systematic deviations caused by accumulator truncation or zero-point loss. Through the above-mentioned deep adaptation for specific data types, this application ensures that the precision constraint preservation mechanism can accurately respond to the underlying physical characteristics of various low-bit formats, rather than remaining at the level of abstract mathematical equivalence.
[0042] After generating the numerical error certificate through the aforementioned steps, as follows: Figure 6As shown, in step S6, the target variant is selected based on the runtime information of the current inference request during the runtime phase. Specifically, this includes extracting the quantization scaling factor (scale), maximum absolute value (amax), or lightweight statistics from the current inference request during the runtime phase to determine whether it falls within the input application domain of the numerical error certificate. This determination process is designed as a low-overhead metadata matching operation, rather than complex numerical computation. The Dispatcher can directly read key statistics such as maximum absolute value (amax) and scaling factor (scale) from the tensor descriptor or pre-computed header information and perform a simple numerical comparison with the predefined domain boundaries in the certificate. If it falls within the input application domain, a lightweight variant with fewer conditionally reserved boundaries in the reserved subset is selected for execution. The conditionally reserved boundaries are target boundaries that need to be retained in the reserved subset based on the input domain range, error propagation characteristics, or hardware resource conditions. The lightweight variant achieves the highest throughput and lowest latency during the runtime phase because the safety of omitting some boundaries within a specific input domain is verified during the compilation phase. If the input does not fall within the applicable domain, the full variant with a higher number of conditionally reserved boundaries in the reserved subset is selected for execution. The full variant reproduces the precision constraint behavior in non-main memory storage resources using candidate reproduction methods for some or all conditionally reserved boundaries. When the input exceeds the certificate-guaranteed safety range during runtime, the system automatically switches to a more conservative full variant. Although this variant incurs a slight performance penalty under normal conditions due to retaining more precision constraint operations, it effectively mitigates numerical risks caused by abnormal inputs by explicitly reproducing critical boundaries in registers or on-chip SRAM. If no verified variant in the system has an applicable domain that covers the current inference request, a pre-verified conservative fallback path is executed. This fallback path uses operators that are not fused or only retain mandatory boundaries to ensure numerical correctness. This certificate-domain-based deterministic scheduling mechanism decouples performance and safety: it enjoys a lightweight path with extreme optimization in the vast majority of expected inference requests, and automatically degrades to a safe path only in a few edge cases, thereby maximizing the performance gains of low-bit fusion optimization while ensuring end-to-end numerical reliability.
[0043] Building upon the foregoing embodiments, this application further provides specific implementation methods for typical fusion scenarios in large-scale model inference. The operator subgraph corresponds to at least one of the following fusion scenarios: residual connection and normalization fusion, where a calibration-defined precision constraint boundary exists after residual addition, and counterfactual verification determines whether this boundary needs to be reproduced in the register; query-key-value projection and rotational position encoding fusion, where Q and K use different scaling factors (scale or dtype), independent counterfactual verifications are established, and different error budgets are set based on the sensitivity of subsequent attention scores; and feedforward network fusion of hybrid expert models, where different experts use different group scaling factors (scale), and counterfactual verifications are established for the intermediate precision constraint boundaries of each expert. These scenarios cover the most representative numerically sensitive regions in the current mainstream Transformer architecture, and through targeted precision constraint preservation strategies, effectively solve the numerical semantic drift problem caused by general fusion optimization in specific business operators.
[0044] Specifically, in the residual connection and normalization fusion scenario, the core challenge lies in the fact that after the residual addition operation, there is often an FP8 precision constraint boundary explicitly defined by the quantization calibration process. In the unfused original execution path, the result of the residual addition is written back to main memory and reloaded, a process that naturally enforces the rounding and saturation behavior defined by this FP8 boundary. However, when the residual addition and the subsequent RMSnorm operator are fused into a single kernel, the intermediate result may be directly passed in registers in high-precision BF16 or FP32 format, causing the calibration-defined boundary to be implicitly eliminated. Although high-precision passing seems more accurate from a purely mathematical perspective, it actually undermines the numerical distribution assumptions established by the quantization model during the calibration phase, potentially causing the output of subsequent layers to deviate from expectations. In this embodiment, the numerical semantic model explicitly records the optional requant event and its attributes after the residual addition. The compiler establishes counterfactual verification for this boundary: the reference path strictly executes the requant and subsequent dequant operations, simulating the original quantization behavior; the candidate path skips this boundary and directly uses the high-precision intermediate value. If, within the input domain defined by the numerical error certificate, the local error of the candidate path relative to the reference path and the subsequent amplification effect both meet the preset error budget, then the boundary is deemed omitting. Otherwise, the compiler will insert an equivalent requant-dequant instruction sequence into the register in the generated fusion operator variant to reproduce the boundary behavior. This mechanism ensures that fusion optimization does not unintentionally tamper with the carefully calibrated numerical semantics, while avoiding the performance loss caused by mechanically preserving the boundary in all cases.
[0045] In the scenario of query-key-value projection and rotation position encoding fusion, the main technical challenge stems from the heterogeneity of the numerical characteristics of the Q-path and the K-path. In actual deployments, the Q and K tensors may use different quantization scaling factors (scale), data types (e.g., Q is E4M3 while K is E5M2), and even have different dynamic range distributions. If a unified precision constraint strategy is adopted, it is often impossible to simultaneously ensure the numerical safety of both. To address this characteristic, this embodiment models the requant, dequant, sin / cos multiplication-addition precision in RoPE rotation position encoding, and output cast operations of Q and K as independent event nodes in the numerical semantic model. Based on this, the system establishes independent counterfactual verification anchors for the Q-path and K-path respectively, rather than treating them as a whole. More importantly, in the combinatorial optimization solution stage, differentiated error budgets are dynamically allocated based on the differences in the sensitivity of Q and K to subsequent attention score calculations. For example, since the numerical stability of the K-path directly affects the denominator calculation of Softmax, its amplification effect on errors is usually higher than that of the Q-path. Therefore, the system allocates a stricter error budget to the K-path, forcing the retention of more precision constraint boundaries or adopting a higher-precision reproduction method; while for the relatively robust Q-path, constraints can be appropriately relaxed in exchange for performance. In addition, the generated numerical error certificate also incorporates the sequence length, head_dim, Q / K activation value amplitude, and scaling factor scale range into the definition of the input applicable domain, preventing the misuse of lightweight variants that are only applicable to normal scenarios under extremely long contexts or abnormal input amplitudes. Through this fine-grained differentiation processing, this embodiment maximizes the inference throughput of the QKV fusion operator while ensuring the numerical stability of the attention mechanism.
[0046] In feedforward network fusion scenarios involving hybrid expert models, the complexity of preserving accuracy constraints further increases to the expert level. Different expert networks in the MoE architecture often employ independent quantization parameters, especially when using extremely low-bit formats such as FP4, where each expert may have completely different group scaling factor (scale) configurations. If all experts' FFNs are merged into a single large kernel or a globally uniform accuracy strategy is adopted, it is highly susceptible to accuracy collapse for some experts due to neglecting the numerical heterogeneity among experts. In this embodiment, the numerical semantic model independently and completely records each expert's weightdequant, group scaling factor (scale) application, intermediate quantization boundaries of the activation function, accumulated accuracy of the two GEMMs, and outputrequant. For intermediate accuracy constraint boundaries that may be eliminated by fusion in each expert path (e.g., FP8requant after the activation function), the system establishes independent counterfactual verifications. This means that optimization decisions are no longer globally uniform but are evaluated individually for each expert's specific numerical behavior. A lightweight variant without VQC will only be generated for a specific expert if the numerical error certificate proves that removing a certain intermediate boundary still satisfies that expert's error budget and saturation conditions. Otherwise, the corresponding virtual quantization checkpoint will be reserved for that expert in on-chip memory or registers. This expert-level fine-grained verification mechanism allows the MoE model to enjoy the memory access benefits of fusion optimization while ensuring that the numerical behavior of each expert branch strictly conforms to its independent quantization calibration specifications, thereby guaranteeing the reliability and consistency of the overall inference results of the MoE model.
[0047] It should be understood that the three fusion scenarios described above are merely illustrative examples and are not intended to limit the scope of protection of this application. In practical applications, the accuracy constraint preservation and verification method of this application can also be extended to other fusion scenarios involving low-bit numerical computation, such as the fusion of LayerNorm and linear layers, and the internal fusion of SwiGLU activation functions. As long as there are numerical semantic boundaries that may be eliminated during the fusion process, a balance between accuracy and performance can be achieved by constructing a numerical semantic model, performing counterfactual verification, and generating numerical error certificates.
[0048] Example 2 like Figure 7As shown in the figure, this application provides an AI inference chip precision preservation and verification device. This device achieves a complete technical closed loop from semantic analysis in the compilation stage to secure scheduling in the runtime stage through a modular architecture. Specifically, the device includes a semantic recovery module 71, a boundary determination module 72, a counterfactual verification module 73, a combinatorial optimization module 74, a certificate generation module 75, and a runtime scheduling module 76. The modules cooperate through clearly defined data interfaces to jointly support the precision preservation and performance optimization of low-bit fusion operators.
[0049] The semantic recovery module 71 is configured to acquire the operator subgraph to be fused and its associated numerical precision configuration. The operator subgraph contains multiple computation nodes in AI inference. Based on the operator subgraph, it recovers the numerical semantic model, which includes the precision constraint events corresponding to each computation node and the relationships between these events. Specifically, as the data foundation of the entire device, the semantic recovery module is responsible for aggregating heterogeneous information from multiple levels, including model configuration, operator contracts, compilation artifacts, and optimization passes, and mapping it uniformly into a numerical event graph containing the original identifier and the target identifier after downgrading. This module not only parses static quantization parameters but also dynamically tracks the modifications to numerical semantics caused by compilation transformations, thereby establishing cross-level causal relationships throughout the entire compilation process and providing traceable and verifiable semantic input for subsequent modules.
[0050] The boundary determination module 72 is configured to determine the target boundaries that need to be retained after fusion from the precision constraint boundaries eliminated during the fusion process when performing fusion optimization on the operator subgraph. After receiving the numerical semantic model output by the semantic recovery module, the boundary determination module acts as a key decision filter. Based on a pre-set three-state classification logic, it automatically identifies which boundaries are mandatory boundaries that must be retained and which are redundant boundaries that can be safely removed, and filters the conditional boundaries that truly need further verification into a list of target boundaries and passes it to downstream modules. This hierarchical filtering mechanism effectively reduces the search space for subsequent counterfactual verification, allowing the device's computational resources to focus on the key decision points that truly affect the trade-off between numerical correctness and performance.
[0051] The counterfactual verification module 73 is configured to establish counterfactual verification for the target boundary, constructing a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics. Under the same input conditions, it performs a numerical comparison between the two paths and determines whether the corresponding boundary can be omitted after fusion based on the comparison results. For target boundaries that cannot be omitted, it determines at least one candidate reproduction method. This module is the core analysis engine of the device, which builds a parallel dual-path execution environment offline during the compilation phase. The reference path strictly simulates quantization-aware Golden semantics, while the candidate paths reflect the actual numerical behavior after fusion. By comparing local errors, saturation behavior, and event set differences within the applicable domain of the certificate input, the module can quantitatively assess the safety of boundary omission. For boundaries determined to be indispensable, the module also generates multiple candidate reproduction methods, such as in-register requantization and on-chip SRAM temporary storage, based on the microarchitecture characteristics of the target chip, providing feasible implementation options for subsequent optimization solutions.
[0052] The combinatorial optimization module 74 is configured to perform combinatorial optimization on candidate reproduction methods for each target boundary that cannot be omitted, under preset error constraints, safety constraints, and hardware resource constraints of the target AI inference chip, to determine the retained subset and its corresponding reproduction method. For the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets. In each variant, the precision constraint behavior of the corresponding boundary is reproduced through numerical operations in the non-main memory storage resources of the target chip. This module receives the set of candidate reproduction methods output by the counterfactual verification module and transforms it into a resource scheduling problem with multiple constraints. Under the premise of satisfying error budget, numerical safety, and hardware physical constraints, the module uses a search algorithm to find the combination of retained subsets with the minimum additional overhead. Based on the optimization results, the module directly drives the code generator to produce multiple fusion operator variants, ensuring that all retained precision constraint behaviors are implemented through numerical operations in non-main memory storage resources, thereby maximizing the memory access benefits of fusion optimization while maintaining numerical semantics.
[0053] The certificate generation module 75 is configured to generate machine-readable numerical error certificates for the generated fusion operator variants. The numerical error certificate contains the input domain of the fusion operator variant and corresponding error evidence, used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario. If it does not, the module returns to the combinatorial optimization module, adjusts the constraints of the combinatorial optimization solution, and re-executes the combinatorial optimization solution and the generation of the numerical error certificate until the deployment requirements are met. This module is not only a recorder of verification results but also the control center of the self-verification closed loop during the compilation phase. It encapsulates the input domain and error evidence into a strongly bound certificate object and continuously monitors the verification status. If the current certificate cannot cover the actual deployment requirements or the accuracy is not up to standard, the module automatically triggers a feedback mechanism, adjusts the retained subset, and drives the combinatorial optimization module and itself to iterate again until a certificate that meets the requirements is generated. Simultaneously, the module's built-in failure chain mechanism ensures that any code or environmental changes will cause the original certificate to automatically become invalid, fundamentally preventing the risk of inconsistency between the verification object and the deployment object.
[0054] The runtime scheduling module 76 is configured to select a target variant from verified fusion operator variants for inference computation during the runtime phase, based on the runtime information of the current inference request and the input applicability domain of the numerical error certificate. As the execution agent of the device during the runtime phase, this module extracts lightweight statistical information such as the quantization scaling factor (scale) and the maximum absolute value (amax) from the inference request with extremely low overhead and matches it against the predefined input applicability domain in the certificate. If a match is successful, it distributes the request to a lightweight variant with fewer conditional boundary reservations to achieve optimal performance; if a match fails, it automatically switches to a full variant that retains more boundaries or uses higher-precision accumulation to ensure numerical safety. This certificate-based deterministic scheduling mechanism enables the device to maximize inference performance for normal inputs without sacrificing safety, and automatically degrades to ensure correctness under abnormal inputs.
[0055] It should be understood that the above module division is only an example of logical function. In actual engineering implementation, the modules can be integrated, split, or deployed in a distributed manner. For example, the semantic recovery module and the boundary determination module can be merged into a unified semantic analysis front-end; the combinatorial optimization module and the certificate generation module can be integrated into the same compilation pass pipeline; the runtime scheduling module can be used as an independent runtime component or embedded in the inference framework's Dispatcher. As long as the data flow and collaboration relationships between the functional units conform to the above description, they all fall within the protection scope of this application. Through the above modular architecture, the device provided by the embodiments of this application transforms the abstract precision constraint preservation method into a feasible, reusable, and verifiable engineering system, effectively supporting the efficient and reliable deployment of low-bit, large-model inference chips.
[0056] It should be noted that the AI inference chip accuracy maintenance and verification device provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the AI inference chip accuracy maintenance and verification device and the AI inference chip accuracy maintenance and verification method embodiment provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiment, which will not be repeated here.
[0057] This application also provides an AI inference chip compilation device, please refer to... Figure 8 The compilation device includes a processor and a memory, in which at least one instruction, at least one program, code set, or instruction set is stored. The processor loads and executes the at least one instruction, at least one program, code set, or instruction set to implement the AI inference chip accuracy maintenance and verification method provided in the above-described method embodiments.
[0058] The embodiments of this application also provide a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the AI inference chip accuracy maintenance and verification method provided in the above-described method embodiments.
[0059] Embodiments of this application also provide a computer program product, which includes a computer program. A processor of a computer device reads the computer program from a computer-readable storage medium and executes the computer program, causing the computer device to perform any of the AI inference chip accuracy maintenance and verification methods described in the above embodiments.
[0060] For ease of description, the above systems or devices are described separately as various modules or units based on their functions. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware components.
[0061] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0062] Finally, it should be noted that in this document, relational terms such as first, second, third, and fourth are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0063] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for maintaining and verifying the accuracy of an AI inference chip, characterized in that, include: Step S1: Obtain the operator subgraph to be fused and its associated numerical precision configuration, wherein the operator subgraph contains multiple computation nodes in AI inference; The numerical semantic model is recovered from the operator subgraph, and the numerical semantic model includes the precision constraint events corresponding to each computing node and the correlation between the precision constraint events. Step S2: When performing fusion optimization on the operator subgraph, determine the target boundary that needs to be retained after fusion from the precision constraint boundaries that are eliminated during the fusion process; Step S3: Establish counterfactual verification for the target boundary, construct a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics, perform numerical comparison on the two paths under the same input conditions, and determine whether the corresponding boundary is allowed to be omitted after fusion based on the comparison result; for target boundaries that are not allowed to be omitted, determine at least one candidate reproduction method. Step S4: Under the preset error constraints, security constraints, and hardware resource constraints of the target AI inference chip, the candidate reproduction methods of each target boundary that cannot be omitted are combined and optimized to determine the retained subset and its corresponding reproduction method; for the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets, and the precision constraint behavior of the corresponding boundary is reproduced in each variant using numerical operations in the non-main memory storage resources of the target chip. Step S5: Generate a machine-readable numerical error certificate for the generated fusion operator variant; The numerical error certificate includes the input application domain of the fusion operator variant and the corresponding error evidence, used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario; if it does not meet the requirements, the constraints of the combinatorial optimization solution are adjusted, and steps S4 and S5 are re-executed until the deployment requirements are met. Step S6: During the runtime phase, based on the runtime information of the current inference request and the input applicable domain of the numerical error certificate, select the target variant from the verified fusion operator variants to perform inference computation; when there is no input applicable domain covering the verified fusion operator variant of the current inference request, execute the conservative fallback path specified by the certificate or pre-verified.
2. The method according to claim 1, characterized in that, Step S1, which involves recovering the numerical semantic model based on the operator subgraph, includes: The quantization strategy, weight scaling factor, and calibration parameters are obtained from the numerical precision configuration as model-level sources; The operator-level source is obtained from the input-output precision contract, internal accumulation precision, and reduction order of each computation node in the operator subgraph; The instruction sequence, vectorization method, register residency, and device mathematical functions are obtained from the compilation artifacts corresponding to the operator subgraph as kernel-level sources; The compilation optimization process corresponding to the operator subgraph obtains fusion, reassociation, common subexpression elimination, layout transformation, and mixed-precision compilation passes as compilation-level sources; The precision constraint events from various sources are uniformly mapped to the numerical semantic model. Each precision constraint event is recorded with an original identifier and a downgraded target identifier, forming a cross-level causal relationship.
3. The method according to claim 1, characterized in that, The step S2, which determines the target boundary that needs to be retained after fusion, includes: Among the eliminated precision constraint boundaries, the boundaries that would necessarily change the defined quantization semantics, overflow strategy, or integer equivalence relation after deletion are determined as the mandatory retention boundaries after fusion. Boundaries that retain the same numerical semantics across all allowed input domains after deletion and do not exhibit subsequent amplification are identified as removable boundaries after fusion. The boundary that determines whether deletion is allowed depends on the range of the input domain, error propagation characteristics, or hardware resource conditions, and is thus identified as a conditional boundary requiring further judgment.
4. The method according to claim 1, characterized in that, The construction of the reference execution path and the candidate execution path in step S3 includes: Construct the reference execution path to perform either raw quantization semantics or quantization-aware Golden semantics, while preserving all numerical operations within the original precision constraint boundaries; and Construct the candidate execution path so that its execution target is the fused numerical semantics, and skip some or all precision constraint boundaries; Specifically, within the same intermediate input domain, the local error, saturation behavior, and event set differences of the reference execution path and the candidate execution path are compared as numerical comparisons.
5. The method according to claim 1, characterized in that, The objective function of the combinatorial optimization solution in step S4 is to minimize the overhead of the reserved subset. The overhead includes at least one of the following: additional instruction count, register usage, on-chip memory usage, format conversion delay, and pipeline blockage. The constraints for the combined optimization solution include: error constraints, security constraints, and hardware resource constraints, wherein, The error constraint is that the upper bound of the local error propagation of each computing node in the fusion operator variant does not exceed the preset error budget, wherein the upper bound of the local error propagation is determined by the input error, quantization error, rounding error, accumulation error and the local amplification coefficient of the corresponding computing node in the input applicable domain; The safety constraint is to prevent the generation of non-numbers, infinity, numerical overflow, or saturation exceeding the device limits; Hardware resource constraints are that register usage and on-chip memory usage cannot exceed the upper limit of the target chip.
6. The method according to claim 1, characterized in that, In step S5, generating the error evidence includes: By using the first reference path, the actual output of the fusion operator variant is compared with the output of the quantization-aware high-precision simulation calculation under the same input, and evidence of implementation error is obtained. By using the second reference path, the output of the low-bit model is compared with the output of the high-precision model before quantization under the same input, and evidence of quantization deviation is obtained. The implementation error evidence and the quantification deviation evidence together constitute the error evidence, and the two are recorded independently of each other.
7. The method according to claim 1, characterized in that, Step S6, which selects the target variant based on the runtime information of the current inference request, includes: During the runtime phase, extract the quantization scaling factor, maximum absolute value, or lightweight statistics from the current inference request to determine whether it falls within the input application domain of the numerical error certificate. If the conditional boundary is not met, a lightweight variant with fewer conditional boundary retentions in the retention subset is selected for execution. The conditional boundary retentions are the target boundaries that need to be retained in the retention subset based on the input domain range, error propagation characteristics, or hardware resource conditions. If the conditional boundary is not met, a full variant with more conditional boundary retentions in the retention subset is selected for execution. The full variant reproduces the precision constraint behavior in non-main memory storage resources in a candidate reproduction manner of some or all conditional boundary retentions.
8. An AI inference chip accuracy maintenance and verification device, characterized in that, include: The semantic recovery module is configured to acquire the operator subgraph to be fused and its associated numerical precision configuration, wherein the operator subgraph contains multiple computing nodes in AI inference; and to recover the numerical semantic model based on the operator subgraph, wherein the numerical semantic model contains the precision constraint events corresponding to each computing node and the correlation between the precision constraint events. The boundary determination module is configured to determine the target boundary that needs to be retained after fusion from the precision constraint boundaries that are eliminated during the fusion process when performing fusion optimization on the operator subgraph. The counterfactual verification module is configured to establish counterfactual verification for the target boundary, construct a reference execution path that preserves the original numerical semantics and a candidate execution path that executes the fused numerical semantics, perform numerical comparison on the two paths under the same input conditions, and determine whether the corresponding boundary is allowed to be omitted after fusion based on the comparison result; for target boundaries that are not allowed to be omitted, at least one candidate reproduction method is determined. The combinatorial optimization module is configured to perform combinatorial optimization on the candidate reproduction methods of each target boundary that cannot be omitted, under preset error constraints, security constraints and hardware resource constraints of the target AI inference chip, so as to determine the retained subset and its corresponding reproduction method; for the boundaries determined to be retained, fusion operator variants are generated according to different retained subsets, and the precision constraint behavior of the corresponding boundary is reproduced in each variant using numerical operations in the non-main memory storage resources of the target chip; The certificate generation module is configured to generate machine-readable numerical error certificates for the generated fusion operator variants; The numerical error certificate includes the input application domain of the fusion operator variant and the corresponding error evidence, used to determine whether the fusion operator variant meets the accuracy requirements in the current deployment scenario; if it does not meet the requirements, the process returns to the combinatorial optimization module, and after adjusting the constraints of the combinatorial optimization solution, the combinatorial optimization solution and the generation of the numerical error certificate are re-executed until the deployment requirements are met. The runtime scheduling module is configured to select a target variant from verified fusion operator variants to perform inference computation based on the runtime information of the current inference request and the input applicable domain of the numerical error certificate during the runtime phase.
9. An AI inference chip compilation device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1-7.
