CoolFace
Modelpublic

WaylonJBrown/Maq-1.0-4B-SWE

sourceHugging Faceapache-2.0updated 16d agoView on Hugging Face
0likes222downloads
Model Card

Maq 1.0 4B SWE

Post-trained Gemma 4 E4B (instruction-tuned) for software-engineering, coding-agent, and competitive-programming style chat. Fine-tuned with LoRA SFT on a mix of NVIDIA Nemotron code/SWE datasets plus Fable/OpenCode agent traces, then merged into full BF16 weights.

  • —Base: `google/gemma-4-E4B-it` (Gemma 4 E4B-IT; ~4.5B effective / ~8B with per-layer embeddings)
  • —Method: LoRA SFT, then manual merge into dense BF16 (W += (α/r) B A)
  • —This repo: merged Transformers checkpoint (model.safetensors, ~15 GB)
This is not a full-data, multi-epoch Nemotron-scale post-train. It is a LoRA run on a sampled mix (33,585 JSONL rows collected; 4,096 used for the actual 400-step train) on a single Intel Arc iGPU.

Intended use

  • —Coding assistants and SWE-style issue → plan → patch conversations
  • —Tool-using / agentic coding traces (bash, file edits, multi-turn)
  • —Competitive programming and code-reasoning prompts
  • —Local / on-device experiments on Gemma 4 E4B

Not intended as a general chatbot replacement, a safety-tuned model, or a drop-in for 70B+ SWE agents.

How to use

python
from transformers import AutoModelForCausalLM, AutoProcessor
import torch

model_id = "WaylonJBrown/Maq-1.0-4B-SWE"
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id, dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
)
tokenizer = getattr(processor, "tokenizer", processor)

messages = [
    {"role": "user", "content": "Write a Python function that returns the nth Fibonacci number."},
]
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=256, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))

Requires a recent transformers (Gemma 4 / Gemma4ClippableLinear support).

Training

Hardware

ItemValue
MachineNative Windows 11 (no WSL)
GPUIntel Arc 140T (shared ~32 GB, PyTorch XPU)
RAM64 GB
FrameworkPyTorch 2.14.0+xpu, transformers 5.16.1, trl 1.12.0, peft 0.20.0

PLE embedding tables (embed_tokens, embed_tokens_per_layer, ~5.3 GB + 1.3 GB) stayed on CPU. Decoder weights + an untied lm_head copy ran on XPU. Vision/audio towers were dropped for this text SFT.

Recipe

HyperparameterValue
Basegoogle/gemma-4-E4B-it
ObjectiveCausal LM SFT (trl.SFTTrainer)
LoRA rank r8
LoRA alpha16 (scale α/r = 2.0 at merge)
LoRA dropout0.0
Target modulesq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Trainable params17,440,768 (~0.23% of 7.49B reported)
Max sequence length1024
Per-device batch1
Grad accumulation8 (effective batch 8)
Max steps400
OptimizerAdamW (TRL/Transformers default)
LR1.5e-4 cosine, 12 warmup steps
Precisionbf16
Grad checkpointingon
Seed3407
Packingoff

Wall clock: 400/400 steps in 7h 22m (train_runtime 26540 s). ~2.98M tokens seen. ~63–85 s/step.

PEFT cannot re-inject this adapter into Gemma 4 Gemma4ClippableLinear on reload, so merge was done by applying LoRA deltas onto the base Linear weights (258/258 pairs, 0 missing, 0 shape mismatches).

Metrics (train only — no held-out eval)

losstoken acc
Step 13.0660.537
Mean over 400 steps0.880—
Min step loss0.217—
Step 4001.2250.718

Loss is noisy because sequences vary in length and source. No SWE-Bench / LiveCodeBench numbers for this checkpoint.

Data

Collected by streaming (not full Hub dumps) into a unified messages JSONL, then shuffled. Competitive-Programming-v2 is 97 GB on Hub; it was not downloaded in full.

DatasetHub rows (approx)Rows kept in mixRole
`nvidia/Nemotron-SFT-OpenCode-v1`459k (~33 GB)6,000OpenCode-style agent / tool traces
`nvidia/Nemotron-SWE-v1`~51k (~11 GB)4,000OpenHands SWE trajectories
`nvidia/Nemotron-Cascade-SFT-SWE`~141k (~6.8 GB)4,000SWE localization / repair / testgen (DeepSeek-R1-0528)
`nvidia/Nemotron-SFT-Competitive-Programming-v2`large (~97 GB)3,000Competitive programming / SQL / Exercism
`DavidrPatton/Fable-5-GLM-5.2-Traces`10,5269,023Agentic coding traces + CoT narration
`TitleOS/Nemotron-3-Ultra-High-Effort-OpenCode-Distilled-2k`1,8221,562High-effort Nemotron 3 Ultra distill
`Nexlab/fable5-agentic-coding-sft`159,9726,000Multi-turn tool-call coding SFT
Mix JSONL33,585
Actually trained4,096 shuffled subsetTokenizing all 33k was ~12h on this box

Normalization: messages / ShareGPT conversations / Fable traces → {role, content} with system/user/assistant. Tool roles flattened into user/assistant text. Per-message cap 24k chars. Skip every 7th stream row for light diversity.

Safety note: Nexlab/fable5-agentic-coding-sft documents that refusals were filtered. That subset is in the mix; guardrails vs the base IT model may be weaker.

Files

PathWhat
model.safetensorsMerged BF16 weights (~15 GB)
config.json / generation_config.jsonGemma 4 E4B-IT config
tokenizer.json / tokenizer_config.json / chat_template.jinjaTokenizer + chat template
processor_config.jsonProcessor (text; vision/audio not trained)

Unmerged LoRA adapter (66.6 MB adapter_model.safetensors, r=8) was trained at adapter_config.json peft_type: LORA and merged here. PEFT from_pretrained on Gemma 4 ClippableLinear is currently unsupported; use these merged weights.

Limitations

  • —1024 context during SFT (base supports much longer)
  • —400 steps / ~0.78 epoch on 4096 examples — a short post-train, not a Nemotron production blend
  • —No benchmark suite reported
  • —Text-only SFT; multimodal towers were not trained
  • —Intel XPU mixed-device training path is research-grade
  • —Dataset licenses are mixed (NVIDIA CC-BY / subset BSD, MIT on Fable derivatives, Gemma Apache 2.0). Check each source before commercial use.

License

Weights derived from Gemma 4: Apache 2.0. Datasets retain their upstream licenses.

Citation

bibtex
@misc{maq10-4b-swe,
  title        = {Maq 1.0 4B SWE},
  author       = {Waylon Brown},
  year         = {2026},
  howpublished = {Hugging Face},
  note         = {LoRA SFT of google/gemma-4-E4B-it on sampled Nemotron + Fable coding/SWE mixes}
}

Base model: Gemma Team, Gemma 4 Technical Report, arXiv:2607.02770.