Instructions to use gxunda/Qwen4-27B-Upcycle-Dev with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gxunda/Qwen4-27B-Upcycle-Dev with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gxunda/Qwen4-27B-Upcycle-Dev", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("gxunda/Qwen4-27B-Upcycle-Dev", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gxunda/Qwen4-27B-Upcycle-Dev with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gxunda/Qwen4-27B-Upcycle-Dev" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gxunda/Qwen4-27B-Upcycle-Dev", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/gxunda/Qwen4-27B-Upcycle-Dev
- SGLang
How to use gxunda/Qwen4-27B-Upcycle-Dev with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "gxunda/Qwen4-27B-Upcycle-Dev" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gxunda/Qwen4-27B-Upcycle-Dev", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "gxunda/Qwen4-27B-Upcycle-Dev" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gxunda/Qwen4-27B-Upcycle-Dev", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use gxunda/Qwen4-27B-Upcycle-Dev with Docker Model Runner:
docker model run hf.co/gxunda/Qwen4-27B-Upcycle-Dev
Qwen4-27B-Upcycle-Dev (DenseQwen4ExpForCausalLM)
Qwen4-27B-Upcycle-Dev is a 26.12B-parameter True Dense Qwen4-Exp causal language model (trust_remote_code=True) surgically upcycled and distilled from Qwen/Qwen3.8-27B (commit 37561816e66b5b9153b1b64c10968c18c1e6f4a0).
Instead of sparse MoE routing, this checkpoint replaces Qwen4ExpTextSparseMoeBlock with a Wanda-pruned Dense SwiGLU MLP (17,408 → 14,336) to fund 4-Stream Hyper-Connections (hc_count=4, hc_lowrank=320) across all 64 hybrid GatedDeltaNet + Attention layers, paired with 1 shared Multi-Token Prediction (mtp) module trained unrolled across draft depths k = 1..4.
Key Highlights
- Lossless Surgical Upcycling + 40.96M-Token Top-64/Tail-KL Distillation:
- Trained on
40.96M<think>reasoning tokens (OpenThoughts-114k, NuminaMath-CoT, CodeFeedback) using exact chunked Top-64 log-probabilities + scalar FP32 tail-mass Forward KL,0.1 × CE, and 4-step discounted MTP loss ($\sum_{k=1}^4 0.5^k \text{CE}_k$) with a Hybrid Muon + AdamW optimizer. - Surpasses the unpruned 27B Teacher on held-out
<think>validation cross-entropy (0.6546vs0.7024,ΔCE = -0.0479) while achieving92.05%Top-1 greedy token agreement with the Teacher.
- Trained on
- Emergent 4-Stream Hyper-Connection Specialization:
- Initialized via exact
(1 + w)RMSNorm×2gate compensation (w_hc = 2 * w_src + 1, FP32 Step-0 error4.77e-7) plus zero-sum per-stream symmetry-breaking micro-offsets. - Without any auxiliary HC regularizer in backpropagation, ablating dynamic HC gates at inference degrades held-out CE by
+0.0427nats (0.6546 → 0.6973), confirming load-bearing multi-stream specialization.
- Initialized via exact
- 1-Shared-MTP Speculative Decoding (
k = 1..4):- Maps all 15 raw
mtp.*tensors fromQwen3.8-27Band unrolls a single shared MTP layer (0.42Bparams) over 4 draft steps with strict anti-leakage shifting. - Achieves
2.596mean accepted tokens per verification pass (64.7%–71.1%per-step conditional acceptance) and a1.569×end-to-end wall-clock TPOT speedup (49.85 ms/tok → 31.77 ms/tok) using in-place hybrid KV + GatedDeltaNet cache rollback.
- Maps all 15 raw
Model Architecture
| Specification | Value |
|---|---|
| Architecture Class | DenseQwen4ExpForCausalLM (model_type="dense_qwen4_exp") |
| Total Parameters | 26.12B (25.69B trunk + 0.42B shared MTP; 48.53 GiB in BF16 across 13 safetensors shards) |
| Layers | 64 (48 GatedDeltaNet linear_attention + 16 Gated GQA full_attention, 3:1 interleaved) |
| Hidden Size / Vocab Size | 5,120 / 248,320 (untied embed_tokens & lm_head) |
| Full-Attention Heads | 24 Query heads / 4 KV heads (head_dim = 256, partial RoPE 0.25, Q/K RMSNorm, output gate) |
| GatedDeltaNet Heads | 16 K heads (dim=128) / 48 V heads (dim=128), conv_kernel=4, silu gated RMSNorm |
| Hyper-Connections (HC) | hc_count = 4 streams, hc_lowrank = 320 (Qwen4ExpTextGatedResidual, 1.70B params) |
Dense FFN (Qwen4ExpTextMLP) |
SwiGLU intermediate_size = 14,336 (num_experts = 0, LoRA r=16 merged into base weights) |
| QSA Token Indexer | Qwen4ExpTextQSAIndexer preserved (4Q/1KV, dim=128), qsa_dense_bypass = True in Round 1 |
| Per-Layer Embeddings (PLE) | Disabled in Round 1 (ple_layer_ids = []) |
| Multi-Token Prediction (MTP) | 1 shared DenseQwen4ExpMTP layer (mtp_intermediate_size = 17,408), unrolled k = 1..4 steps |
Evaluation & Distillation Results
1. Held-Out Validation Progression (128 × 2048 Disjoint Reasoning Windows, 231,281 Assistant Tokens)
Unpruned Qwen/Qwen3.8-27B Teacher held-out baseline: CE = 0.702417.
| Training Step | Tokens Seen | val_ce_hc_on (Student) |
CE_student - CE_teacher |
val_ce_hc_off (HC Ablated) |
CE_hc_off - CE_hc_on |
|---|---|---|---|---|---|
| 0 (Post-Wanda Init) | 0 |
0.714951 |
+0.012534 |
0.714951 |
0.000000 |
| 500 | 8.19M |
0.701532 |
-0.000885 |
0.727651 |
+0.026118 |
| 1000 | 16.38M |
0.692816 |
-0.009601 |
0.742411 |
+0.049594 |
| 1500 | 24.58M |
0.671884 |
-0.030533 |
0.715269 |
+0.043384 |
| 2000 | 32.77M |
0.659251 |
-0.043166 |
0.703664 |
+0.044413 |
| 2500 (Final Merged) | 40.96M |
0.654564 |
-0.047853 |
0.697251 |
+0.042687 |
2. Final Standalone Checkpoint Metrics (final_eval_report.json)
| Metric Category | Metric | Score |
|---|---|---|
| Teacher Alignment | Top-1 Greedy Token Agreement (58,264 tokens) |
92.05% |
| Teacher Alignment | Top-32 Candidate Set Overlap | 74.77% |
Reasoning (<think>) |
GSM8K Test Probe (25 problems, max_new_tokens=768) |
88.0% (92.0% adjusted for \$ formatting) |
Reasoning (<think>) |
50-Problem Combined Probe (25 GSM8K + 25 MATH-500 @ 768 tok cap) |
54.0% (82.0% <think> closure within 768 tok) |
MTP (k=1..4) |
Conditional Draft Acceptance Rate (k=1 / 2 / 3 / 4) |
64.65% / 71.09% / 62.64% / 70.18% |
MTP (k=1..4) |
Cumulative Acceptance Rate (k=1 / 2 / 3 / 4) |
64.65% / 45.96% / 28.79% / 20.20% |
MTP (k=1..4) |
Mean Accepted Length per Verification Pass | 2.596 tokens / step |
MTP (k=1..4) |
End-to-End Single-Stream TPOT (RTX PRO 6000 Blackwell, BF16) | 31.77 ms/tok vs 49.85 ms/tok baseline (1.569× speedup) |
| Export Integrity | LoRA Merge 64-Layer Logit Cosine Similarity / Reload Max Diff | 0.999984 / 0.0 |
Quickstart Usage
Requirements
pip install "torch>=2.4" "transformers>=4.48" safetensors accelerate
# Optional CUDA fast kernels (automatically detected by modeling_dense_qwen4_exp.py):
# pip install flash-linear-attention causal-conv1d flash-attn
Standard Inference (transformers + trust_remote_code=True)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "gxunda/Qwen4-27B-Upcycle-Dev"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
dtype=torch.bfloat16,
device_map="auto",
).eval()
messages = [
{"role": "user", "content": "Prove that the square root of 2 is irrational."}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) + "<think>\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
output_ids = model.generate(
**inputs,
max_new_tokens=1024,
do_sample=False,
use_cache=True,
)
print("<think>\n" + tokenizer.decode(output_ids[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
4-Step Shared-MTP Speculative Decoding
The custom modeling file exposes model.mtp (DenseQwen4ExpMTP) and DenseQwen4HybridCache (begin_spec_verify() / rewind_spec_verify()), allowing lossless single-pass 5-token verification without recomputing rejected GatedDeltaNet recurrent states:
# Draft 4 tokens via the shared MTP head, verify [cur_tok, d1, d2, d3, d4] in one trunk pass,
# and rewind KV + GDN conv/recurrent states in-place to (prev_len + n_accepted + 1):
prev_len = cache.get_seq_length()
cache.begin_spec_verify()
verify_hidden = model.model(input_ids=verify_tokens, past_key_values=cache, use_cache=True).last_hidden_state
cache.rewind_spec_verify(prev_len, n_accepted + 1)
Repository Structure
- Root (
/): Standalone merged Hugging Face checkpoint (config.json,model-00001-of-00013.safetensors..model-00013-of-00013.safetensors,model.safetensors.index.json,configuration_dense_qwen4_exp.py,modeling_dense_qwen4_exp.py, tokenizer files, andfinal_eval_report.json). checkpoints/: Verified pre-merge trainable delta weights (HC + FFN LoRA + MTP),checkpoint_manifest.json, anddistill_summary.jsonfrom the 2,500-step distillation run.teacher_cache/: Tokenized corpus manifest,harvest_manifest.json, and held-out Teacher reference (heldout_teacher_ref.pt) for reproducible offline evaluation.
License & Acknowledgements
- License: Apache-2.0 (inherits from
Qwen/Qwen3.8-27B). - Base Model & Architecture: Built upon the Qwen Team's
Qwen3.8-27Bcheckpoint andqwen4_exparchitectural primitives in Hugging Facetransformers.
- Downloads last month
- 25
Model tree for gxunda/Qwen4-27B-Upcycle-Dev
Base model
Qwen/Qwen3.8-27B