# US 2024/0202501 A1 · System and method for mathematical modeling of hardware quantization process

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0202501 A1
- Document ID: US20240202501A1
- Status: Published application
- Kind: A1
- Application number: 18/081,515
- Filed: 2022-12-14
- Published: 2024-06-20
- Earliest claimed: 2022-12-14
- Assignees: Black Sesame Technologies Inc.
- Applicants: Black Sesame Technologies Inc.
- Inventors: Peng Zan
- Web page: https://patentgrep.com/patent/US20240202501A1

## CPC

- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06F 9/3001: {Arithmetic instructions}
- G06F 9/30134: {Register stacks; shift registers}
- G06N 3/063: using electronic means
- G06N 3/084: Backpropagation, e.g. using gradient descent
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In one aspect, a system that can minimize quantization accuracy losses when implementing a neural network node on an edge device is disclosed. During operation, the system identifies a set of adjustable parameters in the edge device. The set of adjustable parameters include a set of registers of the edge device. The system then models the quantization of parameters and output of the neural network node on the edge device as an optimization problem by formulating at least an objective function, wherein the objective function is a function of the set of adjustable parameters. Next, the system solves the optimization problem by identifying a set of values for the set of adjustable parameters that satisfies the objective function. The system subsequently programs the edge device by configuring the set of adjustable parameters with the set of identified values. The programmed edge device implements the neural network node with improved precision.

## Claims

### Claim 1

A computer-implemented method for minimizing quantization accuracy losses when implementing a neural network node on a hardware device, the method comprising:
identifying a set of adjustable parameters to be stored in the hardware device;
modeling the quantization of neural network parameters and output of the neural network node on the hardware device as an optimization problem by formulating at least an objective 5 function, wherein the objective function is a function of the set of adjustable parameters;
solving the optimization problem by identifying a set of values for the set of adjustable parameters that satisfies the objective function; and
programming the hardware device by configuring the set of adjustable parameters with the set of identified values, thereby allowing the programmed hardware device to implement the neural network node with improved precision at an output of the neural network node.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the objective function is to minimize quantization accuracy losses in terms of a set of optimizable variables associated with the quantization of the set of neural network parameters; and
wherein formulating the objective function comprises mapping the set of optimizable variables of the objective function to the set of adjustable parameters of the hardware device.

### Claim 3 (depends on 2)

The computer-implemented method of claim 2,
wherein the set of optimizable variables comprises a set of bit-shift variables associated with the quantization of the set of neural network parameters; and
wherein the set of adjustable parameters comprises a set of registers of the hardware device.

### Claim 4 (depends on 3)

The computer-implemented method of claim 3, wherein the set of bit-shift variables comprises a set of right bit-shift variables, and wherein formulating the objective function to minimize quantization accuracy losses in terms of the set of optimizable variables comprises minimizing a weighted sum of the set of right bit-shift variables.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1,
wherein the optimization problem additionally comprises a set of constraints associated with the set of adjustable parameters; and
wherein solving the optimization problem comprises identifying the set of values for the set of adjustable parameters that satisfy the set of constraints.

### Claim 6 (depends on 5)

The computer-implemented method of claim 5, wherein formulating the optimization problem further comprises generating the set of constraints by:
identifying a set of arithmetic operations within the neural network node; and
for each identified arithmetic operation, generating one or more constraints by mathematically modeling the arithmetic operation with respect to both the set of adjustable parameters and a set of quantization parameters associated with the quantization of neural network parameters.

### Claim 7 (depends on 6)

The computer-implemented method of claim 6, wherein the set of identified arithmetic operations comprises one or more of:
a multiplication operation;
an adding operation;
a clipping operation;
a rounding operation;
a left bit-shift operation; and
a right bit-shift operation.

### Claim 8 (depends on 6)

The computer-implemented method of claim 6, wherein the set of quantization parameters for a given quantized neural network parameter comprises:
a quantization scale;
a zero point value; and
a calibrated upper bound value for the quantized neural network parameter.

### Claim 9 (depends on 8)

The computer-implemented method of claim 8, wherein the set of constraints comprises a first quantization-scale equality constraint between the quantization scales of a set of input values of the neural network node and the quantization scale of an output of the neural network node.

### Claim 10 (depends on 8)

The computer-implemented method of claim 8,
wherein the identified set of arithmetic operations comprises a set of addition operations; and
wherein the set of constraints comprises a second quantization-scale equality constraint between the two inputs of each addition operation within the set of identified addition operations.

### Claim 11 (depends on 6)

The computer-implemented method of claim 6,
wherein the identified set of arithmetic operations comprises a set of bit-shift operations; and
wherein the set of constraints comprises a set of inequality constraints corresponding to size limits of a set of registers in the hardware device used to implement the set of identified bit-shift operations.

### Claim 12 (depends on 1)

The computer-implemented method of claim 1, wherein solving the optimization problem comprises applying one of the following optimization techniques:
a linear optimization technique; and
a brute-force search technique.

### Claim 13

An apparatus, comprising:
a processor; and
a storage device coupled to the processor, wherein the storage device storing instructions which, when executed by the processor, cause the processor to perform a method for minimizing quantization accuracy losses when implementing a neural network node on a hardware device, the method comprising:
identifying a set of adjustable parameters to be stored in the hardware device;
modeling the quantization of neural network parameters and output of the neural network node on the hardware device as an optimization problem by formulating at least 9 an objective function, wherein the objective function is a function of the set of adjustable parameters;
solving the optimization problem by identifying a set of values for the set of adjustable parameters that satisfies the objective function; and
program the hardware device by configuring the set of adjustable parameters with the set of identified values, thereby allowing the programmed hardware device to implement the neural network node with improved precision at an output of the neural network node.

### Claim 14 (depends on 13)

The apparatus of claim 13, wherein formulating the optimization problem comprises:
formulating the objective function to minimize quantization accuracy losses in terms of a set of optimizable variables associated with the quantization of the set of neural network parameters; and
mapping the set of optimizable variables of the objective function to the set of adjustable parameters of the hardware device.

### Claim 15 (depends on 14)

The apparatus of claim 14,
wherein the set of optimizable variables comprises a set of bit-shift variables associated with the quantization of the set of neural network parameters; and
wherein the set of adjustable parameters comprises a set of registers of the hardware device.

### Claim 16 (depends on 15)

The apparatus of claim 15, wherein the set of bit-shift variables comprises a set of right bit-shift variables, and wherein formulating the objective function to minimize quantization accuracy losses in terms of the set of optimizable variables comprises minimizing a weighted sum of the set of right bit-shift variables.

### Claim 17 (depends on 13)

The apparatus of claim 13,
wherein the optimization problem additionally comprises a set of constraints associated with the set of adjustable parameters; and
wherein solving the optimization problem comprises identifying the set of values for the set of adjustable parameters that satisfy the set of constraints.

### Claim 18

A non-transitory computer readable storage medium storing instructions which, when executed by a processor, causes the processor to perform a method for minimizing quantization accuracy losses when implementing a neural network node on a hardware device, the method comprising:
one or more processors; and
a memory coupled to the one or more processors, wherein the memory storing instructions that, when executed by the one or more processors, cause the edge device to:
identifying a set of adjustable parameters to be stored in the hardware device;
modeling the quantization of neural network parameters and output of the neural 5 network node on the hardware device as an optimization problem by formulating at least an objective function, wherein the objective function is a function of the set of adjustable parameters;
solving the optimization problem by identifying a set of values for the set of adjustable parameters that satisfies the objective function; and
program the hardware device by configuring the set of adjustable parameters with the set of identified values, thereby allowing the programmed hardware device to implement the neural network node with improved precision at an output of the neural network node.

### Claim 19 (depends on 18)

The non-transitory computer readable storage medium of claim 18, wherein formulating the optimization problem comprises:
formulating the objective function to minimize quantization accuracy losses in terms of a set of optimizable variables associated with the quantization of the set of neural network 4 parameters; and
mapping the set of optimizable variables of the objective function to the set of adjustable parameters of the hardware device.

### Claim 20 (depends on 18)

The non-transitory computer readable storage medium of claim 18, wherein the optimization problem additionally comprises a set of constraints associated with the set of adjustable parameters; and
wherein solving the optimization problem comprises identifying the set of values for the set of adjustable parameters that satisfy the set of constraints.
