MCPcopy
hub / github.com/mudler/LocalAI / get_inner_model

Function get_inner_model

backend/python/mlx-distributed/sharding.py:75–85  ·  view source on GitHub ↗

Get the inner model (model.model or model.transformer).

(model)

Source from the content-addressed store, hash-verified

73
74
75def get_inner_model(model):
76 """Get the inner model (model.model or model.transformer)."""
77 for attr in ("model", "transformer"):
78 inner = getattr(model, attr, None)
79 if isinstance(inner, nn.Module):
80 # Some models have model.model (e.g. language_model.model)
81 inner_inner = getattr(inner, "model", None)
82 if isinstance(inner_inner, nn.Module):
83 return inner_inner
84 return inner
85 raise ValueError("Model must have a 'model' or 'transformer' attribute")
86
87
88def get_layers(inner_model):

Callers 1

pipeline_auto_parallelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected