Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/pruna/algorithms/sage_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import torch
from diffusers import DiffusionPipeline
from typing_extensions import cast

from pruna.algorithms.base.pruna_base import PrunaAlgorithmBase
from pruna.algorithms.base.tags import AlgorithmTag as tags
Expand Down Expand Up @@ -91,10 +92,8 @@ def _apply(self, model: Any, smash_config: SmashConfigPrefixWrapper) -> Any:
target_modules = smash_config["target_modules"]

if target_modules is None:
target_modules = self.get_model_dependent_hyperparameter_defaults(
model,
smash_config
)
target_modules = self.get_model_dependent_hyperparameter_defaults(model, smash_config)["target_modules"]
target_modules = cast(TARGET_MODULES_TYPE, target_modules)

def apply_sage_attn(
root_name: str | None,
Expand Down Expand Up @@ -154,7 +153,7 @@ def get_model_dependent_hyperparameter_defaults(
self,
model: Any,
smash_config: SmashConfigPrefixWrapper,
) -> TARGET_MODULES_TYPE:
) -> dict[str, Any]:
"""
Provide default `target_modules` targeting all transformer modules.

Expand All @@ -178,5 +177,5 @@ def get_model_dependent_hyperparameter_defaults(
# SageAttn might also be applicable to other modules but could significantly decrease model quality.
include = ["transformer*"]
exclude = []

return {"include": include, "exclude": exclude}
target_modules = {"include": include, "exclude": exclude}
return {"target_modules": target_modules}
Loading