YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
qwen3-14b-code-agent-v2 β fully merged code-agent model
v2 = qwen3-14b-code-agent (fine-tune) + wsurgery weight patch + MCP LoRA adapter, all merged into plain safetensors. Load it like any normal HF model β no patch step, no adapter directory:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"harshagowtham/qwen3-14b-code-agent-v2", torch_dtype="bfloat16", device_map="auto")
or with the engine (auto 4-bit on small GPUs, OpenAI-compatible API, thinking mode, tool calls):
from llm_engine import LocalLLM # https://huggingface.co/harshagowtham/qwen-agent-scripts
llm = LocalLLM("harshagowtham/qwen3-14b-code-agent-v2", hf_token="hf_...")
Recipe
| step | source | operation |
|---|---|---|
| 1 | harshagowtham/qwen3-14b-code-agent |
starting weights (Qwen3-14B fine-tune) |
| 2 | harshagowtham/qwen3-14b-code-agent-wsurgery |
W = W_base + 0.70*(W_ft - W_base) on the top-8 o_proj + top-5 down_proj residual writers (13 tensors, byte-exact splice) |
| 3 | harshagowtham/qwen3-14b-code-agent-mcp-lora |
LoRA merge_and_unload() (tool-calling adapter) |
Why: the fine-tune drifted lightly but uniformly across all 280 projection
tensors; the surgery trims 30% of that drift on the 13 highest-energy
residual writers (deep layers dominate), keeping the learned code/tool
behaviour. The MCP adapter restores/boosts structured tool calling.
Full analysis: harshagowtham/qwen3-14b-code-agent-wsurgery -> SURGERY_REPORT.md.
Build it yourself (Kaggle, ~40-60 min)
Two equivalent paths:
- Notebook (recommended): open
kaggle_notebooks/build_v2_merged_weights.ipynbin a Kaggle notebook with GPU T4 x2, Internet ON, and your HF token. - CLI script:
pip install -U transformers accelerate peft huggingface_hub sentencepiece
python build_v2.py --token hf_YOUR_WRITE_TOKEN
# options: --workdir /kaggle/working/v2-build --skip-push --device auto
Requirements: ~28-29 GB RAM (bf16 CPU merge β Kaggle has ~29 GB), ~35 GB free
disk. The script verifies every step (patch sha256s, adapter merge, 50-token
smoke test) before pushing to harshagowtham/qwen3-14b-code-agent-v2.
Disk: how the build avoids "No space left on device"
A naive build needs 28 GB (download) + 28 GB (save) = 56 GB at the same
time, which ENOSPCs on a ~58 GB Kaggle volume with anything else on it β
typically dying at Writing model shards: 0%. This build instead:
- reuses an already-cached snapshot when re-running in the same session (no 28 GB re-download after a crashed attempt);
- frees the 28 GB fine-tune snapshot right after the LoRA merge β
hub-loaded safetensors are mmap-backed and on Linux an unlinked mapping
stays readable, so
save_pretrainedstreams through the still-live mapping. Peak disk ~30 GB instead of ~56 GB; - checks free space before the save and prints
free/neededclearly; - removes stale partial shards from a crashed run before saving;
- after a successful push, deletes the merged dir and hub caches (Kaggle
caps persisted session output at 20 GB);
--keep-outputkeeps them.
Troubleshooting: ImportError: Found an incompatible version of torchao
Some Kaggle images ship torchao 0.10 while the installed PEFT requires
= 0.16 whenever torchao is present, which crashes
PeftModel.from_pretrained(step 4/6). As of this commitbuild_v2.pyauto-applies a guard that tells PEFT "torchao unavailable", so PEFT skips its torchao LoRA dispatch and uses the standard LoRA path. If you hit the error with an old copy:git pull/ re-downloadbuild_v2.pyand re-run β no pip changes needed (do NOTpip uninstall torchao; other packages on the image may want it).
Files
build_v2.py # standalone CLI builder (this repo)
kaggle_notebooks/
build_v2_merged_weights.ipynb # same build as a Kaggle notebook
Model card
- Base: Qwen/Qwen3-14B (40 layers, hidden 5120, 32k native context)
- Languages: English (code + general)
- Intended use: coding agent, tool calling, long-form site/code generation
- Serving: transformers / llm_engine / vLLM (standard Qwen3 arch β
enable_thinkingchat-template flag supported) - Quantization-friendly: works with bitsandbytes NF4 (auto in llm_engine under 24 GB VRAM)
License
Apache-2.0, inherited from Qwen3-14B and the constituent repos.