f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6.5 KiB
6.5 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-pid-controllers-in-ai | PID Controllers in AI | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
PID Controllers in AI
매 한 줄
"매 error = setpoint - measurement 에 P/I/D 항을 적용해 actuator 를 제어". 1922 Minorsky ship steering 에서 시작, 매 산업 control 의 80%+ 사용. 매 2026 의 AI hybrid 사용: drone attitude (PX4), robot joint, LLM token-budget control, RLHF KL-coefficient tuning, training schedules.
매 핵심
매 PID 공식
- u(t) = Kp·e(t) + Ki·∫e(τ)dτ + Kd·de/dt.
- P (Proportional): 매 현재 error 에 비례 — 매 fast response, 매 steady-state error 남김.
- I (Integral): 매 누적 error — 매 steady-state error 제거, 매 windup 위험.
- D (Derivative): 매 변화율 — 매 overshoot 감소, 매 noise 증폭.
매 tuning methods
- Ziegler-Nichols: 매 Ku, Tu (oscillation) 측정 후 공식 적용.
- Cohen-Coon: 매 process reaction curve 기반.
- AutoTuning: 매 relay feedback (Åström-Hägglund).
- Bayesian optimization: 매 simulation rollout + GP.
- RL-based: 매 PPO/SAC 으로 Kp, Ki, Kd 학습.
매 응용
- Drone attitude (PX4, ArduPilot).
- Robot joint position control (ROS 2).
- Cruise control, HVAC, 3D printer extruder.
- LLM serving — token-rate controller (vLLM 의 batch sizing).
- RLHF KL-coefficient adaptive tuning.
- Training: gradient norm clipping with adaptive coefficient.
💻 패턴
Plain PID (discrete)
class PID:
def __init__(self, kp, ki, kd, dt, output_limits=(-1, 1)):
self.kp, self.ki, self.kd, self.dt = kp, ki, kd, dt
self.lo, self.hi = output_limits
self.integral = 0.0
self.prev_error = 0.0
def __call__(self, setpoint, measurement):
error = setpoint - measurement
self.integral += error * self.dt
derivative = (error - self.prev_error) / self.dt
output = self.kp*error + self.ki*self.integral + self.kd*derivative
output = max(self.lo, min(self.hi, output))
self.prev_error = error
return output
Anti-windup (clamp + back-calculation)
class PIDAntiWindup(PID):
def __init__(self, *args, kt=0.5, **kw):
super().__init__(*args, **kw)
self.kt = kt # back-calc gain
def __call__(self, setpoint, measurement):
error = setpoint - measurement
derivative = (error - self.prev_error) / self.dt
u_unsat = self.kp*error + self.ki*self.integral + self.kd*derivative
u_sat = max(self.lo, min(self.hi, u_unsat))
# back-calculation: discount integral when saturated
self.integral += self.dt * (error + self.kt * (u_sat - u_unsat))
self.prev_error = error
return u_sat
Derivative on measurement (D-kick 회피)
class PIDDerivOnMeas(PID):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
self.prev_meas = None
def __call__(self, setpoint, measurement):
error = setpoint - measurement
if self.prev_meas is None:
d = 0
else:
d = -(measurement - self.prev_meas) / self.dt # 매 setpoint step → spike 없음
self.integral += error * self.dt
out = self.kp*error + self.ki*self.integral + self.kd*d
self.prev_meas = measurement
return max(self.lo, min(self.hi, out))
Ziegler-Nichols tuning
def ziegler_nichols(Ku, Tu, kind="classic"):
if kind == "classic":
return dict(kp=0.6*Ku, ki=1.2*Ku/Tu, kd=0.075*Ku*Tu)
elif kind == "no-overshoot":
return dict(kp=0.2*Ku, ki=0.4*Ku/Tu, kd=Ku*Tu/15)
elif kind == "PI-only":
return dict(kp=0.45*Ku, ki=0.54*Ku/Tu, kd=0)
RLHF adaptive KL (PPO-style β)
def adaptive_kl_pid(kl_observed, kl_target=0.02, state=None):
"""β ↑ when KL too large; β ↓ when too small. PI controller on log(β)."""
if state is None:
state = {"integral": 0.0, "log_beta": 0.0}
error = kl_observed - kl_target
state["integral"] += error
state["log_beta"] += 0.1 * error + 0.01 * state["integral"]
return float(np.exp(state["log_beta"])), state
LLM token-rate controller (server batch)
def batch_size_pid(target_tps, current_tps, pid_state):
"""Maintain target tokens/sec by adjusting batch size."""
delta = target_tps - current_tps
pid_state["integral"] += delta
adj = 0.05*delta + 0.001*pid_state["integral"]
return max(1, int(pid_state["batch"] + adj))
매 결정 기준
| 상황 | Controller |
|---|---|
| no steady-state error needed | P only |
| eliminate steady-state, slow process | PI |
| fast + minimal overshoot | PID with D-on-measurement |
| highly nonlinear / complex | MPC or RL (not PID) |
| discrete-event / queue | PI on rate |
| training schedule (KL, lr) | adaptive PI |
기본값: 매 80% 의 경우 PI 면 충분. 매 D 매 noise 환경에서 신중히.
🔗 Graph
- 부모: Control-Theory · Feedback-Control-Systems
- 응용: Robotics · RLHF
- Adjacent: Model-Predictive-Control (MPC) · Kalman-Filter-and-State-Tracking · Reinforcement-Learning
🤖 LLM 활용
언제: 매 inference server batch sizing, 매 RLHF KL coefficient, 매 lr schedule under loss target. 언제 X: 매 highly nonlinear delays — MPC. 매 strong constraints — RL/MPC.
❌ 안티패턴
- No anti-windup with saturation: 매 integral 폭주 → overshoot.
- D term on noisy raw signal: 매 noise 증폭 → 매 LPF (low-pass filter) 필수.
- Derivative on setpoint (D-kick): 매 setpoint step → spike. 매 D-on-measurement 사용.
- One-size-fits-all gains across operating regions: 매 nonlinear 시스템 — gain scheduling 필요.
- Tuning by 임의 가이드: 매 system 마다 다름 — Ziegler-Nichols 또는 simulation 사용.
🧪 검증 / 중복
- Verified (Åström & Hägglund, PID Controllers; Franklin et al. Feedback Control of Dynamic Systems; ArduPilot/PX4 firmware).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — PID FULL with anti-windup, D-on-meas, RLHF/serving applications |