Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move common Registry types to MLXLMCommon #229

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ibrahimcetin
Copy link
Contributor

@ibrahimcetin ibrahimcetin commented Mar 8, 2025

This PR moves the common Registry types to MLXLMCommon to avoid code duplication.

Should we reorganize MLXLMCommon directory? at least for the registry types. I created three new files in it and the directory looks like a bit messy IMO.

I misspelled the class name in the first commit message, sorry

@davidkoski
Copy link
Collaborator

I created three new files in it and the directory looks like a bit messy IMO.

If you want to create a group for the model/registry pieces, please do.

public init(creators: [String: @Sendable (URL) throws -> any LanguageModel]) {
self.creators = creators
}
public class LLMTypeRegistry: ModelTypeRegistry, @unchecked Sendable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changing the name here is probably OK -- callers couldn't really do anything directly with the type before and would have pulled it off the ModelRegistry

public init(modelConfigurations: [ModelConfiguration]) {
self.registry = Dictionary(uniqueKeysWithValues: modelConfigurations.map { ($0.name, $0) })
}
public class LLMRegistry: ModelRegistry, @unchecked Sendable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to keep this the same name -- code probably has reference to MLXLLM.ModelRegistry to get at the static members, e.g. codeLlama13b4bit.

Perhaps the parent could be AbstractModelRegistry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this name change is intentional. I am aware that this would be a breaking change but I believe it will make the code more descriptive. However, in this case, we should inform the developers that ModelRegistry is now an abstract class and must be subclassed to be used.

So, we can:

  • Keep the subclasses but rename the parent classes as AbstractModelRegistry and so on. (My suggestion)
  • Keep the previous code and rename the parent classes as AbstractModelRegistry and so on. (Your suggestion)

In my suggestion, it would completely break the existing code but do you agree it's worth it? Because if we make this change, MLXLLM and MLXVLM won't conflict, and the code would be more descriptive when these packages are used IMO. Also, since there has been no release containing MLXVLM so far, this change may be acceptable.

In the end, I am still unsure and looking for your opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants