--- id: wiki-2026-0508-neural-architecture-search-nas title: Neural Architecture Search (NAS) status: verified canonical_id: wiki-2026-0508-neural-architecture-search-nas aliases: [NAS, AutoML-NAS, Architecture Search] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [automl, nas, deep-learning, architecture, optimization] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: [python, pytorch, nni, autokeras] --- # Neural Architecture Search (NAS) ## 한 줄 정의 신경망 **아키텍처 자체를 자동 탐색**해 정확도·지연시간·파라미터 같은 목적함수를 최적화하는 AutoML 분야. 2017–2020년 비전 분야 SOTA를 갱신했지만, 2022+ Transformer/Foundation 모델 표준화 이후 **연구 활성도는 감소**, 현재는 edge·MoE·LLM 변형 설계 등 특정 영역에 잔존한다. ## 핵심 ### 3대 구성요소 (Elsken 2019 정리) 1. **Search space**: 후보 연산(conv 3×3, depthwise, identity 등)과 토폴로지. 2. **Search strategy**: RL, evolution, gradient(DARTS), Bayesian. 3. **Performance estimation**: 짧은 학습, weight sharing, predictor. ### 대표 방법 - **NASNet (2017)**: RL controller로 cell 검색. GPU 수천 일 필요. - **ENAS (2018)**: parameter sharing → 1 GPU 일. - **DARTS (2019)**: 연속 완화 + gradient. **NAS 대중화의 분기점**. - **ProxylessNAS (2019)**: 타겟 hardware latency 직접 최적화. - **Once-for-All (2020)**: 한 번 학습 → 다양한 sub-network 추출 (edge). - **EfficientNet 계열**: NAS+compound scaling. - **Zero-cost NAS (2021+)**: 학습 없이 proxy score (synflow, jacov). ### 2024–2026 현황 - 비전: ConvNeXt/MAE 등 hand-design + 사전학습이 주류. - LLM: 사실상 dense Transformer 표준 → NAS는 **MoE routing, KV cache 구조, 효율 attention** 등 부분 검색에 한정. - **Edge / NPU**: TFLite/CoreML 타겟 latency-aware NAS는 여전히 유용. - **AutoML 도구화**: AutoKeras, NNI, Vertex AI Neural Architecture Search. ### 응용 모바일 비전 모델(MobileNetV3, EfficientNet-Lite), 의료 영상 백본 검색, NPU 최적화, 작은 LLM 변형 (헤드 수·차원 검색). ## 💻 패턴 ### Search space 정의 (간이 cell) ```python OPS = ["conv3x3", "conv5x5", "dwconv3x3", "max_pool3x3", "identity", "skip"] def sample_cell(n_nodes=4): return [(prev_idx, op) for prev_idx in range(n_nodes) for op in [random.choice(OPS)]] ``` ### DARTS — α 학습 (개념 코드) ```python class MixedOp(nn.Module): def __init__(self, C): super().__init__() self.ops = nn.ModuleList([build_op(o, C) for o in OPS]) self.alpha = nn.Parameter(torch.zeros(len(OPS))) def forward(self, x): w = F.softmax(self.alpha, dim=-1) return sum(w[i] * op(x) for i, op in enumerate(self.ops)) # 1차 근사 학습 루프 for x_t, y_t, x_v, y_v in loader_pair: loss_w = ce(model(x_t), y_t); loss_w.backward(); opt_w.step(); opt_w.zero_grad() loss_a = ce(model(x_v), y_v); loss_a.backward(); opt_a.step(); opt_a.zero_grad() best_op_per_edge = [OPS[m.alpha.argmax().item()] for m in mixed_ops] ``` ### Evolutionary search (간단) ```python def evolve(pop, fitness, gens=20, k=5): for _ in range(gens): scored = sorted(pop, key=fitness, reverse=True) parents = scored[:k] children = [mutate(random.choice(parents)) for _ in range(len(pop)-k)] pop = parents + children return scored[0] ``` ### Hardware-aware loss (ProxylessNAS 류) ```python loss = ce(logits, y) + lam * predicted_latency(arch_params) ``` ### Zero-cost proxy (synflow) ```python def synflow(model, x): for p in model.parameters(): p.data = p.data.abs() out = model(x).sum() out.backward() score = sum((p * p.grad).sum().item() for p in model.parameters() if p.grad is not None) return score ``` ### NNI 사용 예 (현실적 default) ```python # search_space.json 정의 후 import nni from nni.experiment import Experiment exp = Experiment("local") exp.config.search_space = json.load(open("search_space.json")) exp.config.trial_command = "python train.py" exp.config.trial_concurrency = 4 exp.config.tuner.name = "TPE" exp.run(8080) ``` ## 결정 기준 | 상황 | 추천 | |---|---| | compute 풍부, 연구용 | DARTS / Evolutionary | | 작은 GPU 1대 | DARTS / ENAS | | Edge / mobile latency 목표 | **ProxylessNAS, Once-for-All** | | 빠른 baseline | hand-design + 사전학습 (EfficientNet, ConvNeXt) | | LLM 사전학습 | NAS 비추 — 표준 Transformer 사용 | | 빠른 평가 | Zero-cost proxy + top-k 재학습 | | 실서비스 자동화 | NNI / Vertex NAS | 기본값: **사전학습 backbone 사용**. NAS는 **edge latency 제약** 또는 **search space가 도메인-specific** 일 때 검토. ## 🔗 Graph - 부모: [[AutoML]] · [[Deep Learning]] · [[Hyperparameters|Hyperparameter-Optimization]] - 응용: [[EfficientNet]] · [[Edge-AI]] - Adjacent: [[Mixture-of-Experts]] · [[LLM_Optimization_and_Deployment_Strategies|Knowledge-Distillation]] · [[LLM_Optimization_and_Deployment_Strategies|Quantization]] ## 🤖 LLM 활용 **언제**: search space 설계 brainstorm, DARTS α 해석 sanity check, 논문 비교 요약, NNI/AutoKeras config 작성. **언제 X**: 실제 NAS 결과를 LLM 직관으로 대체 — 최종 아키텍처는 검증 데이터로 측정 필요. compute 비용 추정도 실측 우선. ## ❌ 안티패턴 - DARTS의 weight sharing 편향(skip connection 폭주) 무시. - 검증셋이 search 와 final 학습에 모두 노출 → 결과 과대평가. - 단일 GPU·짧은 epoch 추정으로 최종 성능 결정 — 재학습 필수. - 하드웨어 latency 측정 없이 "FLOPs만" 최적화 → 실기기 속도와 괴리. - 2026년에 LLM 사전학습용 NAS 시도 — 비용·표준화 문제로 ROI 낮음. ## 🧪 검증 / 중복 Verified source: Elsken et al. *NAS Survey* (2019), Liu et al. *DARTS* (2019), Cai et al. *ProxylessNAS / OFA*, Microsoft NNI 문서, Google Vertex AI NAS docs, recent zero-cost NAS surveys (2022–2024). 신뢰도 A. 중복 없음. [[AutoML]] 은 부모, [[Hyperparameters|Hyperparameter-Optimization]] 은 형제 개념. ## 🕓 Changelog - 2026-05-08 Phase 1 — 초기 stub. - 2026-05-10 Manual cleanup — FULL canonical 재작성. DARTS/ProxylessNAS/OFA/zero-cost 코드 6개, 2024–2026 현황(사용 빈도 감소) 반영.