Knowledge pillar · active

LLM 학습·추론·서빙

41 entries

LLM 기초와 학습, 추론 신뢰성, GPU kernel·scheduler·capacity planning까지 모델 실행 전 과정을 설명합니다.


№040 llm-rag-foundations · 02

LLM 토큰화 입문: BPE부터 Context Window 계산까지 (2/10)

LLM이 문자열을 직접 읽지 않고 토큰 ID로 바꾸는 이유를 문자·단어·subword 관점에서 설명하고, BPE·SentencePiece·특수 토큰·한국어 비용·RAG chunk 예산을 실습으로 연결합니다.

#LLM #Tokenization #BPE #ContextWindow
한국어 질문이 subword 토큰과 토큰 ID를 거쳐 context window에 들어가는 과정
№033 llm-rag-foundations · 09

LLM 추론 입문: Prefill·Decode·KV Cache·Temperature 이해하기 (9/10)

프롬프트가 token이 된 뒤 prefill과 autoregressive decode를 거치는 과정을 설명하고, KV cache·TTFT·token latency·temperature·top-p가 RAG의 context 비용과 답변 안정성에 미치는 영향을 정리합니다.

#LLMInference #KVCache #Prefill #Decoding
긴 프롬프트를 병렬 처리하는 prefill과 KV cache를 재사용해 한 token씩 생성하는 decode 단계
№029 llm-inference-systems-engineering · 03

Transformer 추론 커널: GEMM·Attention·FlashAttention·Fusion (3/10)

Transformer 추론을 GEMM, normalization, RoPE, attention, sampling 커널로 분해합니다. Prefill·decode shape와 HBM 이동, FlashAttention·fusion·fallback을 측정해 serving 성능을 검증합니다.

#LLM #GPU #Inference #Transformer
Transformer block의 operator graph가 prefill과 decode shape에 따라 GEMM, FlashAttention, fused kernel과 fallback 경로로 나뉘고 검증 gate를 통과하는 구조
№028 llm-inference-systems-engineering · 04

Continuous Batching·Chunked Prefill: LLM Scheduler 설계 (4/10)

Scheduler가 iteration마다 decode와 prefill token을 묶는 원리를 설명합니다. Chunked prefill, admission, preemption, fairness를 TTFT·ITL budget과 연결해 continuous batching을 설계합니다.

#LLM #Inference #Scheduler #ContinuousBatching
Active decode를 iteration budget에 넣고 긴 prefill을 작은 chunk로 나누며 admission, fairness, preemption과 SLO gate로 연결하는 LLM scheduler 구조
№027 llm-inference-systems-engineering · 05

Paged KV Cache·Prefix Caching: Block·Eviction·Reuse (5/10)

KV cache를 logical block과 physical page로 나눠 할당합니다. Prefix identity, copy-on-write, refcount, eviction, offload를 연결해 RAG Agent의 cache hit와 tenant 격리를 설계합니다.

#LLM #Inference #KVCache #PagedAttention
요청의 logical KV block을 불연속 physical GPU page에 매핑하고 radix prefix tree에서 공유한 뒤 refcount, copy-on-write, eviction과 CPU·SSD tier로 관리하는 구조
№026 llm-inference-systems-engineering · 06

Speculative Decoding: Draft·Verify·Acceptance와 Serving 설계 (6/10)

Speculative decoding의 draft·target verification과 acceptance/rejection 식을 설명합니다. Draft 길이, tree 후보, KV rollback, scheduler와 품질 검증을 연결해 decode 지연을 줄이는 조건을 찾습니다.

#LLM #Inference #SpeculativeDecoding #DraftModel
Draft model이 후보 token을 제안하고 target model이 한 번에 검증한 뒤 acceptance ratio로 prefix를 채택하며 rejected suffix KV를 rollback하는 구조
№025 llm-inference-systems-engineering · 07

분산 LLM 추론: TP·PP·EP·Context Parallel·P/D 분리 (7/10)

분산 LLM 추론의 replica, tensor·pipeline·expert·context parallel과 prefill/decode 분리를 비교합니다. Weight·KV·activation·collective와 topology를 계산해 SLO goodput에 맞는 배치를 설계합니다.

#LLM #Inference #DistributedSystems #TensorParallel
Weight·layer·expert·context·request·prefill/decode를 GPU에 분할하고 collective, activation, KV transfer와 topology를 비교하는 분산 LLM 추론 구조
№024 llm-inference-systems-engineering · 08

저정밀 LLM 추론: FP8·INT8·INT4·FP4 Kernel과 Calibration (8/10)

LLM 추론의 FP8·INT8·INT4·FP4 표현, scale 단위, calibration과 outlier 처리를 비교합니다. Weight·activation·KV를 줄인 뒤 fused kernel, 실제 byte, 정확도와 SLO goodput으로 빠른 경로를 검증합니다.

#LLM #Inference #Quantization #FP8
BF16에서 W8A8·W4A16·W4A8KV4·FP8·FP4로 정밀도를 낮추며 scale, outlier, fused GEMM, 정확도와 SLO gate를 비교하는 저정밀 LLM 추론 구조
№023 llm-inference-systems-engineering · 09

LLM Serving SLO 운영: Admission Control·Fairness·Autoscaling (9/10)

LLM serving의 TTFT·ITL SLO를 goodput으로 정의하고 admission, token fairness와 overload를 설계합니다. Queue work·KV·cold-start를 반영해 replica와 prefill/decode pool을 autoscale합니다.

#LLM #Inference #Serving #SLO
LLM 요청을 SLO class와 token work로 분류하고 admission, deadline·fairness queue, prefill/decode worker, autoscaling feedback loop로 제어하는 운영 구조
№022 llm-inference-systems-engineering · 10

LLM Serving 벤치마킹과 Capacity Planning: Trace·Goodput·비용 (10/10)

LLM serving을 open-loop trace로 재현해 TTFT·ITL·goodput·비용을 측정합니다. Input/output 결합 분포와 cache를 보존해 SLO knee를 찾고 peak·failure·rollout headroom으로 GPU capacity를 계산합니다.

#LLM #Inference #Benchmarking #CapacityPlanning
Production LLM trace를 open-loop로 재생해 workload·시스템·cache 조건을 고정하고 latency, goodput, failure, 비용으로 GPU capacity와 release gate를 계산하는 구조
№019 llm-training-serving-foundations · 03

현대 Decoder LLM 구조: RMSNorm·RoPE·GQA·SwiGLU·MoE (3/10)

현대 decoder-only LLM block을 pre-norm·RMSNorm, RoPE, SwiGLU, MHA·MQA·GQA, KV cache, dense·MoE로 분해하고 각 구조가 학습 안정성, 메모리, 통신, latency에 미치는 영향을 계산합니다.

#LLM #Transformer #RMSNorm #RoPE
Residual stream이 pre-RMSNorm, RoPE와 GQA attention, SwiGLU 또는 routed MoE를 통과하며 KV cache와 token compute를 결정하는 decoder block
№017 llm-training-serving-foundations · 06

LoRA·QLoRA·DoRA와 PEFT: Rank·Target Module·Merge 설계 (6/10)

LoRA의 low-rank update 수식과 trainable parameter를 계산하고 rank·alpha·target module을 고르는 법, QLoRA의 4-bit frozen base, DoRA, adapter merge·동적 serving·평가 계약까지 설계합니다.

#LLM #PEFT #LoRA #QLoRA
Frozen base weight에 rank r의 LoRA A B update를 더하고 QLoRA 4-bit base와 DoRA를 거쳐 merged checkpoint 또는 dynamic adapter serving으로 배포하는 구조
№015 llm-training-serving-foundations · 07

LLM Quantization: GPTQ·AWQ·SmoothQuant·FP8·KV Cache (7/10)

LLM 양자화를 weight-only, weight·activation, KV cache로 나누고 scale·zero point·granularity를 계산하며 GPTQ, AWQ, SmoothQuant, FP8, KIVI의 memory·kernel·품질을 설계합니다.

#LLM #Quantization #GPTQ #AWQ
Floating point tensor를 quantize해 weight-only, weight·activation, KV cache를 calibration, hardware kernel, 품질 평가로 연결하는 구조
№014 llm-training-serving-foundations · 08

분산 LLM 학습: DDP·ZeRO·FSDP·TP·PP·CP (8/10)

LLM 분산 학습을 parameter·gradient·optimizer·activation 원장으로 계산하고 DDP, ZeRO, FSDP, tensor·pipeline·context parallel의 통신, checkpoint, 확장 효율을 설계합니다.

#LLM #DistributedTraining #FSDP #ZeRO
LLM 학습 상태를 parameter gradient optimizer activation으로 나누고 DDP FSDP TP PP CP를 배치하는 분산 학습 구조
№013 llm-training-serving-foundations · 09

효율적인 LLM 추론 서빙: Prefill·Decode·KV Cache (9/10)

LLM 추론을 queue·prefill·decode로 분해하고 TTFT·ITL·goodput을 계산하며 PagedAttention, continuous batching, prefix cache, speculative decoding, P/D 분리와 SLO를 설계합니다.

#LLM #InferenceServing #Prefill #Decoding
LLM 요청을 queue prefill decode로 나누고 KV cache scheduler와 batching을 TTFT ITL goodput SLO로 연결하는 추론 서빙 구조
№012 llm-training-serving-foundations · 10

RAG Agent 모델 선택과 배포: 평가·Canary·Rollback (10/10)

RAG Agent 모델을 grounding·tool calling·long context·latency·cost·license로 비교하고 hard gate와 Pareto frontier를 거쳐 offline, shadow, canary, rollback으로 안전하게 배포합니다.

#RAGAgent #ModelEvaluation #ToolCalling #Groundedness
RAG Agent 후보 모델을 grounding tool calling latency cost gate로 평가하고 offline shadow canary rollback 단계로 배포하는 구조
№011 llm-reasoning-reliability-foundations · 01

Chain-of-Thought 입문: LLM 추론문과 실제 근거 구분하기 (1/10)

Chain-of-Thought가 중간 token으로 계산을 확장하는 원리를 익히고 정답성·설득력·충실성을 분리합니다. RAG Agent에서는 숨은 생각 대신 증거·도구 결과·검증 기록으로 추론을 감사하는 방법을 설계합니다.

#LLM #ChainOfThought #Reasoning #RAGAgent
질문에서 여러 중간 추론 token을 거쳐 답을 만들되 추론문과 인과적 증명을 구분하고 외부 증거와 도구로 검증하는 구조
№010 llm-reasoning-reliability-foundations · 02

Test-time Compute: Self-Consistency·Best-of-N·Search 설계 (2/10)

LLM 추론 시 여러 후보에 계산 예산을 쓰는 self-consistency, pass@k, Best-of-N, verifier search를 구분합니다. 난이도별 adaptive budget과 중단 조건을 품질·지연·비용 SLO로 설계합니다.

#LLM #TestTimeCompute #SelfConsistency #BestOfN
하나의 질문에서 여러 추론 후보를 병렬 생성하고 합의 또는 verifier로 선택하며 난이도와 SLO에 따라 계산 예산을 조절하는 구조
№009 llm-reasoning-reliability-foundations · 03

Verifier와 Process Supervision: ORM·PRM·Value Model (3/10)

LLM 후보를 고르는 ORM·PRM·value model·generative verifier를 구분합니다. 단계 label과 search 결합, calibration, distribution shift, reward hacking을 RAG Agent 사례로 설계합니다.

#LLM #Verifier #ProcessSupervision #RewardModel
최종 답을 평가하는 ORM과 중간 단계를 평가하는 PRM 및 미래 성공을 추정하는 value model을 후보 생성과 search에 연결하는 구조
№008 llm-reasoning-reliability-foundations · 04

LLM 불확실성과 Calibration: 모르면 멈추게 만들기 (4/10)

LLM의 token 확률·verbal confidence·sample agreement·semantic entropy를 구분하고 Brier·ECE·risk-coverage로 calibration을 평가합니다. RAG Agent가 답변·재검색·질문·중단을 선택하도록 설계합니다.

#LLM #Uncertainty #Calibration #SemanticEntropy
여러 LLM 응답을 의미별 cluster로 묶어 semantic uncertainty를 계산하고 calibration threshold에 따라 답변 재검색 질문 중단으로 routing하는 구조
№007 llm-reasoning-reliability-foundations · 05

LLM Hallucination과 Factuality: Claim·Evidence·Citation 평가 (5/10)

LLM 답을 atomic claim으로 분해해 근거 지지·모순·부족으로 판정합니다. FActScore·SAFE·ALCE 관점의 factuality와 citation 정확성·coverage, RAG 오류 귀속을 설계합니다.

#LLM #Hallucination #Factuality #Grounding
LLM 장문 답변을 atomic claim으로 분해하고 각 claim을 evidence span과 대조해 지원 모순 근거 부족으로 판정하며 citation 정확성과 coverage를 계산하는 구조
№006 llm-reasoning-reliability-foundations · 07

Synthetic Data와 Distillation: Rejection Sampling·Model Collapse (7/10)

Teacher LLM으로 instruction·rationale·response를 합성하고 rejection sampling으로 정제합니다. SFT·on-policy distillation, 오염·편향·model collapse를 평가합니다.

#LLM #SyntheticData #Distillation #RejectionSampling
실제 seed와 teacher LLM에서 여러 합성 후보를 만든 뒤 검증 필터와 rejection sampling으로 선별하고 student 학습과 독립 평가까지 연결하는 데이터 파이프라인
№005 llm-reasoning-reliability-foundations · 08

Tool-Use Learning: Function Calling SFT·Execution Reward 설계 (8/10)

도구 문서와 JSON Schema에서 function call 학습 데이터를 만들고 SFT·execution reward로 학습합니다. No-call·병렬·연속 호출, schema drift와 보안 평가를 설계합니다.

#LLM #ToolUse #FunctionCalling #ToolCalling
도구 registry와 schema에서 다양한 호출 과제를 만들고 구조 검증과 sandbox 실행 보상으로 LLM을 학습한 뒤 실제 실행 성공과 정책 위반을 평가하는 구조
№004 llm-reasoning-reliability-foundations · 10

Model Routing과 Cascades: Compound AI System 설계 (10/10)

요청별로 모델·RAG·test-time compute를 router와 cascade로 배분합니다. 품질·비용·지연 제약, counterfactual 학습, Pareto frontier와 drift 운영을 설계합니다.

#LLM #ModelRouting #Cascade #CompoundAI
요청 특징과 정책 제약을 router가 분석해 작은 모델 RAG 강한 모델로 보내고 confidence gate가 필요할 때만 cascade하며 품질 비용 지연을 평가하는 구조
№003 llm-reasoning-reliability-foundations · 09

Agent Trajectory Learning: Long-Horizon Credit Assignment (9/10)

Agent의 state·observation·action 전체 trajectory를 offline imitation과 on-policy RL로 학습합니다. Outcome·step reward, credit assignment, replay와 episode 평가를 설계합니다.

#LLM #Agent #Trajectory #ReinforcementLearning
긴 Agent episode를 상태 관찰 행동 보상 전이로 기록하고 outcome과 step reward를 각 결정에 배분해 offline imitation과 on-policy 학습 및 replay 평가로 연결하는 구조
№002 llm-reasoning-reliability-foundations · 06

Structured Generation: JSON Schema·FSM·CFG로 출력 강제하기 (6/10)

LLM 구조화 출력을 prompt와 재시도에 맡기지 않고 JSON Schema·FSM·CFG로 토큰을 제한합니다. 문법 컴파일, token mask, 의미 검증과 지연 평가를 설계합니다.

#LLM #StructuredGeneration #ConstrainedDecoding #JSONSchema
JSON Schema를 문법 상태 기계로 컴파일하고 매 생성 단계에서 허용 토큰만 남긴 뒤 의미 검증과 권한 검사를 거쳐 도구를 실행하는 흐름