Search
English

PyTorch 어텐션 추론에서 마스크를 쓰면 GPU 메모리가 급증, 대체 경로를 바꿔 줄인 사례(zenn.dev)

startupxo Discuss

Writing language: KoreanRead translation

Summary / Read source ↗

- 이미지 영역을 표시하는 마스크를 만드는 모델 Xiaomi-Lens-0은 flash-attn이 없을 때 MultiheadAttention 경로로 넘어가며, 이때 마스크를 받으면 헤드 16개 × 패치 수의 제곱 크기 행렬을 만들었다. - 작성자 측정 기준 3메가픽셀 이미지의 마스크 단계 추가 VRAM 피크는 기존 경로 18.02GB, SDPA 경로 2.28GB였다. 측정 환경은 RTX 5090 32GB, Windows 11, flash-attn 미설치다. - PyTorch 문서는 need_weights=False일 때 최적화 경로를 쓴다고 설명하지만, 작성자가 CUDA 소스를 보니 마스크가 있으면 그 경로에 들어가지 않았다. CPU 프로파일링에서는 학습 모드의 같은 층이 SDPA를 써서 eval 추론에서만 재현됐다. - 작성자는 6개 샘플 비교에서 토큰과 박스가 같았고 마스크 IoU는 0.9976에서 0.9998 사이였다고 보고했다. 이는 제한된 비교이며 품질 전체 평가가 아니다.
Found on

Zenn ↗ / Published by source

Have you run into something like this? Tell us in a line or two what you did. You do not need to know the product.

Sign in to comment

1 comment

Editorial opinionstartupxo

O: 사내 추론 서버를 맡은 엔지니어가 패딩 마스크를 넣은 eval과 inference_mode 상태에서 GPU 메모리 피크를 한 번 재 보고 SDPA 경로와 비교해 볼 때 쓸 만합니다. X: 수치는 작성자 환경의 마스크 단계 추가 피크라서 전체 VRAM이 아니며, GPU와 해상도, 모델 구조가 다르면 결과가 달라질 수 있다는 점을 먼저 따져야 합니다.
Writing language: Korean

Keyboard shortcuts

Choose a post with J and K or the arrow keys, then press Enter.

K ↑ / J ↓
Previous post / next post
Enter C
Open summary and comments for the selected post
O
Open the original link of the selected post
/
Search
?
Show this help
Tab
Move to the submit or comment button, then press Enter

Type normally in text fields. Tab and Enter are always available.