Qwen3-1.7B GRPO for GSM8K, running on a PlayStation 4
On a PlayStation 4 GPU (Vulkan, Q4_K_M): 11.2 s per answer, 1.56× faster than the PS4 CPU (first 100 test questions), with the same accuracy as a CPU on the full test set (72.9% flexible, n = 1,319, p = 1.0).
Qwen/Qwen3-1.7B fine-tuned with GRPO (LoRA) on the GSM8K train split to answer grade-school math problems in a fixed, machine-readable format (#### <number> on the last line), in non-thinking mode. This model is part of a project that runs it on a PlayStation 4 with llama.cpp, on the CPU and on the GPU through Vulkan.
Summary. GRPO taught the format: on the full GSM8K test set (n = 1,319, full precision) the model answers in the requested format 75.8% of the time, against 67.1% and 71.3% for the base model with the best prompts tested (McNemar p < 0.001 for both). It did so without losing accuracy (flexible 76.3% vs 76.6% for the base, p = 0.81). It did not improve reasoning: accuracy is unchanged.
Which weights reproduce the reported numbers. The GSM8K results on this card (75.8% strict, 76.3% flexible) were measured on Kaggle with the LoRA adapter active on the base model, before merging. The merged checkpoint at the root of this repository (
model.safetensors) was saved in bf16, and rounding to bf16 discarded most of the adapter update: about 20% of it survives. On 120 test questions, the merged checkpoint reproduces the Kaggle outputs word for word in 28 (23%); the same adapter merged in fp32 does so in 110 (92%). The GGUF files ingguf/were converted from the bf16 merge and inherit this loss. It affects the answer format, not the accuracy: on the PS4, Q4_K_M from the fp32 merge scores 71.7% strict against 66.8% for the published file, with the same flexible accuracy (73.0% vs 72.9%). To reproduce the reported numbers, load the base model with the adapter inlora/(see Usage), or merge it yourself in fp32.
Results
Greedy decoding, non-thinking mode, at most 320 new tokens. Strict = the last #### <number> matches the reference. Flexible = the strict answer if present, otherwise the last number in the output (commas and $ ignored). Comparisons are paired on the same questions. p-values are exact McNemar tests, and intervals are 95% (Wilson for accuracies, Newcombe for paired differences).
Base vs this model (full GSM8K test, full precision, n = 1,319)
Same system prompt for both models (see Prompt).
| Model | Strict | Flexible (95% CI) | Mean tokens | Truncated |
|---|---|---|---|---|
| Qwen3-1.7B (base) | 2.9% | 76.6% (74.2–78.8) | 149.6 | 40 (3.0%) |
| This model | 75.8% | 76.3% (73.9–78.5) | 129.2 | 19 (1.4%) |
- Flexible: 79 questions fixed and 83 broken, p = 0.81.
- Strict: 963 fixed and 1 broken, p < 10⁻²⁰⁰.
Prompt baselines (base model, full precision, n = 1,319)
The 2.9% above uses a prompt the base model handles poorly. The fair comparison is against the best prompts for the base model, which used this system prompt: "Solve the math problem step by step. Be concise. On the last line, write only the final answer in the format: #### <number>". The 2-shot prompt uses training questions 0 and 1. This model was regraded with the same grader as the baselines.
| Strict (95% CI) | Flexible (95% CI) | Tokens per answer | |
|---|---|---|---|
| This model (regraded) | 75.7% | 76.2% | 129 |
| Base + instruction | 67.1% (64.5–69.6) | 75.2% (72.8–77.5) | 127.8 |
| Base + 2-shot | 71.3% (68.8–73.6) | 72.0% (69.5–74.4) | 89.4 |
- Format: +8.6 points vs instruction (186 vs 73 discordant questions, p < 0.0001) and +4.4 vs 2-shot (158 vs 100, p = 0.0004).
- Accuracy: tied with the instruction prompt (96 vs 83, p = 0.37). The 2-shot prompt shortens answers by 30% but loses 4.2 points of flexible accuracy (153 vs 98, p = 0.0006).
Quantization (full GSM8K test, n = 1,319)
All quantized runs use llama.cpp commit dde879bc with this model's chat template and the same prompt. The laptop is an x86 CPU (Intel i5-10300H, 4 threads), used only to separate quantization from backend.
| Configuration | Flexible (95% CI) | Strict (95% CI) | Tokens | Truncated |
|---|---|---|---|---|
| Full precision (PyTorch) | 76.3% (73.9–78.5) | 75.8% | 129.2 | 19 |
| Q5_K_M, laptop CPU | 74.8% (72.3–77.0) | 57.6% (54.9–60.3) | 135.0 | 25 |
| Q4_K_M, laptop CPU | 72.9% (70.4–75.2) | 63.2% (60.5–65.7) | 132.2 | 17 |
| Q4_K_M, PS4 GPU (Vulkan) | 72.9% (70.5–75.3) | 66.8% (64.2–69.3) | 131.2 | 24 |
| Q8_0, PS4 GPU (Vulkan) | 76.1% (73.7–78.3) | 65.9% (63.3–68.4) | 139.7 | 33 |
| Comparison | Δ flexible (95% CI) | McNemar flexible | Δ strict (95% CI) | McNemar strict |
|---|---|---|---|---|
| Q4_K_M PS4 GPU − full precision | −3.3 (−5.5 to −1.2) | 86 vs 130, p = 0.003 | −9.0 (−11.4 to −6.6) | 78 vs 197, p < 0.001 |
| Q4_K_M laptop − full precision | −3.4 (−5.6 to −1.2) | 85 vs 130, p = 0.003 | −12.7 (−15.2 to −10.1) | 79 vs 246, p < 0.001 |
| Q4_K_M laptop − Q4_K_M PS4 GPU | −0.1 (−1.8 to +1.7) | 67 vs 68, p = 1.0 | −3.6 (−5.8 to −1.5) | 80 vs 128, p = 0.001 |
| Q5_K_M − full precision | −1.5 (−3.5 to +0.5) | 79 vs 99, p = 0.15 | −18.2 (−20.9 to −15.5) | 64 vs 304, p < 0.001 |
| Q5_K_M − Q4_K_M (laptop) | +1.9 (−0.3 to +4.1) | 120 vs 95, p = 0.10 | −5.5 (−8.4 to −2.6) | 158 vs 231, p < 0.001 |
| Q8_0 PS4 GPU − Q4_K_M PS4 GPU | +3.2 (+1.1 to +5.4) | 129 vs 87, p = 0.005 | −0.9 | p = 0.53 |
- Q4_K_M loses about 3.4 points of flexible accuracy against full precision, the same on an x86 CPU and on the PS4 GPU.
- Q8_0 recovers that loss: 76.1% flexible (1,004 of 1,319) on the PS4 GPU, +3.2 points over Q4_K_M (p = 0.005) and within two questions of full precision (1,006). This was measured on the published Q8_0 file, which was generated from the bf16 merge. The loss at 4 bits therefore comes from quantization, not from llama.cpp. Q8_0 is slower on the PS4 (13.1 s per answer against 11.6 s) and does not recover the format (65.9% strict; see the note at the top).
- Q5_K_M sits in between: it is not significantly different from Q4_K_M (p = 0.10) or from full precision (p = 0.15). The Q5_K_M file is not in this repository.
- The format is fragile to quantization: strict accuracy ranges from 57.6% to 66.8% across quantizations and backends, with no order by precision, while flexible accuracy stays within ~2 points.
GGUF files
In gguf/, converted with llama.cpp commit dde879bc (no imatrix):
| File | Size | SHA-256 |
|---|---|---|
qwen3-1.7b-gsm8k-grpo-Q4_K_M.gguf | 1.11 GB | d7771967dc6e5a69a8c676f8d0103763062d44b5b581aa9c707bc60a4684722b |
qwen3-1.7b-gsm8k-grpo-Q8_0.gguf | 1.83 GB | 037c54e893afc4aa12280df84939aba2ae4acb213ef912a4bde133c7800eb36c |
chat_template_treinado.jinja | 4.8 KB | 8428c815ac94d82064e35ff1e841dcbe260e7e53a8d0bd3b94afa2eefa9bccab |
chat_template_neutro.jinja (general chat, see below) | 5.1 KB | 173bdefad00cbd11b4a853c30ec8869ce8ed379d3c89f3ceb8222f0bf8b5a2bd |
- Q4_K_M costs ~3.4 points of flexible accuracy against full precision (n = 1,319, p = 0.003; table above).
- The format is fragile to quantization: strict accuracy is 57.6–66.8% on the quantized runs, against 75.8% in full precision. If you parse the
####line, expect more answers without it, and fall back to the last number. - Q8_0 recovers the accuracy, not the format: on the full test set on the PS4 GPU it scores 76.1% flexible and 65.9% strict (table above). F16 has not been evaluated on the full test set.
- Both GGUF files were converted from the bf16 merge (see the note at the top).
Prompt
System prompt used in training and in all evaluations of this model:
Solve the math problem. Reason briefly, step by step. On the last line, write only the final answer as: #### <number>
Use the chat template with enable_thinking=False.
Usage
llama.cpp (llama-server)
This is the setup used in the evaluations: the model, the chat template from gguf/, -c 4096, -n 320, greedy decoding and thinking disabled per request.
hf download felipedutrain/qwen3-1.7b-gsm8k-grpo \
gguf/qwen3-1.7b-gsm8k-grpo-Q4_K_M.gguf gguf/chat_template_treinado.jinja --local-dir .
llama-server -m gguf/qwen3-1.7b-gsm8k-grpo-Q4_K_M.gguf \
--jinja --chat-template-file gguf/chat_template_treinado.jinja \
-c 4096 -n 320 --host 127.0.0.1 --port 8080
curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"messages": [
{"role": "system", "content": "Solve the math problem. Reason briefly, step by step. On the last line, write only the final answer as: #### <number>"},
{"role": "user", "content": "Joana has 3 boxes with 12 pencils each and gives 7 pencils to her sister. How many pencils are left?"}
],
"temperature": 0, "seed": 42, "max_tokens": 320,
"chat_template_kwargs": {"enable_thinking": false}
}'
transformers (base model + LoRA adapter)
This is the artifact the reported numbers were measured on. It needs peft (tested with peft 0.21.3 and transformers 4.57.6).
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "felipedutrain/qwen3-1.7b-gsm8k-grpo"
tokenizer = AutoTokenizer.from_pretrained(repo)
base = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-1.7B", torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(base, repo, subfolder="lora")
messages = [
{"role": "system", "content": "Solve the math problem. Reason briefly, step by step. "
"On the last line, write only the final answer as: #### <number>"},
{"role": "user", "content": "Joana has 3 boxes with 12 pencils each and gives 7 pencils to her sister. "
"How many pencils are left?"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True,
enable_thinking=False)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=320, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
The model.safetensors at the root of this repository is the same adapter merged into the base and saved in bf16. AutoModelForCausalLM.from_pretrained(repo) loads it without peft, but it does not reproduce the reported format accuracy (see the note at the top).
General chat use: configuration matters more than the tuning (added 2026-11-15)
This model was tuned for GSM8K, but the same Q4_K_M file is also used as a general chat assistant in Portuguese on the PS4. For that use, the settings changed the result far more than the weights did. The weights in this repository did not change; only the recommended way to run them for chat.
Evaluation. 120 items in Portuguese (the development split of a 360-item assistant evaluation: conversation, documents, instructions, reasoning, technical and tool-like questions, 20 each), graded by rules, run on a laptop CPU with llama.cpp.
| Same Q4_K_M file | Previous chat setup | Neutral configuration |
|---|---|---|
| Thinking | on | off |
| System prompt | none | short, in Portuguese, with date and time |
| Token limit | 320 | 400 |
| Sampling | — | temperature 0.7, top_p 0.8, top_k 20 |
| Accuracy | 27.5% (33/120) | 59.2% (71/120) |
| Empty answers | 67 | 0 |
| Truncated answers | 90 | 11 |
| Median time per answer | 28.3 s | 14.0 s |
| Generation speed | 11.5 tok/s | 10.5 tok/s |
| Category (20 items each) | Previous chat setup | Neutral configuration |
|---|---|---|
| Conversation | 55% | 75% |
| Documents | 45% | 75% |
| Instructions | 45% | 55% |
| Reasoning | 0% | 60% |
| Technical | 5% | 65% |
| Tool-like questions | 15% | 25% |
- +31.7 points (95% CI +20.8 to +42.5; 47 items gained, 9 lost; p < 0.001), paired on the same items.
- Why: with thinking on and a 320-token limit, the model often spends the whole budget thinking and returns an empty or truncated answer.
- Faster answers, same generation speed: the time halves because fewer tokens are generated.
- The tuning itself does not help here: with the same neutral configuration, the untuned Qwen3-1.7B scores 58.3%, a tie. The gain of this model is the GSM8K answer format.
Caveats. Development split, one run per configuration (run-to-run noise is about 3–4 points); the items were written by an AI model and audited by a second one; the previous setup was reproduced on the laptop with the same settings, not measured on the console; on the PS4 the neutral configuration had a smoke test and hands-on use only (11.9 tokens/s on the GPU).
How to run it for chat (llama-server):
hf download felipedutrain/qwen3-1.7b-gsm8k-grpo \
gguf/qwen3-1.7b-gsm8k-grpo-Q4_K_M.gguf gguf/chat_template_neutro.jinja --local-dir .
llama-server -m gguf/qwen3-1.7b-gsm8k-grpo-Q4_K_M.gguf \
--jinja --chat-template-file gguf/chat_template_neutro.jinja \
--reasoning off -c 4096 -n 400 --temp 0.7 --top-p 0.8 --top-k 20 --min-p 0 \
--host 127.0.0.1 --port 8080
chat_template_neutro.jinja is the trained template plus one change: when the client sends no system message, it inserts a short Portuguese system prompt and the current date and time (llama.cpp's strftime_now). A system message from the client replaces it. For the GSM8K format, keep using chat_template_treinado.jinja and the prompt above.
Evaluation items, grader, per-item results and the PS4 chat setup: github.com/FelipeSales18/llm-ps4, assistente/.
Inference on a PlayStation 4
The Q4_K_M file runs on a 2013 PlayStation 4 running Linux (8-core AMD Jaguar, GCN 2 GPU, 8 GB shared GDDR5) with llama.cpp dde879bc.
| Q4_K_M, first 100 test questions | PS4 CPU (8 threads) | PS4 GPU (Vulkan) |
|---|---|---|
| Seconds per answer | 17.5 | 11.2 (1.56× faster) |
| Generation speed | 8.9 tokens/s | 11.9 tokens/s |
| Flexible / strict | 81 / 74 | 77 / 70 |
- Accuracy is the same as on a CPU. On these 100 questions the GPU and CPU are not significantly different (flexible 2 vs 6 discordant questions, p = 0.29). On all 1,319 questions the GPU scores exactly like the same Q4_K_M file on an x86 CPU (72.9% vs 72.9%, p = 1.0). The 1.56× speed-up was measured on the 100 questions.
- GPU without installing anything: the system had no Vulkan driver. The RADV driver was extracted from a community-built Mesa package for the PS4 into the project folder, checked by SHA-256, and loaded with
VK_DRIVER_FILES. llama.cpp was built with-DGGML_VULKAN=ONand runs with-ngl 99.
Scripts and per-question results: github.com/FelipeSales18/llm-ps4.
Training
- Method: GRPO with LoRA (r = 16, alpha = 32, all attention and MLP projections), loss type
dapo, beta = 0.0 - Rewards: correctness 2.0 (flexible match), format 1.0 (last line is
#### <number>), length penalty 0.0 - 357 steps, 4 prompts per step, 8 completions per prompt (1428 prompts seen), learning rate 5e-06, cosine schedule, 10 warmup steps
- Hardware: 1x Tesla T4 (Kaggle), 6.02 h of training
- Software: unsloth 2026.10.11, trl 1.15.0, transformers 5.16.1, peft 0.20.0, datasets 4.8.5, torch 2.11.0+cu128
Limitations
- One seed. A single training run with one seed. Differences of a few points can be noise; see the confidence intervals and the McNemar tests.
- A heavily reused test set. The GSM8K test set was used for every decision in the project (prompts, token limit, quantization, GPU vs CPU), so the reported numbers may be optimistic for unseen data.
- F16 not evaluated on the full test set. The attribution of the ~3.4-point loss of Q4_K_M to quantization rests on the Q8_0 run (76.1% flexible on the PS4 GPU).
- The merged weights are not the evaluated artifact. The reported full-precision numbers come from the adapter active on the base model; the bf16 merge at the root, and the GGUF files converted from it, lost most of the adapter update (see the note at the top).
- One GPU hang. On the PS4 GPU, generation stopped once (at one question of the full run) with no kernel message. After a reboot the same question ran normally, and the rest of the run finished with no hang. The cause is unknown.
- GSM8K only, English only, greedy decoding with a 320-token limit; truncated answers count as wrong.
Repository
Merged weights (bf16) at the root, LoRA adapter in lora/, GGUF files in gguf/, per-question evaluation outputs and training logs in eval/. Code, scripts and benchmarks: https://github.com/FelipeSales18/llm-ps4