arXiv:2608.08740v1 cs.LG

슬라이딩 윈도우와 히르쉬버그 알고리즘 기반의 메모리 효율적인 활성화 체크포인팅을 통한 PyTorch의 0/1 배낭 문제 해결

Memory-Efficient Activation Checkpointing with Sliding Window and Hirschberg's Algorithm for 0/1 Knapsack Solving in PyTorch

Jędrzej Maczan

제출 2026-08-09

한국어 초록

활성화 체크포인팅(activation checkpointing)은 어떤 중간 텐서를 저장하고 어떤 텐서를 재계산할지 선택함으로써, 주어진 메모리 예산 내에서 신경망의 실행 시간을 최소화합니다. PyTorch는 이를 0/1 배낭 문제(0/1 knapsack problem)로 모델링하여 해결하며, 여기서 결합 순방향-역방향 계산 그래프의 연산들은 메모리 비용(가중치)과 실행 시간 절약(가치)을 갖는 아이템이 됩니다. 기본 솔버인 `dp_knapsack`은 $(n+1) \times (W+1)$ 크기의 전체 동적 계획법(DP) 테이블을 할당하는데, 여기서 $n$은 연산의 수이고 $W$는 양자화된 메모리 예산입니다. 이 방식은 많은 리소스를 소모하며 64GB RAM이 장착된 머신에서 아이템 수 $n = 100$일 때 충돌이 발생합니다. 본 논문에서는 슬라이딩 윈도우 기법과 히르쉬버그 알고리즘(Hirschberg's algorithm)을 결합하여 정확한 최적해를 보존하면서도 피크 메모리를 $O(nW)$에서 $O(W)$로 줄이는 `dp_knapsack_sliding_hirschberg`를 소개합니다. 실험 결과, `dp_knapsack`이 $n = 100$에서 실패하는 반면 본 방식은 $n = 2000$에서도 배낭 문제를 성공적으로 해결하여 계산 가능한 문제 크기를 20배 증가시켰습니다. 또한 벤치마크 평가에서 `dp_knapsack` 대비 일관되게 25-28%의 실행 속도 향상을 보였습니다. 해당 구현체는 PyTorch에 병합되어 2.10 버전에 릴리스되었습니다.

원문 초록

Activation checkpointing minimizes the runtime of neural networks under a given memory budget, by selecting which intermediate tensors to store and which to recompute. PyTorch solves this as a 0/1 knapsack problem, where operations from a joint forward-backward computation graph are items with a memory cost (weight) and a runtime saving (value). The default solver, dp_knapsack, allocates a full dynamic programming (DP) table of shape $(n+1) \times (W+1)$, where $n$ is the number of operations and $W$ is the quantized memory budget. This method is resource-hungry and crashes at $n = 100$ items on a machine with 64 GB RAM. In this paper, we introduce dp_knapsack_sliding_hirschberg, which combines the sliding window trick and Hirschberg's algorithm to reduce peak memory from $O(nW)$ to $O(W)$ while preserving the exact optimal solution. Our experiments show successful knapsack execution at $n = 2000$, where dp_knapsack fails at $n = 100$, a 20$\times$ increase in computable problem size. In addition, our benchmarks show a consistent 25-28\% runtime speedup over dp_knapsack. The implementation is merged into PyTorch and released in version 2.10.

제출 이력

확인된 버전만 표시합니다. 전체 제출 이력은 arXiv 원문에서 확인하세요.

  1. arXiv:2608.08740v1제출 시각 미확인

함께 살펴볼 논문

공통 태그를 근거로 연결했습니다. 실제 인용 관계나 논문의 우수성을 뜻하지 않습니다.

공통 태그로 연결된 공개 논문이 아직 없습니다.

토론

이 논문과 연결된 포럼 글이 아직 없습니다.