Skip to content

Pydantic error when merging models #681

Description

@wmoell1

The pydantic dependency listed, 2.10.6, generates the error below with mergekit 0.1.4. Text of error:
'pydantic.errors.PydanticUserError: ConfiguredModuleArchitecture is not fully defined;
you should define torch, then call ConfiguredModuleArchitecture.model_rebuild().'

The error manifests during the merge planning phase when mergekit-yaml (or other mergekit entry points) attempts to load and analyze the model architectures before executing the merge graph. Specifically occurs in MergePlanner._out_module_arch().

I was able to workaround the error by modifying __init__py.file to import torch at the beginning and call the rebuild classes at the end:
ConfiguredModuleArchitecture.model_rebuild()
ConfiguredModelArchitecture.model_rebuild()

After making the above changes to init.py, mergekit was able to begin successfully executing the graph.

When I was researching how to resolve the conflict, I came across the issue on Pydantic's repo:
pydantic/pydantic#11004

This seems to suggest that mergekit needs to update its pydantic dependency possibly to avoid running into this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions