Skip to content

feat(models): add ByteDance Seed-OSS (seed_oss) - #261

Merged
inureyes merged 2 commits into
mainfrom
feat/issue-250-seed-oss
Jun 13, 2026
Merged

inureyes merged 2 commits into
mainfrom
feat/issue-250-seed-oss

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Port ByteDance's Seed-OSS (seed_oss), a plain Llama-style dense transformer, as a config-backed text model. It reuses the shared UnifiedLinear / UnifiedEmbedding / RMSNorm / fast_rope / compiled_swiglu_activation helpers and mirrors src/models/granite.rs structurally, without the four Granite scalar multipliers (plain embedding, head_dim^-0.5 attention 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)) then out = h + mlp(post_attention_layernorm(h))), SwiGLU MLP, final model.norm, untied lm_head with the tied fallback to embed_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).
  • Registration: detection.rs (seed_oss to ModelType::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

  • Split attention bias: attention_bias (true) biases q/k/v, attention_out_bias (false) controls o_proj separately. UnifiedLinear::from_weights loads a .bias only 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.
  • 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; the tied case drops any stray lm_head.weight. EOS token id is 2.

Test plan

  • cargo check --release --features metal,accelerate --lib
  • cargo clippy --release --features metal,accelerate --lib -- -D warnings
  • cargo fmt --check
  • cargo 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)
  • Real-model generation against mlx-community/Seed-OSS-36B-Instruct-4bit (maintainer-side Metal gate)

Closes #250

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.
@inureyes inureyes added type:enhancement New features, capabilities, or significant additions priority:medium Medium priority area:models Model architectures, weights, loading, metadata status:review Under review labels Jun 13, 2026
@inureyes inureyes added status:done Completed and removed status:review Under review labels Jun 13, 2026
@inureyes
inureyes merged commit abb611e into main Jun 13, 2026
4 checks passed
@inureyes
inureyes deleted the feat/issue-250-seed-oss branch June 13, 2026 10:03
@inureyes inureyes added this to the 0.3 milestone Jun 21, 2026
@inureyes inureyes self-assigned this Aug 31, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(models): add ByteDance Seed-OSS (seed_oss)

1 participant