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

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

Item Value
Machine Native Windows 11 (no WSL)
GPU Intel Arc 140T (shared ~32 GB, PyTorch XPU)
RAM 64 GB
Framework PyTorch 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

Hyperparameter Value
Base google/gemma-4-E4B-it
Objective Causal LM SFT (trl.SFTTrainer)
LoRA rank r 8
LoRA alpha 16 (scale Ξ±/r = 2.0 at merge)
LoRA dropout 0.0
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Trainable params 17,440,768 (~0.23% of 7.49B reported)
Max sequence length 1024
Per-device batch 1
Grad accumulation 8 (effective batch 8)
Max steps 400
Optimizer AdamW (TRL/Transformers default)
LR 1.5e-4 cosine, 12 warmup steps
Precision bf16
Grad checkpointing on
Seed 3407
Packing off

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)

loss token acc
Step 1 3.066 0.537
Mean over 400 steps 0.880 β€”
Min step loss 0.217 β€”
Step 400 1.225 0.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.

Dataset Hub rows (approx) Rows kept in mix Role
nvidia/Nemotron-SFT-OpenCode-v1 459k (~33 GB) 6,000 OpenCode-style agent / tool traces
nvidia/Nemotron-SWE-v1 51k (11 GB) 4,000 OpenHands SWE trajectories
nvidia/Nemotron-Cascade-SFT-SWE 141k (6.8 GB) 4,000 SWE localization / repair / testgen (DeepSeek-R1-0528)
nvidia/Nemotron-SFT-Competitive-Programming-v2 large (~97 GB) 3,000 Competitive programming / SQL / Exercism
DavidrPatton/Fable-5-GLM-5.2-Traces 10,526 9,023 Agentic coding traces + CoT narration
TitleOS/Nemotron-3-Ultra-High-Effort-OpenCode-Distilled-2k 1,822 1,562 High-effort Nemotron 3 Ultra distill
Nexlab/fable5-agentic-coding-sft 159,972 6,000 Multi-turn tool-call coding SFT
Mix JSONL 33,585
Actually trained 4,096 shuffled subset Tokenizing 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

Path What
model.safetensors Merged BF16 weights (~15 GB)
config.json / generation_config.json Gemma 4 E4B-IT config
tokenizer.json / tokenizer_config.json / chat_template.jinja Tokenizer + chat template
processor_config.json Processor (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

@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.

Downloads last month
14
Safetensors
Model size
8B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for WaylonJBrown/Maq-1.0-4B-SWE

Adapter
(515)
this model
Adapters
1 model

Paper for WaylonJBrown/Maq-1.0-4B-SWE