Qwen2.5-Coder-7B — Federated FlowerTune Adapter (FedProx + DoRA)

A DoRA adapter for Qwen/Qwen2.5-Coder-7B-Instruct fine-tuned on code instruction-following data using federated learning via the Flower framework with the FedProx strategy. This is an adapter only — the base model weights are unchanged.

Model Details

How to Get Started with the Model

This is a PEFT adapter, not a standalone model. You must load it on top of the base model.

Adapter only (recommended)

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model_id = "Qwen/Qwen2.5-Coder-7B-Instruct"
adapter_id = "rishabbalakrishnan/qwen2.5-coder-7b-fed-flowertune-adapter"

tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(
    base_model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True
)
model = PeftModel.from_pretrained(base, adapter_id)
model.eval()

inputs = tokenizer("Write a Python function to reverse a linked list:", return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Merging the adapter into the base model

If you want a single standalone model without a PEFT dependency:

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model_id = "Qwen/Qwen2.5-Coder-7B-Instruct"
adapter_id = "rishabbalakrishnan/qwen2.5-coder-7b-fed-flowertune-adapter"

tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
base = AutoModelForCausalLM.from_pretrained(
    base_model_id, torch_dtype=torch.float16, device_map="auto", trust_remote_code=True
)
model = PeftModel.from_pretrained(base, adapter_id)
model = model.merge_and_unload()  # merges adapter weights into base

model.save_pretrained("./merged_model")
tokenizer.save_pretrained("./merged_model")

Training Details

Training Data

flwrlabs/code-alpaca-20k — 20k code instruction-following examples, partitioned across 4 federated clients using IID partitioning.

Training Procedure

Fine-tuned using federated learning with the Flower framework. Clients train locally using a custom FedProx trainer (proximal term µ=0.01) to penalise client drift, and only adapter weights are aggregated via FedAvg — no raw data ever leaves the client. Training used a warm-start from a prior checkpoint, with cosine learning rate decay across rounds.

Training Hyperparameters

Hyperparameter Value
Training regime bf16 mixed precision
Optimizer paged_adamw_8bit
Learning rate cosine decay 8e-5 → 1e-6
Per-device batch size 4
Max sequence length 512
Local steps per round 20
FL rounds 80
FL clients 4 (IID partition, 50% sampled per round)
FL strategy FedProx (proximal µ=0.01)
Warm start Yes
Quantization 4-bit QLoRA (bitsandbytes)
Gradient checkpointing Yes

DoRA / LoRA Configuration

Parameter Value
Rank (r) 16
Alpha 64
Dropout 0.05
Use DoRA Yes
Target modules q_proj, k_proj, v_proj, o_proj, gate_proj, down_proj, up_proj

Results

Best train loss of 0.0370 achieved at round 80 across 4 federated clients. Evaluated on the merged model using bigcode-evaluation-harness

Benchmark pass@1
HumanEval 64.63%
MBPP 64.60%
MultiPL-E (JavaScript) 70.81%
MultiPL-E (C++) 64.60%
Average 66.16%

Framework Versions

  • PEFT 0.14.0
  • Transformers 4.50.0
  • Flower (flwr) ≥ 1.27.0
  • TRL 0.8.1
  • bitsandbytes 0.45.5
Downloads last month
5
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for rishabbalakrishnan/qwen2.5-coder-7b-fed-flowertune-adapter

Base model

Qwen/Qwen2.5-7B
Adapter
(717)
this model

Dataset used to train rishabbalakrishnan/qwen2.5-coder-7b-fed-flowertune-adapter

Evaluation results