Qwen3 14B / 32B Base + YaRN: Long-Context FT (32K → 128K) RTX 4090'da Marjinal Mümkün
Qwen3 14B'nin RTX 4090'da QLoRA + 32K context FT'si — mem peak 21 GB, marjinal sığıyor. YaRN rope-scaling math (β_fast, β_slow, scaling), long-context SFT dataset (NIAH + RULER), 32B'nin 4090'da imkansız olduğu yer. Cloud 1×H100 80GB alternatifi.
Şükrü Yusuf KAYA
32 dakikalık okuma
İleri1. YaRN Rope-Scaling Matematiği#
Standard RoPE: , base genelde 10,000.
θ_i = base^(-2i/d)RoPE'nin sorunu: pre-train'in seq_len'inden uzun input'ta yüksek-frekans bileşenler "out of distribution".
YaRN (Peng et al. 2023) çözümü: Frequency-dependent scaling:
λ(s) = (1 - s) × λ_orig + s × (factor × λ_orig)
- λ_orig: yüksek frekanslar (kısa-mesafe attention) — değiştirme
- factor × λ_orig: düşük frekanslar (uzun-mesafe) — scale et
- s: rope dimension'a göre interpolation weight (smooth transition)
Qwen3'in config'i (32K base → 128K):
"rope_scaling": { "type": "yarn", "factor": 4.0, "original_max_position_embeddings": 32768, "attention_factor": 0.1 }
2. RTX 4090 + Qwen3 14B + 32K context — Memory Math#
| Term | Value | Notlar |
|---|---|---|
| W (NF4) | 7.4 GB | 14.77B × 0.5 B/p |
| G | 0.16 GB | LoRA r=16 only |
| O | 0.40 GB | paged_adamw_8bit on LoRA |
| A (seq=32K, batch=1, grad-ckpt + FA2) | 9.8 GB | uzun seq baskın |
| B | 3.0 GB | |
| Total | 20.8 GB | sığar, headroom 3 GB |
Batch=1 zorunlu. Grad accumulation=8 ile effective batch=8.
# === Qwen3 14B + 32K context QLoRA === model, tok = FastLanguageModel.from_pretrained( "unsloth/Qwen3-14B-bnb-4bit", max_seq_length=32768, # YaRN-extended dtype="bfloat16", load_in_4bit=True, ) model = FastLanguageModel.get_peft_model( model, r=16, # 14B için düşük r — mem lora_alpha=32, lora_dropout=0.05, target_modules=["q_proj","k_proj","v_proj","o_proj"], # attn-only — mem use_gradient_checkpointing="unsloth", ) # Long-context SFT dataset (Ders 2.11'den) # ... 0.5 step/s, 8 saat 1 epoch
3. Qwen3 32B — RTX 4090'da Marjinal İmkansız#
32B NF4 = 16 GB sadece W. + activation (long seq) → 28-32 GB. Tek 4090'da sığmaz.
Alternatifler:
- Cloud 1×H100 80GB ($2.99/saat Lambda) → tam-FT bile mümkün
- Cloud 8×H100 NVSwitch ($24/saat) → FSDP+QLoRA tam-FT 4 saat
- Lokal CPU offload — paged_adamw + bnb 4-bit CPU offload + 64GB RAM → çalışır ama 0.05 step/s (40 saat 1 epoch)
Cookbook'un tavsiyesi: 32B için 1×H100 80GB 2 saat ($6) — ucuz ve hızlı, lokal denemeye değmez.
✅ Teslim
- Qwen3 14B + 16K context QLoRA Lab koş (32K mem-borderline ise 16K dene). 2) NIAH test ile long-context recall'ı ölç. 3) Sonraki ders: 3.5 — Mistral 7B v0.3 + Mistral Small 3.
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
İlgili İçerikler
Part 0 — Engineering Foundations
Fine-Tuning Cookbook'a Hoş Geldin: Sistematik, Stage Taksonomisi ve Reproducibility Kontratı
Öğrenmeye BaşlaPart 0 — Engineering Foundations
Reproducibility Stack: Seeds, cuDNN Flags ve Deterministic CUDA — 'Sende Niye Çalışıyor Bende Çalışmıyor' Sorununu Bitir
Öğrenmeye BaşlaPart 0 — Engineering Foundations