LoopedPhai-A1-35B / docs /VALIDATION.md
ramachandrajoshi's picture
LoopedQwen35: looped config, adapter v1, vLLM plugin, trainer, docs
2f04653 verified
|
Raw History Blame Contribute Delete
4.22 kB
# Validation log
Environment: RTX 5060 Ti 16 GB (sm_120, WSL2), 78 GB RAM, vLLM 0.34.0, PyTorch 2.14 (CUDA 13.0),
Transformers 5.22.2. Date: 2026-11-30.
## 1. Adapter maths (`tests/test_adapter_math.py`, CPU)
* A fresh adapter and the training-initialised adapter are exact identities for every pass/depth.
* Gradients reach entry gates, mixer gates, block up-projections and router LoRA from step 0.
* Pass-slot clamping and checkpoint round-trip work.
## 2. Trainer vs Hugging Face Transformers (`tests/test_trainer_parity.py`, tiny model)
| Check | Result |
|---|---|
| T=1 logits vs `Qwen3_5MoeForConditionalGeneration` (fp32) | within atol 2e-3 (logit scale ~7) |
| Identity adapter, T=2/3/4 vs T=1 | **bit-exact** |
| Gradients reach all adapter parts; no base weight trainable | pass |
| Cached decode (per-pass KV/GDN caches, prefill + 1-token steps) vs full forward, T=1/3, experts on GPU and on CPU (sparse fetch) | within 2e-4 (fp32) |
In BF16, per-layer outputs match Transformers to 1 ulp. On a *random* model that rounding compounds
chaotically (~5% relative after 12 layers), which is why the parity check runs in FP32.
## 3. vLLM plugin on the tiny model (`scripts/run_tiny_matrix.sh`, `tests/test_vllm_plugin.py`)
BF16 (vLLM's GatedDeltaNet kernels are BF16-only). Teacher-forced prompt logprob differences:
| Comparison | max \|Δ logprob\| | Meaning |
|---|---|---|
| base vs base (2nd run) | 0.0 | deterministic |
| looped T=3 eager vs CUDA-graph/compiled | 0.23 | BF16 kernel-fusion noise floor |
| base vs looped T=1 (compiled / eager) | 0.28 / 0.16 | ≈ noise floor |
| looped T=1 vs looped T=3, identity adapter | 0.12 | ≈ noise floor |
| base vs looped T=3, random adapter | 4.2 | adapter really changes the model |
| multimodal vs text-only looped class | 0.0 | identical |
| 3 copies of each prompt in one batch, eager | 0.0, identical tokens | per-pass caches are isolated |
| same, compiled + CUDA graphs | ≤ 0.03 | token-offset kernel variance (vLLM is not batch-invariant); one near-tie greedy flip; a cache leak would be ≫ 1 |
## 4. vLLM plugin vs trainer (`scripts/check_plugin_vs_trainer.py`)
Same random adapter, same tokens:
| Comparison | top-1 agreement | max \|Δ logprob\| |
|---|---|---|
| trainer (fp32) vs vLLM, T=3 | 98% | 0.21 |
| trainer (bf16) vs vLLM, T=3 | 94% | 0.19 |
| control: trainer T=2 vs vLLM T=3 | 0% | 8.5 |
| control: trainer looped vs vLLM base | 0% | 9.8 |
An adapter trained with `looped_qwen_moe.training` therefore behaves the same once served by the
plugin.
## 5. Real model on 16 GB (`scripts/real_model_smoke.py --expert-device cpu`)
| Check | Result |
|---|---|
| Load (experts FP8 in CPU RAM) | 112 s, 4.6 GB VRAM, ~33 GB RAM |
| Greedy T=1 "The capital of France is" | " Paris. Paris is a city" |
| Greedy T=1 "def add(a, b):\n return" | " a + b\n\ndef subtract" |
| Identity adapter T=3 vs T=1 hidden states | max \|Δ\| = 0 |
| Train step, T=3, 256 tokens (fwd+bwd) | 20.8 s, peak 9.9 GB VRAM |
| Inference without KV cache | ~5.5–6.3 s/token (PCIe-bound expert streaming) |
| Cached greedy decode (`scripts/eval_local.py`), 10 core layers' experts pinned | ~2.1–2.4 tok/s at T=1, ~1.6 tok/s at T=3, 13 GB VRAM |
## 6. vLLM on the real FP8 checkpoint (16 GB card)
The 38 GB model does not fit in 16 GB of VRAM, so only `--cpu-offload-gb` could run it here.
That run exposed (and led to the fix of) a real bug: the extra-pass layers were built with the
checkpoint's FP8 quantisation config, whose ignore-list is keyed by module name. They are now
built unquantised and then share pass-0's (FP8) modules. With that fixed, construction and FP8
weight loading succeed. vLLM's per-module CPU offloader cannot follow weights shared across
modules, though, so the plugin refuses `--cpu-offload-gb` when T>1 with a clear error. The
full-GPU path is unaffected; run it on the L40S box.
## Not yet validated
* Tensor parallelism (TP=2) needs 2 GPUs. By design the adapter only touches replicated tensors
(residual stream, router logits). First run on the L40S box:
`RUN_VLLM_TESTS=1 pytest tests/test_vllm_plugin.py`, then the probe with `--tp 2`.
* Quality: no trained adapter exists yet, so there is no accuracy claim.