docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,180 @@
---
id: wiki-2026-0508-serverless-computing-for-ai
title: Serverless Computing for AI
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Serverless GPU, Modal, Replicate, Cloudflare Workers AI, Lambda AI]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [infrastructure, serverless, deployment, mlops]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: python
framework: Modal / Replicate / AWS Lambda / Cloudflare Workers AI
---
# Serverless Computing for AI
## 매 한 줄
> **"매 GPU/CPU 를 request 단위로 — scale to zero, cold start 감수, capacity 걱정 없이"**. 매 2026: Modal (Python-native, fast cold start), Replicate (model marketplace), Cloudflare Workers AI (edge inference), AWS Lambda (CPU/small GPU), Beam, RunPod Serverless 가 매 dominant. 매 inference 가 90%, training 은 매 spot/dedicated 이 더 economical.
## 매 핵심
### 매 platform 비교
- **Modal**: Python decorator, ~2-15s cold start, A100/H100/H200, $/sec billing. 매 dev 친화.
- **Replicate**: model-first, COG container. 매 community model marketplace.
- **Cloudflare Workers AI**: edge, ~ms cold start, but limited models (curated).
- **AWS Lambda**: 10GB memory, ~15min limit, 매 GPU 없음 (small). 매 CPU 추론용.
- **Bedrock / Vertex / Azure OpenAI**: 매 fully-managed model API — serverless 끝판.
- **RunPod Serverless / Beam**: lower price, longer cold start.
### 매 cold start
- 매 model size 가 dominant. 7B fp16 ≈ 14GB → S3 → GPU pull 매 slow.
- Mitigation: keep-warm (min replicas=1), persistent volume, model preload, FP8/INT4 quantization.
- 매 2026 trick: snapshot-restore (CRIU-like), prefetch via NVMe-backed volume.
### 매 비용 모델
- Per-second GPU. H100 ~$3-4/hr → $0.001/sec.
- Cold start charged or not depending on platform.
- 매 traffic burst: serverless win. Steady high QPS: dedicated instance win.
### 매 응용
1. Image gen API (FLUX, SDXL on Replicate/Modal).
2. Whisper batch transcription.
3. Embedding service (BGE, E5).
4. Webhook → LLM → DB pipeline.
5. Background job (PDF extraction, OCR).
6. Edge AI: Cloudflare Workers AI for low-latency global.
## 💻 패턴
### Modal — image gen endpoint
```python
import modal
app = modal.App("flux-api")
image = modal.Image.debian_slim().pip_install("torch", "diffusers", "transformers")
@app.cls(gpu="H100", image=image, scaledown_window=120)
class FLUX:
@modal.enter()
def load(self):
from diffusers import FluxPipeline
import torch
self.pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16
).to("cuda")
@modal.method()
def generate(self, prompt: str):
img = self.pipe(prompt, num_inference_steps=28).images[0]
buf = io.BytesIO(); img.save(buf, "PNG"); return buf.getvalue()
@app.local_entrypoint()
def main():
print(len(FLUX().generate.remote("a cat on mars")))
```
### Replicate — run a public model
```python
import replicate
out = replicate.run(
"black-forest-labs/flux-1.1-pro",
input={"prompt": "neon city", "aspect_ratio": "16:9"},
)
print(out) # URL
```
### Cloudflare Workers AI
```javascript
export default {
async fetch(req, env) {
const ai = env.AI;
const r = await ai.run("@cf/meta/llama-3.1-8b-instruct", {
prompt: "Hello"
});
return Response.json(r);
}
}
```
### AWS Lambda — small CPU LLM (llama.cpp)
```python
import boto3, json
def handler(event, ctx):
from llama_cpp import Llama
llm = Llama(model_path="/opt/ml/qwen2-0.5b.gguf", n_ctx=2048)
out = llm(event["prompt"], max_tokens=128)
return {"statusCode": 200, "body": json.dumps(out)}
```
### Modal scheduled batch
```python
@app.function(schedule=modal.Cron("0 2 * * *"), gpu="A10G")
def nightly_embed():
docs = fetch_new_docs()
embs = embed_model(docs)
upsert(embs)
```
### Keep-warm pattern
```python
@app.cls(gpu="A100", min_containers=1, scaledown_window=600)
class WarmModel: ...
```
### Streaming response (Modal + FastAPI)
```python
@app.function(gpu="A100")
@modal.fastapi_endpoint(method="POST")
def stream(req: dict):
from fastapi.responses import StreamingResponse
def gen():
for tok in llm.stream(req["prompt"]):
yield tok
return StreamingResponse(gen(), media_type="text/plain")
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Python ML researcher, fast iter | Modal |
| Public model, no infra | Replicate |
| Global low-latency edge | Cloudflare Workers AI |
| Use OpenAI / Claude / Gemini API | 매 already serverless — API 직접 |
| Steady high QPS | Dedicated GPU (vLLM on K8s) |
| CPU-only small model | AWS Lambda + llama.cpp |
| Tightest price | RunPod Serverless / Beam |
**기본값**: Modal (Python-first dev), API providers (Claude/OpenAI) for foundation models.
## 🔗 Graph
- 부모: [[MLOps]]
- 변형: [[Modal]] · [[Replicate]] · [[Cloudflare-Workers-AI]]
- 응용: [[Edge-AI]]
- Adjacent: [[LLM_Optimization_and_Deployment_Strategies|vLLM]] · [[Kubernetes]]
## 🤖 LLM 활용
**언제**: traffic bursty, model 자주 swap, dev velocity 중요. 매 ops team 작음.
**언제 X**: steady very-high QPS (cost), strict latency SLA (cold start), data residency 제약.
## ❌ 안티패턴
- **Cold-start ignore**: 매 user-facing 5-30s 첫 응답 → bad UX. Keep-warm 또는 prefetch.
- **Big container image**: 50GB image → 매 pull 매번 길어짐. Layer caching, persistent volume.
- **Long-running training on serverless**: 매 hourly cap, expensive. Spot 쓰기.
- **No timeout**: 매 runaway request → bill explode.
- **State on local disk**: 매 ephemeral — S3/Volume 사용.
## 🧪 검증 / 중복
- Verified (Modal docs, Replicate docs, Cloudflare AI docs, AWS Lambda docs 2025-2026).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Modal/Replicate/CF/Lambda 2026 comparison |