CANN/mat-chem-sim-pred IPDT PID批量评分算法
PidIpdtBatchRolloutScore Algorithm【免费下载链接】mat-chem-sim-pred面向工业领域聚焦计算仿真、预测两大核心场景构建面向流程工业机理数据双轮驱动的领域计算层推动AI for Science在材料化学领域的深度应用。项目地址: https://gitcode.com/cann/mat-chem-sim-predPurposeThis operator evaluates many PID candidates for many IPDT loops during the tuning stage and returns the best candidate for each loop.The target workload is:batch loops x candidate set x rollout time stepsModelThe plant model is discretized IPDT (integrator plus dead time):y[k1] y[k] b * u[k-delay]This is thea 1special case of the FOPDT recurrencey[k1] a*y[k] b*u[k-delay]: there is no self-regulating decay term, so the plant integrates the (delayed) control input. There is noainput;bis the per-step integration gain. Everything else (PID law, scoring, candidate-axis SIMD, delay ring, tiling) is identical toPidFopdtBatchRolloutScore.The PID law is:e[k] sp - y[k] integral e[k] * dt derivative (e[k] - e[k-1]) / dt u[k] clamp(Kp * e[k] Ki * integral Kd * derivative, -10, 10)ScoreFor each candidate, the rollout accumulates:IAEISEovershootsettling_timecontrol_energyThe optimization target is:score IAE overshoot_weight * overshoot settling_weight * settling_time control_weight * control_energyThe operator returns the candidate with minimumscore.NPU Execution StrategyThe current implementation uses a two-stage tiled structure:host splits the candidate axis into tileslocal kernel evaluates one tile for all assigned loops and writes partial best resultsfinal kernel reduces all tile-local best results into one best result per loopThis structure was chosen because the earlier single-launch(loop, tile)task mapping showed unstable coverage onnode202. The current host-per-tile launch plus conservative loop-range partitioning restores correctness.Kernel difference from FOPDTThe only change versus the FOPDT kernel is the state recurrence: theMuls(ytmp, y, model_a)decay step is dropped andyis updated in place asAdd(y, y, model_b * u[k-delay]). TheaGM input and its tensor are removed. The state vector count, scratch layout, delay ring and reduction are unchanged, sokLane768still fits the 192 KB UB budget.VectorizationThe rollout time dimension is a serial recurrence (y[k1]depends ony[k]) and cannot be turned into GEMM-style dense math without dropping the per-step nonlinearities (control clamp) and the nonlinear score functionals (IAE/ISE/overshoot/settling), so the kernel keeps the exact step-by-step recurrence.The parallelism instead lives on the candidate axis: every timestep applies the same chain of vector ops to all candidates at once. Because the recurrence is serial, that chain of dependent vector ops cannot be pipelined across timesteps, so with a narrow lane the inner loop is bound by per-instruction issue/latency rather than by compute throughput. The kernel therefore evaluates the candidate axis with a wide SIMD lane (kLane768): more candidates per vector instruction means fewer instructions for the same work, which amortises the fixed instruction latency and makes the loop throughput-bound.kLane768is the largest lane that keeps the 8 state vectors scratch the 32-slot delay ring (delay spec0..31) I/O queues within the 192 KB UB budget. Widening the lane is a pure layout change and leaves the output bit-identical.Engineering ConclusionThis operator is valuable as:an independent PID tuning operator samplea correctness-verified NPU exploration artifact (NPU output matches the CPU reference, quality rel-err 1e-3)a single-card rollout that reuses the FOPDT wide-lane plus fused inner-loop optimizationsThe inner loop was also reduced from ~37 to ~32 vector ops per timestep by reusing the response error as the next steps error and by folding the non-feedback metric accumulators (IAE/ISE/control energy) into fused multiply-accumulates; this is bit-identical to the original. The remaining single-card headroom is a cheaper settling reduction; multi-card data parallelism scales the absolute time further but is a hardware lever, not a single-card algorithmic speedup.【免费下载链接】mat-chem-sim-pred面向工业领域聚焦计算仿真、预测两大核心场景构建面向流程工业机理数据双轮驱动的领域计算层推动AI for Science在材料化学领域的深度应用。项目地址: https://gitcode.com/cann/mat-chem-sim-pred创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考