[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
+129 -40
View File
@@ -2,64 +2,153 @@
id: wiki-2026-0508-joint-optimization
title: Joint Optimization
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-JOOP-001]
aliases: [Multi-Objective Optimization, Co-Optimization, End-to-End Optimization]
duplicate_of: none
source_trust_level: A
confidence_score: 0.91
tags: [auto-reinforced, joint-Optimization, _system-design, end-to-end, synergetic-optimization]
confidence_score: 0.9
verification_status: applied
tags: [optimization, ML, multi-objective]
raw_sources: []
last_reinforced: 2026-04-20
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: python
framework: pytorch-jax
---
# [[Joint-Optimization|Joint-Optimization]]
# Joint Optimization
## 📌 한 줄 통찰 (The Karpathy Summary)
> "전체는 부분의 합보다 크다: 개별 부품이나 단계를 제각각 최적화(Local Optima)하기보다, 시스템의 모든 구성 요소가 서로에게 미치는 영향을 고려하여 전체의 목표(Global Optima)를 위해 동시에 조율하는 하모니의 기술."
## 한 줄
> **"매 multiple objectives / variables 를 동시에 optimize"**. 매 separate / sequential optimization 보다 매 globally better solution 도달 가능 — 매 cost: 매 higher complexity, 매 risk: 매 conflicting gradients. 매 modern DL (end-to-end training), 매 RL (actor-critic), 매 chip design (DSE) 의 매 핵심.
## 📖 구조화된 지식 (Synthesized Content)
공동 최적화(Joint-Optimization)는 여러 변수나 프로세스를 개별적으로 처리하지 않고 통합적으로 최적화하는 접근법입니다.
## 매 핵심
1. **주요 개념**:
* **End-to-End Learning**: 데이터 입력부터 최종 출력까지 중간 단계 없이 하나의 신경망으로 통째로 최적화. (Deep Learning (DL)의 철학)
* **[[Hardware|Hardware]]-Software Co-design**: 소프트웨어 로직과 반도체 설계를 동시에 최적화하여 압도적 성능 달성. (Hardware와 연결)
2. **왜 중요한가?**:
* 각 부분은 최선일지라도 그들의 연결점에서 병목(Bottleneck)이 생기는 것을 원천 봉쇄하여 전체 시스템의 효율을 극대화함. ([[Efficiency|Efficiency]]와 연결)
### 매 왜 jointly?
- **Coupling**: 매 variables 의 interaction 강 → 매 separate solve 매 suboptimal.
- **Information sharing**: 매 shared representation / gradient → 매 mutual benefit.
- **End-to-end**: 매 pipeline 의 손실 누적 X.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌**: 과거에는 복잡성을 줄이기 위해 각 단계를 독립적으로 분리하여 관리하는 '모듈화 정책'이 우세했으나, 현대 정책은 최고 성능을 위해 모듈 간의 경계를 허물고 동시에 학습/설계하는 '통합 정책'이 대세가 됨(RL Update).
- **정책 변화(RL Update)**: 다계층 에이전트 시스템 정책에서, 기획 에이전트와 실행 에이전트를 따로 두지 않고 서로의 피드백을 즉시 반영하여 전체 워크플로우를 공동 최적화하는 정책이 차세대 에이전트 설계의 핵심이 됨. (Agentic-Workflow와 연결)
### 매 challenges
- **Conflicting gradients**: 매 objectives 매 push opposite directions.
- **Scaling**: 매 loss magnitudes 매 mismatched → 매 dominant loss problem.
- **Local minima**: 매 joint landscape 매 더 rugged.
- **Compute**: 매 N variables 매 jointly → search space exponential.
## 🔗 지식 연결 (Graph)
- [[Optimization|Optimization]], [[Efficiency|Efficiency]], Deep Learning (DL), [[Hardware|Hardware]], Agentic-Workflow
- **Modern Tech/Tools**: DeepSpeed (Training optimization), End-to-end autonomous driving, ASIC co-design.
---
### 매 응용
1. **Multi-task learning**: 매 shared encoder + 매 multiple heads.
2. **Actor-critic RL**: 매 policy + value 매 jointly.
3. **HW/SW co-design**: 매 chip floorplan + scheduler 매 jointly.
4. **Pareto front**: 매 cost vs latency 매 frontier.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
## 💻 패턴
**언제 이 지식을 쓰는가:**
- *(TODO)*
### Weighted sum (simplest)
```python
import torch
**언제 쓰면 안 되는가:**
- *(TODO)*
def joint_loss(pred1, pred2, y1, y2, w=(0.5, 0.5)):
l1 = torch.nn.functional.cross_entropy(pred1, y1)
l2 = torch.nn.functional.mse_loss(pred2, y2)
return w[0] * l1 + w[1] * l2
```
## 🧪 검증 상태 (Validation)
### GradNorm (auto-balance)
```python
# Chen et al 2018 — 매 dynamic loss weighting
class GradNorm:
def __init__(self, n_tasks, alpha=1.5):
self.weights = torch.ones(n_tasks, requires_grad=True)
self.alpha = alpha
def update(self, losses, shared_params):
# 매 normalize 매 gradient magnitudes across tasks
grads = [torch.autograd.grad(l, shared_params, retain_graph=True)
for l in losses]
norms = torch.stack([g[0].norm() for g in grads])
target = norms.mean() * (losses / losses.mean()) ** self.alpha
gradnorm_loss = (norms - target.detach()).abs().sum()
return gradnorm_loss
```
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
### MGDA (Multi-Gradient Descent)
```python
# Sener & Koltun 2018 — 매 Pareto-optimal direction 찾기
import numpy as np
## 🧬 중복 검사 (Duplicate Check)
def mgda_solver(grads):
"""grads: list of gradient vectors per task."""
# 매 minimum-norm point in convex hull
G = np.stack([g.flatten() for g in grads])
# solve min ||sum α_i g_i||² s.t. α≥0, sum α=1
from scipy.optimize import minimize
def obj(a): return np.linalg.norm(a @ G) ** 2
a0 = np.ones(len(grads)) / len(grads)
cons = [{"type": "eq", "fun": lambda a: a.sum() - 1}]
bnds = [(0, 1)] * len(grads)
res = minimize(obj, a0, constraints=cons, bounds=bnds)
return res.x # 매 Pareto direction
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### Actor-critic joint update
```python
# PPO-style joint optimization
def actor_critic_loss(states, actions, advantages, returns, policy, value):
log_p = policy.log_prob(states, actions)
actor_loss = -(log_p * advantages).mean()
critic_loss = (value(states) - returns).pow(2).mean()
entropy = policy.entropy(states).mean()
return actor_loss + 0.5 * critic_loss - 0.01 * entropy
```
## 🕓 변경 이력 (Changelog)
### Pareto frontier sampling
```python
# 매 multi-objective 의 frontier 발견
def pareto_front(solutions):
"""solutions: list of (obj1, obj2) tuples (minimize both)."""
front = []
for s in solutions:
dominated = any(
s2[0] <= s[0] and s2[1] <= s[1] and s2 != s
for s2 in solutions
)
if not dominated:
front.append(s)
return front
```
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 매 결정 기준
| 상황 | Strategy |
|---|---|
| 매 objectives 매 aligned | Weighted sum (simple) |
| 매 objectives 매 conflicting | MGDA / PCGrad |
| 매 magnitude 매 mismatched | GradNorm |
| 매 trade-off 매 explore 필요 | Pareto frontier sweep |
| 매 RL actor + critic | Joint PPO/SAC |
**기본값**: Weighted sum 시작 → 매 imbalance 발견시 GradNorm 도입.
## 🔗 Graph
- 부모: [[Optimization]] · [[Multi-Task-Learning]]
- 변형: [[Pareto-Optimization]] · [[Bilevel-Optimization]]
- 응용: [[Actor-Critic]] · [[End-to-End-Learning]] · [[HW-SW-CoDesign]]
- Adjacent: [[Loss-Weighting]] · [[Gradient-Surgery]]
## 🤖 LLM 활용
**언제**: 매 loss function design 매 multi-objective, 매 gradient conflict diagnosis, 매 Pareto analysis explanation.
**언제 X**: 매 single-objective optimization — over-complication.
## ❌ 안티패턴
- **Random weight tuning**: 매 grid search w/o GradNorm → 매 unstable.
- **Ignore gradient conflict**: 매 cosine(g1,g2) < 0 무시 → 매 destructive interference.
- **Premature joint**: 매 separate pretrain → joint finetune 매 더 좋은 경우 많음.
## 🧪 검증 / 중복
- Verified (Chen 2018 GradNorm; Sener & Koltun 2018 MGDA; Yu 2020 PCGrad; Schulman 2017 PPO).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — multi-objective optimization patterns + Pareto |