CANN/PID FOPDT批量闭环滚动评分算子

📅 2026/7/4 7:15:22
CANN/PID FOPDT批量闭环滚动评分算子
PidFopdtBatchRolloutScore【免费下载链接】mat-chem-sim-pred面向工业领域聚焦计算仿真、预测两大核心场景构建面向流程工业机理数据双轮驱动的领域计算层推动AI for Science在材料化学领域的深度应用。项目地址: https://gitcode.com/cann/mat-chem-sim-predOverviewPidFopdtBatchRolloutScoreis an independent FOPDT batch closed-loop rollout operator for PID candidate scoring. It evaluates a batch of FOPDT process models against a shared PID candidate set on NPU and returns the best candidate per loop.This operator is used in the tuning stage as the FOPDT candidate simulation and selection kernel:input is process model parameters plus PID candidate arraysoutput is per-loop best score and best PID gainsimplementation is independent from the earlier model-fit operators工程语义候选仿真不是模型辨识后处理。模型辨识/残差评估使用历史mv/pv回答“模型能否解释过去的数据”本算子在已知 FOPDT 模型后用 PID 自己计算出的未来控制量u做闭环递推回答“如果使用某组 PID 参数未来闭环响应好不好”。FOPDT 离散对象为y[k1] a * y[k] b * u[k - delay]PID 控制律为error sp - y integral error * sample_interval derivative (error - prev_error) / sample_interval u Kp * error Ki * integral Kd * derivative算子会对每个候选Kp/Ki/Kd仿真整段闭环响应在递推过程中累计IAE/ISE/overshoot/settling_time/control_energy按固定权重形成score最后输出每条回路的最优候选。也就是说当前主链已经把“候选特征提取、候选评分、候选选优”融合在同一个 rollout kernel 中只输出 best不输出所有候选的完整特征表。PID 候选来源不由本算子决定。它只接收已经准备好的kp[M]、ki[M]、kd[M]数组这些候选可以来自 Ziegler-Nichols/IMC/Cohen-Coon 规则也可以来自规则结果附近的扰动网格、人工网格、历史现场参数附近搜索或外部优化器。当前 accuracy E2E 使用三套规则产生的 3 个候选performance E2E 使用手工生成的大规模候选网格候选数可扫到 256、512、1024、4096、16384 等。与其他 rollout/候选评估算子的关系pid_ipdt_batch_rollout_score使用积分加滞后对象y[k1] y[k] b*u[k-delay]。pid_sopdt_batch_rollout_score使用二阶对象y[k1] a1*y[k] a2*y[k-1] b*u[k-delay]。早期 FOPDT 标量 rollout 原型已从本次正式提交中撤回本算子是候选维向量化/tiling 后的正式版本。pid_step_response_features适用于上游已经产生完整pv_candidates[B,C,N]且需要保留每个候选可解释特征的场景当前 batch rollout 主链已经融合固定评分和 best 选择不需要再接独立候选评分/选优算子。小例子只看比例控制以便手算设a 1.0, b 0.5, delay 0, y0 0, sp 1 候选 A: Kp 1, Ki 0, Kd 0 候选 B: Kp 3, Ki 0, Kd 0候选 Ak0: error1, u1, y_next0 0.5*1 0.5 k1: error0.5, u0.5, y_next0.50.5*0.5 0.75 k2: error0.25,u0.25,y_next0.750.5*0.25 0.875候选 Bk0: error1, u3, y_next1.5 k1: error-0.5, u-1.5, y_next0.75 k2: error0.25, u0.75, y_next1.125候选 B 响应更快但有超调/振荡候选 A 更稳但慢。rollout 算子会把这类轨迹差异压成 score并选出代价最小的 PID。Current status:correctness has been validated against the CPU reference onnode202 / Ascend910B3; NPU output is bit-identicalthe rollout is a serial time recurrence; the candidate axis is evaluated with a wide vector SIMD lane (kLane768) so the inner loop is throughput-bound rather than latency-boundon a single card the NPU kernel runs roughly 4-7x the 64-thread CPU baseline at the candidate counts that dominate the tuning sweep (see the benchmark report), with no accuracy trade-offSee benchmark report for the measured results.Inputs And OutputsTensorDtypeShapeMeaningafloat32[B]FOPDT discrete coefficientbfloat32[B]FOPDT discrete gain termdelayint32[B]input delay, clamped to0..31in kernely0float32[B]initial outputspfloat32[B]setpointkpfloat32[M]PID candidate Kpkifloat32[M]PID candidate Kikdfloat32[M]PID candidate Kdbest_resultfloat32[B, 8]best candidate metrics per loopbest_idxint32[B]best candidate index per loopbest_resultlayout:best_score,best_kp,best_ki,best_kd,best_iae,best_ise,best_overshoot,best_settling_timeBuildcd prediction/ProcessControl/PIDModelFit/pid_fopdt_batch_rollout_score cmake -S . -B build -DCMAKE_BUILD_TYPERelease -DSOC_VERSIONAscend910B3 cmake --build build -j$(nproc)Note:this project now defaults toReleaseifCMAKE_BUILD_TYPEis not specifiedonnode202, runtime typically needs:export LD_LIBRARY_PATH/usr/local/Ascend/ascend-toolkit/latest/lib64:$PWD/build:$PWD/build/lib:${LD_LIBRARY_PATH}TestPython reference test:python tests/test_pid_fopdt_batch_rollout_score.pyNPU smoke:./build/test_aclnn_pid_fopdt_batch_rollout_score 0NPU / CPU benchmark:./build/benchmark_pid_fopdt_batch_rollout_score 0 64 1024 1024 0 2 0 64 # candidate_tile0 auto (min(C, kLane768))DocumentsAlgorithmAPI ReferenceBenchmark Report【免费下载链接】mat-chem-sim-pred面向工业领域聚焦计算仿真、预测两大核心场景构建面向流程工业机理数据双轮驱动的领域计算层推动AI for Science在材料化学领域的深度应用。项目地址: https://gitcode.com/cann/mat-chem-sim-pred创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考