8000 Add Qwen3.5 model support (config, weights, and hybrid Gated DeltaNet) by janpfeifer · Pull Request #87 · gomlx/go-huggingface · GitHub
[go: up one dir, main page]

Skip to content

Add Qwen3.5 model support (config, weights, and hybrid Gated DeltaNet) - #87

Merged
janpfeifer merged 2 commits into
mainfrom
add-qwen3.5
Nov 25, 2026
Merged

janpfeifer merged 2 commits into
mainfrom
add-qwen3.5

Conversation

@janpfeifer
Copy link
Copy Markdown
Contributor

Depends on gomlx/gomlx#502 (once merged, go.mod should be bumped to the new github.com/gomlx/gomlx release).

Summary

  • Extend transformer.Config (models/transformer/config.go) with Qwen3.5 hybrid Gated DeltaNet fields (attn_output_gate, full_attention_interval, linear_conv_kernel_dim, linear_key_head_dim, linear_value_head_dim, linear_num_key_heads, linear_num_value_heads, mamba_ssm_dtype, tie_word_embeddings).
  • Update Config.UnmarshalJSON to parse both flat rope_parameters objects (Qwen3.5) and nested per-layer-type maps (Gemma 4) without breaking existing models.
  • Update models/transformer/model.go:
    • Recognize qwen3_5 / qwen3_5_text in detectCausalMask and honor typed Config.TieWordEmbeddings.
    • Map layers.{N}.linear_attn.* safetensors weights (in_proj_qkv, in_proj_z, in_proj_b, in_proj_a, out_proj, conv1d.weight, A_log, dt_bias, norm.weight) and untied lm_head.weight, cleanly skipping model.visual.* and mtp.* tensors.
  • Update models/transformer/transformer.go to configure mltransformer.ArchitectureQwen35, mltransformer.LinearLayer layer types, zero-centered RMSNorm (RMSNormOffset = 1.0), gated attention output (WithAttnOutputGate(true)), linear attention dims/state dtype, and standard partial RoPE (partial_rotary_factor).
  • Add TestQwen35ConfigAndTensorMapping in models/transformer/transformer_test.go covering Qwen3.5 config/tensor mapping and Gemma 4 nested rope_parameters compatibility.
  • Update docs/CHANGELOG.md and .agents/AGENTS.md.

Verification

  • go test -short ./... passes.
  • Sentence embedding verified with:
    GOEXPERIMENT=simd GOMLX_BACKEND=go go run github.com/gomlx/go-huggingface/examples/msmarco/benchmark_embed/ -bucket=0 -model Qwen/Qwen3.5-4B -limit 10 -num_embedders=32 -warmup -dynamic=true
    (327 tokens/s across 100 passages, 12.4 GiB MaxRSS; go vs xla:cpu cross-backend mean cosine distance 8.95e-05).
  • Autoregressive generation verified with:
    GOEXPERIMENT=simd GOMLX_BACKEND=go go run ./examples/dolly/browse -n=2 -model="Qwen/Qwen3.5-4B" -prompt_tokens=1024 -gen_tokens=128
    (accurate responses with clean <|im_end|> stopping, ~60–67 tok/s prefill, ~5.94 tok/s decode, 11.3 GiB MaxRSS).

@janpfeifer
janpfeifer merged commit 0bd8f10 into main Nov 25, 2026
5 checks passed
@janpfeifer
janpfeifer deleted the add-qwen3.5 branch November 28, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

< 2C14 !--/$-->
0