Analytical gradient-based thin film structure parameter optimization method and system

CN122595517BActive Publication Date: 2026-10-30GAZER PRECISION TECHNOLOGY (SUZHOU) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202611099236.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-30
Estimated Expiration
2046-07-23

AI Technical Summary

Technical Problem

[0004]本发明提供了基于解析梯度的薄膜结构参数优化方法及系统,用于解决现有薄膜结构参数优化方法在梯度计算效率不足与大规模并行计算能力受限的问题

Benefits of technology

本发明的技术方案首先在优化初始化阶段,根据膜层总数与GPU共享内存大小动态确定张量核心的并行粒度参数K,使特征矩阵分块规模与硬件资源精确匹配,避免计算资源浪费或并行度不足,同时一次性加载全部膜层厚度向量至GPU内存,减少迭代过程中的数据传输开销。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122595517B_ABST
    Figure CN122595517B_ABST
Patent Text Reader

Abstract

The application provides a thin film structure parameter optimization method and system based on analytical gradient, and belongs to the technical field of structure optimization design. The method comprises the following steps: obtaining the total number of film layers and the total number of wavelength sampling points of a film system to be optimized, determining the parallel granularity adaptive parameters of the tensor core of a graphics processing unit, and loading a film layer thickness vector; assigning an independent thread block to each wavelength sampling point and performing parallel calculation; performing forward propagation calculation to obtain the characteristic matrix of each layer of thin film at each wavelength sampling point; performing block combination on the characteristic matrix; transmitting the block combination of the characteristic matrix to the tensor core to perform batch matrix multiplication, and calculating the loss function value; performing back propagation calculation to obtain the analytical gradient value; transmitting the obtained analytical gradient value from the graphics processing unit to the host end, and updating the film layer thickness vector. The application solves the problems of insufficient gradient calculation efficiency and limited large-scale parallel calculation capacity of the existing thin film structure parameter optimization method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of structural optimization design technology, specifically to a method and system for optimizing thin film structure parameters based on analytical gradients. Background Technology

[0002] The Transfer Matrix Method (TMM) is a core numerical tool for thin-film optical design and inverse optimization, calculating the optical response of a film system by multiplying the characteristic matrices of each film layer. Existing thin-film optimization methods based on analytical gradients face challenges such as low computational efficiency and high memory consumption when calculating forward and backward gradients for large-scale film systems. While Chinese patent CN121743652A proposes a GPU kernel fusion optimization scheme for LU decomposition of strip matrices, and Chinese patent CN118069969A discloses a method for accelerating the calculation of Somoff integrals in layered media using CUDA tensor cores, these schemes are geared towards numerical linear algebra and computational electromagnetics. They fail to specifically optimize for the batch multiplication characteristics of the characteristic matrices of the thin-film transfer matrix, nor do they address combining tensor core acceleration with mixed-precision strategies and gradient checkpointing techniques to adapt to the inverse design scenario of film systems.

[0003] Therefore, there is an urgent need for a hardware acceleration scheme for the analytical gradient calculation of the thin film transport matrix. Summary of the Invention

[0004] This invention provides a method and system for optimizing thin film structure parameters based on analytical gradients, which addresses the problems of insufficient gradient calculation efficiency and limited large-scale parallel computing capabilities in existing thin film structure parameter optimization methods.

[0005] In view of the above problems, the present invention provides a method and system for optimizing thin film structure parameters based on analytical gradient.

[0006] In a first aspect, the present invention provides a method for optimizing thin film structure parameters based on analytical gradients, including: Obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized. Determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points. The parallel granularity adaptation parameters include the number of consecutive film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized. Each wavelength sampling point is assigned an independent thread block, and the calculations are performed in parallel among the thread blocks. In each of the thread blocks, forward propagation calculations are performed based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each thin film at each wavelength sampling point. In each thread block, the feature matrix is ​​divided and combined according to the number of consecutive film layers K to obtain several feature matrix block groups; In each of the thread blocks, the plurality of feature matrices are divided into blocks and transmitted to the tensor core to perform batch matrix multiplication, thereby obtaining the system matrix under each wavelength sampling point, and the loss function value is calculated based on the system matrix. Backpropagation calculations are performed in each of the aforementioned thread blocks to obtain the analytical gradient value of the film thickness of each film layer, wherein the matrix multiplication operations involved in the calculation of the analytical gradient value are transmitted to the tensor core for execution. The analytical gradient values ​​calculated by each of the thread blocks are transmitted from the graphics processor to the host, and the film thickness vector is updated on the host based on the analytical gradient values.

[0007] Secondly, the present invention provides a thin film structure parameter optimization system based on analytical gradients, comprising: The parallel granularity adaptation and data loading module is used to obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized, determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points, the parallel granularity adaptation parameters include the number of consecutive film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized. The wavelength parallel scheduling module is used to allocate an independent thread block to each wavelength sampling point, and the calculations are performed in parallel among the thread blocks. The forward propagation calculation module is used to perform forward propagation calculations in each of the thread blocks based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each film layer at each wavelength sampling point. The feature matrix block combination module is used to divide and combine the feature matrix in each thread block according to the number of consecutive film layers K to obtain several feature matrix block groups. The Tensor Core Batch Multiplication Module is used to transmit the several feature matrices in blocks to the Tensor Core for batch matrix multiplication in each thread block, to obtain the system matrix under each wavelength sampling point, and to calculate the loss function value based on the system matrix. The backpropagation analytical gradient calculation module is used to perform backpropagation calculation in each of the thread blocks to obtain the analytical gradient value of the film thickness value of each film layer, wherein the matrix multiplication operation involved in the calculation of the analytical gradient value is transmitted to the tensor core for execution. The gradient backpropagation and parameter update module is used to transmit the analytical gradient values ​​calculated by each thread block from the graphics processor to the host, and update the film thickness vector on the host according to the analytical gradient values.

[0008] One or more technical solutions provided in this invention have at least the following technical effects or advantages: The technical solution of this invention firstly determines the parallel granularity parameter K of the tensor core dynamically based on the total number of membrane layers and the size of the GPU shared memory during the optimization initialization stage. This ensures that the feature matrix block size is precisely matched with the hardware resources, avoiding waste of computing resources or insufficient parallelism. At the same time, all membrane thickness vectors are loaded into the GPU memory at once, reducing data transfer overhead during the iteration process.

[0009] Furthermore, by allocating an independent thread block for parallel execution to each wavelength sampling point, the serial loop of the wavelength dimension is transformed into parallel computation of single instruction multi-thread, which significantly shortens the total computation time under multiple wavelength points and effectively improves the throughput of the optimization task.

[0010] Furthermore, the feature matrices of each film layer are constructed independently within each thread block, enabling the parallel construction of all film layer feature matrices at each wavelength point. This transforms the original multi-wavelength, multi-film-layer serial loop into a single-layer loop, reducing computational latency, avoiding data dependencies between threads, and improving the utilization of GPU computing resources.

[0011] Furthermore, the feature matrices of each film layer at the same wavelength sampling point are organized into feature matrix blocks in the form of matrix sequences by K layers. This transforms multiple small matrices that originally needed to be multiplied sequentially layer by layer into regular data sequences that can be processed in batches by tensor cores, eliminating the instruction issuance overhead caused by layer-by-layer loops and providing a data foundation for hardware-accelerated computing.

[0012] Furthermore, the feature matrix is ​​divided into blocks and transmitted to the tensor core for batch matrix multiplication, transforming the serial matrix multiplication of multilayer thin films into hardware-accelerated parallel batch processing. The system matrix calculation and loss function evaluation are completed synchronously at each wavelength point, realizing the integrated parallel execution of forward propagation and optimization evaluation.

[0013] Furthermore, gradients are calculated precisely layer by layer analytically in reverse order along the membrane layers, avoiding the truncation error of the finite difference method; the matrix multiplication-intensive operations in gradient calculation are offloaded to the tensor core, giving backpropagation the same hardware acceleration capability as forward propagation; with the help of the checkpoint mechanism, intermediate results are saved at intervals and recalculated as needed from the forward start of the interval, achieving efficient memory reuse for large-scale membrane gradient calculation under the constraint of limited GPU memory; through hybrid precision adaptive scheduling, half-precision and single-precision floating-point formats are dynamically switched during the optimization process, taking into account both numerical stability and computational throughput.

[0014] Finally, the analytical gradients at each wavelength point are summarized and sent back to the host. An adaptive moment estimation optimizer is used to independently calculate the adaptive update step size for each film layer, overcoming the problem of uneven convergence speed of each layer under a fixed learning rate, and realizing efficient collaboration between GPU parallel gradient calculation and host fine parameter update.

[0015] In summary, the technical solution of this invention, while ensuring the accuracy of gradient calculation, breaks through the bottlenecks of computational efficiency and memory usage in large-scale multi-wavelength optimization of thin film systems, and achieves efficient, stable, and scalable optimization of thin film structure parameters. This solves the problems of insufficient gradient calculation efficiency and limited large-scale parallel computing capabilities in existing thin film structure parameter optimization methods. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating the thin film structure parameter optimization method based on analytical gradient provided by the present invention.

[0017] Figure 2 This is a schematic diagram of the batch matrix multiplication process in the thin film structure parameter optimization method based on analytical gradient provided by the present invention.

[0018] Figure 3 This is a schematic diagram of the thin film structure parameter optimization system based on analytical gradient provided by the present invention.

[0019] In the attached diagram, the labels representing each component are as follows: Parallel granularity adaptation and data loading module 11, wavelength parallel scheduling module 12, forward propagation calculation module 13, feature matrix block combination module 14, tensor core batch multiplication module 15, backpropagation analytical gradient calculation module 16, gradient backpropagation and parameter update module 17. Detailed Implementation

[0020] This invention provides a method and system for optimizing thin film structure parameters based on analytical gradients, which solves the problems of insufficient gradient calculation efficiency and limited large-scale parallel computing capabilities in existing thin film structure parameter optimization methods.

[0021] It should be noted that the terms "comprising" and "having" are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to these processes, methods, products, or devices.

[0022] Example 1, as Figure 1 As shown, this invention provides a method for optimizing thin film structure parameters based on analytical gradients, the method comprising: S100: Obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized. Determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points. The parallel granularity adaptation parameters include the number of consecutive film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized.

[0023] In this step, the basic scale parameters of the thin film structure to be optimized are first obtained, including the total number of film layers P and the total number of wavelength sampling points N. The total number of film layers P is obtained by reading the film structure design file input by the user and parsing the number of film layers stacked recorded in the file; the total number of wavelength sampling points N is calculated by reading the starting wavelength, ending wavelength and sampling step size specified by the user for spectral optimization, and using the formula N=(ending wavelength - starting wavelength) / sampling step size + 1.

[0024] For example, if the membrane system to be optimized is a broadband antireflection membrane, and the user-input membrane structure design file shows 8 layers stacked, then the total number of layers P=8. Simultaneously, the user-specified spectral range has a starting wavelength of 400nm, an ending wavelength of 800nm, and a sampling step size of 50nm. Calculating using the formula N=(800-400) / 50+1=9, the total number of wavelength sampling points N=9.

[0025] This step, which determines the parallel granularity adaptation parameters of the graphics processor's tensor cores based on the total number of film layers and the total number of wavelength sampling points, also includes: The number of consecutive film layers K is determined based on the total number of film layers and the available shared memory size of the graphics processor.

[0026] Specifically, the available shared memory size for each thread block in the current graphics processor is queried by calling the graphics processor driver application interface to obtain the total amount of shared memory. According to a preset allocation ratio, an upper limit for storage space used to cache feature matrix block groups is determined from the total shared memory. The data storage volume of a single feature matrix is ​​multiplied by the number of candidate consecutive films K, and the product must not exceed the upper limit of storage space. This constraint is used to deduce the maximum possible value of K. If the maximum possible value of K is greater than the total number of films P obtained, then the value of K is set to P.

[0027] The preset allocation ratio can be configured in the optimization parameter configuration file, and the specific value can be configured according to the actual hardware characteristics, data precision, and parallel scale. The data storage volume of a single feature matrix is ​​predetermined based on the matrix dimension and data precision and recorded as a constant. The above parameters are configuration parameters that those skilled in the art can routinely set based on experience or testing when implementing GPU parallel computing.

[0028] For example, by calling the graphics processor driver application interface, the total shared memory for each thread block of the current graphics processor is found to be 48KB, or 49152 bytes. The shared memory allocation ratio is read as 80% from the optimization parameter configuration file, and the maximum storage space available for caching feature matrix blocks is calculated to be 49152 × 0.8 ≈ 39321 bytes. Each feature matrix is ​​a 2 × 2 double-precision complex matrix, with a single matrix storage volume of 64 bytes. The maximum possible value of K is calculated to be 39321 / 64 ≈ 614. Since 614 is greater than the total number of film layers P = 8, the number of consecutive film layers K is set to 8, meaning that the entire 8-layer film system is considered a complete block.

[0029] Finally, the determined number of continuous film layers K is recorded as the core parameter for parallel particle size adaptation. At the same time, the initial thickness value of each film layer is read from the film system structure design file, and the thickness values ​​of all film layers are arranged into a film layer thickness vector according to the film layer order and loaded into the graphics processor memory.

[0030] For example, K=8 is recorded as the currently optimized parallel granularity adaptation parameter. The initial thickness values ​​of each film layer are read from the film structure design file. The thicknesses of each layer are 100nm, 200nm, 80nm, 150nm, 120nm, 90nm, 180nm, and 110nm respectively. The resulting film layer thickness vector is [100,200,80,150,120,90,180,110], and this vector is transferred to the global memory of the graphics processor for subsequent calculations.

[0031] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0032] In summary, this step ensures that the block size of subsequent matrix multiplications is precisely matched with hardware resources, avoiding waste of computing resources or insufficient parallelism caused by improper block partitioning. At the same time, loading all film thickness vectors into GPU memory at once reduces the number of data transfers between the host and device during the iteration process, providing an efficient initial computing state for the overall optimization process.

[0033] S200: Allocate an independent thread block for each wavelength sampling point, and perform calculations in parallel among the thread blocks.

[0034] In this step, an independent thread block is allocated for each wavelength sampling point. These thread blocks execute in complete parallelism and are independent of each other. Each thread block independently performs the calculation of the feature matrix of all films corresponding to that wavelength sampling point, matrix multiplication, and subsequent gradient solving, thereby achieving coarse-grained parallelism along the wavelength dimension.

[0035] For example, if the total number of wavelength sampling points N=9, corresponding to 9 wavelength points [400nm, 450nm, 500nm, 550nm, 600nm, 650nm, 700nm, 750nm, 800nm], then the GPU starts 9 thread blocks. Thread block 0 is responsible for all calculations at the 400nm wavelength point, thread block 1 is responsible for all calculations at the 450nm wavelength point, and so on, with thread block 8 responsible for all calculations at the 800nm ​​wavelength point. All 9 thread blocks start and execute simultaneously on their respective multiprocessors, without waiting or communicating with each other, achieving full parallelization of the 9 wavelength point calculation tasks.

[0036] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0037] In summary, this step, by allocating the computational tasks for different wavelength sampling points to independent thread blocks for parallel execution, transforms the serial loop of the wavelength dimension into a single-instruction, multi-threaded parallel computation, significantly shortening the total computation time for membrane system optimization at multiple wavelength points and effectively improving the throughput of large-scale membrane system optimization tasks.

[0038] S300: In each of the thread blocks, forward propagation calculations are performed based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each thin film at each wavelength sampling point.

[0039] In this step, within each thread block, the feature matrix of each thin film is calculated layer by layer using the loaded film thickness vector, the preset film complex refractive index tensor, and the wavelength sampling point corresponding to the current thread block. The film complex refractive index tensor contains the complex refractive index values ​​of each thin film material at different wavelengths. During calculation, for the i-th thin film, its film thickness, film complex refractive index, and current wavelength are substituted into the standard calculation formula for the thin film feature matrix to obtain a 2×2 complex feature matrix for that layer at the corresponding wavelength. After traversing all film layers, the feature matrix of each thin film at the current wavelength sampling point is obtained.

[0040] For example, the thread block responsible for the 550nm wavelength reads the film thickness vector [100,200,80,150,120,90,180,110] in nm from global memory, along with the complex refractive indices of the eight thin film layers at 550nm. For the first layer, with a thickness of 100nm and a complex refractive index N1 = n1 - ik1, its phase thickness δ1 = (2π / 550)·N1·100 is calculated and substituted into the characteristic matrix formula to obtain a 2×2 complex matrix. The calculations are repeated for the second to eighth layers, ultimately yielding eight characteristic matrices at 550nm. Thread blocks at other wavelength sampling points synchronously perform similar calculations, each obtaining its corresponding eight characteristic matrices at its wavelength.

[0041] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0042] In summary, this step achieves parallel construction of all film feature matrices at each wavelength point by independently executing forward propagation calculations within each thread block. This transforms the original multiple loops that required sequential execution wavelength by wavelength and film by film layer into a single-layer loop, reducing computational latency. At the same time, the calculations at each wavelength point are completely isolated, avoiding data dependencies between threads and improving the utilization of GPU computing resources and the overall computational efficiency of the forward propagation stage.

[0043] S400: In each of the thread blocks, the feature matrix is ​​divided and combined according to the number of continuous film layers K to obtain several feature matrix block groups.

[0044] Within each thread block, based on the determined number of consecutive film layers K, the feature matrices of all film layers at the current wavelength sampling point are divided into several consecutive block groups according to the film layer order. Each block group contains the feature matrices of K consecutive film layers. Through the block combination operation, well-organized matrix data blocks are prepared for subsequent calculations.

[0045] Step S400 in the method provided by the present invention includes: In each of the aforementioned thread blocks, the feature matrices of each thin film are arranged sequentially according to the continuous order of the film layers; In each of the thread blocks, the arranged feature matrices are divided into several groups, with K layers as the unit. The K feature matrices in each group correspond to consecutive K-layer thin films and are sampled at the same wavelength. In each thread block, the K feature matrices in each group are combined into a matrix sequence according to the membrane layer order, and the matrix sequence is used as the feature matrix block group.

[0046] In this step, firstly, within each thread block, the feature matrices of all films at the current wavelength sampling point are calculated and arranged sequentially from the incident side to the substrate side, forming a feature matrix sequence. Each feature matrix is ​​a 2×2 complex matrix, and the sequence length is the total number of films, P.

[0047] For example, in the thread block responsible for the 550nm wavelength, the forward propagation calculation has obtained 8 feature matrices for the 8 thin films, denoted as M1, M2, M3, M4, M5, M6, M7, and M8. M1 corresponds to the first film closest to the incident medium, and M8 corresponds to the eighth film closest to the substrate. Arranged in this order, they form the feature matrix sequence [M1, M2, M3, M4, M5, M6, M7, M8].

[0048] Furthermore, within each thread block, the determined number of consecutive film layers K is read, and the arranged feature matrix sequence is divided into several groups, with K layers as the unit. Each group contains K consecutive film layer feature matrices, corresponding to K consecutive thin films, all belonging to the same wavelength sampling point. If the total number of film layers P is not divisible by K, then the last group contains fewer than K film layers.

[0049] For example, the number of consecutive film layers K=8 determined in the previous steps, and the total number of film layers P=8, are divisible. Therefore, the feature matrix sequence [M1,M2,M3,M4,M5,M6,M7,M8] is divided into a group, which contains the feature matrices of all 8 consecutive film layers.

[0050] In another possible embodiment, if K=3 and P=8, the system is divided into three groups: the first group [M1, M2, M3] corresponds to layers 1 to 3, the second group [M4, M5, M6] corresponds to layers 4 to 6, and the third group [M7, M8] corresponds to layers 7 to 8. The last group has fewer than K and contains only two feature matrices.

[0051] Finally, the K 2×2 feature matrices in the group are arranged sequentially according to the order of the film layer from the incident side to the substrate side, forming a matrix sequence of length K. This matrix sequence is directly used as the feature matrix block group output.

[0052] For example, in the thread block responsible for the wavelength 550nm, the 8 feature matrices M1 to M8 obtained are combined into a matrix sequence [M1,M2,M3,M4,M5,M6,M7,M8] according to the film layer order. This matrix sequence is the complete feature matrix block group under the 550nm wavelength sampling point.

[0053] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0054] In summary, this step organizes the feature matrices of each film layer at the same wavelength sampling point into a regular matrix sequence according to the number K of continuous film layers for the tensor core calculation granularity. This combines the originally scattered small matrices into data blocks that can be directly processed in batches, providing an ordered data input basis for the subsequent batch matrix multiplication of the tensor core.

[0055] S500: In each of the thread blocks, the plurality of feature matrices are divided into blocks and transmitted to the tensor core to perform batch matrix multiplication, thereby obtaining the system matrix under each wavelength sampling point, and calculating the loss function value based on the system matrix.

[0056] like Figure 2As shown, in this step, within each thread block, the generated feature matrices are first divided into several groups and sequentially transmitted to the GPU's tensor core. The tensor core performs high-speed batch matrix multiplication on the K feature matrices within each group to obtain the equivalent matrix of each block. Then, the equivalent matrices of each block are multiplied in the order of the film layers to obtain the 2×2 system matrix of the entire film system at the current wavelength sampling point. Based on this system matrix, the reflectivity or transmittance is calculated and compared with the target spectrum to obtain the loss function value at that wavelength point.

[0057] In this step, within each thread block, the plurality of feature matrices are grouped and transmitted to the tensor core for batch matrix multiplication to obtain the system matrix at each wavelength sampling point, including: In each of the aforementioned thread blocks, each of the feature matrix block groups is loaded from the global memory of the graphics processor to the shared memory of the graphics processor; In each of the aforementioned thread blocks, each of the feature matrix blocks in the shared memory is loaded into the register of the tensor core through the thread bundle matrix multiply-add application programming interface; In each of the thread blocks, within the tensor core, a batch matrix multiplication is performed on the K feature matrices in each feature matrix block group to obtain the corresponding block multiplication result matrix. In each thread block, the block multiplication result matrix corresponding to each feature matrix block group is multiplied sequentially in the order of continuous membrane layers to obtain the system matrix.

[0058] Specifically, within each thread block, each generated feature matrix is ​​first divided into blocks, read from the GPU global memory, and loaded into the shared memory corresponding to that thread block. The shared memory is located inside the GPU chip, and its access latency is much lower than that of global memory. Preloading data into the shared memory reduces data waiting time during subsequent tensor core calculations. For example, in the thread block responsible for the 550nm wavelength, the matrix sequence [M1, M2, M3, M4, M5, M6, M7, M8] is loaded from the GPU global memory into the shared memory.

[0059] Furthermore, within each thread block, the thread-beam-level matrix multiplication-addition application programming interface is invoked to load the feature matrix block group data already cached in shared memory into the internal registers of the tensor core. The tensor core is a hardware unit in the GPU dedicated to matrix multiplication-addition operations. By directly transferring data to its registers through the thread-beam-level interface, the general-purpose computing unit can be bypassed, achieving data feed with minimal latency.

[0060] For example, the thread block calls the thread bundle matrix multiply-add interface function to load the first two feature matrices M1 and M2 of the matrix sequence in shared memory into the input registers A and B of the tensor core.

[0061] Furthermore, within each of the thread blocks, in the tensor core, a batch matrix multiplication is performed on the K feature matrices within each feature matrix block group, including: In each of the thread blocks, within the tensor core, matrix multiplication is performed between the first and second feature matrices in each feature matrix block group to obtain a first intermediate result matrix. In each of the aforementioned thread blocks, matrix multiplication is performed between the first intermediate result matrix and the third feature matrix to obtain the second intermediate result matrix; In each of the aforementioned thread blocks, matrix multiplication is repeatedly performed until the (K-1)th intermediate result matrix is ​​multiplied by the Kth feature matrix to obtain the block-wise multiplication result matrix.

[0062] Specifically, within each thread block, the tensor core reads the first and second feature matrices from the feature matrix block group in the register, performs matrix multiplication, and obtains the first intermediate result matrix. The dimension of this intermediate result matrix is ​​the same as that of a single feature matrix, which is a 2×2 complex matrix.

[0063] For example, the tensor core reads the feature matrix M1 of the first membrane and the feature matrix M2 of the second membrane in the feature matrix block group, performs matrix multiplication of M1×M2, and obtains the first intermediate result matrix, denoted as T1, which is a 2×2 complex matrix.

[0064] Furthermore, within each thread block, the Tensor Core performs matrix multiplication on the first intermediate result matrix obtained and the third feature matrix within the feature matrix block group to obtain the second intermediate result matrix. For example, the Tensor Core reads the feature matrix M3 of the third membrane in the feature matrix block group, performs a matrix multiplication of T1×M3, and obtains the second intermediate result matrix, denoted as T2.

[0065] Finally, in each thread block, the tensor core repeatedly performs the above matrix multiplication operation, multiplying the intermediate result matrix of the previous step with the next feature matrix in turn, until the (K-1)th intermediate result matrix is ​​multiplied with the Kth feature matrix, and finally obtains the block-by-block multiplication result matrix.

[0066] For example, the tensor core sequentially performs T2×M4 to obtain T3, T3×M5 to obtain T4, T4×M6 to obtain T5, T5×M7 to obtain T6, and finally T6×M8 to obtain the block-wise chain multiplication result matrix M. M is a 2×2 complex matrix, equivalent to the equivalent characteristic matrix of an 8-layer thin film.

[0067] In each of the thread blocks, when performing batch matrix multiplication in the tensor core, the matrix elements of the feature matrix are stored in half-precision floating-point format, and the accumulator of the batch matrix multiplication is in single-precision floating-point format.

[0068] Specifically, in the above batch matrix multiplication process, the matrix elements of each feature matrix are stored in half-precision floating-point format to reduce shared memory usage and improve the computational throughput of the tensor core; at the same time, the accumulators of all intermediate result matrices are in single-precision floating-point format to retain sufficient numerical precision during the multiplication process and avoid the accumulation of rounding errors caused by multiple accumulations.

[0069] For example, each complex element from M1 to M8 is stored in 16-bit half-precision floating-point format. When executing T1 = M1 × M2, the tensor core performs multiplication and accumulation operations in 32-bit single-precision floating-point format, and the elements of the first intermediate result matrix T1 are retained in single-precision format; each subsequent multiplication step is performed in this manner to ensure that the final block multiplication result matrix M has sufficient numerical precision to meet the precision requirements of subsequent system matrix calculations and analytical gradient solutions.

[0070] Furthermore, within each thread block, the block multiplication result matrix corresponding to each feature matrix output from the tensor core batch multiplication calculation is sequentially multiplied according to the continuous order of the film layers from the incident side to the substrate side, ultimately obtaining the system matrix of the entire film system at the current wavelength sampling point. The system matrix is ​​a 2×2 complex matrix, representing the comprehensive transmission characteristics of the entire film layer to the incident light. When the number of feature matrix blocks is only one, i.e., K≥P, the unique block multiplication result matrix is ​​the system matrix, requiring no additional matrix multiplication operations.

[0071] For example, since the number of continuous film layers K=8 is equal to the total number of film layers P=8, the entire film system is divided into only one characteristic matrix block group. The block multiplication result matrix M output by the tensor core is the system matrix at the 550nm wavelength sampling point, denoted as S(550).

[0072] In another possible embodiment, if the total number of film layers P=8 and the number of consecutive film layers K=3, the film system is divided into three groups: the first group corresponds to layers 1-3, and the result of block multiplication is matrix R1; the second group corresponds to layers 4-6, and the result is R2; the third group corresponds to layers 7-8, and the result is R3. Multiplying them sequentially according to the consecutive order of the film layers yields the system matrix S=R1×R2×R3. Here, R1, R2, R3, and S are all 2×2 complex matrices, and the multiplication order strictly follows the physical order of the film layers from the incident side to the substrate side.

[0073] Finally, within each thread block, based on the system matrix obtained at the current wavelength sampling point, the spectral characteristic parameters for that wavelength point are calculated. These calculated spectral characteristic parameters are then compared with preset target spectral characteristic parameters. Using a preset loss function, such as mean square error, the loss function value for that wavelength point is calculated. After all thread blocks corresponding to all wavelength sampling points have completed their loss function value calculations, the loss function values ​​for each wavelength point are reduced and summed or averaged to obtain the overall loss function value for the current iteration batch.

[0074] For example, assuming the incident medium is air with a refractive index of 1, and the substrate is glass with a refractive index of 1.52, and the incidence is perpendicular, the current reflectivity R = 0.15 is calculated from the system matrix elements according to thin-film optics theory. Assuming the target spectrum requires zero reflectivity at 550 nm, using the mean squared error loss function, the loss function value at this wavelength is (0.15 - 0). 2 =0.0225. After similar calculations were performed on the thread blocks at each wavelength point, the overall loss function value was obtained, that is, the average value of the loss function values ​​at the 9 wavelength points was 0.018.

[0075] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0076] In summary, this step transforms the serial multiplication of the multilayer feature matrix of the membrane system into hardware-accelerated parallel batch processing, thereby improving the computational throughput of the system matrix. At the same time, each wavelength sampling point synchronously completes the system matrix calculation and loss function evaluation within an independent thread block, realizing the integrated parallel execution of forward propagation and optimization evaluation, which significantly shortens the computation time of a single iteration in large-scale multi-wavelength optimization of membrane systems.

[0077] S600: Perform backpropagation calculation in each of the thread blocks to obtain the analytical gradient value of the film thickness of each film layer, wherein the matrix multiplication operation involved in the calculation of the analytical gradient value is transmitted to the tensor core for execution.

[0078] This step, before performing backpropagation computation in each of the aforementioned thread blocks, also includes: During the forward propagation calculation performed by each thread block, the corresponding feature matrix is ​​saved as a checkpoint matrix every L layers of film, and the unsaved intermediate layer feature matrix is ​​discarded, where L is a preset positive integer and L is less than the total number of film layers. When each of the aforementioned thread blocks needs an unsaved intermediate layer feature matrix during the backpropagation calculation, the sub-core of the graphics processor is activated to recalculate the feature matrix of the corresponding interval starting from the forward start checkpoint matrix of the interval where the intermediate layer is located.

[0079] Specifically, during the forward propagation calculation in each thread block, after calculating the feature matrix of each L-layer film according to a preset interval of L layers, the feature matrix corresponding to the current layer is saved as a checkpoint matrix and stored in the global memory or shared memory of the graphics processor. For the feature matrix of an intermediate layer located between two adjacent checkpoints, it is not retained after subsequent calculations and is directly discarded to free up memory space. Each checkpoint matrix and the subsequent L-layer films constitute a recalculation interval, with the checkpoint matrix serving as the starting point for recalculation within this interval. Here, L is a preset positive integer, and L is less than the total number of film layers P. The specific value is preset by the user or optimization configuration file based on hardware memory resources and the scale of the film system.

[0080] For example, the preset interval layer number L=3. The thread block performs forward propagation calculations from layer 1 to layer 8 in membrane layer order. When the calculation of layer 3 is completed, the feature matrix M3 of layer 3 is saved as checkpoint matrix C1; the calculation continues forward, and when the calculation of layer 6 is completed, the feature matrix M6 of layer 6 is saved as checkpoint matrix C2; the calculation continues until layer 8 to complete the entire forward propagation. M1, M2, M4, M5, and M7 are discarded after subsequent calculations, and only checkpoint matrices C1 and C2 are retained, corresponding to M3 and M6.

[0081] Furthermore, during the backpropagation calculation in each thread block, the backpropagation proceeds in reverse order from the substrate side to the incident side along the membrane layer. When the gradient calculation requires a feature matrix of an intermediate layer that has not been saved, the graphics processor subcore is activated, and starting from the most recently saved checkpoint matrix, all feature matrices between the checkpoint and the target intermediate layer are recalculated along the forward direction. The recalculated target intermediate layer feature matrix is ​​then provided for use in the backpropagation gradient calculation.

[0082] For example, the backpropagation calculation proceeds from layer 8 back to layer 1. When calculating the gradient of layer 5, the feature matrices M5 and M4 of layers 5 and 4 are needed, but they were discarded during the forward propagation phase. Since layer 5 is located in the interval between layers 4 and 6, the forward start checkpoint matrix for this interval is C2, corresponding to M6 of layer 6. A sub-core of the graphics processor is activated, starting from checkpoint matrix C2, to re-execute the forward calculation, obtaining recalculated M5 and M4, which are then used to calculate the thickness gradient of the corresponding layers 5 and 4. When the feature matrices of layers 2 and 1 are needed, since layer 1 is located in the interval between layers 1 and 3, the forward start checkpoint matrix for this interval is C1, corresponding to M3 of layer 3. The calculation starts from C1, obtaining recalculated M2 and M1.

[0083] In this step, starting from the loss function value at the current wavelength sampling point in each thread block, the gradient of the loss function with respect to the thickness of each film layer is calculated layer by layer in reverse order from the substrate side to the incident side. The required feature matrices for each layer have been saved through the forward propagation stage or restored through the checkpoint mechanism. For the i-th film layer, its analytical gradient value is calculated using the chain rule of differentiation, specifically involving the derivative of the feature matrix of that layer with respect to the film thickness, the left multiplication matrix of the feature matrix of that layer, and the right multiplication matrix. Among them, the left multiplication matrix is ​​the result of multiplying the feature matrices of the (i+1)-th to the P-th layers, and the right multiplication matrix is ​​the result of multiplying the feature matrices of the 1-th to the (i-1)-th layers.

[0084] For example, in the thread block responsible for the 550nm wavelength point, backpropagation starts from the 8th layer. For the 5th layer film, its left multiplication matrix is ​​the product of the characteristic matrices of layers 6 to 8, M6×M7×M8, and its right multiplication matrix is ​​the product of the characteristic matrices of layers 1 to 4, M1×M2×M3×M4. Combining the derivative of the 5th layer characteristic matrix with respect to thickness d5, the analytical gradient of the loss function with respect to d5 is calculated using the chain rule.

[0085] Furthermore, during the layer-by-layer gradient calculation, the multi-matrix multiplication operations involved, including the calculation of left and right multiplication matrices, are all transferred to the tensor core for execution. Specifically, for the left and right multiplication matrices required for the gradient calculation of each membrane layer, the corresponding feature matrix sequence is organized into a matrix sequence as described in the previous steps, loaded into the tensor core to complete the batch matrix multiplication, and the multiplication result is returned for the final solution of the gradient value of that layer.

[0086] For example, when calculating the gradient of the 5th layer, left multiplication of matrix M6×M7×M8 requires performing a chain multiplication of three feature matrices. The thread block combines M6, M7, and M8 into a matrix sequence according to the membrane layer order, loads it into shared memory, and transmits it to the tensor core to complete the chain multiplication, returning a 2×2 result matrix. Right multiplication of matrix M1×M2×M3×M4 is similar, performing a chain multiplication of four feature matrices through the tensor core. The two chain multiplication results, along with the derivative matrix of the 5th layer feature matrix, participate in the final gradient calculation.

[0087] In this invention, after the backpropagation calculation is completed, the preceding step of performing batch matrix multiplication in the tensor core within each thread block to obtain the system matrix at each wavelength sampling point further includes: During the execution of the batch matrix multiplication in each of the thread blocks, the change in the loss function value and the gradient norm of the analytical gradient value are monitored. When the change in the loss function value is greater than a preset change threshold or the gradient norm is greater than a preset gradient norm threshold, the matrix elements of the feature matrix of the current batch are switched from the half-precision floating-point format to the single-precision floating-point format to perform matrix multiplication. When the change in the loss function value recovers to less than or equal to the preset change threshold and the gradient norm recovers to less than or equal to the preset gradient norm threshold, the matrix elements of the feature matrix are switched from the single-precision floating-point format back to the half-precision floating-point format to perform matrix multiplication.

[0088] Specifically, after the backpropagation calculation is completed, each thread block has obtained the loss function value of the current iteration and the analytical gradient value of each film thickness. At this time, the change of the loss function value relative to the previous iteration is calculated, that is, the absolute value of the difference between the loss function values ​​of the two iterations; at the same time, the gradient norm of the analytical gradient value is calculated, that is, the magnitude of the vector formed by the gradient components of each film thickness. For example, in the t-th iteration, the loss function value is 0.15, and in the (t-1)-th iteration, the loss function value is 0.12. Therefore, the change in the loss function value is |0.15 - 0.12| = 0.03. The analytical gradient vector in the t-th iteration is [0.8, -0.5, 1.2, -0.3, 0.6, -0.9, 0.4, -0.2], and its gradient norm is approximately 1.93.

[0089] Furthermore, when the change in the loss function value exceeds a preset change threshold, or the gradient norm exceeds a preset gradient norm threshold, it indicates that the numerical precision of the half-precision floating-point format is insufficient to stably support optimization convergence, and gradient direction deviations or oscillations may occur due to rounding errors. In this case, the matrix elements of the feature matrix in the current batch (i.e., the (t+1)th iteration batch) are switched from half-precision floating-point format to single-precision floating-point format for matrix multiplication. This switching only affects the forward propagation and batch matrix multiplication stages of the current batch; subsequent batches will still dynamically determine the precision format based on monitoring results.

[0090] The preset change threshold is determined based on the spectral fitting accuracy requirements of the optimization target and historical iteration data. It is typically set to 1% to 5% of the initial loss function value. For example, if the initial loss function value is 1.0, the preset change threshold can be set to 0.01 to 0.05. Setting it too low will lead to frequent switching of accuracy, while setting it too high will prevent timely capture of numerical instability.

[0091] The preset gradient norm threshold is determined based on the magnitude of the initial values ​​of the membrane system size and membrane thickness. It can be achieved by performing several half-precision pre-calculations on the initial membrane system, statistically averaging the gradient norm, and then setting the threshold to 2-3 times the average value. For example, if the pre-calculations show that the average gradient norm of the first 5 iterations is 1.0, then the preset gradient norm threshold can be set to 2.0-3.0.

[0092] For example, the preset change threshold is 0.01, and the preset gradient norm threshold is 2.0. If the current loss function value change of 0.03 is greater than the change threshold of 0.01, and the gradient norm of 1.93 is less than the gradient norm threshold of 2.0, a precision switch is triggered. In the (t+1)th iteration, i.e., in the current batch, the matrix elements of the feature matrices M1 to M8 of the 8-layer membrane system are switched from 16-bit half-precision floating-point format to 32-bit single-precision floating-point format, and the tensor core performs batch matrix multiplication in single-precision format for this batch.

[0093] Finally, the changes in the loss function value and the gradient norm are monitored in subsequent iterations. When the change in the loss function value recovers to less than or equal to a preset change threshold, and the gradient norm recovers to less than or equal to a preset gradient norm threshold, it indicates that the optimization process has entered a stable convergence phase, and the requirement for numerical precision decreases. At this point, the matrix elements of the feature matrix in the current batch (i.e., the next iteration batch that meets the recovery conditions) are switched from single-precision floating-point format back to half-precision floating-point format for matrix multiplication to restore higher computational throughput and lower shared memory usage.

[0094] For example, rounds t+1 and t+2 are both executed in single-precision format. After backpropagation in round t+2, the change in the loss function value is 0.005, which is less than the change threshold of 0.01, and the gradient norm is 1.2, which is less than the gradient norm threshold of 2.0, thus satisfying the condition. The feature matrix storage format of the current batch, i.e., round t+3, is switched back to 16-bit half-precision floating-point, and the tensor core is restored to perform batch matrix multiplication in half-precision format.

[0095] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0096] In summary, this step employs an analytical approach to accurately calculate gradients layer by layer in reverse order along the membrane layers, avoiding truncation errors and numerical instability introduced by improper perturbation step size selection in the finite difference method. Furthermore, by saving the checkpoint matrix at intervals during the forward propagation stage and recalculating the intermediate layer feature matrix from the forward start checkpoints of each interval as needed during backpropagation, efficient memory reuse for large-scale membrane gradient calculations is achieved under limited GPU memory constraints. This significantly improves the computational efficiency and memory scalability of backpropagation in multi-wavelength, multi-layer membrane optimization scenarios while ensuring gradient solution accuracy.

[0097] S700: The analytical gradient values ​​calculated by each thread block are transmitted from the graphics processor to the host, and the film thickness vector is updated on the host according to the analytical gradient values.

[0098] In this step, the analytical gradient values ​​of all thread blocks are first transferred from the global memory of the graphics processor to the host memory via the PCIe bus, and then summarized according to the film layer index to obtain the complete analytical gradient vector, which is used as the input for the subsequent optimizer to update the film layer thickness vector.

[0099] The aggregation method is as follows: for the same film layer index, the analytical gradient components of the film layer thickness calculated by the thread block corresponding to each wavelength sampling point are reduced. The reduction method includes averaging or summing. The specific method is consistent with the reduction method of the overall loss function value in the previous step, and both are read from the optimization parameter configuration file.

[0100] For example, in a GPU, nine thread blocks corresponding to nine wavelength sampling points each perform analytical gradient calculations at their respective wavelengths. Each thread block outputs an 8-dimensional gradient vector, corresponding to the thickness gradient of the eight film layers. The host machine reads the nine sets of 8-dimensional gradient vectors from the GPU's global memory via the PCIe bus. In the host machine's memory, the gradient components at each wavelength are reduced according to the film layer index to obtain the summarized analytical gradient vector = [0.8, -0.5, 1.2, -0.3, 0.6, -0.9, 0.4, -0.2], in nm. -1 .

[0101] In this step, updating the film thickness vector on the host side based on the analytical gradient value includes: An adaptive moment estimation optimizer is loaded on the host side. The adaptive moment estimation optimizer is an optimization algorithm that dynamically adjusts the learning rate of each film layer thickness value using the first-order moment estimation and second-order moment estimation of the gradient. The analytical gradient value of the thickness of each film layer is input into the adaptive moment estimation optimizer. The adaptive moment estimation optimizer calculates the update step size for the film thickness value of each film layer. Based on the update step size of the film thickness value of each film layer, update the film thickness value corresponding to each film layer index in the film thickness vector.

[0102] Specifically, on the host side, an adaptive moment estimation optimizer is first loaded from the optimization parameter configuration file. The optimizer uses the first moment estimate of the gradient (i.e., the exponential moving average of the gradient) and the second moment estimate (i.e., the exponential moving average of the squared gradient) to dynamically adjust the learning rate of each film thickness value. It can converge quickly in the early stage of optimization and automatically reduce the update step size in the later stage of optimization to approximate the optimal solution more precisely. It also automatically adapts different effective learning rates to different film thickness parameters.

[0103] For example, the host machine reads the optimizer type as Adam from the optimization parameter configuration file and loads its hyperparameters: learning rate α=0.001, first-order moment decay coefficient β1=0.9, second-order moment decay coefficient β2=0.999, and numerical stability constant ε=10. -8 At the same time, the first-order moment vector and the second-order moment vector are initialized to zero vectors with the same dimension as the film thickness vector [100,200,80,150,120,90,180,110].

[0104] Secondly, on the host side, the analytical gradient values ​​of the film thickness of each layer are aggregated and input sequentially into the loaded adaptive moment estimation optimizer according to the film layer index order. The gradient values ​​of each film layer constitute a gradient vector, with each component corresponding to the thickness gradient of one film layer.

[0105] For example, the aggregated analytical gradient vector is [0.8, -0.5, 1.2, -0.3, 0.6, -0.9, 0.4, -0.2]. The analytical gradient vector is input into the Adam optimizer, which processes it component by component according to the film layer index. The gradient for the first layer is 0.8, for the second layer it is -0.5, and so on up to the eighth layer, which is -0.2.

[0106] Next, the adaptive moment estimation optimizer updates the first-order moment estimate and second-order moment estimate for the thickness value of each film layer, and then calculates the update step size for that film layer's thickness value based on the bias-corrected first-order and second-order moments. The bias correction method involves dividing the first-order moment estimate by... Divide the second moment estimate by This eliminates the zero-biased estimation bias caused by initializing the first and second moments to zero in the early stages of iteration, making the corrected moment estimate an unbiased estimate, where t is the current iteration number.

[0107] For example, in the current 10th iteration, the analytical gradient value of the 3rd layer membrane is 1.2. The historical values ​​of the first and second moments, saved at the end of the 9th iteration, are 0.05 and 0.02 respectively. These are read from the optimizer's internal state cache from the previous iteration batch. The optimizer updates the first moment of the 3rd layer to 0.165 and the second moment to 0.0214. After bias correction, , The first moment after bias correction is 0.165 / (1-0.349)≈0.253, and the second moment after bias correction is 0.0214 / (1-0.990)≈2.14. After bias correction, the update step size is approximately -0.00017nm. The update step size for the remaining 7 layers is calculated similarly.

[0108] Finally, based on the update step size of the membrane thickness value for each membrane layer, the thickness value at the corresponding membrane layer index in the membrane thickness vector is updated. The original thickness value is then added to the update step size to obtain the updated membrane thickness vector. After the update is complete, the membrane thickness vector will be used as the input for the forward propagation of the next iteration batch.

[0109] For example, the original thickness value of layer 3 is d3 = 80 nm. With an update step size of approximately -0.00017 nm, the updated thickness value of layer 3 is 80 - 0.00017 = 79.99983 nm. The remaining layers are updated simultaneously, and the updated film thickness vector is approximately [99.9998, 200.0001, 79.9998, 150.0001, 119.9999, 90.0002, 179.9999, 110.0001], in nm. After the update is complete, the above vector will be used as the forward propagation input for the next iteration batch, entering the next round of optimization loop.

[0110] It should be noted that the above values ​​are for illustrative purposes only and do not constitute a limitation on the present invention.

[0111] In summary, this step achieves efficient collaboration between GPU parallel gradient calculation and host-side fine-grained parameter updates, significantly accelerating the convergence speed and stability of large-scale membrane-based multi-parameter joint optimization while ensuring the accuracy of gradient information.

[0112] In summary, while ensuring the accuracy of gradient calculation, the bottlenecks of computational efficiency and memory usage in large-scale multi-wavelength optimization of thin film systems have been overcome, achieving efficient, stable, and scalable optimization of thin film structure parameters.

[0113] Example 2, as Figure 3 As shown, this invention provides a thin film structure parameter optimization system based on analytical gradients, the system comprising: The parallel granularity adaptation and data loading module 11 is used to obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized, determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points, the parallel granularity adaptation parameters include the number of continuous film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized.

[0114] The method for determining the parallel granularity adaptation parameters of the graphics processor's tensor core based on the total number of film layers and the total number of wavelength sampling points also includes: The number of consecutive film layers K is determined based on the total number of film layers and the available shared memory size of the graphics processor.

[0115] The wavelength parallel scheduling module 12 is used to allocate an independent thread block for each wavelength sampling point, and the thread blocks perform calculations in parallel.

[0116] The forward propagation calculation module 13 is used to perform forward propagation calculations in each of the thread blocks based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each thin film at each wavelength sampling point.

[0117] The feature matrix block combination module 14 is used to divide and combine the feature matrix in each thread block according to the number of continuous film layers K to obtain several feature matrix block groups.

[0118] Within each thread block, the feature matrix is ​​divided and combined according to the number of consecutive membrane layers K to obtain several feature matrix block groups, including: In each of the aforementioned thread blocks, the feature matrices of each thin film are arranged sequentially according to the continuous order of the film layers; In each of the thread blocks, the arranged feature matrices are divided into several groups, with K layers as the unit. The K feature matrices in each group correspond to consecutive K-layer thin films and are sampled at the same wavelength. In each thread block, the K feature matrices in each group are combined into a matrix sequence according to the membrane layer order, and the matrix sequence is used as the feature matrix block group.

[0119] The tensor core batch multiplication module 15 is used to transmit the plurality of feature matrices in blocks to the tensor core for batch matrix multiplication in each thread block, to obtain the system matrix under each wavelength sampling point, and to calculate the loss function value based on the system matrix.

[0120] Within each thread block, the plurality of feature matrices are grouped and transmitted to the tensor core for batch matrix multiplication to obtain the system matrix at each wavelength sampling point, including: In each of the aforementioned thread blocks, each of the feature matrix block groups is loaded from the global memory of the graphics processor to the shared memory of the graphics processor; In each of the aforementioned thread blocks, each of the feature matrix blocks in the shared memory is loaded into the register of the tensor core through the thread bundle matrix multiply-add application programming interface; In each of the thread blocks, within the tensor core, a batch matrix multiplication is performed on the K feature matrices in each feature matrix block group to obtain the corresponding block multiplication result matrix. In each thread block, the block multiplication result matrix corresponding to each feature matrix block group is multiplied sequentially in the order of continuous membrane layers to obtain the system matrix.

[0121] Within each thread block, in the tensor core, batch matrix multiplication is performed on the K feature matrices within each feature matrix block group, including: In each of the thread blocks, within the tensor core, matrix multiplication is performed between the first and second feature matrices in each feature matrix block group to obtain a first intermediate result matrix. In each of the aforementioned thread blocks, matrix multiplication is performed between the first intermediate result matrix and the third feature matrix to obtain the second intermediate result matrix; In each of the aforementioned thread blocks, matrix multiplication is repeatedly performed until the (K-1)th intermediate result matrix is ​​multiplied by the Kth feature matrix to obtain the block-wise multiplication result matrix.

[0122] In each of the thread blocks, when performing batch matrix multiplication in the tensor core, the matrix elements of the feature matrix are stored in half-precision floating-point format, and the accumulator of the batch matrix multiplication is in single-precision floating-point format.

[0123] Within each of the thread blocks, performing batch matrix multiplication in the tensor core to obtain the system matrix at each wavelength sampling point further includes: During the execution of the batch matrix multiplication in each of the thread blocks, the change in the loss function value and the gradient norm of the analytical gradient value are monitored. When the change in the loss function value is greater than a preset change threshold or the gradient norm is greater than a preset gradient norm threshold, the matrix elements of the feature matrix of the current batch are switched from the half-precision floating-point format to the single-precision floating-point format to perform matrix multiplication. When the change in the loss function value recovers to less than or equal to the preset change threshold and the gradient norm recovers to less than or equal to the preset gradient norm threshold, the matrix elements of the feature matrix are switched from the single-precision floating-point format back to the half-precision floating-point format to perform matrix multiplication.

[0124] The backpropagation analytical gradient calculation module 16 is used to perform backpropagation calculation in each of the thread blocks to obtain the analytical gradient value of the film thickness of each film layer, wherein the matrix multiplication operation involved in the calculation of the analytical gradient value is transmitted to the tensor core for execution.

[0125] Prior to performing backpropagation computation in each of the aforementioned thread blocks, the method further includes: During the forward propagation calculation performed by each thread block, the corresponding feature matrix is ​​saved as a checkpoint matrix every L layers of film, and the unsaved intermediate layer feature matrix is ​​discarded, where L is a preset positive integer and L is less than the total number of film layers. When each of the aforementioned thread blocks needs an unsaved intermediate layer feature matrix during the backpropagation calculation, the sub-core of the graphics processor is activated to recalculate the feature matrix of the corresponding interval starting from the forward start checkpoint matrix of the interval where the intermediate layer is located.

[0126] The gradient backpropagation and parameter update module 17 is used to transmit the analytical gradient values ​​calculated by each thread block from the graphics processor to the host, and update the film thickness vector on the host according to the analytical gradient values.

[0127] Updating the film thickness vector on the host side based on the analytical gradient value includes: An adaptive moment estimation optimizer is loaded on the host side. The adaptive moment estimation optimizer is an optimization algorithm that dynamically adjusts the learning rate of each film layer thickness value using the first-order moment estimation and second-order moment estimation of the gradient. The analytical gradient value of the thickness of each film layer is input into the adaptive moment estimation optimizer. The adaptive moment estimation optimizer calculates the update step size for the film thickness value of each film layer. Based on the update step size of the film thickness value of each film layer, update the film thickness value corresponding to each film layer index in the film thickness vector.

[0128] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0129] This specification and accompanying drawings are merely illustrative examples of the invention and are intended to cover any and all modifications, variations, combinations, or equivalents within the scope of the invention. Clearly, those skilled in the art can make various alterations and modifications to the invention without departing from its scope. Therefore, if such modifications and modifications fall within the scope of the invention and its equivalents, the invention is intended to include these modifications and modifications.

Claims

1. A method for optimizing thin film structure parameters based on analytical gradients, characterized in that, include: Obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized. Determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points. The parallel granularity adaptation parameters include the number of consecutive film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized. Each wavelength sampling point is assigned an independent thread block, and the calculations are performed in parallel among the thread blocks. In each of the thread blocks, forward propagation calculations are performed based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each thin film at each wavelength sampling point. Within each thread block, the feature matrix is ​​divided and combined according to the number of consecutive film layers K to obtain several feature matrix block groups, including: In each of the aforementioned thread blocks, the feature matrices of each thin film are arranged sequentially according to the continuous order of the film layers; In each of the thread blocks, the arranged feature matrices are divided into several groups, with K layers as the unit. The K feature matrices in each group correspond to consecutive K-layer thin films and are sampled at the same wavelength. In each thread block, the K feature matrices in each group are combined into a matrix sequence according to the membrane layer order, and the matrix sequence is used as the feature matrix block group; In each of the aforementioned thread blocks, the plurality of feature matrices are grouped and transmitted to the tensor core for batch matrix multiplication to obtain the system matrix at each wavelength sampling point, and the loss function value is calculated based on the system matrix, including: In each of the aforementioned thread blocks, each of the feature matrix block groups is loaded from the global memory of the graphics processor to the shared memory of the graphics processor; In each of the aforementioned thread blocks, each of the feature matrix blocks in the shared memory is loaded into the register of the tensor core through the thread bundle matrix multiply-add application programming interface; In each of the thread blocks, within the tensor core, a batch matrix multiplication is performed on the K feature matrices in each feature matrix block group to obtain the corresponding block multiplication result matrix. In each of the thread blocks, the block multiplication result matrices corresponding to each feature matrix block group are multiplied sequentially in the order of continuous membrane layers to obtain the system matrix; In each of the aforementioned thread blocks, the loss function value is calculated based on the system matrix; Backpropagation calculations are performed in each of the aforementioned thread blocks to obtain the analytical gradient value of the film thickness of each film layer, wherein the matrix multiplication operations involved in the calculation of the analytical gradient value are transmitted to the tensor core for execution. The analytical gradient values ​​calculated by each of the thread blocks are transmitted from the graphics processor to the host, and the film thickness vector is updated on the host based on the analytical gradient values.

2. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 1, characterized in that, The parallel granularity adaptation parameters of the graphics processor's tensor cores are determined based on the total number of film layers and the total number of wavelength sampling points, and also include: The number of consecutive film layers K is determined based on the total number of film layers and the available shared memory size of the graphics processor.

3. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 1, characterized in that, Within each thread block, in the tensor core, a batch matrix multiplication is performed on the K feature matrices within each feature matrix block group, including: In each of the thread blocks, within the tensor core, matrix multiplication is performed between the first and second feature matrices in each feature matrix block group to obtain a first intermediate result matrix. In each of the aforementioned thread blocks, matrix multiplication is performed between the first intermediate result matrix and the third feature matrix to obtain the second intermediate result matrix; In each of the aforementioned thread blocks, matrix multiplication is repeatedly performed until the (K-1)th intermediate result matrix is ​​multiplied by the Kth feature matrix to obtain the block-wise multiplication result matrix.

4. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 1, characterized in that, Before performing backpropagation computation in each of the aforementioned thread blocks, the following is also included: During the forward propagation calculation performed by each thread block, the corresponding feature matrix is ​​saved as a checkpoint matrix every L layers of film, and the unsaved intermediate layer feature matrix is ​​discarded, where L is a preset positive integer and L is less than the total number of film layers. When each of the aforementioned thread blocks needs an unsaved intermediate layer feature matrix during the backpropagation calculation, the sub-core of the graphics processor is activated to recalculate the feature matrix of the corresponding interval starting from the forward start checkpoint matrix of the interval where the intermediate layer is located.

5. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 1, characterized in that, In each of the aforementioned thread blocks, when performing batch matrix multiplication in the tensor core, the matrix elements of the feature matrix are stored in half-precision floating-point format, and the accumulator of the batch matrix multiplication is in single-precision floating-point format.

6. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 5, characterized in that, Within each of the aforementioned thread blocks, batch matrix multiplication is performed in the tensor core to obtain the system matrix at each wavelength sampling point, and the process further includes: During the execution of the batch matrix multiplication in each of the thread blocks, the change in the loss function value and the gradient norm of the analytical gradient value are monitored. When the change in the loss function value is greater than a preset change threshold or the gradient norm is greater than a preset gradient norm threshold, the matrix elements of the feature matrix of the current batch are switched from the half-precision floating-point format to the single-precision floating-point format to perform matrix multiplication. When the change in the loss function value recovers to less than or equal to the preset change threshold and the gradient norm recovers to less than or equal to the preset gradient norm threshold, the matrix elements of the feature matrix are switched from the single-precision floating-point format back to the half-precision floating-point format to perform matrix multiplication.

7. The method for optimizing thin film structure parameters based on analytical gradients as described in claim 1, characterized in that, Updating the film thickness vector on the host side based on the analytical gradient value includes: An adaptive moment estimation optimizer is loaded on the host side. The adaptive moment estimation optimizer is an optimization algorithm that dynamically adjusts the learning rate of each film layer thickness value using the first-order moment estimation and second-order moment estimation of the gradient. The analytical gradient value of the thickness of each film layer is input into the adaptive moment estimation optimizer. The adaptive moment estimation optimizer calculates the update step size for the film thickness value of each film layer. Based on the update step size of the film thickness value of each film layer, update the film thickness value corresponding to each film layer index in the film thickness vector.

8. A thin film structure parameter optimization system based on analytical gradient, characterized in that, The method for performing the thin film structure parameter optimization based on analytical gradient as described in any one of claims 1 to 7 includes: The parallel granularity adaptation and data loading module is used to obtain the total number of film layers and the total number of wavelength sampling points of the film system to be optimized, determine the parallel granularity adaptation parameters of the tensor core of the graphics processor based on the total number of film layers and the total number of wavelength sampling points, the parallel granularity adaptation parameters include the number of consecutive film layers K contained in each feature matrix block group, and load the film layer thickness vector of the film system to be optimized. The wavelength parallel scheduling module is used to allocate an independent thread block to each wavelength sampling point, and the calculations are performed in parallel among the thread blocks. The forward propagation calculation module is used to perform forward propagation calculations in each of the thread blocks based on the film thickness vector, the film complex refractive index tensor, and the wavelength sampling point tensor to obtain the feature matrix of each film layer at each wavelength sampling point. The feature matrix block combination module is used to divide and combine the feature matrix in each thread block according to the number of consecutive film layers K to obtain several feature matrix block groups. The Tensor Core Batch Multiplication Module is used to transmit the several feature matrices in blocks to the Tensor Core for batch matrix multiplication in each thread block, to obtain the system matrix under each wavelength sampling point, and to calculate the loss function value based on the system matrix. The backpropagation analytical gradient calculation module is used to perform backpropagation calculation in each of the thread blocks to obtain the analytical gradient value of the film thickness value of each film layer, wherein the matrix multiplication operation involved in the calculation of the analytical gradient value is transmitted to the tensor core for execution. The gradient backpropagation and parameter update module is used to transmit the analytical gradient values ​​calculated by each thread block from the graphics processor to the host, and update the film thickness vector on the host according to the analytical gradient values.

Citation Information

Patent Citations

  • Layered medium Green function rapid calculation method and device based on GPU

    CN118069969A

  • Banded matrix LU decomposition fusion optimization method and system

    CN121743652A

  • Optical system polarization aberration optimization design method based on multi-group film system collaborative optimization strategy

    CN115826228A

  • Thin film circuit board display technology processing system

    CN121284836A