Adaptive quantization method and device for analog computing and storage integrated vector retrieval

CN122925713APending Publication Date: 2026-10-16TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611077071.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-20
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0013]本申请提供一种面向模拟存算一体向量检索的自适应量化方法及装置,以解决现有技术对不同检索任务输出分布的适应能力差、量化资源分配不合理、实现复杂度和成本较大,且容易出现距离碰撞等问题

Benefits of technology

本申请的实施例可通过利用目标模拟存算一体阵列对所有候选向量执行预设并行计算操作,得到目标模拟输出电流,并通过模数转换器的第一组量化参数对目标模拟输出电流进行第一次量化操作,得到第一组数字码值;对第一组数字码值进行初步排序,得到粗Top-k结果和扩展候选结果,并判断粗Top-k结果和扩展候选结果是否满足预设可区分条件,其中,k为正整数,响应于不满足预设可区分条件时,根据粗Top-k结果重算对应的第二组量化参数;基于第二组量化参数,对目标模拟输出电流进行第二次量化操作,得到第二组数字码值,并根据第二组数字码值执行预设最终排序操作,以输出最终Top-k检索结果。本申请在不增加模数转换器位数的前提下,提高Top-k及其邻近区间的有效距离分辨率,减少关键候选之间的距离碰撞,提升Top-k结果的可区分性和稳定性。由此,解决了现有技术对不同检索任务输出分布的适应能力差、量化资源分配不合理、实现复杂度和成本较大,且容易出现距离碰撞等问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122925713A_ABST
    Figure CN122925713A_ABST
Patent Text Reader

Abstract

The application discloses an adaptive quantization method and device for analog memory-compute integrated vector retrieval, wherein the method comprises the following steps: obtaining target analog output current by performing a preset parallel calculation operation on all candidate vectors by using an analog memory-compute integrated array, and performing first quantization on the target analog output current to obtain a first group of digital code values; performing preliminary sorting on the first group of digital code values to obtain a coarse Top-k result and an extended candidate result, and judging whether the extended candidate result meets a distinguishable condition; when the extended candidate result does not meet the distinguishable condition, recalculating a second group of quantization parameters according to the coarse Top-k result; performing second quantization on the target analog output current based on the second group of quantization parameters to obtain a second group of digital code values, and performing final sorting on the second group of digital code values to output a final Top-k retrieval result. Thus, the problems of poor adaptability of existing technologies to output distribution of different retrieval tasks, unreasonable allocation of quantization resources, large implementation complexity and cost, and easy distance collision are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of vector retrieval technology, and in particular to an adaptive quantization method and apparatus for analog in-memory vector retrieval. Background Technology

[0002] In a vector retrieval system based on analog in-memory computing, the array output is typically an analog current that monotonically corresponds to a distance or similarity value. To facilitate subsequent sorting, filtering, and digital system processing, an analog-to-digital converter (ADC) is needed to convert the analog current into a digital distance code or a digital similarity code. Then, the digital sorting module outputs Top-k candidates based on the conversion results (Top-k refers to selecting the k highest-ranking results from all candidate results according to the principle of minimum distance or maximum similarity).

[0003] The computational parallelism of Compute-In-Memory (CIM) is determined by the number of analog-to-digital converters (ADCs). Due to limitations in chip area, power consumption, and clock frequency, the bit width of ADCs used in practice is usually relatively low. A lower bit width means a limited number of quantization levels.

[0004] When there are many candidate vectors and the differences between them are small, the analog current differences between different candidates are often very small. If these differences are smaller than the current quantization step size, multiple candidates that should be distinguishable will be quantized to the same digital code value, forming a "distance collision" or "code value collision" (meaning that two or more candidate vectors with different actual distances obtain the same digital code value after quantization, thus making them indistinguishable at the current precision). Once a large number of collisions occur in the Top-k critical region, it will make it difficult to distinguish between the k-th, k+1-th, and even k+2-th candidates, thereby affecting the accuracy and stability of the final Top-k retrieval results.

[0005] Currently, existing technologies can implement analog-to-in-memory vector retrieval by using a fixed quantization window (the quantization window refers to the range of input current or input voltage covered by the current effective quantization of the analog-to-digital converter). However, the core characteristic of this approach is that the quantization window of the analog-to-digital converter is fixed before the retrieval, and it is usually evenly divided across the entire range according to the minimum to maximum current that the array may output. In other words, regardless of whether the actual region of interest for a particular retrieval is concentrated in a very narrow current range, existing technologies will still distribute all quantization levels evenly across the entire range.

[0006] In this approach, to improve resolution, the traditional method is often to directly increase the bit width of the analog-to-digital converter (ADC), such as upgrading from 8 bits to 10 or 12 bits, to obtain more quantization levels. Other approaches improve quantization accuracy by increasing the number of comparisons, adding precision reference circuitry, adding high-precision ADC channels, or directly introducing a higher-performance readout link. However, these methods still fundamentally rely on improvements in ADC hardware capabilities, making it difficult to achieve a balance between area, power consumption, and engineering implementation complexity.

[0007] Existing technologies employ a fixed quantization window and full-range uniform quantization, which directly results in the limited quantization levels of the analog-to-digital converter (ADC) being evenly distributed across the entire output current range. If the full output current range is assumed to be from Imin to Imax, and the ADC bit width is n bits, then the single quantization step size is approximately: Quantization step size = (Imax - Imin) / 2^n As the total number of candidate vectors increases, the optimal candidate tends to cluster in a narrower local current range. Especially in the Top-k region and its vicinity, the actual current difference between multiple candidates may be much smaller than the quantization step size mentioned above.

[0008] Therefore, the main technical shortcomings of existing technologies can be summarized as follows: 1. Under the condition of fixed low bit width analog-to-digital converter, the distance code resolution near Top-k is insufficient, which easily leads to distance collision.

[0009] 2. The allocation of quantization resources is unreasonable. Important candidate intervals receive too few codewords, while unimportant distant intervals occupy too many quantization levels.

[0010] 3. Directly increasing the bit width of the analog-to-digital converter to improve resolution will significantly increase hardware area, power consumption, and implementation complexity.

[0011] 4. Existing solutions have poor adaptability to the output distribution of different retrieval tasks and cannot dynamically adjust the quantization strategy according to the candidate density of the current query.

[0012] In summary, existing technologies have poor adaptability to different output distributions of retrieval tasks, unreasonable allocation of quantification resources, high implementation complexity and cost, and are prone to distance collisions, which urgently need to be addressed. Summary of the Invention

[0013] This application provides an adaptive quantization method and apparatus for analog in-memory vector retrieval, which solves the problems of poor adaptability to different retrieval task output distributions, unreasonable allocation of quantization resources, high implementation complexity and cost, and easy occurrence of distance collision in existing technologies.

[0014] The first aspect of this application provides an adaptive quantization method for analog in-memory computing vector retrieval, comprising the following steps: performing a preset parallel computation operation on all candidate vectors using a target analog in-memory computing array to obtain a target analog output current; performing a first quantization operation on the target analog output current using a first set of quantization parameters from an analog-to-digital converter to obtain a first set of digital code values; performing a preliminary sorting of the first set of digital code values ​​to obtain coarse Top-k results and extended candidate results; determining whether the coarse Top-k results and the extended candidate results satisfy a preset distinguishability condition; and, in response to not satisfying the preset distinguishability condition, recalculating the corresponding second set of quantization parameters based on the coarse Top-k results; performing a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain a second set of digital code values; and performing a preset final sorting operation based on the second set of digital code values ​​to output the final Top-k retrieval result.

[0015] Optionally, in one embodiment of this application, the step of performing a preset parallel computation operation on all candidate vectors using a target analog-in-memory array to obtain a target analog output current, and performing a first quantization operation on the target analog output current using a first set of quantization parameters of an analog-to-digital converter to obtain a first set of digital code values ​​includes: loading a preset query vector into the target analog-in-memory array, and using the target analog-in-memory array to perform distance calculation or similarity calculation in parallel on all candidate vectors containing the query vector and the preset storage vector to obtain a set of target analog output currents monotonically corresponding to the candidate results; performing a preset readout, hold, or shaping operation on the target analog output current to obtain the current to be converted, and determining the first set of quantization parameters corresponding to the analog-to-digital converter to perform analog-to-digital conversion on the current to be converted using the first set of quantization parameters to obtain the first set of digital code values, wherein the first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset.

[0016] Optionally, in one embodiment of this application, the preliminary sorting of the first group of numeric code values ​​to obtain coarse Top-k results and extended candidate results, and determining whether the coarse Top-k results and the extended candidate results satisfy a preset distinguishable condition, and in response to not satisfying the preset distinguishable condition, recalculating the corresponding second group of quantization parameters based on the coarse Top-k results, includes: performing a preset coarse sorting operation on the first group of numeric code values ​​to obtain the coarse Top-k results and extended candidate results including at least the (k+1)th and (k+2)th positions, and determining whether the coarse Top-k results and the extended candidate results satisfy the preset distinguishable condition, where k is a positive integer; if the preset distinguishable condition is satisfied, the coarse Top-k results are directly used as the final Top-k retrieval results; if the preset distinguishable condition is not satisfied, the coarse code values ​​corresponding to the 1st, kth, and (k+Δ)th positions in the coarse Top-k results are determined, and ranked from Top1 to Top(k+Δ). As the region of interest, the initial current boundary of the region of interest is inferred from the coarse code value, and a preset protection margin is added on both sides of the initial current boundary to construct the target quantization window and obtain the second set of quantization parameters, where Δ is the expansion coefficient.

[0017] Optionally, in one embodiment of this application, the step of performing a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain a second set of digital code values, and performing a preset final sorting operation based on the second set of digital code values ​​to output the final Top-k search result includes: writing the second set of quantization parameters into the reference configuration interface of the analog-to-digital converter to reset the reference range, quantization slope, and offset of the analog-to-digital converter to obtain corresponding reset parameters; loading the reset parameters into the analog-to-digital converter or the analog-to-digital converter reference level generation circuit to perform a second quantization operation on the target analog output current corresponding to all candidate vectors to obtain the second set of digital code values, and performing a final sorting operation based on the second set of digital code values ​​to output the final Top-k search result.

[0018] Optionally, in one embodiment of this application, the preset distinguishable conditions include: the numeric code values ​​corresponding to the k-th and (k+1)-th candidate vectors are different; the numeric code values ​​corresponding to the k-th and (k+2)-th candidate vectors are different; within the extended candidate interval corresponding to the Top-k and the extended candidate results, the code value interval between adjacent candidate vectors is greater than or equal to a first preset threshold; the number of repeated code values ​​among the Top-k and subsequent candidate vectors is less than a second preset threshold; and the coarse Top-k result selects at least one of the top k candidate vectors if the preset stability requirements are met.

[0019] A second aspect of this application provides an adaptive quantization device for analog-in-memory vector retrieval, comprising: an analog-in-memory computing array for performing parallel operations on a target query vector and a preset storage vector to obtain a set of target analog output currents monotonically corresponding to candidate results; a readout and sample-and-hold module for reading out, holding, or shaping the target analog output current to obtain a current to be converted; and an analog-to-digital converter for converting the current to be converted into a first set of digital code values ​​according to a preset first set of quantization parameters, wherein the first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset; and a preliminary... The sorting module is used to perform preliminary sorting on the first set of digital code values ​​to obtain coarse Top-k results and extended candidate results; the digital feedback module is used to determine whether the coarse Top-k results and the extended candidate results meet preset distinguishable conditions, and in response to not meeting the preset distinguishable conditions, recalculate the corresponding second set of quantization parameters based on the coarse Top-k results, and perform a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain a second set of digital code values; the final sorting output module is used to perform a preset final sorting operation based on the second set of digital code values ​​to output the final Top-k retrieval result.

[0020] Optionally, in one embodiment of this application, the digital feedback module includes: a collision detection module, used to determine whether the coarse Top-k result and the extended candidate result satisfy the preset distinguishable condition, and obtain the corresponding collision detection result, where k is a positive integer; a parameter recalculation module, used to calculate the new quantization window boundary, new quantization slope and new offset corresponding to the analog-to-digital converter according to the collision detection result, and obtain the second set of quantization parameters; a reference configuration module, used to load the configuration value corresponding to the second set of quantization parameters into the analog-to-digital converter or the reference level generation circuit of the analog-to-digital converter; and a secondary quantization control module, used to re-quantize the target analog output current corresponding to all candidate vectors according to the second set of quantization parameters, and obtain the second set of digital code values.

[0021] Optionally, in one embodiment of this application, it further includes: a query input module, used to receive the query vector and write the query vector into the input interface of the analog in-memory computing array.

[0022] Optionally, in one embodiment of this application, the preset distinguishable conditions include: the numeric code values ​​corresponding to the k-th and (k+1)-th candidate vectors are different; the numeric code values ​​corresponding to the k-th and (k+2)-th candidate vectors are different; within the extended candidate interval corresponding to the Top-k and the extended candidate results, the code value interval between adjacent candidate vectors is greater than or equal to a first preset threshold; the number of repeated code values ​​among the Top-k and subsequent candidate vectors is less than a second preset threshold; and the coarse Top-k result selects at least one of the top k candidate vectors if the preset stability requirements are met.

[0023] Optionally, in one embodiment of this application, the propagation derivation module includes: a packaging unit, used to perform variable propagation derivation operations based on the seed diffusion point, the control flow graph, and the target alias graph to obtain at least one target variable of all the plurality of core rules and the underlying instruction corresponding to the at least one target variable, and package the at least one target variable and the underlying instruction to generate the statement-level influence domain network, and perform regression test redundant test case elimination and priority scheduling operations according to the statement-level influence domain network.

[0024] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the adaptive quantization method for analog in-memory vector retrieval as described in the above embodiments.

[0025] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described adaptive quantization method for analog-in-memory vector retrieval.

[0026] A fifth aspect of this application provides a computer program product, including a computer program that is executed to implement the above-described adaptive quantization method for analog in-memory vector retrieval.

[0027] Therefore, the embodiments of this application have the following beneficial effects: The embodiments of this application utilize a target analog in-memory computing array to perform preset parallel computation operations on all candidate vectors to obtain the target analog output current. The target analog output current is then quantized for the first time using a first set of quantization parameters from an analog-to-digital converter (ADC) to obtain a first set of digital code values. These first set of digital code values ​​are then preliminarily sorted to obtain coarse Top-k results and extended candidate results. It is then determined whether the coarse Top-k results and extended candidate results meet preset distinguishability conditions, where k is a positive integer. If the preset distinguishability conditions are not met, the corresponding second set of quantization parameters is recalculated based on the coarse Top-k results. Based on the second set of quantization parameters, the target analog output current is quantized for the second time to obtain a second set of digital code values. Finally, a preset final sorting operation is performed based on these second set of digital code values ​​to output the final Top-k retrieval result. This application improves the effective distance resolution of the Top-k and its neighboring intervals without increasing the number of bits in the ADC, reduces distance collisions between key candidates, and enhances the distinguishability and stability of the Top-k results. This solves the problems of poor adaptability to different retrieval task output distributions, unreasonable allocation of quantization resources, high implementation complexity and cost, and susceptibility to distance collisions in existing technologies.

[0028] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0029] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart of an adaptive quantization method for analog in-memory vector retrieval provided according to an embodiment of this application; Figure 2 A schematic diagram of experimental test results provided for one embodiment of this application; Figure 3 A schematic diagram illustrating the improvement of the average interval of adjacent distances within the Top-K range, provided as an embodiment of this application; Figure 4 A schematic diagram illustrating the execution logic of an adaptive quantization method for analog in-memory vector retrieval, provided as an embodiment of this application; Figure 5 This is an example diagram of an adaptive quantization device for analog in-memory vector retrieval according to an embodiment of this application; Figure 6 A schematic diagram of an adaptive quantization device for analog in-memory vector retrieval provided in one embodiment of this application; Figure 7This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0030] Among them, 10-adaptive quantization device for analog in-memory vector retrieval; 100-analog in-memory computing array; 200-readout and sample-and-hold module; 300-analog-to-digital converter; 400-preliminary sorting module; 500-digital feedback module; 600-final sorting output module; 701-memory; 702-processor; 703-communication interface. Detailed Implementation

[0031] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.

[0032] The adaptive quantization method and apparatus for analog in-memory computing vector retrieval according to embodiments of this application are described below with reference to the accompanying drawings. Addressing the problems mentioned in the background art, this application provides an adaptive quantization method for analog in-memory computing vector retrieval. In this method, a target analog output current is obtained by performing a preset parallel computation operation on all candidate vectors using a target analog in-memory computing array. The target analog output current is then quantized for the first time using a first set of quantization parameters from an analog-to-digital converter to obtain a first set of digital code values. These first set of digital code values ​​are then preliminarily sorted to obtain coarse Top-k results and extended candidate results. It is then determined whether the coarse Top-k results and extended candidate results meet a preset distinguishability condition, where k is a positive integer. If the preset distinguishability condition is not met, the corresponding second set of quantization parameters is recalculated based on the coarse Top-k results. Based on the second set of quantization parameters, the target analog output current is quantized for the second time to obtain a second set of digital code values. Finally, a preset final sorting operation is performed based on the second set of digital code values ​​to output the final Top-k retrieval result. This application improves the effective distance resolution of the Top-k and its neighboring regions without increasing the number of bits in the analog-to-digital converter, reduces distance collisions between key candidates, and enhances the distinguishability and stability of the Top-k results. This solves the problems of existing technologies, such as poor adaptability to different retrieval task output distributions, unreasonable allocation of quantization resources, high implementation complexity and cost, and susceptibility to distance collisions.

[0033] Specifically, Figure 1 This is a flowchart illustrating an adaptive quantization method for analog in-memory vector retrieval provided in an embodiment of this application.

[0034] like Figure 1As shown, this adaptive quantization method for analog in-memory vector retrieval includes the following steps: In step S101, a preset parallel computation operation is performed on all candidate vectors using the target analog in-memory array to obtain the target analog output current. The target analog output current is then quantized for the first time using the first set of quantization parameters of the analog-to-digital converter to obtain the first set of digital code values.

[0035] The embodiments of this application first receive query vectors and write them into the input interface of the analog in-memory array, and perform parallel operations on all candidate vectors to output an analog current (i.e., the target analog output current) that monotonically corresponds to the distance value or similarity value. Secondly, the embodiments of this application can perform corresponding analog-to-digital conversion on the target analog output current to obtain the corresponding first set of digital code values, thereby providing reliable data basis for subsequent sorting operations.

[0036] Optionally, in one embodiment of this application, a target analog-in-memory computing array is used to perform a preset parallel computation operation on all candidate vectors to obtain a target analog output current. The target analog output current is then quantized for the first time using a first set of quantization parameters of the analog-to-digital converter to obtain a first set of digital code values. This includes: loading a preset query vector into the target analog-in-memory computing array, and using the target analog-in-memory computing array to perform distance calculation or similarity calculation in parallel on all candidate vectors containing the query vector and the preset storage vector to obtain a set of target analog output currents that monotonically correspond to the candidate results; performing a preset readout, hold, or shaping operation on the target analog output current to obtain the current to be converted, and determining the first set of quantization parameters corresponding to the analog-to-digital converter to perform analog-to-digital conversion on the current to be converted using the first set of quantization parameters to obtain the first set of digital code values. The first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset.

[0037] It should be noted that, in this embodiment, the query vector can be obtained first and loaded into the analog in-memory computing array; second, the analog in-memory computing array can be used to perform distance calculation or similarity calculation on all candidate vectors, including the query vector and the storage vectors pre-stored in the analog in-memory computing array, in parallel to obtain a set of analog output currents (i.e., target analog output currents) that monotonically correspond to the candidate results.

[0038] Furthermore, in this embodiment, the array output current (i.e., the target analog output current) can be read out, held, or shaped to obtain the current to be converted for subsequent analog-to-digital conversion. Then, in this embodiment, the analog-to-digital converter can call the first set of quantization parameters corresponding to default values ​​or empirical values ​​to perform the first quantization of all output currents, obtaining the first set of digital code values. This first set of quantization parameters includes at least a first quantization window, a first quantization slope, and a first offset. The analog-to-digital converter has a configurable reference range, a quantization slope or equivalent scaling factor (referring to the proportional relationship between changes in the input analog quantity and changes in the output digital code value), and an offset (referring to the initial bias in the quantization mapping relationship, used to determine the origin position of the code value corresponding to the input analog quantity).

[0039] In step S102, the first group of digital code values ​​are initially sorted to obtain coarse Top-k results and extended candidate results. It is then determined whether the coarse Top-k results and extended candidate results meet the preset distinguishable conditions. If the preset distinguishable conditions are not met, the corresponding second group of quantization parameters is recalculated based on the coarse Top-k results.

[0040] In a simulated in-memory vector retrieval scenario, this embodiment can first perform a first quantization using default quantization parameters, and then determine whether a two-stage or multi-stage quantization mechanism for reconfiguring the quantization window needs to be used based on the first quantization result. This embodiment can trigger a feedback judgment mechanism for quantization parameter adjustment based on the code value distribution, code value interval, number of repeated code values, or boundary distinguishability of the Top-k neighboring candidates. Specifically, this embodiment can perform coarse sorting or local sorting operations on the first set of digital code values ​​obtained from the first quantization to obtain coarse Top-k results and extended candidate results. Based on the coarse Top-k results and extended candidate results, it analyzes whether there are code value collisions, excessively small code value intervals, or unstable sorting boundaries (i.e., whether the distinguishability condition is met) in the Top-k neighboring regions to obtain corresponding collision detection results. Based on the collision detection results, it calculates a new quantization window boundary, a new quantization slope, and a new offset to obtain the corresponding second set of quantization parameters. In this embodiment, the Top1 to Top(k+Δ) or the local candidate interval around the k-th boundary can be used as the region of interest, and the upper and lower boundaries of the quantization window can be dynamically recalculated to obtain a new quantization window boundary.

[0041] Therefore, in this embodiment of the application, while keeping the bit width of the analog-to-digital converter unchanged, zoom quantization of the current range of interest is achieved by recalculating the quantization slope or scaling factor and offset.

[0042] Optionally, in one embodiment of this application, the first group of digital code values ​​is initially sorted to obtain a coarse Top-k result and extended candidate results. It is then determined whether the coarse Top-k result and extended candidate results meet a preset distinguishability condition. In response to not meeting the preset distinguishability condition, the corresponding second group of quantization parameters is recalculated based on the coarse Top-k result. This includes: performing a preset coarse sorting operation on the first group of digital code values ​​to obtain a coarse Top-k result and extended candidate results including at least the (k+1)th and (k+2)th ranked results, and determining whether the coarse Top-k result and extended candidate results meet the preset distinguishability condition, where k is a positive integer. If the preset distinguishability condition is met, the coarse Top-k result is directly used as the final Top-k retrieval result. If the preset distinguishability condition is not met, the coarse code values ​​corresponding to the 1st, kth, and (k+Δ)th ranked results in the coarse Top-k result are determined, and the results are ranked from Top1 to Top(k+Δ). As the region of interest, the initial current boundary of the region of interest is deduced from the coarse code value, and a preset protection margin is added on both sides of the initial current boundary to construct the target quantization window and obtain the second set of quantization parameters, where Δ is the expansion coefficient.

[0043] In actual implementation, the embodiments of this application can perform preliminary sorting based on the first group of digital code values ​​to obtain coarse Top-k results and extended candidate results including at least the k+1th and k+2nd results, and determine whether the current coarse quantization result, i.e., the coarse Top-k results and the extended candidate results, meets the distinguishability condition.

[0044] If the distinguishability condition is met, the embodiment of this application can directly output the first quantization result (i.e., the first set of digital code values) as the corresponding final Top-k search result, and the process ends.

[0045] If the distinguishability condition is not met, the embodiments of this application can trigger the digital feedback module to recalculate the second set of quantization parameters based on the coarse Top-k results. As one possible approach, the target quantization window corresponding to the second set of quantization parameters covers the estimated current range from Top1 to Top(k+Δ) in the current coarse sort (i.e., meets the preset estimated current range requirement), where Δ is an expansion coefficient, preferably ranging from 5 to 20, and more preferably 10.

[0046] It should be noted that after the first quantization, the embodiments of this application can perform full sorting, local selection sorting, bucket sorting, comparison tree filtering, or approximate sorting, as long as the density of the Top-k neighboring candidates can be identified; in addition, the digital feedback module can be centrally deployed in the on-chip main controller or distributed in the local controllers of each subarray, without specific limitations.

[0047] It should be noted that a key aspect of this application's embodiments is how to recalculate the quantization parameters after a collision is detected. In this application's embodiments, the full-range window used for the first quantization can be set to [I0_L, I0_H], with a bit width of n bits. The first quantization step size can then be expressed as: ΔI0 = (I0_H - I0_L) / 2^n In this embodiment, the coarse code values ​​corresponding to the 1st, kth, and k+Δth positions in the ranking results after the first quantization can be denoted as D1, Dk, and Dk+Δ, respectively. Preferably, this embodiment uses Top1 to Top(k+Δ) as the region of interest to construct a new quantization window [I1_L, I1_H].

[0048] Specifically, in actual implementation, a preferred approach is as follows: 1. Based on the coarse code value, deduce the approximate current boundary (i.e., the initial current boundary) of the region of interest. 2. Add protective margins on both sides of the boundary to prevent the optimal candidate or extended candidate from being truncated during the second quantization; 3. Replace the original full-range window with a new narrow window.

[0049] For example, the new window can be determined according to the following approach in the embodiments of this application: I1_L = I0_L + (D1- G1) × ΔI0 I1_H = I0_L + (Dk+Δ+ G2 + 1) × ΔI0 G1 and G2 are protection margin parameters, which can be set to 1 to 4 coarse quantization least significant bits, or adaptively set according to historical noise, process deviation, and current drift. If the calculation result exceeds the configurable range of the analog-to-digital converter, it can be trimmed to within the allowable boundary.

[0050] The new quantization step size is: ΔI1 = (I1_H - I1_L) / 2^n Since I1_H - I1_L is generally much smaller than I0_H - I0_L, ΔI1 will be significantly smaller than ΔI0. That is, without increasing the bit width n, a higher equivalent resolution of the region of interest is achieved.

[0051] Furthermore, the quantization slope and offset required for the second quantization can be obtained from the following relationship: Second quantization slope: S1 = 1 / ΔI1 Second offset: O1 = -I1_L / ΔI1 It should be noted that, in addition to covering Top1 to Top(k+10), those skilled in the art may also cover Top1 to Top(k+5), Top1 to Top(k+20), or construct a symmetric or asymmetric window around the k-th boundary in actual implementation. Furthermore, besides directly recalculating the reference upper and lower limits, those skilled in the art can also equivalently change the quantization window and quantization step size by altering the current integration time, ramp time, gain factor, reference current ratio, or preamplifier gain, etc., without specific limitations.

[0052] In specific circuit implementations, those skilled in the art may not directly adopt the above mathematical form, but instead achieve equivalent S1 and O1 by setting a lower reference limit, an upper reference limit, a comparison time constant, a current reference, a ramp start point, or a ramp end point. As long as the function of "reducing the window and remapping the codeword distribution" is substantially completed, it should be considered to fall within the protection scope of this application.

[0053] Optionally, in one embodiment of this application, the preset distinguishable conditions include: the digital code values ​​corresponding to the k-th and (k+1)-th candidate vectors are different; the digital code values ​​corresponding to the k-th and (k+2)-th candidate vectors are different; within the extended candidate interval corresponding to the Top-k and extended candidate results, the code value interval between adjacent candidate vectors is greater than or equal to a first preset threshold; the number of repeated code values ​​among the Top-k and subsequent candidate vectors is less than a second preset threshold; and at least one of the top k candidate vectors is selected from the coarse Top-k results if the preset stability requirements are met.

[0054] It should be noted that, as another key innovation of this application, this application proposes a judgment mechanism based on the distribution of Top-k neighbor interval code values ​​to determine whether "focusing is necessary" after the first quantization. The following explanation uses the example of a smaller output current indicating a closer distance; if in some systems a larger output current indicates a higher similarity, then only an equivalent adjustment to the sorting direction is needed, which does not affect the essence of this application.

[0055] In the embodiments of this application, the distinguishability criteria are preferably constructed around the k-th boundary, because Top-k retrieval is not truly sensitive to whether all candidates are completely distinguishable, but rather whether the top k candidates and their immediate neighbors can be distinguished. Specifically, the distinguishability criteria can be determined using one or more of the following combined judgment methods: 1. The numeric code values ​​corresponding to the k-th candidate and the (k+1)-th candidate are different; 2. The numeric code values ​​corresponding to the k-th candidate and the (k+2)-th candidate are different; 3. Within the Top-k and extended candidate intervals, the code value interval between adjacent candidates is greater than or equal to the first preset threshold. 4. The number of duplicate code values ​​among the Top-k and several subsequent candidates is lower than the second preset threshold; 5. The current coarse sorting result can reliably select the top k candidates without causing boundary uncertainty due to a large number of identical code values.

[0056] In the embodiments of this application, if the code values ​​corresponding to the kth and (k+1)th positions are the same, it is determined to be a boundary collision; if the code values ​​corresponding to the kth and (k+2)th positions are the same, it is determined to be a collision near the boundary with extensibility; if the code value difference between the kth and (k+1)th positions is only one least significant bit, and the number of repeated code values ​​in the Top(k+Δ) interval is too large, it is determined that the current quantization resources are still insufficient; if the number of different code values ​​in Top1 to Top(k+Δ) is less than a preset threshold, it indicates that the local density is too high, and the quantization interval should be refocused.

[0057] It is understood that the judgment mechanism of this application embodiment has the advantage of being directly oriented towards the retrieval target. That is to say, this application embodiment does not require high-precision differentiation of all global candidates, but specifically performs resource scheduling for the boundary region most sensitive to the final output result.

[0058] It should be noted that, in the specific implementation process, the embodiments of this application may also use other feasible technical solutions to replace the triggering conditions such as comparing the code value difference between the kth and k+1th and k+2th candidates, such as using local histogram density, number of repeated code values, sorting stability score, minimum interval between candidates or confidence index as the triggering basis, without making specific limitations here.

[0059] In step S103, based on the second set of quantization parameters, the target analog output current is quantized a second time to obtain the second set of digital code values, and a preset final sorting operation is performed according to the second set of digital code values ​​to output the final Top-k search result.

[0060] Subsequently, in this embodiment, when needed, the entire batch of candidate vectors can be requantized according to the second set of quantization parameters (i.e., a second quantization operation is performed) to obtain the second set of digital code values, and the final Top-k retrieval results can be output based on the reconfigured quantization results (i.e. the second set of digital code values).

[0061] It should be noted that the number of iterations in this application is not fixed. Those skilled in the art can employ a single reconfiguration, two reconfigurations, or a multi-level coarse-to-fine quantization strategy. In practical applications, this application can be used in both distance-first and similarity-first retrieval systems, requiring only adjustments to the sorting direction and boundary definitions.

[0062] Optionally, in one embodiment of this application, based on the second set of quantization parameters, a second quantization operation is performed on the target analog output current to obtain a second set of digital code values, and a preset final sorting operation is performed according to the second set of digital code values ​​to output the final Top-k search results. This includes: writing the second set of quantization parameters into the reference configuration interface of the analog-to-digital converter to reset the reference range, quantization slope, and offset of the analog-to-digital converter to obtain corresponding reset parameters; loading the reset parameters into the analog-to-digital converter or the analog-to-digital converter reference level generation circuit to re-quantize the target analog output current corresponding to all candidate vectors to obtain a second set of digital code values, and performing a final sorting operation according to the second set of digital code values ​​to output the final Top-k search results.

[0063] In the specific execution process, the embodiments of this application can write the second set of quantization parameters into the analog-to-digital converter reference configuration interface, and reset the reference range, quantization slope and offset; secondly, the embodiments of this application can re-quantize the output current (i.e. the target analog output current) corresponding to the entire batch of candidate vectors to obtain the second set of digital code values, and perform the final sorting according to the second set of digital code values ​​to output the final Top-k search results.

[0064] In practice, although it is preferable to requantize the entire batch of candidates, those skilled in the art can also perform local reconfiguration quantization on sub-batches, sub-arrays, or subspaces containing Top-k neighboring candidates when hardware support is available.

[0065] It should be noted that, from a hardware implementation perspective, this application can be completed collaboratively by the "analog computing section" and the "digital feedback control section".

[0066] The simulation calculation section includes at least the following: 1. Analog in-memory computing array; 2. Readout circuit or transimpedance amplifier readout circuit; 3. Sample and hold circuit; 4. Analog-to-digital converter; 5. Reference level generation circuit.

[0067] The digital feedback control section includes at least: 1. Coarse sorting unit; 2. Boundary collision detection unit; 3. Target window calculation unit; 4. Slope and offset generation unit; 5. Reference Register Update Unit; 6. Secondary quantization trigger control unit; 7. Final sorting output unit.

[0068] In a preferred circuit structure, the reference level generation circuit can be implemented by a digital-to-analog converter (DAC), a programmable current source, a programmable voltage reference, or a variable ramp generator. In this embodiment, digital feedback control logic can be used to drive the reconfiguration of the DAC's reference level, reference current, reference voltage, ramp parameters, or equivalent quantization parameters without increasing the core bit width of the DAC. The digital feedback control section changes the configuration value of the reference level generation circuit by writing to registers, thereby changing the effective quantization window of the DAC. That is to say, in this embodiment, the bit width of the DAC itself does not need to be upgraded, but the current range covered by the bit width is changed while the bit width remains unchanged.

[0069] The embodiments of this application are applicable to various types of analog-in-memory computing architectures, including but not limited to analog-in-memory computing architectures based on Static Random Access Memory (SRAM), analog-in-memory computing architectures based on Resistive Random Access Memory (RRAM), and other in-memory computing architectures capable of outputting analog current.

[0070] Experimental results based on memristor chips show that the adaptive quantization method proposed in this application can effectively improve the distance resolution capability of the Top-k nearest neighbor interval in analog in-memory vector retrieval. Figure 2 As shown, under 8-bit analog-to-digital conversion, the array output current exhibits obvious non-uniform distribution characteristics after initial quantization, and the search results of multiple queries show a strong clustering phenomenon near Top-k, indicating that key candidates are mainly concentrated in a narrow local current range, while the traditional full-range uniform quantization method is difficult to fully distinguish this range.

[0071] Furthermore, after adopting the adaptive quantization strategy of this application, the "average interval of adjacent distances within the Top-K" is used as the evaluation index, such as... Figure 3 As shown, the metric improved from 1.51 LSB to 9.64 LSB, an increase of 6.38 times. This result demonstrates that by reconfiguring the window for the region of interest, a limited number of quantization levels can be reassigned to key candidates near the Top-k, thereby significantly reducing the distance collision probability and improving the distinguishability and ranking stability of the k-th boundary.

[0072] Therefore, this application does not rely on increasing the ADC bit width to obtain higher resolution, but achieves "zoom quantization" of key search intervals by dynamically adjusting the quantization window, thereby obtaining near-high-precision quantization effect without increasing the core bit width of the ADC.

[0073] In summary, this application does not use a fixed and unchangeable quantization window. Instead, it first performs a coarse quantization using initial quantization parameters corresponding to a default or empirical value. If the coarse quantization result can reliably distinguish the Top-k candidate vectors, the result is output directly without adding extra latency. If the coarse quantization result shows severe code value collisions in the Top-k neighboring regions, or if the top k candidates cannot be stably determined, the digital feedback module is triggered to recalculate the quantization window and drive the analog-to-digital converter to perform a more focused quantization of the candidates to improve the resolution of critical intervals.

[0074] The default values ​​or empirical values ​​can be understood as a set of initial quantization parameters obtained by the system during long-term operation, calibration, or historical retrieval statistics, such as the default minimum reference current, default maximum reference current, default quantization slope, and default offset. This set of parameters can cover most common retrieval scenarios, thus enabling most query tasks to be completed with only one quantization.

[0075] The core of this application lies not in increasing the bit width of the analog-to-digital converter, but in dynamically focusing a limited number of quantization levels onto the truly distinguishable intervals. For vector retrieval, this interval is typically not the full range, but rather a locally dense interval surrounding the Top-k and subsequent candidates in the current query results; for example, the current range corresponding to Top1 to Top(k+10). By narrowing the quantization window, the equivalent quantization step size can be significantly reduced while maintaining the same n bits, thereby improving the distinguishability between key candidates.

[0076] The execution logic of the adaptive quantization method for analog in-memory vector retrieval of this application is described below with reference to the accompanying drawings.

[0077] Figure 4 This is a schematic diagram illustrating the execution logic of the adaptive quantization method for analog-to-in-memory vector retrieval proposed in this application. Figure 4 As shown, the execution process of the adaptive quantization method for analog in-memory vector retrieval in this application is as follows: S401: Obtain the query vector; S402: Array well-row calculation, outputs analog current; S403: Perform the first quantization using the default or empirical values; S404: Extract Top-k and expand candidate vectors; S405: Based on the Top-k and extended candidate vectors, determine whether the distinguishability condition is met. If it is met, proceed to S406; otherwise, proceed to S407. S406: Output the result directly; S407: Recalculate the second set of quantization parameters; S408: Update reference range, slope, and offset; S409: Perform a second quantification on the entire batch of candidates; S4010: Perform the final sorting operation and output the final Top-k search results.

[0078] It should be noted that in some implementations, steps S407 to S4010 are executed only once to control retrieval latency. In other implementations, if severe boundary collisions are still detected after the second quantization, a third or even more reconfiguration quantizations can be performed. However, in practical engineering, it is preferable to limit the number of iterations to one or two to avoid excessive increases in latency.

[0079] Understandably, this application transfers a limited number of quantization levels from the full-range redundant interval to the key interval adjacent to the op-k level. Therefore, without changing the bit width of the analog-to-digital converter, the equivalent quantization step size between key candidates is significantly reduced. Because the equivalent quantization step size between key candidates is reduced, multiple candidates that would otherwise collide can be distinguished, thereby improving the ranking stability of the k-th boundary and its neighboring candidates. Secondly, due to the improved ranking stability, the final Top-k retrieval result is more accurate, especially suitable for high-density retrieval tasks with a large number of candidates and small distance differences between candidates.

[0080] Since this application mainly achieves its purpose by adding digital feedback control logic and a configurable reference mechanism, without requiring an increase in the number of bits of the analog-to-digital converter core, it results in a smaller increase in hardware area, lower power consumption, and stronger engineering feasibility compared to directly upgrading a high-bit-width analog-to-digital converter. This application allows most query tasks to continue to use the default empirical value to complete quantization once, and only triggers secondary quantization when a severe collision is detected, thus achieving a balance between accuracy improvement and latency overhead.

[0081] Furthermore, the adaptation logic of this invention is dynamically based on the "distribution of current query results," thus exhibiting stronger task adaptability compared to fixed quantization window schemes. This application is applicable to various analog-to-in-memory computing media and various configurable analog-to-digital conversion architectures, thus possessing good universality and scalability. Therefore, this application achieves the technical effect of "improving the resolution of key intervals while maintaining the same bit width," balancing retrieval accuracy, area, power consumption, and implementation complexity.

[0082] The adaptive quantization method for analog-in-memory computing vector retrieval proposed in this application involves performing a preset parallel computation operation on all candidate vectors using a target analog-in-memory computing array to obtain the target analog output current. The target analog output current is then quantized for the first time using a first set of quantization parameters from an analog-to-digital converter (ADC) to obtain a first set of digital code values. These first set of digital code values ​​are then preliminarily sorted to obtain coarse Top-k results and extended candidate results. It is then determined whether the coarse Top-k results and extended candidate results meet a preset distinguishability condition, where k is a positive integer. If the preset distinguishability condition is not met, the corresponding second set of quantization parameters is recalculated based on the coarse Top-k results. Based on the second set of quantization parameters, the target analog output current is quantized for the second time to obtain a second set of digital code values. Finally, a preset final sorting operation is performed based on the second set of digital code values ​​to output the final Top-k retrieval result. This application improves the effective distance resolution of the Top-k and its neighboring regions without increasing the number of bits in the ADC, reduces distance collisions between key candidates, and enhances the distinguishability and stability of the Top-k results.

[0083] Secondly, with reference to the accompanying drawings, an adaptive quantization device for analog in-memory vector retrieval proposed according to an embodiment of this application is described.

[0084] Figure 5 This is a block diagram of an adaptive quantization device for analog in-memory vector retrieval according to an embodiment of this application.

[0085] like Figure 5 As shown, the adaptive quantization device 10 for analog-in-memory vector retrieval includes: an analog-in-memory computing array 100, a readout and sample-and-hold module 200, an analog-to-digital converter 300, a preliminary sorting module 400, a digital feedback module 500, and a final sorting output module 600.

[0086] Among them, the analog in-memory computing array 100 is used to perform parallel operations on the target query vector and the preset storage vector to obtain a set of target analog output currents that monotonically correspond to the candidate results.

[0087] The readout and sample-and-hold module 200 is used to read out, hold, or shape the target analog output current to obtain the current to be converted.

[0088] The analog-to-digital converter 300 is used to convert the current to be converted into a first set of digital code values ​​according to a preset first set of quantization parameters. The first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset.

[0089] The preliminary sorting module 400 is used to perform preliminary sorting of the first group of digital code values ​​to obtain coarse Top-k results and extended candidate results.

[0090] The digital feedback module 500 is used to determine whether the coarse Top-k result and the extended candidate result meet the preset distinguishable conditions. In response to the failure to meet the preset distinguishable conditions, the module recalculates the corresponding second set of quantization parameters based on the coarse Top-k result, and performs a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain the second set of digital code values.

[0091] The final sorting output module 600 is used to perform a preset final sorting operation based on the second set of numeric code values ​​to output the final Top-k search results.

[0092] Optionally, in one embodiment of this application, the digital feedback module 500 includes: a collision detection module, a parameter recalculation module, a reference configuration module, and a secondary quantization control module.

[0093] The collision detection module is used to determine whether the coarse Top-k results and the extended candidate results meet the preset distinguishable conditions, and to obtain the corresponding collision detection results, where k is a positive integer.

[0094] The parameter recalculation module is used to calculate the new quantization window boundary, new quantization slope, and new offset corresponding to the analog-to-digital converter based on the collision detection results, and obtain the second set of quantization parameters.

[0095] The reference configuration module is used to load the configuration values ​​corresponding to the second set of quantization parameters into the analog-to-digital converter or the reference level generation circuit of the analog-to-digital converter.

[0096] The secondary quantization control module is used to perform a second quantization operation on the target analog output current corresponding to all candidate vectors according to the second set of quantization parameters to obtain the second set of digital code values.

[0097] Optionally, in one embodiment of this application, it further includes: a query input module, used to receive a query vector and write the query vector into the input interface of the analog in-memory computing array.

[0098] Optionally, in one embodiment of this application, the preset distinguishable conditions include: the digital code values ​​corresponding to the k-th and (k+1)-th candidate vectors are different; the digital code values ​​corresponding to the k-th and (k+2)-th candidate vectors are different; within the extended candidate interval corresponding to the Top-k and extended candidate results, the code value interval between adjacent candidate vectors is greater than or equal to a first preset threshold; the number of repeated code values ​​among the Top-k and subsequent candidate vectors is less than a second preset threshold; and at least one of the top k candidate vectors is selected from the coarse Top-k results if the preset stability requirements are met.

[0099] Specifically, such as Figure 6As shown, the adaptive quantization device for analog in-memory vector retrieval in this application embodiment includes the following functional modules: 1. Query input module, used to receive query vectors and write them into the input interface of the analog in-memory array.

[0100] 2. Analog in-memory computing array, used to perform parallel operations on query vectors and stored vectors, outputting analog currents that monotonically correspond to distance or similarity values.

[0101] 3. Readout and Sample-and-Hold Module: Used to read out, hold, or shape the array output current for subsequent analog-to-digital conversion.

[0102] 4. Analog-to-digital converter (n-bit analog-to-digital converter module) for converting analog current into digital code values; the analog-to-digital converter has a configurable reference range, quantization slope or equivalent scaling factor, and offset.

[0103] 5. Preliminary sorting module, used to perform coarse or partial sorting on the digital code values ​​obtained from the first quantization.

[0104] 6. Collision detection module, used to analyze whether there are code value collisions, code value intervals that are too small, or sorting boundaries that are unstable in the Top-k neighboring regions.

[0105] 7. Parameter recalculation module, used to calculate new quantization window boundaries, new quantization slopes and new offsets based on collision detection results.

[0106] 8. Reference configuration module, used to load the configuration value output by the parameter recalculation module into the analog-to-digital converter or its reference level generation circuit.

[0107] 9. Secondary quantization control module, used to control the requantization of the entire batch of candidates when needed.

[0108] 10. Final sorting output module, used to output the final Top-k search results based on the reconfigured quantization results.

[0109] The collision detection module, parameter recalculation module, reference configuration module, and secondary quantization control module can collectively constitute the digital feedback module. This digital feedback module can be implemented using digital logic, a finite state machine (FSM), a microcontroller, or an on-chip controller.

[0110] It should be noted that the foregoing explanation of the adaptive quantization method embodiment for analog in-memory vector retrieval also applies to the adaptive quantization device for analog in-memory vector retrieval in this embodiment, and will not be repeated here.

[0111] An adaptive quantization device for analog-in-memory vector retrieval, as proposed in the embodiments of this application, includes an analog-in-memory computing array 100 for performing parallel operations on a target query vector and a preset storage vector to obtain a set of target analog output currents monotonically corresponding to candidate results; a readout and sample-and-hold module 200 for reading out, holding, or shaping the target analog output current to obtain the current to be converted; and an analog-to-digital converter 300 for converting the current to be converted into a first set of digital code values ​​according to a preset first set of quantization parameters, including but not limited to a first quantization window, a first quantization slope, and a first offset. The system comprises: a preliminary sorting module 400, used to perform preliminary sorting on the first set of digital code values ​​to obtain coarse Top-k results and extended candidate results; a digital feedback module 500, used to determine whether the coarse Top-k results and extended candidate results meet preset distinguishability conditions; in response to not meeting the preset distinguishability conditions, recalculating the corresponding second set of quantization parameters based on the coarse Top-k results, and performing a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain the second set of digital code values; and a final sorting output module 600, used to perform a preset final sorting operation based on the second set of digital code values ​​to output the final Top-k retrieval results. This application improves the effective distance resolution of Top-k and its neighboring intervals without increasing the number of bits in the analog-to-digital converter, reduces distance collisions between key candidates, and enhances the distinguishability and stability of the Top-k results.

[0112] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 701, the processor 702, and the computer program stored on the memory 701 and executable on the processor 702.

[0113] When the processor 702 executes the program, it implements the adaptive quantization method for analog in-memory vector retrieval provided in the above embodiments.

[0114] Furthermore, electronic devices also include: Communication interface 703 is used for communication between memory 701 and processor 702.

[0115] The memory 701 is used to store computer programs that can run on the processor 702.

[0116] The memory 701 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0117] If the memory 701, processor 702, and communication interface 703 are implemented independently, then the communication interface 703, memory 701, and processor 702 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0118] Optionally, in a specific implementation, if the memory 701, processor 702, and communication interface 703 are integrated on a single chip, then the memory 701, processor 702, and communication interface 703 can communicate with each other through an internal interface.

[0119] The processor 702 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0120] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described adaptive quantization method for analog-in-memory vector retrieval.

[0121] This application also provides a computer program product, including a computer program, which, when executed, is used to implement the above-described adaptive quantization method for analog in-memory vector retrieval.

[0122] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0123] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0124] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0125] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0126] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0127] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0128] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0129] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.

Claims

1. An adaptive quantization method for analog in-memory vector retrieval, characterized in that, Includes the following steps: The target analog in-memory computing array is used to perform a preset parallel computing operation on all candidate vectors to obtain the target analog output current. The target analog output current is then quantized for the first time using the first set of quantization parameters of the analog-to-digital converter to obtain the first set of digital code values. The first group of digital code values ​​is initially sorted to obtain coarse Top-k results and extended candidate results. It is then determined whether the coarse Top-k results and the extended candidate results meet a preset distinguishable condition. If the preset distinguishable condition is not met, the corresponding second group of quantization parameters is recalculated based on the coarse Top-k results. Based on the second set of quantization parameters, the target analog output current is subjected to a second quantization operation to obtain a second set of digital code values. A preset final sorting operation is then performed based on the second set of digital code values ​​to output the final Top-k search results.

2. The adaptive quantization method for analog in-memory vector retrieval according to claim 1, characterized in that, The target analog in-memory computing array is used to perform a preset parallel computation operation on all candidate vectors to obtain the target analog output current. The target analog output current is then quantized for the first time using the first set of quantization parameters from the analog-to-digital converter to obtain the first set of digital code values, including: The preset query vector is loaded into the target analog in-memory array, and the target analog in-memory array is used to perform distance calculation or similarity calculation in parallel on all candidate vectors containing the query vector and the preset storage vector, so as to obtain a set of target analog output currents that monotonically correspond to the candidate results. The target analog output current is subjected to a preset readout, hold, or shaping operation to obtain the current to be converted, and the first set of quantization parameters corresponding to the analog-to-digital converter is determined so as to perform analog-to-digital conversion on the current to be converted through the first set of quantization parameters to obtain the first set of digital code values. The first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset.

3. The adaptive quantization method for analog in-memory vector retrieval according to claim 2, characterized in that, The process involves initially sorting the first group of digital code values ​​to obtain a coarse Top-k result and an expanded candidate result, and determining whether the coarse Top-k result and the expanded candidate result satisfy a preset distinguishability condition. If the preset distinguishability condition is not satisfied, the corresponding second group of quantization parameters is recalculated based on the coarse Top-k result, including: Perform a preset coarse sorting operation on the first group of digital code values ​​to obtain the coarse Top-k results and extended candidate results including at least the (k+1)th and (k+2)th results, and determine whether the coarse Top-k results and the extended candidate results satisfy the preset distinguishable condition, where k is a positive integer; If the preset distinguishable conditions are met, the coarse Top-k result is directly used as the final Top-k search result; If the preset distinguishable condition is not met, then the coarse code values ​​corresponding to the 1st, kth, and k+Δth names in the coarse Top-k results are determined, and Top1 to Top(k+Δ) is taken as the region of interest. The initial current boundary of the region of interest is deduced based on the coarse code value, and a preset protection margin is added on both sides of the initial current boundary to construct the target quantization window and obtain the second set of quantization parameters, where Δ is the expansion coefficient.

4. The adaptive quantization method for analog in-memory vector retrieval according to claim 3, characterized in that, The second quantization operation is performed on the target analog output current based on the second set of quantization parameters to obtain a second set of digital code values. A preset final sorting operation is then performed based on these second set of digital code values ​​to output the final Top-k search results, including: Write the second set of quantization parameters into the reference configuration interface of the analog-to-digital converter to reset the reference range, quantization slope and offset of the analog-to-digital converter, and obtain the corresponding reset parameters; The reset parameters are loaded into the analog-to-digital converter or the analog-to-digital converter reference level generation circuit to re-quantize the target analog output current corresponding to all candidate vectors for the second time, to obtain the second set of digital code values, and to perform the final sorting operation based on the second set of digital code values ​​to output the final Top-k search result.

5. The adaptive quantization method for analog in-memory vector retrieval according to claim 3, wherein the preset distinguishable conditions include: The digital code values ​​corresponding to the k-th and (k+1)-th candidate vectors are different; the digital code values ​​corresponding to the k-th and (k+2)-th candidate vectors are different; within the extended candidate interval corresponding to the Top-k and the extended candidate results, the code value interval between adjacent candidate vectors is greater than or equal to a first preset threshold; among the Top-k and subsequent candidate vectors, the number of repeated code values ​​is less than a second preset threshold; and the coarse Top-k result selects at least one of the top k candidate vectors while meeting preset stability requirements.

6. An adaptive quantization device for analog in-memory vector retrieval, characterized in that, include: An analog in-memory computing array is used to perform parallel operations on a target query vector and a preset storage vector to obtain a set of target analog output currents that monotonically correspond to the candidate results. The readout and sample-and-hold module is used to read out, hold, or shape the target analog output current to obtain the current to be converted. An analog-to-digital converter is used to convert the current to be converted into a first set of digital code values ​​according to a preset first set of quantization parameters, wherein the first set of quantization parameters includes, but is not limited to, a first quantization window, a first quantization slope, and a first offset. The preliminary sorting module is used to perform preliminary sorting on the first group of digital code values ​​to obtain coarse Top-k results and expanded candidate results; The digital feedback module is used to determine whether the coarse Top-k result and the extended candidate result meet the preset distinguishable conditions. In response to the fact that the preset distinguishable conditions are not met, the module recalculates the corresponding second set of quantization parameters based on the coarse Top-k result, and performs a second quantization operation on the target analog output current based on the second set of quantization parameters to obtain the second set of digital code values. The final sorting output module is used to perform a preset final sorting operation based on the second set of digital code values ​​to output the final Top-k search results.

7. The adaptive quantization device for analog in-memory vector retrieval according to claim 6, characterized in that, The digital feedback module includes: The collision detection module is used to determine whether the coarse Top-k result and the extended candidate result satisfy the preset distinguishable condition, and obtain the corresponding collision detection result, where k is a positive integer; The parameter recalculation module is used to calculate the new quantization window boundary, new quantization slope and new offset corresponding to the analog-to-digital converter based on the collision detection results, so as to obtain the second set of quantization parameters. The reference configuration module is used to load the configuration values ​​corresponding to the second set of quantization parameters into the analog-to-digital converter or the reference level generation circuit of the analog-to-digital converter; The secondary quantization control module is used to perform a second quantization operation on the target analog output current corresponding to all candidate vectors according to the second set of quantization parameters to obtain the second set of digital code values.

8. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the adaptive quantization method for analog in-memory vector retrieval as described in any one of claims 1-5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the adaptive quantization method for analog in-memory vector retrieval as described in any one of claims 1-5.

10. A computer program product, comprising a computer program, characterized in that, The computer program is executed to implement the adaptive quantization method for analog in-memory vector retrieval as described in any one of claims 1-5.