google / google/gemma.cpp

Add SmolLM2 support — reuse the Qwen3 converter path?

Đang mở
#982 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
7k
Fork
660
Merge trung bình
20 giờ 43 phút
Pull request đã merge (30 ngày)
33

Mô tả

Hi @jan-wassenberg — I'd like to contribute SmolLM2 (135M / 360M / 1.7B) support, and wanted to check the approach with you before writing any code.

SmolLM2 is plain Llama-style: RMSNorm, SwiGLU, RoPE theta 10000, no biases, no QK-norm, tied embeddings, byte-level BPE, ChatML turn tokens. As far as I can tell that needs **no new kernels** — everything is already on the Qwen3 path.

Sketch:

1. `python/convert_from_safetensors.py` — the HF tensor names are identical to Qwen3's, so `export_qwen3_lm_sbs` almost works as-is. The only blockers are the `has_qk_norm` assert and deriving `head_dim` from `q_norm.weight`. Plus a `smollm2-*` dispatch prefix.
2. `gemma/configs.{h,cc}` — new `Model` enum values + config functions.
3. `gemma/tokenizer.cc` — reuse the Qwen3 branch (same `<|im_start|>` / `<|im_end|>`).
4. `gemma/gemma.cc` — `HasEmbeddingScaling()` has to return false for it.

Questions:

- Is a third family outside Gemma/Qwen welcome here, or would you rather keep the model list narrow?
- Prefer a family-neutral `export_llama_style_lm_sbs` that both Qwen3 and SmolLM2 route through, or a separate function?
- For `HasEmbeddingScaling`, would you rather grow the per-family check, or add a `ModelConfig` field?

Happy to send a PR if the direction sounds right.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Trước tiên, hãy đọc python/convert_from_safetensors.py và đường dẫn Qwen3 hiện có, sau đó kiểm tra gemma/configs.{h,cc}, gemma/tokenizer.cc và gemma/gemma.cc để xem xét việc đăng ký model, xử lý token và scale embedding. Được xem là hoàn tất khi các maintainer đã chọn họ model và thiết kế converter, đồng thời hỗ trợ SmolLM2 135M, 360M và 1.7B được triển khai mà không có kernel mới.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
cpp, python
Lĩnh vực
machine-learning
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.