Repository navigation
feat(models): add ByteDance Seed-OSS (seed_oss) - #261
Merged
Merged
Conversation
Port ByteDance's Seed-OSS, a plain Llama-style dense decoder, as a config-backed text model. The block is standard (`h = x + self_attn(input_layernorm(x))` then `out = h + mlp(post_attention_layernorm(h))`) with a SwiGLU MLP and a final `model.norm`, so the implementation reuses the shared `UnifiedLinear` / `UnifiedEmbedding` / `RMSNorm` / `fast_rope` / `compiled_swiglu_activation` helpers. It mirrors `src/models/granite.rs` structurally but drops all four Granite scalar multipliers (plain embedding, `head_dim^-0.5` attention scale, plain residual adds, plain logits).
Deltas from a vanilla Llama, all handled at the loader boundary:
- Split attention bias: `attention_bias` (true) puts a bias on q/k/v projections, `attention_out_bias` (false) controls o_proj separately. `UnifiedLinear::from_weights` loads a `.bias` only when the checkpoint carries one, so each projection resolves the correct bias with no flag threading.
- Explicit `head_dim` (128), which is not `hidden_size / num_attention_heads` (5120 / 80 = 64).
- `rope_scaling = {"rope_type": "default"}` means no scaling, so RoPE is a plain `fast_rope` with `rope_theta` (1e7), like granite and minicpm. No llama3 or linear scaling is applied.
- Untied embeddings (`tie_word_embeddings` false): a separate `lm_head` (no bias) projects the final hidden state; the tied case reuses `embed_tokens.as_linear` and drops any stray `lm_head.weight`. EOS token id is 2.
Registered in detection (`seed_oss` -> `ModelType::SeedOss`), the model module map, `ModelType` enum, `ALL_MODEL_TYPES`, the model metadata table (config-backed route), `LoadedModel`, and the tensor-parallel name map. Metadata family is the existing "Specialized" group. Added checkpoint-free config-parse unit tests (`seed_oss_tests.rs`) and listed the family in `docs/supported-models.md`.
Validated by `cargo check --release --features metal,accelerate --lib` and `cargo clippy --lib -- -D warnings`. Real-model generation against `mlx-community/Seed-OSS-36B-Instruct-4bit` is the maintainer-side gate.
3 tasks
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
* feat(models): add ByteDance Seed-OSS (seed_oss)
Port ByteDance's Seed-OSS, a plain Llama-style dense decoder, as a config-backed text model. The block is standard (`h = x + self_attn(input_layernorm(x))` then `out = h + mlp(post_attention_layernorm(h))`) with a SwiGLU MLP and a final `model.norm`, so the implementation reuses the shared `UnifiedLinear` / `UnifiedEmbedding` / `RMSNorm` / `fast_rope` / `compiled_swiglu_activation` helpers. It mirrors `src/models/granite.rs` structurally but drops all four Granite scalar multipliers (plain embedding, `head_dim^-0.5` attention scale, plain residual adds, plain logits).
Deltas from a vanilla Llama, all handled at the loader boundary:
- Split attention bias: `attention_bias` (true) puts a bias on q/k/v projections, `attention_out_bias` (false) controls o_proj separately. `UnifiedLinear::from_weights` loads a `.bias` only when the checkpoint carries one, so each projection resolves the correct bias with no flag threading.
- Explicit `head_dim` (128), which is not `hidden_size / num_attention_heads` (5120 / 80 = 64).
- `rope_scaling = {"rope_type": "default"}` means no scaling, so RoPE is a plain `fast_rope` with `rope_theta` (1e7), like granite and minicpm. No llama3 or linear scaling is applied.
- Untied embeddings (`tie_word_embeddings` false): a separate `lm_head` (no bias) projects the final hidden state; the tied case reuses `embed_tokens.as_linear` and drops any stray `lm_head.weight`. EOS token id is 2.
Registered in detection (`seed_oss` -> `ModelType::SeedOss`), the model module map, `ModelType` enum, `ALL_MODEL_TYPES`, the model metadata table (config-backed route), `LoadedModel`, and the tensor-parallel name map. Metadata family is the existing "Specialized" group. Added checkpoint-free config-parse unit tests (`seed_oss_tests.rs`) and listed the family in `docs/supported-models.md`.
Validated by `cargo check --release --features metal,accelerate --lib` and `cargo clippy --lib -- -D warnings`. Real-model generation against `mlx-community/Seed-OSS-36B-Instruct-4bit` is the maintainer-side gate.
* fix(loader): suppress misleading bf16 warning for quantized-scale promotion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port ByteDance's Seed-OSS (
seed_oss), a plain Llama-style dense transformer, as a config-backed text model. It reuses the sharedUnifiedLinear/UnifiedEmbedding/RMSNorm/fast_rope/compiled_swiglu_activationhelpers and mirrorssrc/models/granite.rsstructurally, without the four Granite scalar multipliers (plain embedding,head_dim^-0.5attention scale, plain residual adds, plain logits).Upstream reference: https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/models/seed_oss.py
What changed
src/models/seed_oss.rs: new model. Standard decoder block (h = x + self_attn(input_layernorm(x))thenout = h + mlp(post_attention_layernorm(h))), SwiGLU MLP, finalmodel.norm, untiedlm_headwith the tied fallback toembed_tokens.as_linear.src/models/seed_oss_tests.rs: checkpoint-free config-parse unit tests (explicit head_dim, split bias flags, untied flag, default rope_scaling, quantization defaults).detection.rs(seed_osstoModelType::SeedOss),models/mod.rs(module, re-export, enum,ALL_MODEL_TYPES, "Specialized" metadata, test module),model_metadata.rs(config-backed route),loaded_model.rs(variant plus delegate arm),distributed/tensor_parallel/inference.rs(tensor-parallel name map).docs/supported-models.md: listed under the dense families.Architecture notes
attention_bias(true) biases q/k/v,attention_out_bias(false) controls o_proj separately.UnifiedLinear::from_weightsloads a.biasonly when present, so each projection resolves the correct bias with no flag threading. Verified against the checkpoint: q/k/v carry.bias, o_proj does not.head_dim(128), which is nothidden_size / num_attention_heads(5120 / 80 = 64).rope_scaling = {"rope_type": "default"}means no scaling, so RoPE is a plainfast_ropewithrope_theta(1e7), like granite and minicpm. No llama3 or linear scaling is applied.lm_head.weight. EOS token id is 2.Test plan
cargo check --release --features metal,accelerate --libcargo clippy --release --features metal,accelerate --lib -- -D warningscargo fmt --checkcargo check --release --features metal,accelerate --tests(type-checks the new unit tests; release test-binary codegen exceeds the local time budget, so the tests are not executed here)mlx-community/Seed-OSS-36B-Instruct-4bit(maintainer-side Metal gate)Closes #250