Skip to content

fix: include user-defined LLM families in _resolve_architectures - #5351

Open
Ricardo-M-L wants to merge 1 commit into
xorbitsai:mainfrom
Ricardo-M-L:fix/user-defined-llm-families-resolve
Open

fix: include user-defined LLM families in _resolve_architectures#5351
Ricardo-M-L wants to merge 1 commit into
xorbitsai:mainfrom
Ricardo-M-L:fix/user-defined-llm-families-resolve

Conversation

@Ricardo-M-L

Copy link
Copy Markdown
Contributor

This PR addresses: include user-defined LLM families in _resolve_architectures

The _resolve_architectures method only looked up architectures from
BUILTIN_LLM_FAMILIES, which caused custom-registered models with a
model_family pointing to a user-defined model to fail architecture
resolution. Now combines both builtin and user-defined families.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@XprobeBot XprobeBot added the bug Something isn't working label Aug 17, 2026
@XprobeBot XprobeBot added this to the v3.x milestone Aug 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the _resolve_architectures method in xinference/model/llm/llm_family.py to support user-defined LLM families alongside builtin ones. The reviewer pointed out a performance overhead issue where dictionaries are rebuilt on every call, and suggested optimizing this by first checking builtin families and lazily importing and checking user-defined families.

Comment on lines +168 to 175
from .custom import get_user_defined_llm_families

user_defined = {f.model_name: f for f in get_user_defined_llm_families()}
all_families = {f.model_name: f for f in BUILTIN_LLM_FAMILIES}
all_families.update(user_defined)
if self.model_family in all_families:
return all_families[self.model_family].architectures
return None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Rebuilding dictionaries for all builtin and user-defined families on every call to _resolve_architectures introduces unnecessary performance overhead, especially since builtin families are static and represent the vast majority of lookups.

Instead, we can first check BUILTIN_LLM_FAMILIES using a simple loop. If not found, we can then lazily import and check the user-defined families. This avoids the overhead of dictionary creation and imports for builtin models.

Suggested change
from .custom import get_user_defined_llm_families
user_defined = {f.model_name: f for f in get_user_defined_llm_families()}
all_families = {f.model_name: f for f in BUILTIN_LLM_FAMILIES}
all_families.update(user_defined)
if self.model_family in all_families:
return all_families[self.model_family].architectures
return None
for family in BUILTIN_LLM_FAMILIES:
if family.model_name == self.model_family:
return family.architectures
from .custom import get_user_defined_llm_families
for family in get_user_defined_llm_families():
if family.model_name == self.model_family:
return family.architectures
return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants