@@ -195,8 +195,10 @@ def write_ort_genai_config(
195195 directory: Output directory (created if needed).
196196 hf_model_id: HuggingFace model ID. When provided, used to fetch token
197197 IDs (``bos``/``eos``/``pad``) and download tokenizer files.
198- When ``None``, token IDs default to ``None`` and tokenizer files
199- are not copied.
198+ When ``None``, token IDs are read from ``pkg.config`` fields
199+ (``bos_token_id``, ``eos_token_id``, ``pad_token_id``) populated
200+ by :meth:`~mobius._configs.ArchitectureConfig.from_transformers`,
201+ and tokenizer files are not copied.
200202 ep: Execution provider for ``session_options`` in
201203 ``genai_config.json`` (e.g. ``"cpu"``, ``"cuda"``, ``"dml"``,
202204 ``"trt-rtx"``). Defaults to ``"cpu"``.
@@ -248,19 +250,26 @@ def write_ort_genai_config(
248250 eos_token_id = getattr (hf_config , "eos_token_id" , None )
249251 pad_token_id = getattr (hf_config , "pad_token_id" , None )
250252 else :
251- # Fall back to model_type from the mobius ArchitectureConfig.
252- # This path is taken when hf_model_id is not provided, so HF config
253- # is unavailable. The ArchitectureConfig.model_type may be absent on
254- # older configs, producing 'unknown' — ORT-GenAI may reject it.
255- raw_type = getattr (config , "model_type" , "unknown" )
253+ # Fall back to fields stored in ArchitectureConfig (set by from_transformers()).
254+ # This path is taken when hf_model_id is not provided (e.g. --config mode).
255+ raw_type = getattr (config , "model_type" , None ) or "unknown"
256256 ort_model_type = _resolve_ort_genai_model_type (raw_type )
257257 if ort_model_type == "unknown" :
258258 logger .warning (
259- "Could not determine ORT-GenAI model type: pkg.config has no "
260- "'model_type' attribute. Pass hf_model_id to resolve it from "
261- "the HuggingFace config, or the generated genai_config.json "
262- "may not load correctly."
259+ "Could not determine ORT-GenAI model type: pkg.config.model_type "
260+ "is missing, None, or not mapped to an ORT-GenAI type (got %r). "
261+ "Pass hf_model_id to resolve it from the HuggingFace config, or "
262+ "the generated genai_config.json may not load correctly." ,
263+ raw_type ,
263264 )
265+ # Read token IDs from ArchitectureConfig (populated by from_transformers()
266+ # when --config is used with a local directory).
267+ bos_token_id = getattr (config , "bos_token_id" , None )
268+ eos_token_id = getattr (config , "eos_token_id" , None )
269+ # pad_token_id lives in BaseModelConfig with DEFAULT_INT (-42) as the
270+ # "not set" sentinel (negative IDs are never valid token positions).
271+ _pad = getattr (config , "pad_token_id" , None )
272+ pad_token_id = None if (_pad is None or _pad < 0 ) else _pad
264273
265274 # Detect multimodal capabilities from the package keys
266275 is_vlm = "vision" in pkg and "embedding" in pkg
0 commit comments