Open
Conversation
progressive_model_dual_path.py의 activate_layers_instant() 시 CPU→GPU weight 복사 성능 개선. 변경 사항: - prefetch_weights(): load_file() 후 pin_memory() 변환 → non_blocking=True 가 실제 DMA async 전송으로 동작하도록 - _load_layer_weights(): .copy_(w.to(device)) → .copy_(w, non_blocking=True) → 중간 GPU 임시 텐서 제거 (H2D+D2D 이중 복사 → H2D 단일) - _load_qkv_fused() / _load_mlp_fused(): torch.cat() 제거, param.data 슬라이스에 각 텐서 직접 async H2D 복사 기대 효과: - t_activation 개선 (복사가 bottleneck인 경우 5-10x) - CPU concat 연산 제거로 메모리 할당 오버헤드 감소
- t_ttft_s (Time To First Token, max_tokens=1) 측정 추가
- 디코딩 시간에 묻히는 문제 해결: prefill 비용만 격리하여 비교
- Origin: 전체 토큰 fresh prefill / Partial: 신규 질문 토큰만 prefill
- t_total_effective를 transition + t_ttft 기준으로 재정의
- _measure_transition_partial: Method A (GPU-resident) 적용
- t_sync 제거 (CPU 복사 불필요, 0.000s 고정)
- advance_fn 이후 mark_all_blocks_as_uncomputed() 호출
→ prefix cache가 context_len=0으로 판단하여 back layers 재계산 정상 동작
- benchmark는 chatbot_partial_cache.py를 거치지 않으므로 직접 block reset 수행
기존 방식은 prefetch_weights() 호출마다 모든 텐서에 pin_memory()를 수행해 매 전환 시 ~16s의 page registration 비용이 발생하였다. 변경 후: __init__에서 _pinned_staging_buffer를 None으로 초기화하고, prefetch_weights() 첫 호출 시 체크포인트 크기 기반으로 pinned 메모리를 단 1회 사전 할당한다 (동기, 메인 스레드). 이후 호출에서는 동일 버퍼를 재사용하여 백그라운드 워커가 CPU→CPU 복사(~0.1s)만 수행하도록 한다. 결과: - t_activation: 14.5s → 0.08s (약 180배 개선) - 2회차 이상 전환의 staging buffer 할당 비용: ~16s → 0s - 실서비스에서 첫 할당 비용(~16s)은 prefetch_stage2() 호출이 Stage 1 서빙 시작 직후 이루어지므로 사용자 체감 지연 없음
Partial 모드의 KV cache 보존 이점(t_ttft 절감)이 대화 길이에 비례해 커진다는 가설을 검증하기 위해 Stage 1 대화 횟수를 확장. 변경 사항: - STAGE1_PROMPTS / STAGE1_FIXED_RESPONSES: 3턴 → 20턴 (Turn 4-20 응답은 ~45 tok으로 짧게 설계하여 토큰 한도 내 수납) - max_model_len: 2048 → 4096 (20턴 누적 시 Stage 2→3 전환 시점 컨텍스트 ~2050 tok 초과 대응) 기대 결과: - Origin t_ttft: ~1500 tok 전체 재prefill → 이전 대비 5배 증가 예상 - Partial t_ttft: 새 질문 토큰만 prefill → 대화 길이 무관 일정 유지
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.