Skip to content

Commit 3ead2d5

Browse files
committed
Add support for seed models
1 parent 1a33601 commit 3ead2d5

3 files changed

Lines changed: 73 additions & 5 deletions

File tree

backend/architecture_profiles.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,66 @@ def __init__(self) -> None:
172172
super().__init__(names=("qwen", "qwen2", "qwen3", "qwen2moe", "qwen3moe"))
173173

174174

175+
@register_profile
176+
class SeedProfile(StandardDecoderProfile):
177+
"""
178+
Profile for Seed OSS models (Seed-OSS-36B, etc.).
179+
Seed models are Llama-based but may use different metadata keys.
180+
Seed-OSS-36B has 64 transformer layers (not 32).
181+
"""
182+
def __init__(self) -> None:
183+
super().__init__(names=("seed", "seed-oss", "seedoss"))
184+
185+
def _calculate_layers(
186+
self, metadata: Dict[str, Any], base_block_count: int
187+
) -> LayerConfig:
188+
# Seed models might use 'llama' prefix or 'seed' prefix
189+
# Check multiple candidate keys, prioritizing seed-specific keys
190+
candidate_keys = [
191+
"seed.block_count",
192+
"seed.n_layer",
193+
"seed.n_layers",
194+
"llama.block_count",
195+
"llama.n_layer",
196+
"llama.n_layers",
197+
"general.block_count",
198+
"general.n_layer",
199+
]
200+
201+
metadata_block_count = _get_first_valid_int(
202+
metadata, candidate_keys, default=None
203+
)
204+
205+
# Use the maximum of metadata value or tensor-based count
206+
# This is important because Seed models might have incorrect metadata
207+
# but correct tensor counts
208+
if metadata_block_count is not None:
209+
block_count = max(metadata_block_count, base_block_count) if base_block_count > 0 else metadata_block_count
210+
if metadata_block_count < base_block_count:
211+
logger.info(
212+
f"Seed profile: metadata shows {metadata_block_count} layers but tensor count suggests {base_block_count}, "
213+
f"using tensor count ({base_block_count})"
214+
)
215+
else:
216+
block_count = base_block_count if base_block_count > 0 else 0
217+
218+
# Special handling: If we detect around 32 layers but the model size suggests 64,
219+
# it might be a Seed model with incorrect metadata
220+
if block_count > 0 and block_count < 40:
221+
# Check if tensor count suggests more (Seed-OSS-36B should have ~64)
222+
if base_block_count > block_count * 1.5:
223+
logger.warning(
224+
f"Seed profile: Detected potential mismatch - metadata={block_count}, "
225+
f"tensor_count={base_block_count}. Using tensor_count."
226+
)
227+
block_count = base_block_count
228+
229+
# Standard decoder: blocks + output head
230+
effective = (block_count + 1) if block_count > 0 else 0
231+
232+
return LayerConfig(block_count=block_count, effective_layer_count=effective)
233+
234+
175235
@register_profile
176236
class LlamaLikeProfile(StandardDecoderProfile):
177237
"""LLaMA, Mistral, Mixtral, Gemma, Phi, etc."""

backend/gguf_reader.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,26 +707,32 @@ def _extract_layer_count(metadata: Dict[str, Any]) -> int:
707707
"""
708708
# Try different possible keys for layer count
709709
layer_keys = [
710-
'llama.block_count', # Most common for Llama models
710+
'seed.block_count', # Seed OSS models
711+
'seed.n_layer',
712+
'seed.layer_count',
713+
'llama.block_count', # Most common for Llama models (Seed models may use this)
711714
'glm4moe.block_count', # GLM4 MoE architecture
712715
'glm4.block_count', # GLM4 architecture (non-MoE)
713716
'glm.block_count', # GLM architecture (non-MoE)
714717
'qwen3.block_count', # Qwen3 architecture
715718
'qwen3moe.block_count', # Qwen3 MoE architecture
716719
'qwen.block_count', # Qwen architecture
717720
'general.block_count',
721+
'seed.layer_count', # Seed OSS models
718722
'llama.layer_count',
719723
'glm4moe.layer_count',
720724
'glm4.layer_count', # GLM4 architecture (non-MoE)
721725
'glm.layer_count', # GLM architecture (non-MoE)
722726
'general.layer_count',
723727
'qwen.layer_count',
724728
'qwen3.layer_count',
729+
'seed.n_layer', # Seed OSS models
725730
'llama.n_layer',
726731
'glm4moe.n_layer',
727732
'glm4.n_layer', # GLM4 architecture (non-MoE)
728733
'glm.n_layer', # GLM architecture (non-MoE)
729734
'general.n_layer',
735+
'seed.num_layers', # Seed OSS models
730736
'llama.num_layers',
731737
'glm4moe.num_layers',
732738
'glm4.num_layers', # GLM4 architecture (non-MoE)

frontend/src/views/ModelConfig.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,9 @@ const applyPreset = async (presetName, skipPreview = false) => {
12261226
const defaults = getDefaultConfig()
12271227
const newConfig = { ...defaults, ...smartConfig }
12281228
1229-
// Calculate changes
1230-
const changes = calculateChanges(newConfig, config.value)
1229+
// Calculate changes - merge defaults with current config to get accurate "before" values
1230+
const currentConfig = { ...defaults, ...config.value }
1231+
const changes = calculateChanges(newConfig, currentConfig)
12311232
12321233
// Calculate impact (only if changes detected)
12331234
let impact = null
@@ -1376,8 +1377,9 @@ const generateAutoConfig = async (skipPreview = false) => {
13761377
const newConfig = { ...defaults, ...smartConfig }
13771378
console.log('Merged new config for application:', newConfig)
13781379
1379-
// Calculate changes
1380-
const changes = calculateChanges(newConfig, config.value)
1380+
// Calculate changes - merge defaults with current config to get accurate "before" values
1381+
const currentConfig = { ...defaults, ...config.value }
1382+
const changes = calculateChanges(newConfig, currentConfig)
13811383
console.log(`Detected ${changes.length} configuration changes`, changes)
13821384
13831385
// Calculate impact (don't fail if this errors) - only if we have changes

0 commit comments

Comments
 (0)