티스토리 뷰
Paper/NAS
[Paper 리뷰] HELP: Hardware-Adaptive Efficient Latency Prediction for NAS via Meta-Learning
feVeRin 2023. 6. 17. 12:27반응형
HELP: Hardware-Adaptive Efficient Latency Prediction for NAS via Meta-Learning
- 배포와 device별 제약 조건을 만족하기 위해 Neural Architecture Search (NAS)는 hardware를 고려해야 함
- 기존에는 Lookup table / Latency estimator를 통해 target device의 latency sample을 수집
-> 서로 다른 사양의 hardware를 많이 요구하기 때문에 비실용적임 - Hardware-adaptive Efficient Latency Predictor (HELP)
- Device별 latency 추정 문제를 meta-learning 문제로 공식화
- Latency를 출력하는 black-box를 고려해 모든 device를 embedding 하는 hardware embedding 방식을 제안
- Hardware embedding을 사용해 Hardware-adaptive Latency Predictor를 meta-learning
- 논문 (NeurIPS 2021) : Paper Link
1. Introduction
- NAS가 실제 시나리오에서 적용되기 위해서는 hardware를 고려해야 함
- 메모리, latency, 에너지 소비 등 다양한 device 제약 조건을 만족하는 architecture를 찾아야 함
- Latency가 efficieny 제약으로 가장 많이 고려됨
- Latency를 측정하기 위해서는 target device의 architecture-latency pair를 수집해야 하므로 비용이 많이 소모됨
- OFA는 고성능의 supernet을 활용해 모델의 훈련 시간을 줄이지만, 각 device별로 latency predictor를 구축해야 함
- BigNAS는 FLOP을 기준으로 efficieny를 측정하지만, 정확한 efficieny 기준이라고 볼 수 없음
- Device의 종류와 task에 따라 여러 시간이 소요되므로 latency-constrained NAS의 병목으로 작용함
-> 그래서 효율적인 latency predictor인 HELP를 제안
- 알려진 device를 통해 학습한 knowledge를 새로운 device로 transfer 하여 모르는 device에서 latency 추정 시 높은 효율성을 달성
- Latency prediction 문제를 few-shot 회귀 문제로 고려해 주어진 architecture-device pair에서 latency를 추정
- 새로운 hardware embedding 방법 제안
- 각 device에서 참조 architecture의 latency를 활용해 모든 device를 embedding - 제안된 hardware embedding을 활용해 여러 device에 걸쳐 latency predictor를 학습
- amortized meta-learning, gradient-based meta-learning을 결합
- Device에 구애받지 않는 hardware embedding을 통해 모든 hardware platform 및 architecture search space에 적용가능
- NAS framework와 HELP를 결합하여 latencty-constrained NAS의 컴퓨팅 병목 현상을 줄일 수 있음
- MetaD2A, OFA, HAT와 결합했을 때 효과적임
< Overall of HELP (Hardware-adaptive Efficient Latency Predictor) >
- Latency 추정을 few-shot 회귀로 공식화해 주어진 architecture-device pair로부터 latency를 출력
- 참조 architecture의 latency에 따라 device를 embedding 하는 device-agnostic hardware embedding을 제안
- 새로운 device의 latency를 추정하기 위해 few-shot 회귀 모델을 meta 학습하는 HELP를 제안
- HELP를 기존 NAS framework와 결합해 latency-constrained NAS의 병목 현상을 해소

2. Method
- Problem Definition
- (목표) Device에서 적은 수의 sample만을 사용하여 architecture-device pair의 latency를 예측하는 모델을 설계하는 것
- Task specification
가 주어졌을때, 주어진 hardware deviceτ={hτ,Xτ,Yτ} 에 대한 neural architectureh 의 latencyx 를 추정하는 회귀 모델y 를 학습f(x;θ):X→R : Hardware devicehτ∈H : Neural architecture 집합Xτ⊂X :Yτ⊂Y 의 latency 집합Xτ - 예측값
와 실제 측정값f(Xτ;θ) 에 대한 LossYτ 을 최소화 :L minθL(fτ(Xτ;θ),Yτ)
- BUT, 회귀 모델을 학습하는 것은 간단하지 않음
- 여러 device에 걸쳐 일반화할 수 없기 때문에
개의 device에 대해N 개의 predictorN 을 개별적으로 학습하고 sample을 수집해야 함{fτ(⋅;θτ)}Nτ=1 - 회귀 모델을 overfit 하지 않고 신뢰할만한 예측 성능을 얻으려면 각 device 별로 많은 수의 architecture-latency pair를 필요로 함
- Device와 architecture에 대한 일반화가 부족하기 때문에 NAS framework는 새로운 device가 제공될 때마다 sample 수집을 반복해야 하므로 시간 소모적임
- 여러 device에 걸쳐 일반화할 수 없기 때문에
- Single predictor
의 사용f(⋅;θ) - 적은 수의 architecture-latency 만을 수집하여 (
) 새로운 target device와 architecture에 빠르게 일반화 가능Xτ≪Xτ,Yτ≪Yτ - Meta-learning framework를 통해 device와 architrcture pool
에서 얻은 knowledge를 transfer 함p(τ)
- 적은 수의 architecture-latency 만을 수집하여 (

- Hardware-adaptive Latency Prediction with Device Embedding
- 측정된 latency
는 device typey←(x,h) 와 architectureh 에 따라 달라짐x - 기존의 latency predictor는 device별로 개별적으로 학습되기 때문에 device 제약조건을 무시하고
형식을 취함f(x;θ)
- 새로운 device를 포함하는 환경에서 Single latency predictor를 학습하면 성능이 저하됨 - Hardware-conditioned prediction model이 필요 :
f(x,h;θ):X×H→R
- 기존의 latency predictor는 device별로 개별적으로 학습되기 때문에 device 제약조건을 무시하고
- Hardware-conditioned prediction model
- 동일한 architecture
에 대해서도 device type에 따라 latency를 다르게 예측 가능x - Platform type에 관계없이 모든 device에 대해 hardware device
를 표현하는 것이 중요h
- Hardware device의 물리적 architectrue가 다를 수 있기 때문 (CPU, FPGA..) - Hardware device를 주어진 architecture에서 추론된 latency을 출력하는 black-box function으로 고려
- 동일한 architecture
- 고정된 참조 neural architecture 집합에 대한 device의 latency :
Vh : 참조 neural architectureE 의 집합{x1,x2,...,xd}⊂X
- meta-training, meta-test 작업 전반에서 고정되어 사용됨 : 참조 architecture의 수d : 표준화된 latency 값 (0~1)y∗i(xi,h)={yi(xi,h)−min(V(0)h)}/{max(V(0)h)−min(V(0)h)}
- 이때,V(0)h={y1(x1,h),y2(x2,h),...,yd(xd,h)} - 참조 device 집합은 대표성이 있어야 하므로 다양하고 이질적인 것으로 선택
- 참조 architecture는 search space에서 random sampling

- Hardware device에 대한 black-box 처리 및 latency-based hardware embedding을 통해 자세한 hardware specification을 고려하지 않고 새로운 device를 embedding 가능
- Meta-Learning the Hardware-adaptive Latency Predictor
- 수집된 device 및 architecture pool
를 활용하여 여러 device에 대한 few-shot 회귀 문제를 해결해야 함p(τ) - Meta-learning을 활용한 hardware-adaptive latency predictor
- Task distribution 에서p(τ) 를 meta-learningf(x,h;θ)
- Predictor 를 새로운 task specificationf(x,h;θτ) 가 주어졌을 때 neural architectureτ={hτ,Vh,Xτ,Yτ} 에 빠르게 적응시킴x
- Meta-learning을 활용한 hardware-adaptive latency predictor
- Meta-training 단계에서는 Episodic Training Strategy 활용
- Device-architecture pool
에서 taskp(τ) 를 random sampling 하여 각 반복마다 few-shot regression 수행τ
- Training set / Test setD={hτ,Xτ,Yτ} ˜D={hτ,˜Xτ,˜Yτ}
- ,Xτ⊂X : neural architecture sample의 집합˜Xτ⊂X
- : few-shot sample의 집합 (Xτ )|Xτ|≪|X|
-> 이 집합 간에는 교집합이 없음 ( )Xτ⋂˜Xτ=∅
- ,Yτ⊂Y : neural architecture˜Yτ⊂Y ,Xτ 에 대응하는 latency 값의 집합˜Xτ - Hardware-adaptive 예측 모델 :
f(X,Vτ;θτ)
- Device-architecture pool
- Latency predictor를 Meta-training 하기 위한 test loss
L(⋅;˜Dτ)
- Task embedding
를 사용해서 task-conditioned latency predictor를 얻을 수 있음Vτh - Amortized meta-learning framework의 사용 : dataset-adaptive performance predictor와 NAS framework를 meta-learn 하는 것이 목표
- Task embedding

- Target device에서 수집된 latency를 사용해서 few-shot adaptation을 추가로 수행
:t 번째 inner gradient stept : inner gradient step의 총 수T : multi-dimensional global learning rate vectorα - Meta-learning에서 사용되는 device에 대한 knowledge를 사용하여 새로운 device에 빠르게 적응 가능
- Meta-device pool과 관련성이 없는 완전히 새로운 device를 접하게 되면
에 의해 기존에 캡처된 meta-knowledge에서 벗어나게 됨θτ(t)

- Hardware-adaptive modulator :
Zτ=g(Vτh;ϕ):Rd→Rdθ - Initial parameter를
로 modulate 하기 위함θ(0)=θ∗zτ : hardwareθ(0) 에 대한 새로운 initializationhτ - Weight 설정 :
(θ(0)←θ∘zτ : element-wise multiplication operator)∘ - Bias 설정 :
θ(0)←θ+zτ
- Initial parameter를

- 최종적인 Meta-learning objective function
- Hardware-adaptive latency predictor와 shared initial parameter에 대한 modulator를 모두 meta-learn

- Few-shot Adaptation to Unseen Devices (Meta-Test)
- Meta-train 된 latency prediction model
를 통해 새로운 devicef(⋅;θ) 에서 architecture의 device 추정hν - Device-conditioned meta-learning을 활용하면 few latency 값 만으로도 새로운 architecture
의 latency˜xν 를 측정할 수 있음yν - For example,
1. (Given) 새로운 device 에서 architecturehν,ν={hν,Xν} 의 latency 예측˜xν
2. Hardware embedding 계산 : 고정된 참조 architecture 집합에서 latency를 얻음Vh
3. 얻어진 를 Latency predictorVh 의 device-optimized parameter로 활용θν(T+1)
4. Device-optimized latency predictor 을 사용해f(⋅,Vhν;θν(T+1)) 의 latency 예측˜xν - Meta latency predictor를 NAS method와 결합하여 새로운 device에 대해 latency가 제한된 NAS를 수행 가능
- Device-conditioned meta-learning을 활용하면 few latency 값 만으로도 새로운 architecture
- Computational Complexity of HELP
- Latency predictor의 meta-training은 한 번만 수행되고 얻어진 latency predictor를 조정해서 사용할 수 있음
- 기존 방식은 많은 양의 sample을 수집해 각 target device별로 latency predictor를 학습시켜야 하지만, HELP는 device 당 10개의 sample만 수집하면 됨
- Time complexity를
에서O(DN) 으로 줄임O(N) : device 수D : sample 수N
- Time complexity를

3. Experiment
- Settings
- Search space : NAS-Bench-201, FBNet, MoblieNetV3, HAT
- Meta-training / Meta-test pool : 18 heterogeneous device (CPU, GPU, mobile..)
- Baseline : MAML, Meta-SGD, ANP, BRP-NAS, MetaD2A
- Efficacy of HELP on Few-shot Latency Estimation for Novel Devices
- Meta-knowledge (Meta-SGD, HELP)를 사용하는 것이 처음부터 Latency predictor를 학습하는 것보다 우수한 성능을 보임
- 특히 HELP는 샘플 수가 적을 때 다른 방식들보다 훨씬 높은 성능 보임
- Hardware-adaptive initial parameter
을 사용하기 때문θ0

- HELP가 다른 hardware-independent 한 방식들보다 우수한 성능을 보임
- Meta-training dataset에서 device의 이질성으로 인해 task conditioning이 더 중요해지기 때문

- Meta-training pool에 있는 device 수가 10개 이상일 때, 새로운 target device에 대해 0.9 이상의 상관관계를 달성

- HELP는 10개의 sample 만으로 GPU에서 0.987, CPU에서 0.989의 Spearman 순위 상관을 얻어 최고의 sample 효율성을 보임

- End-to-end Latency-constrained NAS with HELP
- HELP가 Pixel2, Titan RTX에서 각각 90배의 샘플 효율성과 9.8배, 9.9배의 계산 효율성을 달성해 최고의 성능을 보임
- HELP+MetaD2A는 125초 만에 최적의 Latency-constrained architecture를 탐색했음

- HELP가 각 traget device에 대해 총 NAS 비용을 크게 줄여줌

- OFA+HELP는 target device의 총 NAS 비용을 2140배까지 줄임

- Transformer 모델에 대한 NAS를 수행했을 때, HELP는 기존의 HAT보다 200배 더 적은 sample을 사용하면서 경쟁력 있는 Transformer 모델을 얻었음

반응형