common : common_prompt_batch_decode 내 상태 저장 오류 수정 ([#23468](https://github.com/g
요약
llama.cpp의 common_prompt_batch_decode 과정에서 발생하는 세션 상태 저장 및 복구 오류를 수정했습니다. session_tokens 저장 시 토큰 개수를 n개로 조정하여 동일 토큰이 잘못된 위치에서 재생되는 버그를 해결했습니다.
핵심 포인트
- session_tokens 저장 시 n-1개가 아닌 n개의 토큰을 저장하도록 수정
- KV 캐시와 세션 토큰 간의 불일치로 인한 토큰 재생 오류 해결
- Transformer, Recurrent, Hybrid 모델 모두에서 검증 완료
common : common_prompt_batch_decode 내 상태 저장 오류 수정 (#23468)
- common : common_prompt_batch_decode 내 상태 저장 오류 수정
이 커밋은 completion.cpp 및 save-load-state.cpp의 세션 상태 저장/복구(store/restore)에 영향을 미치는 common_prompt_batch_decode의 버그를 해결합니다.
이 수정의 동기는 현재 코드가 session_tokens와 KV 캐시(KV cache) 모두에 n-1개의 토큰을 저장하고 있다는 점입니다. 그 후 세션 토큰을 로드할 때, 프롬프트가 일치하면 마지막으로 저장된 토큰(n-1)을 다음 위치에 다시 재생(replay)하게 되어, 결과적으로 동일한 토큰을 잘못된 위치에서 다시 재생하게 됩니다.
해결 방법은 session_tokens에 n개의 토큰을 모두 저장하는 것입니다. 반면, common_prompt_batch_decode에서 마지막 토큰이 디코딩(decode)되기 전에 저장이 이루어지므로, 메모리 상태(memory state)는 처리된 n-1개의 토큰만을 반영하게 됩니다.
저는 Transformer, Recurrent, 그리고 Hybrid 모델을 사용하여 completion.cpp와 save-load-state.cpp를 모두 실행했습니다.
해결 사항: #23400
공동 작성자: fairydreaming 166155368+fairydreaming@users.noreply.github.com
macOS/iOS:
- macOS Apple Silicon (arm64)
- macOS Apple Silicon (arm64, KleidiAI 활성화) 비활성화됨
- macOS Intel (x64)
- iOS XCFramework
Linux:
<strong>Linux:</strong>
- Ubuntu x64 (CPU)
- Ubuntu arm64 (CPU)
- Ubuntu s390x (CPU)
- Ubuntu x64 (Vulkan)
- Ubuntu arm64 (Vulkan)
- Ubuntu x64 (ROCm 7.2)
- Ubuntu x64 (OpenVINO)
- Ubuntu x64 (SYCL FP32) DISABLED
<strong>Android:</strong>
<strong>Windows:</strong>
<strong>Windows:</strong>
- Windows x64 (CPU)
- Windows arm64 (CPU)
- Windows x64 (CUDA 12) - CUDA 12.4 DLLs
- Windows x64 (CUDA 13) - CUDA 13.3 DLLs
- Windows x64 (Vulkan)
- Windows x64 (SYCL) DISABLED
- Windows x64 (HIP)
openEuler:
- DISABLED
- openEuler x86 (310p)
- openEuler x86 (910b, ACL Graph)
- openEuler aarch64 (310p)
- openEuler aarch64 (910b, ACL Graph)
UI:
AI 자동 생성 콘텐츠
본 콘텐츠는 llama.cpp Releases의 원문을 AI가 자동으로 요약·번역·분석한 것입니다. 원 저작권은 원저작자에게 있으며, 정확한 내용은 반드시 원문을 확인해 주세요.
원문 바로가기