Skip to main content
QUICK REVIEW

[논문 리뷰] GPUTOK: GPU Accelerated Byte Level BPE Tokenization

Venu Gopal Kadamba, Kanishkha Jaisankar|arXiv (Cornell University)|2026. 03. 03.
Natural Language Processing TechniquesComputer Science인용 수 0
한 줄 요약

GPUTOK은 그레이디 병합을 보존하면서 CPU 토큰나이저에 비해 긴 시퀀스에서 상당한 속도 향상을 제공하는 GPT-2-호환 GPU 기반 바이트 단위 BPE 토크나이저를 구현한다.

ABSTRACT

As large language models move toward million-token context windows, CPU tokenizers become a major slowdown because they process text one step at a time while powerful GPUs sit unused. We built a GPU-based byte-level BPE tokenizer that follows GPT-2's merge rules. It includes a basic BlockBPE-style kernel and a faster, optimized version that uses cuCollections static map, CUB reductions, and a pybind11 interface for Python. On WikiText103 sequences up to 131k tokens, the optimized GPU tokenizer produces the same tokens as a CPU version and, for the longest inputs, is about 1.7x faster than tiktoken and about 7.6x faster than the HuggingFace GPT-2 tokenizer. Nsight profiling shows that 70-80% of CUDA API time goes to memory allocation, so adding memory pooling should give the biggest speed boost next. Tests on generation tasks using WikiText103 prompts show that our GPU tokenizer's outputs stay within about one percentage point of tiktoken and HuggingFace GPT-2 on similarity and overlap metrics, meaning it keeps output quality while making long-context inference more practical.

연구 동기 및 목표

  • 롱 컨텍스트 LLM 추론에서 대기 시간을 줄이기 위해 GPU 기반 토큰화의 필요성을 제시한다.
  • 그레이디 병합을 보존하는 GPT-2 스타일 바이트 수준 BPE의 GPU 지향 설계를 기술한다.
  • PyTorch 서빙 스택과의 통합을 위한 Python 친화적 인터페이스와 오픈 소스 구현을 제공한다.
  • CPU 기반 토크나이저 및 기본 GPU 접근 방식과의 성능 및 정확도 벤치마킹을 수행한다.

제안 방법

  • CPU에서 GPT-2 바이트 인코더를 재구성하고 바이트를 GPT-2 스타일 기호에 매핑한다.
  • 빠른 조회를 위해 cuCollections static_map를 사용해 GPU에 GPT-2 병합 어휘를 저장한다.
  • 하나의 CUDA 블록 내에서 시퀀스별 그레이디 BPE 병합을 수행하는 두 개의 CUDA 커널(베이스라인과 최적화)을 구현한다.
  • 각 병합 후 토큰 시퀀스를 업데이트하기 위한 이중 버퍼링 방식의 메모리 효율적 콤팩션 스킴을 사용한다.
  • 배치 문자열에 대해 토큰화를 실행하고 결과와 함께 커널 시간 측정을 보고하기 위해 pybind11 Python API를 노출한다.
Figure 1: CUDA API breakdown from Nsight Systems on the long-document workload. Memory allocations dominate API time, indicating that device-side memory pooling could substantially reduce overhead.
Figure 1: CUDA API breakdown from Nsight Systems on the long-document workload. Memory allocations dominate API time, indicating that device-side memory pooling could substantially reduce overhead.

실험 결과

연구 질문

  • RQ1GPU에 상주하는 GPT-2 호환 BPE 토크나이저가 CPU 기준 병합을 정확히 재현할 수 있는가?
  • RQ2토큰화를 GPU로 옮길 때 긴 시퀀스(예: 최대 131k 토큰)에 대해 어떤 성능 향상이 달성될 수 있는가?
  • RQ3커널 설계 선택(베이스라인 대 최적화된 콤팩션)이 처리량과 대기시간에 어떤 영향을 미치는가?
  • RQ4GPU 토큰화에서의 메모리 할당 오버헤드가 미치는 영향은 무엇이며, 메모리 풀링이 이를 실질적으로 줄일 수 있는가?
  • RQ5GPU 토크나이저가 토큰 수준의 정확성과 다운스트림 생성 품질을 CPU 기준과 비교해 유지하는가?

주요 결과

  • 최적화된 GPU 커널은 131k 토큰 시퀀스에서 tiktoken보다 약 1.7배 빠르고 HuggingFace GPT-2 토크나이저보다 7배 이상 빠르다.
  • GPU 토큰화가 WikiText103 규모의 입력에 대해 CPU 기준 토큰 시퀀스와 일치하여 정확한 그레이디 병합 의미를 시사한다.
  • 긴 입력에서 GPU 토큰화는 엔드-투-엔드 대기시간 및 처리량 측면에서 CPU 기반 토크나이저를 능가한다.
  • 프로파일링 결과 CUDA API 시간의 70–80%가 메모리 할당에 소요되어 메모리 풀링이 주요 향상 가능성을 시사한다.
  • 생성 유사성 테스트에서 겹침 지표상 출력이 CPU 기반 토크나이저와 약 1%포인트 이내로 유지된다.
Figure 2: Tokenization latency versus sequence length on WikiText103 in latency mode. The optimized GPU kernel overtakes tiktoken at around two thousand tokens and reaches a clear advantage at the longest context lengths.
Figure 2: Tokenization latency versus sequence length on WikiText103 in latency mode. The optimized GPU kernel overtakes tiktoken at around two thousand tokens and reaches a clear advantage at the longest context lengths.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.