Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 6831cc6

Browse files
committed
get around gguf issue
1 parent b9d1621 commit 6831cc6

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

torchchat/model.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -486,27 +486,6 @@ def _load_model_state_dict(
486486
state_dict[new_key] = state_dict.pop(key)
487487
return state_dict
488488

489-
def __getattr__(self, name):
490-
"""
491-
Rewrite __getattr__ to search attribute in Model and its model attribute.
492-
Note that this is a temporary solution to expose internal model attributes to the user.
493-
494-
:param name: The name of the attribute to get.
495-
:return: The attribute value if found, otherwise raise AttributeError.
496-
"""
497-
try:
498-
if name in self.__dict__:
499-
return self.__dict__[name]
500-
except AttributeError:
501-
pass
502-
503-
try:
504-
return getattr(self.model, name)
505-
except AttributeError:
506-
raise AttributeError(
507-
f"'{type(self).__name__}' object has no attribute '{name}'"
508-
)
509-
510489
@abstractmethod
511490
def forward(self, *args, **kwargs):
512491
raise NotImplementedError("forward method is not implemented")

torchchat/utils/gguf_loader.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def _fqn_lookup(fqn: str, module: torch.nn.Module) -> Any:
5454
if fqn == "":
5555
return module
5656
atoms = fqn.split(".")
57+
# Expose the root module to users.
58+
# Note this is temporary, and will be removed once we removed Model.model
59+
if isinstance(module, Model):
60+
module = module.model
5761
curr = module
5862
for a in atoms:
5963
curr = getattr(curr, a)

0 commit comments

Comments
 (0)