SlideShare a Scribd company logo
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
K O R E A | M A Y 1 1 - 1 2 , 2 0 2 1
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon SageMaker를 통한
대용량 모델 훈련 방법 살펴보기
김대근
AIML 스페셜리스트 솔루션즈 아키텍트
AWS
최영준
솔루션즈 아키텍트
AWS
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
Background
분산 훈련 성능을 높이기 위한 AWS 3가지 기술
분산 훈련 모니터링하기
Demo
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Background
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
분산 훈련의 주요 이슈
Network I/O, Storage ↔ CPU ↔ GPU 간의 병목
• 훈련을 위해 GB 및 TB의 데이터에 빠르게 액세스 필요
• 수백 개 이상 GPU의 훈련에 대한 인프라 관리 전문가 필요
모니터링
• 모델 훈련 과정에 대한 가시성 미확보
• 리소스 사용율 및 훈련 오류 모니터링 통합 솔루션의 부재
기존 솔루션 (EC2 DLAMI / AWS Batch / ECS&EKS 등)
• 분산 훈련에 필요한 인프라 & 환경 설정 및 동기화의 어려움
• 디버깅 툴의 부재 (예: Gradient Checking, Attention, GradCam)
. . .
. . .
. . .
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
분산 훈련 성능을 높이기 위한
AWS 3가지 기술
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Architecture for SageMaker
Distributed Training
Amazon S3
훈련 데이터셋
Amazon SageMaker
훈련 스크립트
Amazon FSx
for Lustre
SageMaker Training Job
VPC p3dn/p4d instances
Amazon ECR
관리되고 최적화된
데이터/모델 병렬 훈련 툴킷 포함
Amazon
CloudWatch
Amazon
SageMaker
Debugger
Amazon S3
모델 아티팩트
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon FSx for Lustre
on Amazon SageMaker
Amazon
S3
Amazon
SageMaker
•SageMaker 머신 러닝 모델의 입력 데이터 소스로 사용 가능
•S3 다운로드 단계 제거로 파일 시스템 곧바로 시작 가능 → 훈련 속도 향상
•동일 데이터셋에서 반복 작업을 위해 공통 오브젝트를 반복적으로 다운로드할 필요 없음
Massively scalable performance
100+ GiB/s throughput
Millions of IOPS
Consistent low latencies Amazon
FSx for Lustre
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Fabric Adapter (EFA)
• 긴밀하게 결합된 HPC 및 ML 워크로드 확장
• 15ms 미만의 네트워크 대기 시간
• 100 Gbps 네트워크 대역폭
EFA
Scale tightly-coupled
HPC applications on AWS
• Elastic Fabric Adapter,
대규모 HPC 워크로드에 가장 적합
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SageMaker’s Model/Data parallelism Library
Amazon SageMaker
Data Parallel
Amazon SageMaker
Model Parallel
GPU 0 GPU 1 GPU N
…
…
W Wgrad
batch size
𝑁
batch size
𝑁
batch size
𝑁
Reference : FAST DISTRIBUTED TRAINING OF DEEP NEURAL NETWORKS: DYNAMIC COMMUNICATION THRESHOLDING FOR MODEL AND DATA PARALLELISM
GPU 0 GPU 1 GPU N
Xact
Xgrad
model
subgraph 1 subgraph 2 subgraph n
…
batch-split
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S3로 데이터를 업로드한 후, SageMaker에서 TensorFlow/PyTorch로분산 훈련을 수행합니다.
SageMaker Data Parallelism 동작 원리
Amazon SageMaker
데이터 병렬 처리가
활성화된 SageMaker
훈련 작업 시작
Amazon
SageMaker
관리되고 최적화된
데이터 병렬 훈련 툴킷
포함
Horovod 및 Distributed Data
Parallel과 같은 널리 사용되는
API 지원
Worker의 복제본에 대한 완전
관리형 훈련
여러 GPU에서 worker를
자동으로 동기화
Amazon S3
훈련 데이터셋 저장
훈련 스크립트로
데이터 병렬 처리
라이브러리 가져오기
배포 준비가 완료된
Amazon S3의
훈련된 모델
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Communication cost가 많이 소요됩니다.
Traditional Data Parallelism
GPU 0
GPU N GPU 1
GPU 2
…
grad_GPU0
grad_GPU1 +
grad_GPU2
grad_GPU1 +
grad_GPU2 +
…
grad_GPUN
Gradient averaging
GPU GPU GPU GPU
병목 현상이 발생합니다.
Parameter Server Ring All-reduce (Horovod)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Balanced Fusion Buffers (BFB)
• 전통적인 파라메터 서버는 변수를
원자 단위atomic unit로 취급합니다.
• 각 변수는 하나의 서버에 배치됩니다.
• 각 서버는 각 역방향 패스 경로 중
일부만 활성화됩니다.
• BFB는 gradient를 보유하는 각 GPU의 버퍼입니다.
• 각 서버마다 정확히 동일한 바이트를 할당합니다.
• i번째 서버는 모든 worker로부터 BFB의 i번째
파티션을 수신하고 이를 합산하여 결과를
모든 worker에게 보냅니다.
Wh1
500M
Wh2
100M
150M 150M 150M 150M
파라메터 서버: Worker = 1:1
Traditional BFB
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Balanced Fusion Buffers (BFB) 예시
5 3 1
4 2
50MB 50MB 250MB 75MB 100MB
Gradient
BFB
(GPU 0)
BFB
(GPU 1)
5 3 41 42 43 21 22 11 12
50MB 50MB 100MB 100MB 50MB 50MB 25MB 75MB 25MB
100MB
5 3 4 2 1
5 3 41 42 43 21 22 11 12
50MB 50MB 200MB 100MB 50MB 50MB 25MB 75MB 25MB
5 4 3 2 1
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Training Script (PyTorch)
import smdistributed.dataparallel.torch.distributed as dist
from smdistributed.dataparallel.torch.parallel.distributed 
import DistributedDataParallel as DDP
dist.init_process_group()
batch_size //= dist.get_world_size() // 8
batch_size = max(batch_size, 1)
train_sampler = DistributedSampler(
train_dataset, num_replicas=dist.get_world_size(),
rank=dist.get_rank())
train_loader = torch.utils.data.DataLoader(..)
model = DDP(model.to(device))
torch.cuda.set_device(dist.get_local_rank())
model.cuda(dist.get_local_rank())
if dist.get_rank() == 0:
torch.save(checkpoint_dir)
Initialize
Scale Parameters
Set rank in
DistributedSampler
Pin each GPU
Checkpoint on master node
https://sagemaker.readthedocs.io/en/stable/api/training/smd_data_parallel.html
01.
02.
03.
04.
05.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
훈련 실행 코드에 distribution을 추가해 줍니다.
SageMaker 실행 코드
# 분산 훈련 수행 선언 (CUDA 11에서 수행되도록 설정)
distribution = {"smdistributed": {"dataparallel": {"enabled": True}}}
# Import 문
estimator = PyTorch(
instance_type=‘ml.p4d.24xlarge’, # ml.p3.16xlarge, ml.p3dn.24xlarge 지원
instance_count=8,
framework_version='1.6.0',
py_version='py36’,
...
distribution=distribution,
)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model
Node 수
(p3dn.24xl)
Throughput Scaling Efficiency
TF2-HVD SageMaker Speed up TF2-HVD SageMaker Improvement
BERT Large
(seqs/sec)
2 1300 1600 23% 66% 82% 16%
4 2316 2440 5% 59% 62% 3%
8 5000 5200 4% 63% 66% 3%
MaskRCNN
(samples/sec)
2 130 140 8% 84% 91% 7%
4 255 259 2% 83% 84% 1%
8 495 525 6% 80% 85% 5%
• Throughput : 초당 처리 데이터 수
• Scaling Efficiency : 단일 노드 처리량 * Node 수 대비 클러스터 처리량
SageMaker Data Parallelism vs. TF2 Horovod
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model
Node 수
(p3dn.24xl)
Throughput Scaling Efficiency
PT-DDP SageMaker Speed up PT-DDP SageMaker Improvement
BERT Large
(seqs/sec)
2 1752 2479 41% 64% 90% 26%
4 3017 4603 52% 55% 84% 29%
8 7409 8551 15% 67% 78% 11%
MaskRCNN
(samples/sec)
2 152 158 4% 82% 85% 3%
4 258 307 19% 70% 83% 13%
8 545 617 13% 74% 84% 10%
• Throughput : 초당 처리 데이터 수
• Scaling Efficiency : 단일 노드 처리량 * Node 수 대비 클러스터 처리량
SageMaker Data Parallelism vs. PyTorch DDP
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
모델을 자동으로 분할하고 서브
그래프를 디바이스로 전송
변수 및 그래프 구조 분석
파이프라인 마이크로배치pipelined
microbatches에 대한 관리형 분산 훈련
S3로 데이터를 업로드한 후, SageMaker에서 TensorFlow/PyTorch로분산 훈련을 수행합니다.
SageMaker Data Parallelism 동작 원리
Amazon SageMaker
데이터 병렬 처리가
활성화된 SageMaker
훈련 작업 시작
Amazon
SageMaker
관리되고 최적화된
데이터 병렬 훈련 툴킷
포함
Amazon S3
훈련 데이터셋 저장
훈련 스크립트로
데이터 병렬 처리
라이브러리 가져오기
배포 준비가 완료된
Amazon S3의
훈련된 모델
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Naïve Model Parallelism
GPU 0
GPU 1
GPU 2
Time
•Layerwise partition (Pipeline)
•Forward pass/backward pass 순차 계산
Idle
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Training Script (PyTorch)
import smdistributed.modelparallel.torch as smp
smp.init()
...
model = smp.DistributedModel(model)
scaler = smp.amp.GradScaler()
optimizer = smp.DistributedOptimizer(optimizer)
@smp.step
def train_step(model, scaler, data, target):
output = model(data)
loss = F.nll_loss(output, target, reduction="mean")
model.backward(loss)
return output, loss
for batch_idx, (data, target) in enumerate(train_loader):
_, loss_mb = train_step(model, scaler, data, target)
# SageMaker model parallel: average the loss across
microbatches
loss = loss_mb.reduce_mean()
if smp.rank() == 0:
print(f"Loss: {loss}")
https://sagemaker.readthedocs.io/en/stable/api/training/smd_model_parallel.html
Initialize
01.
Define @smp.step
02.
Average the loss
across microbatches
03.
Print the loss only at rank 0
04.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Model Parallelism Parameters
mpi_options = {
"enabled" : True,
"processes_per_host" : 8,
"custom_mpi_options" : "--mca
btl_vader_single_copy_mechanism none "
}
smp_options = {
"enabled": True,
"parameters": {
"microbatches": 4,
"placement_strategy": "spread",
"pipeline": "interleaved”,
"optimize": "speed",
"partitions": 2,
"ddp": True,
}
}
estimator = PyTorch(
...
distribution={
"smdistributed": smp_options,
"mpi": mpi_options
}
)
https://sagemaker.readthedocs.io/en/stable/api/training/smd_model_parallel.html
Simple
Interleaved
F0: Microbatch 0 for Forward pass
B0: Microbatch 0 for Backward pass
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pipeline Execution (TensorFlow)
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SageMaker Model parallelism performance
Num GPUs Without modelparallel With modelparallel
2 OOM 15.3
4 OOM 24.0
Num GPUs Without modelparallel With modelparallel
8 208.8 264.0
Num GPUs Without modelparallel With modelparallel
8 OOM 18.8
GPT-2 LARGE, TENSORFLOW, P3.16XLARGE, 2 PARTITIONS, SAMPLES/SEC
BERT LARGE, TENSORFLOW, P3.16XLARGE, 2 PARTITIONS, SAMPLES/SEC
T5-3B, PYTORCH, P3DN.24XLARGE, 8 PARTITIONS, SAMPLES/SEC
•partitions : 분석을 통해 모델의 graph를 나눈 subgraph 수
•OOM : Out Of Memory
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
분산 훈련
모니터링하기
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SageMaker Model 모니터링
SageMaker metric definitions
훈련 모델의 성능 모니터링
SageMaker Debugger
모델 훈련 중 Tensor 수집 및 이상 탐지
SageMaker Debugger Profiling
훈련 클러스터 사용률 모니터링
GPU Cluster
Metrics
P4d instance P4d instance P4d instance
… …
Model
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
훈련 모델의 성능 모니터링
Model
…
…
training log
SageMaker 설정
로그 정보를 이용한 Graph 제공
train:Prec@1
train:Loss
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Writes/Reads 요청
SageMaker Debugger
Training in progress
Amazon Simple
Storage Service (S3)
Rule1 : Vanishing Gradient
Rule2 : not Decreasing Loss
Amazon
SageMaker
Debugger
RuleN : Custom Rule
Amazon CloudWatch
Event
Amazon SageMaker
Studio/Notebook
Action
- stoptraining
- email
Analyze/
Visualize
1
4
Debugger
Hook
System /
Framework
metrics
loss,
weight,
biases,
gradients,
etc.
loss,
gradients,
…
3
2
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
훈련 내 Tensor 수집 및 이상 탐지
이미지 gradients와 weights를 응용한 사례
수집된 Loss 를 이용한 Plot
Class Activation Maps 구현
gradients의
분포 plot
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DebuggerProfiling은 자동으로시스템리소스사용률을모니터링하고,
포괄적인보고서로제공합니다.
훈련 클러스터 사용률 모니터링 – Profiling
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
권장 사항
Rule
Parameter
이슈
발생횟수
사전 정의된 rule에 의해 발생하는 이슈와 권장 사항, 발생 횟수,
rule에서 설정한 파라미터 값을 제공합니다.
훈련 클러스터 사용률 모니터링 – Profiling
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Detect Performance Bottlenecks
Time (minutes)
GPU
CPU
Utilization
Detect Training Issues
Bottleneck 발생
분산 훈련 모니터링 사례
Low Model Performance
GPU Cluster
Metrics
P4d instance P4d instance P4d instance
… …
Model
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo Code
https://github.com/Napkin-DL/ml-ws.git
https://github.com/aws-samples/sagemaker-distributed-training-
pytorch-kr.git
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
여러분의 소중한 피드백을 기다립니다.
강연 종료 후, 강연 평가에 참여해 주세요!
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
감사합니다
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

PDF
Amazon OpenSearch Deep dive - 내부구조, 성능최적화 그리고 스케일링
PDF
Amazon SageMaker 모델 배포 방법 소개::김대근, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
PDF
Aws glue를 통한 손쉬운 데이터 전처리 작업하기
PDF
효율적인 빅데이터 분석 및 처리를 위한 Glue, EMR 활용 - 김태현 솔루션즈 아키텍트, AWS :: AWS Summit Seoul 2019
PDF
AWS Personalize 중심으로 살펴본 추천 시스템 원리와 구축
PDF
대규모 온프레미스 하둡 마이그레이션을 위한 실행 전략과 최적화 방안 소개-유철민, AWS Data Architect / 박성열,AWS Pr...
PDF
Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...
PDF
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
Amazon OpenSearch Deep dive - 내부구조, 성능최적화 그리고 스케일링
Amazon SageMaker 모델 배포 방법 소개::김대근, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Aws glue를 통한 손쉬운 데이터 전처리 작업하기
효율적인 빅데이터 분석 및 처리를 위한 Glue, EMR 활용 - 김태현 솔루션즈 아키텍트, AWS :: AWS Summit Seoul 2019
AWS Personalize 중심으로 살펴본 추천 시스템 원리와 구축
대규모 온프레미스 하둡 마이그레이션을 위한 실행 전략과 최적화 방안 소개-유철민, AWS Data Architect / 박성열,AWS Pr...
Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...

What's hot (20)

PDF
실시간 스트리밍 분석 Kinesis Data Analytics Deep Dive
PDF
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
PDF
민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS
PDF
AWS Elastic Beanstalk 활용하여 수 분만에 코드 배포하기 (최원근, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
PDF
EMR 플랫폼 기반의 Spark 워크로드 실행 최적화 방안 - 정세웅, AWS 솔루션즈 아키텍트:: AWS Summit Online Ko...
PDF
Amazon Personalize 소개 (+ 실습 구성)::김영진, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
PDF
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
PDF
AWS를 활용한 상품 추천 서비스 구축::김태현:: AWS Summit Seoul 2018
PDF
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
PDF
AWS Black Belt Online Seminar 2017 Amazon S3
PDF
Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...
PDF
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
PDF
ELB와 EBS의 아키텍터로 생각해보는 사용상 주의할 점들
PDF
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
PDF
AWS 기반 데이터 레이크(Datalake) 구축 및 분석 - 김민성 (AWS 솔루션즈아키텍트) : 8월 온라인 세미나
PDF
AWS Black Belt Tech シリーズ 2015 - AWS Data Pipeline
PDF
데브시스터즈 데이터 레이크 구축 이야기 : Data Lake architecture case study (박주홍 데이터 분석 및 인프라 팀...
PDF
서버리스 아키텍처 패턴 및 로그 처리를 위한 파이프라인 구축기 - 황윤상 솔루션즈 아키텍트, AWS / Matthew Han, SendBi...
PDF
서버리스 기반 데이터베이스 모델링 및 운영 노하우 알아보기 - 변규현 SW 엔지니어, 당근마켓 / 김선형 CTO, 티클 :: AWS Sum...
PDF
AWS Summit Seoul 2023 | Snowflake: 모든 데이터 워크로드를 위한 하나의 클라우드 데이터 플랫폼
실시간 스트리밍 분석 Kinesis Data Analytics Deep Dive
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
민첩하고 비용효율적인 Data Lake 구축 - 문종민 솔루션즈 아키텍트, AWS
AWS Elastic Beanstalk 활용하여 수 분만에 코드 배포하기 (최원근, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
EMR 플랫폼 기반의 Spark 워크로드 실행 최적화 방안 - 정세웅, AWS 솔루션즈 아키텍트:: AWS Summit Online Ko...
Amazon Personalize 소개 (+ 실습 구성)::김영진, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
AWS를 활용한 상품 추천 서비스 구축::김태현:: AWS Summit Seoul 2018
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
AWS Black Belt Online Seminar 2017 Amazon S3
Amazon SageMaker 모델 빌딩 파이프라인 소개::이유동, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스...
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
ELB와 EBS의 아키텍터로 생각해보는 사용상 주의할 점들
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
AWS 기반 데이터 레이크(Datalake) 구축 및 분석 - 김민성 (AWS 솔루션즈아키텍트) : 8월 온라인 세미나
AWS Black Belt Tech シリーズ 2015 - AWS Data Pipeline
데브시스터즈 데이터 레이크 구축 이야기 : Data Lake architecture case study (박주홍 데이터 분석 및 인프라 팀...
서버리스 아키텍처 패턴 및 로그 처리를 위한 파이프라인 구축기 - 황윤상 솔루션즈 아키텍트, AWS / Matthew Han, SendBi...
서버리스 기반 데이터베이스 모델링 및 운영 노하우 알아보기 - 변규현 SW 엔지니어, 당근마켓 / 김선형 CTO, 티클 :: AWS Sum...
AWS Summit Seoul 2023 | Snowflake: 모든 데이터 워크로드를 위한 하나의 클라우드 데이터 플랫폼
Ad

Similar to Amazon SageMaker를 통한 대용량 모델 훈련 방법 살펴보기 - 김대근 AWS AI/ML 스페셜리스트 솔루션즈 아키텍트 / 최영준 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021 (20)

PDF
[AWS Dev Day] 인공지능 / 기계 학습 | AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...
PDF
완전 관리형 ML 서비스인 Amazon SageMaker 의 신규 기능 소개 - 김필호 AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS ...
PDF
Amazon SageMaker 기반 고품질 데이터 생성 및 심화 기계학습 기법 - 김필호 솔루션즈 아키텍트, AWS / 강정희 솔루션즈 아...
PDF
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
PDF
국내 건설 기계사 도입 사례를 통해 보는 AI가 적용된 수요 예측 관리 - 베스핀글로벌 조창윤 AI/ML팀 팀장
PDF
Amazon AI/ML Overview
PDF
End-to-End Machine Learning with Amazon SageMaker
PDF
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
PDF
Deep Learning 모델의 효과적인 분산 트레이닝과 모델 최적화 방법 - 김무현 데이터 사이언티스트, AWS :: AWS Summit...
PDF
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
PDF
[AWS Dev Day] 인공지능 / 기계 학습 | 개발자를 위한 수백만 사용자 대상 기계 학습 서비스 확장 하기 - 윤석찬 AWS 수석테...
PDF
자연어 처리 ML모델을 활용한 이커머스 문제 해결하기 - 진현두 (카카오스타일) :: AWS Community Day Online 2021
PDF
개발자가 알아두면 좋은 5가지 AWS 인공 지능 서비스 깨알 지식 (윤석찬, AWS 테크에반젤리스트) :: AWS DevDay 2018
PPTX
Large scale gpu cluster for ai
PPTX
Demystifying Amazon Sagemaker (ACD Kochi)
PDF
How To Build Efficient ML Pipelines From The Startup Perspective (OpenInfraDa...
PPTX
ACDKOCHI19 - Demystifying amazon sagemaker
PDF
Parallelformers
PDF
AI 클라우드로 완전 정복하기 - 데이터 분석부터 딥러닝까지 (윤석찬, AWS테크에반젤리스트)
PPTX
Demystifying Machine Learning with AWS (ACD Mumbai)
[AWS Dev Day] 인공지능 / 기계 학습 | AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...
완전 관리형 ML 서비스인 Amazon SageMaker 의 신규 기능 소개 - 김필호 AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS ...
Amazon SageMaker 기반 고품질 데이터 생성 및 심화 기계학습 기법 - 김필호 솔루션즈 아키텍트, AWS / 강정희 솔루션즈 아...
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
국내 건설 기계사 도입 사례를 통해 보는 AI가 적용된 수요 예측 관리 - 베스핀글로벌 조창윤 AI/ML팀 팀장
Amazon AI/ML Overview
End-to-End Machine Learning with Amazon SageMaker
[AWS Innovate 온라인 컨퍼런스] Kubernetes와 SageMaker를 활용하여 Machine Learning 워크로드 관리하...
Deep Learning 모델의 효과적인 분산 트레이닝과 모델 최적화 방법 - 김무현 데이터 사이언티스트, AWS :: AWS Summit...
[AWS Dev Day] 실습워크샵 | 모두를 위한 컴퓨터 비전 딥러닝 툴킷, GluonCV 따라하기
[AWS Dev Day] 인공지능 / 기계 학습 | 개발자를 위한 수백만 사용자 대상 기계 학습 서비스 확장 하기 - 윤석찬 AWS 수석테...
자연어 처리 ML모델을 활용한 이커머스 문제 해결하기 - 진현두 (카카오스타일) :: AWS Community Day Online 2021
개발자가 알아두면 좋은 5가지 AWS 인공 지능 서비스 깨알 지식 (윤석찬, AWS 테크에반젤리스트) :: AWS DevDay 2018
Large scale gpu cluster for ai
Demystifying Amazon Sagemaker (ACD Kochi)
How To Build Efficient ML Pipelines From The Startup Perspective (OpenInfraDa...
ACDKOCHI19 - Demystifying amazon sagemaker
Parallelformers
AI 클라우드로 완전 정복하기 - 데이터 분석부터 딥러닝까지 (윤석찬, AWS테크에반젤리스트)
Demystifying Machine Learning with AWS (ACD Mumbai)
Ad

More from Amazon Web Services Korea (20)

PDF
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
PDF
[D3T1S06] Neptune Analytics with Vector Similarity Search
PDF
[D3T1S03] Amazon DynamoDB design puzzlers
PDF
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
PDF
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
PDF
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
PDF
[D3T1S02] Aurora Limitless Database Introduction
PDF
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
PDF
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 2
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 1
PDF
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
PDF
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
PDF
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
PDF
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
PDF
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
PDF
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
PDF
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
PDF
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
PDF
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
[D3T1S06] Neptune Analytics with Vector Similarity Search
[D3T1S03] Amazon DynamoDB design puzzlers
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
[D3T1S02] Aurora Limitless Database Introduction
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
AWS Modern Infra with Storage Roadshow 2023 - Day 2
AWS Modern Infra with Storage Roadshow 2023 - Day 1
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced methodologies resolving dimensionality complications for autism neur...
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
MIND Revenue Release Quarter 2 2025 Press Release
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Approach and Philosophy of On baking technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Reach Out and Touch Someone: Haptics and Empathic Computing
Diabetes mellitus diagnosis method based random forest with bat algorithm
The Rise and Fall of 3GPP – Time for a Sabbatical?

Amazon SageMaker를 통한 대용량 모델 훈련 방법 살펴보기 - 김대근 AWS AI/ML 스페셜리스트 솔루션즈 아키텍트 / 최영준 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021

  • 1. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. K O R E A | M A Y 1 1 - 1 2 , 2 0 2 1
  • 2. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon SageMaker를 통한 대용량 모델 훈련 방법 살펴보기 김대근 AIML 스페셜리스트 솔루션즈 아키텍트 AWS 최영준 솔루션즈 아키텍트 AWS
  • 3. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Agenda Background 분산 훈련 성능을 높이기 위한 AWS 3가지 기술 분산 훈련 모니터링하기 Demo
  • 4. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Background
  • 5. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 분산 훈련의 주요 이슈 Network I/O, Storage ↔ CPU ↔ GPU 간의 병목 • 훈련을 위해 GB 및 TB의 데이터에 빠르게 액세스 필요 • 수백 개 이상 GPU의 훈련에 대한 인프라 관리 전문가 필요 모니터링 • 모델 훈련 과정에 대한 가시성 미확보 • 리소스 사용율 및 훈련 오류 모니터링 통합 솔루션의 부재 기존 솔루션 (EC2 DLAMI / AWS Batch / ECS&EKS 등) • 분산 훈련에 필요한 인프라 & 환경 설정 및 동기화의 어려움 • 디버깅 툴의 부재 (예: Gradient Checking, Attention, GradCam) . . . . . . . . .
  • 6. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 분산 훈련 성능을 높이기 위한 AWS 3가지 기술
  • 7. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Architecture for SageMaker Distributed Training Amazon S3 훈련 데이터셋 Amazon SageMaker 훈련 스크립트 Amazon FSx for Lustre SageMaker Training Job VPC p3dn/p4d instances Amazon ECR 관리되고 최적화된 데이터/모델 병렬 훈련 툴킷 포함 Amazon CloudWatch Amazon SageMaker Debugger Amazon S3 모델 아티팩트
  • 8. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon FSx for Lustre on Amazon SageMaker Amazon S3 Amazon SageMaker •SageMaker 머신 러닝 모델의 입력 데이터 소스로 사용 가능 •S3 다운로드 단계 제거로 파일 시스템 곧바로 시작 가능 → 훈련 속도 향상 •동일 데이터셋에서 반복 작업을 위해 공통 오브젝트를 반복적으로 다운로드할 필요 없음 Massively scalable performance 100+ GiB/s throughput Millions of IOPS Consistent low latencies Amazon FSx for Lustre
  • 9. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Elastic Fabric Adapter (EFA) • 긴밀하게 결합된 HPC 및 ML 워크로드 확장 • 15ms 미만의 네트워크 대기 시간 • 100 Gbps 네트워크 대역폭 EFA Scale tightly-coupled HPC applications on AWS • Elastic Fabric Adapter, 대규모 HPC 워크로드에 가장 적합
  • 10. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. SageMaker’s Model/Data parallelism Library Amazon SageMaker Data Parallel Amazon SageMaker Model Parallel GPU 0 GPU 1 GPU N … … W Wgrad batch size 𝑁 batch size 𝑁 batch size 𝑁 Reference : FAST DISTRIBUTED TRAINING OF DEEP NEURAL NETWORKS: DYNAMIC COMMUNICATION THRESHOLDING FOR MODEL AND DATA PARALLELISM GPU 0 GPU 1 GPU N Xact Xgrad model subgraph 1 subgraph 2 subgraph n … batch-split
  • 11. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. S3로 데이터를 업로드한 후, SageMaker에서 TensorFlow/PyTorch로분산 훈련을 수행합니다. SageMaker Data Parallelism 동작 원리 Amazon SageMaker 데이터 병렬 처리가 활성화된 SageMaker 훈련 작업 시작 Amazon SageMaker 관리되고 최적화된 데이터 병렬 훈련 툴킷 포함 Horovod 및 Distributed Data Parallel과 같은 널리 사용되는 API 지원 Worker의 복제본에 대한 완전 관리형 훈련 여러 GPU에서 worker를 자동으로 동기화 Amazon S3 훈련 데이터셋 저장 훈련 스크립트로 데이터 병렬 처리 라이브러리 가져오기 배포 준비가 완료된 Amazon S3의 훈련된 모델
  • 12. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Communication cost가 많이 소요됩니다. Traditional Data Parallelism GPU 0 GPU N GPU 1 GPU 2 … grad_GPU0 grad_GPU1 + grad_GPU2 grad_GPU1 + grad_GPU2 + … grad_GPUN Gradient averaging GPU GPU GPU GPU 병목 현상이 발생합니다. Parameter Server Ring All-reduce (Horovod)
  • 13. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Balanced Fusion Buffers (BFB) • 전통적인 파라메터 서버는 변수를 원자 단위atomic unit로 취급합니다. • 각 변수는 하나의 서버에 배치됩니다. • 각 서버는 각 역방향 패스 경로 중 일부만 활성화됩니다. • BFB는 gradient를 보유하는 각 GPU의 버퍼입니다. • 각 서버마다 정확히 동일한 바이트를 할당합니다. • i번째 서버는 모든 worker로부터 BFB의 i번째 파티션을 수신하고 이를 합산하여 결과를 모든 worker에게 보냅니다. Wh1 500M Wh2 100M 150M 150M 150M 150M 파라메터 서버: Worker = 1:1 Traditional BFB
  • 14. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Balanced Fusion Buffers (BFB) 예시 5 3 1 4 2 50MB 50MB 250MB 75MB 100MB Gradient BFB (GPU 0) BFB (GPU 1) 5 3 41 42 43 21 22 11 12 50MB 50MB 100MB 100MB 50MB 50MB 25MB 75MB 25MB 100MB 5 3 4 2 1 5 3 41 42 43 21 22 11 12 50MB 50MB 200MB 100MB 50MB 50MB 25MB 75MB 25MB 5 4 3 2 1
  • 15. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Training Script (PyTorch) import smdistributed.dataparallel.torch.distributed as dist from smdistributed.dataparallel.torch.parallel.distributed import DistributedDataParallel as DDP dist.init_process_group() batch_size //= dist.get_world_size() // 8 batch_size = max(batch_size, 1) train_sampler = DistributedSampler( train_dataset, num_replicas=dist.get_world_size(), rank=dist.get_rank()) train_loader = torch.utils.data.DataLoader(..) model = DDP(model.to(device)) torch.cuda.set_device(dist.get_local_rank()) model.cuda(dist.get_local_rank()) if dist.get_rank() == 0: torch.save(checkpoint_dir) Initialize Scale Parameters Set rank in DistributedSampler Pin each GPU Checkpoint on master node https://sagemaker.readthedocs.io/en/stable/api/training/smd_data_parallel.html 01. 02. 03. 04. 05.
  • 16. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 훈련 실행 코드에 distribution을 추가해 줍니다. SageMaker 실행 코드 # 분산 훈련 수행 선언 (CUDA 11에서 수행되도록 설정) distribution = {"smdistributed": {"dataparallel": {"enabled": True}}} # Import 문 estimator = PyTorch( instance_type=‘ml.p4d.24xlarge’, # ml.p3.16xlarge, ml.p3dn.24xlarge 지원 instance_count=8, framework_version='1.6.0', py_version='py36’, ... distribution=distribution, )
  • 17. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model Node 수 (p3dn.24xl) Throughput Scaling Efficiency TF2-HVD SageMaker Speed up TF2-HVD SageMaker Improvement BERT Large (seqs/sec) 2 1300 1600 23% 66% 82% 16% 4 2316 2440 5% 59% 62% 3% 8 5000 5200 4% 63% 66% 3% MaskRCNN (samples/sec) 2 130 140 8% 84% 91% 7% 4 255 259 2% 83% 84% 1% 8 495 525 6% 80% 85% 5% • Throughput : 초당 처리 데이터 수 • Scaling Efficiency : 단일 노드 처리량 * Node 수 대비 클러스터 처리량 SageMaker Data Parallelism vs. TF2 Horovod
  • 18. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model Node 수 (p3dn.24xl) Throughput Scaling Efficiency PT-DDP SageMaker Speed up PT-DDP SageMaker Improvement BERT Large (seqs/sec) 2 1752 2479 41% 64% 90% 26% 4 3017 4603 52% 55% 84% 29% 8 7409 8551 15% 67% 78% 11% MaskRCNN (samples/sec) 2 152 158 4% 82% 85% 3% 4 258 307 19% 70% 83% 13% 8 545 617 13% 74% 84% 10% • Throughput : 초당 처리 데이터 수 • Scaling Efficiency : 단일 노드 처리량 * Node 수 대비 클러스터 처리량 SageMaker Data Parallelism vs. PyTorch DDP
  • 19. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 모델을 자동으로 분할하고 서브 그래프를 디바이스로 전송 변수 및 그래프 구조 분석 파이프라인 마이크로배치pipelined microbatches에 대한 관리형 분산 훈련 S3로 데이터를 업로드한 후, SageMaker에서 TensorFlow/PyTorch로분산 훈련을 수행합니다. SageMaker Data Parallelism 동작 원리 Amazon SageMaker 데이터 병렬 처리가 활성화된 SageMaker 훈련 작업 시작 Amazon SageMaker 관리되고 최적화된 데이터 병렬 훈련 툴킷 포함 Amazon S3 훈련 데이터셋 저장 훈련 스크립트로 데이터 병렬 처리 라이브러리 가져오기 배포 준비가 완료된 Amazon S3의 훈련된 모델
  • 20. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Naïve Model Parallelism GPU 0 GPU 1 GPU 2 Time •Layerwise partition (Pipeline) •Forward pass/backward pass 순차 계산 Idle
  • 21. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Training Script (PyTorch) import smdistributed.modelparallel.torch as smp smp.init() ... model = smp.DistributedModel(model) scaler = smp.amp.GradScaler() optimizer = smp.DistributedOptimizer(optimizer) @smp.step def train_step(model, scaler, data, target): output = model(data) loss = F.nll_loss(output, target, reduction="mean") model.backward(loss) return output, loss for batch_idx, (data, target) in enumerate(train_loader): _, loss_mb = train_step(model, scaler, data, target) # SageMaker model parallel: average the loss across microbatches loss = loss_mb.reduce_mean() if smp.rank() == 0: print(f"Loss: {loss}") https://sagemaker.readthedocs.io/en/stable/api/training/smd_model_parallel.html Initialize 01. Define @smp.step 02. Average the loss across microbatches 03. Print the loss only at rank 0 04.
  • 22. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Model Parallelism Parameters mpi_options = { "enabled" : True, "processes_per_host" : 8, "custom_mpi_options" : "--mca btl_vader_single_copy_mechanism none " } smp_options = { "enabled": True, "parameters": { "microbatches": 4, "placement_strategy": "spread", "pipeline": "interleaved”, "optimize": "speed", "partitions": 2, "ddp": True, } } estimator = PyTorch( ... distribution={ "smdistributed": smp_options, "mpi": mpi_options } ) https://sagemaker.readthedocs.io/en/stable/api/training/smd_model_parallel.html Simple Interleaved F0: Microbatch 0 for Forward pass B0: Microbatch 0 for Backward pass
  • 23. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 24. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 25. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 26. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 27. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 28. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 29. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pipeline Execution (TensorFlow)
  • 30. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. SageMaker Model parallelism performance Num GPUs Without modelparallel With modelparallel 2 OOM 15.3 4 OOM 24.0 Num GPUs Without modelparallel With modelparallel 8 208.8 264.0 Num GPUs Without modelparallel With modelparallel 8 OOM 18.8 GPT-2 LARGE, TENSORFLOW, P3.16XLARGE, 2 PARTITIONS, SAMPLES/SEC BERT LARGE, TENSORFLOW, P3.16XLARGE, 2 PARTITIONS, SAMPLES/SEC T5-3B, PYTORCH, P3DN.24XLARGE, 8 PARTITIONS, SAMPLES/SEC •partitions : 분석을 통해 모델의 graph를 나눈 subgraph 수 •OOM : Out Of Memory
  • 31. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 분산 훈련 모니터링하기
  • 32. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. SageMaker Model 모니터링 SageMaker metric definitions 훈련 모델의 성능 모니터링 SageMaker Debugger 모델 훈련 중 Tensor 수집 및 이상 탐지 SageMaker Debugger Profiling 훈련 클러스터 사용률 모니터링 GPU Cluster Metrics P4d instance P4d instance P4d instance … … Model
  • 33. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 훈련 모델의 성능 모니터링 Model … … training log SageMaker 설정 로그 정보를 이용한 Graph 제공 train:Prec@1 train:Loss
  • 34. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Writes/Reads 요청 SageMaker Debugger Training in progress Amazon Simple Storage Service (S3) Rule1 : Vanishing Gradient Rule2 : not Decreasing Loss Amazon SageMaker Debugger RuleN : Custom Rule Amazon CloudWatch Event Amazon SageMaker Studio/Notebook Action - stoptraining - email Analyze/ Visualize 1 4 Debugger Hook System / Framework metrics loss, weight, biases, gradients, etc. loss, gradients, … 3 2
  • 35. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 훈련 내 Tensor 수집 및 이상 탐지 이미지 gradients와 weights를 응용한 사례 수집된 Loss 를 이용한 Plot Class Activation Maps 구현 gradients의 분포 plot
  • 36. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. DebuggerProfiling은 자동으로시스템리소스사용률을모니터링하고, 포괄적인보고서로제공합니다. 훈련 클러스터 사용률 모니터링 – Profiling
  • 37. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 권장 사항 Rule Parameter 이슈 발생횟수 사전 정의된 rule에 의해 발생하는 이슈와 권장 사항, 발생 횟수, rule에서 설정한 파라미터 값을 제공합니다. 훈련 클러스터 사용률 모니터링 – Profiling
  • 38. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Detect Performance Bottlenecks Time (minutes) GPU CPU Utilization Detect Training Issues Bottleneck 발생 분산 훈련 모니터링 사례 Low Model Performance GPU Cluster Metrics P4d instance P4d instance P4d instance … … Model
  • 39. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo
  • 40. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo Code https://github.com/Napkin-DL/ml-ws.git https://github.com/aws-samples/sagemaker-distributed-training- pytorch-kr.git
  • 41. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 42. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 여러분의 소중한 피드백을 기다립니다. 강연 종료 후, 강연 평가에 참여해 주세요! © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 43. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. 감사합니다 © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.