Files
2nd/10_Wiki/Topics/AI_and_ML/Amdahls Law (암달의 법칙).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
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>
2026-05-20 23:52:15 +09:00

4.9 KiB
Raw Blame History

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-amdahls-law Amdahl's Law 10_Wiki/Topics verified self
암달의 법칙
parallel speedup
scaling limit
Gustafson contrast
none A 0.95 applied
parallel-computing
performance
scaling
hpc
gpu
optimization
profiling
2026-05-10 pending
language applicable_to
any
HPC
GPU
Distributed Systems
ML Training

Amdahl's Law

📌 한 줄 통찰

"매 bottleneck 가 speed 의 결정". 매 90% 의 100× → 매 전체 가 매 10× 의 한계. 매 parallelization 의 ceiling. 매 어디 의 fast 보다 매 어디 의 unchangeable.

📖 핵심

매 formula

Speedup = \frac{1}{(1-P) + \frac{P}{S}}
  • P: 매 parallel 가능 비율 (0..1).
  • S: 매 parallel 부분 의 speedup factor (cores).

매 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×

→ 매 serial 부분 (1-P) 가 매 absolute ceiling.

매 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 의 보완.

Gustafson's Law (보완)

Speedup = (1-P) + P \cdot S

→ 매 problem size 의 scale 가능 → 매 parallel 의 더 큰 win.

매 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.

매 distributed system 의 적용

  • Map step: 매 parallel.
  • Reduce step: 매 sync — 매 serial.
  • Critical path (DAG): 매 serial chain.

매 GPU

  • Warp divergence: 매 control flow 의 split → 매 serial.
  • Memory bandwidth: 매 compute 가 wait → 매 underutilization.
  • Kernel launch overhead: 매 small kernel 의 N 개 = 매 sequential overhead.

💻 패턴

Profile (Python cProfile)

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

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)

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

🤖 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.

🧪 검증 / 중복

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — formula + Gustafson + ML 응용 + profiling code