File size: 2,617 Bytes
63d4d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
license: apache-2.0
base_model: Qwen/Qwen3-8B-Base
library_name: transformers
pipeline_tag: text-generation
tags:
- math
- reasoning
- reinforcement-learning
- lora
- grpo
---

# Qwen3-8B SDFT + math GRPO-LoRA (rollout 120)

Qwen3-8B (dense, 36 layers, 8.19B params). **Fully merged bf16 weights** — the LoRA adapter is
folded into the base matrices, so this is a drop-in replacement for `Qwen/Qwen3-8B-Base`; no PEFT
adapter loading required.

## Training pipeline

1. **Base**: `Qwen/Qwen3-8B-Base`.
2. **SFT**: supervised fine-tuning on a balanced oracle mixture (math / retrieval-augmented QA /
   tool-use dialogue).
3. **Math RL** (this checkpoint): GRPO on math problems with a verifiable boxed-answer reward,
   training LoRA adapters (rank 128, alpha 128 ⇒ scaling 1.0) on `q/k/v`, `o_proj`,
   `gate/up_proj` and `down_proj` of every layer, for 120 rollouts. DAPO-style recipe
   (clip-higher 0.2/0.28, dynamic sampling, token-level policy-gradient loss) with truncated
   importance sampling for the train/rollout mismatch.

Trained with [slime](https://github.com/THUDM/slime) on Megatron-LM (TP=4, CP=1, bf16).

## Honest evaluation note

Over these 120 rollouts the RL stage was **stable but did not measurably improve** the
training-set pass@1 (0.558 → 0.578, linear slope +4e-5 per rollout against a per-rollout standard
deviation of 0.027 — the change is inside the noise). Prompts solved 16/16 rose slightly (50.6 →
56.9 of 256 sampled) and prompts never solved were flat. Treat this as **the SFT model plus a small,
non-degrading RL delta**, not as a demonstrated improvement over the SFT base. It is published for
reproducibility and comparison, and it is the first checkpoint of this line whose frozen base
weights are provably uncorrupted.

## Usage

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "willamazon1/Qwen3-8B-SDFT-Math-LoRA-pristine"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).to("cuda")

prompt = "Question: What is 12*8?\nAnswer:"
ids = tok(prompt, return_tensors="pt").input_ids.cuda()
print(tok.decode(model.generate(ids, max_new_tokens=64, do_sample=False)[0][ids.shape[1]:],
                 skip_special_tokens=True))
```

This is a **base-style (completion)** model, not an instruction-tuned chat model: prompt it with
`Question: … \nAnswer:` style completions rather than a chat template.

## Limitations

Inherits the biases and knowledge cutoff of `Qwen3-8B-Base`. Math answers are not guaranteed
correct — verify before relying on them.