[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,63 +1,159 @@
|
||||
---
|
||||
id: wiki-2026-0508-amdahls-law-암달의-법칙
|
||||
title: Amdahls Law (암달의 법칙)
|
||||
id: wiki-2026-0508-amdahls-law
|
||||
title: Amdahl's Law
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AI-AMDAHL]
|
||||
aliases: [암달의 법칙, parallel speedup, scaling limit, Gustafson contrast]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.98
|
||||
tags: [Computing, Performance, Parallelism, AmdahlsLaw]
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [parallel-computing, performance, scaling, hpc, gpu, optimization, profiling]
|
||||
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: any
|
||||
applicable_to: [HPC, GPU, Distributed Systems, ML Training]
|
||||
---
|
||||
|
||||
# [[Amdahls Law (암달의 법칙)|Amdahls Law (암달의 법칙)]]
|
||||
# Amdahl's Law
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "아무리 엔진을 갈아 끼워도, 좁은 병목 구간이 전체 속도를 결정한다." 시스템 일부분을 병렬화하거나 개선했을 때 얻을 수 있는 전체 성능 향상의 한계는 개선되지 않은 나머지 부분(직렬 구간)에 의해 제한된다는 법칙이다.
|
||||
## 📌 한 줄 통찰
|
||||
> **"매 bottleneck 가 speed 의 결정"**. 매 90% 의 100× → 매 전체 가 매 10× 의 한계. 매 parallelization 의 ceiling. 매 어디 의 fast 보다 매 어디 의 unchangeable.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **The Formula**:
|
||||
- $Speedup = \frac{1}{(1-P) + \frac{P}{S}}$
|
||||
- $P$: 병렬화 가능한 부분의 비율.
|
||||
- $S$: 그 부분을 얼마나 빠르게 개선했는지의 배수.
|
||||
- **Key Message**:
|
||||
- 프로그램의 90%를 100배 빠르게 만들어도, 변하지 않는 나머지 10% 때문에 전체 속도는 절대 10배 이상 빨라질 수 없다.
|
||||
- 성능 최적화 시 '어디를 개선할 것인가'보다 '어디가 변하지 않는가'를 먼저 보는 것이 중요하다.
|
||||
## 📖 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- 암달의 법칙은 '고정된 문제 크기'를 가정한다. 하지만 실제로는 컴퓨팅 파워가 커지면 문제의 크기 자체를 늘리는 경우가 많은데, 이를 설명하는 구스타프슨의 법칙(Gustafson's Law)이 병렬 컴퓨팅의 희망적인 측면을 보완해준다.
|
||||
### 매 formula
|
||||
$$Speedup = \frac{1}{(1-P) + \frac{P}{S}}$$
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Related: [[Parallel-Computing|Parallel-Computing]] , Bottleneck-[[Analysis|Analysis]]
|
||||
- Complement: Gustafsons-Law
|
||||
- **P**: 매 parallel 가능 비율 (0..1).
|
||||
- **S**: 매 parallel 부분 의 speedup factor (cores).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 example
|
||||
| P (parallel) | S (cores) | Total speedup |
|
||||
|---|---|---|
|
||||
| 0.50 | ∞ | 2× |
|
||||
| 0.75 | ∞ | 4× |
|
||||
| 0.90 | ∞ | 10× |
|
||||
| 0.95 | ∞ | 20× |
|
||||
| 0.99 | ∞ | 100× |
|
||||
| 0.50 | 100 | 1.98× |
|
||||
| 0.95 | 100 | 16.81× |
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
→ 매 serial 부분 (1-P) 가 매 absolute ceiling.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### 매 implication
|
||||
1. **매 fast core > 매 many slow core** (단, P 작을 때).
|
||||
2. **Profile 가 critical**: 매 actual P 의 measure.
|
||||
3. **Diminishing return**: 매 core 의 double 의 매 always 의 2× X.
|
||||
4. **Communication overhead**: 매 real S < ideal.
|
||||
5. **Fixed problem size assumption**: 매 Gustafson 의 보완.
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Gustafson's Law (보완)
|
||||
$$Speedup = (1-P) + P \cdot S$$
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
→ 매 problem size 의 scale 가능 → 매 parallel 의 더 큰 win.
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### 매 ML training 의 적용
|
||||
- **Data parallel**: 매 batch 의 split → 매 P 큼. 매 communication = serial.
|
||||
- **Model parallel** (tensor / pipeline): 매 P 가 작음. 매 communication 의 overhead.
|
||||
- **DeepSpeed / FSDP**: 매 mixed parallel.
|
||||
- **Gradient accumulation**: 매 effective batch ↑ 가, 매 sync 의 serial.
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### 매 distributed system 의 적용
|
||||
- **Map step**: 매 parallel.
|
||||
- **Reduce step**: 매 sync — 매 serial.
|
||||
- **Critical path** (DAG): 매 serial chain.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### 매 GPU
|
||||
- **Warp divergence**: 매 control flow 의 split → 매 serial.
|
||||
- **Memory bandwidth**: 매 compute 가 wait → 매 underutilization.
|
||||
- **Kernel launch overhead**: 매 small kernel 의 N 개 = 매 sequential overhead.
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
## 💻 패턴
|
||||
|
||||
### Profile (Python cProfile)
|
||||
```python
|
||||
import cProfile, pstats
|
||||
|
||||
def main():
|
||||
serial_setup() # 매 매 100 ms
|
||||
parallel_compute() # 매 매 900 ms (90%)
|
||||
serial_finalize() # 매 매 100 ms
|
||||
|
||||
cProfile.run('main()', 'out.prof')
|
||||
pstats.Stats('out.prof').sort_stats('cumulative').print_stats(10)
|
||||
|
||||
# 매 actual P 의 calculate
|
||||
P = 900 / 1100 # 0.818
|
||||
# 매 100 cores 의 max speedup
|
||||
speedup = 1 / ((1 - P) + P / 100) # 5.34×
|
||||
```
|
||||
|
||||
### Identify serial bottleneck
|
||||
```python
|
||||
def amdahl_potential(profile_breakdown):
|
||||
total = sum(profile_breakdown.values())
|
||||
serial = profile_breakdown.get('serial', 0)
|
||||
parallel = total - serial
|
||||
P = parallel / total
|
||||
|
||||
print(f'Parallel fraction: {P:.2%}')
|
||||
print(f'Max speedup (∞ cores): {1/(1-P):.2f}×')
|
||||
return P
|
||||
```
|
||||
|
||||
### Distributed training (PyTorch DDP)
|
||||
```python
|
||||
import torch.distributed as dist
|
||||
from torch.nn.parallel import DistributedDataParallel
|
||||
|
||||
dist.init_process_group(backend='nccl')
|
||||
model = DistributedDataParallel(model, device_ids=[local_rank])
|
||||
|
||||
# 매 forward / backward 의 parallel
|
||||
# 매 all-reduce gradient sync 의 serial overhead — 매 N 의 grow 의 communication 의 dominate
|
||||
```
|
||||
|
||||
→ 매 small batch + many GPU = 매 communication 의 bottleneck.
|
||||
|
||||
## 🤔 결정 기준
|
||||
| 상황 | 결정 |
|
||||
|---|---|
|
||||
| P > 0.95 | 매 cores 의 throw |
|
||||
| P 0.7-0.95 | 매 8-32 core sweet |
|
||||
| P < 0.5 | 매 fast core > 매 many |
|
||||
| Variable problem size | Gustafson — 매 scale up |
|
||||
| Communication dominant | 매 batch + locality |
|
||||
|
||||
**기본값**: 매 profile 먼저. 매 P 의 measure. 매 serial bottleneck 의 reduce.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Parallel-Computing]] · [[Performance-Engineering]]
|
||||
- 변형: [[Gustafsons-Law]] · [[Universal-Scalability-Law]]
|
||||
- 응용: [[GPU-Computing]] · [[Distributed-Training]] · [[MapReduce]] · [[CUDA]]
|
||||
- Adjacent: [[Profiling]] · [[Benchmarking]] · [[Critical-Path-Analysis]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 performance optimization decision. 매 GPU / cluster sizing. 매 distributed training planning.
|
||||
**언제 X**: 매 algorithm 의 complexity 의 ignore. 매 P assumption 없이 speculate.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Cores ↑ 무조건**: 매 P 작 의 의미 X.
|
||||
- **Profile 없이 optimize**: 매 wrong place 의 fight.
|
||||
- **Communication 무시**: 매 ideal S 의 reality 의 mismatch.
|
||||
- **Fixed problem assumption (always)**: 매 Gustafson 의 lose.
|
||||
- **모든 part 의 parallelize**: 매 serial 도 OK.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Amdahl 1967, IEEE).
|
||||
- 신뢰도 A.
|
||||
- Related: [[Gustafsons-Law]] · [[Parallel-Computing]] · [[Distributed-Training]].
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — formula + Gustafson + ML 응용 + profiling code |
|
||||
|
||||
Reference in New Issue
Block a user