Skip to content

Commit

Permalink
Pin eager attn in torch-ort backend (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil authored Jul 1, 2024
1 parent 156844a commit dd02f26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions optimum_benchmark/backends/torch_ort/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def automodel_kwargs(self) -> Dict[str, Any]:
if self.config.torch_dtype is not None:
kwargs["torch_dtype"] = getattr(torch, self.config.torch_dtype)

if self.config.attn_implementation is not None:
kwargs["attn_implementation"] = self.config.attn_implementation

return kwargs

def train(
Expand Down
4 changes: 3 additions & 1 deletion optimum_benchmark/backends/torch_ort/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
@dataclass
class TorchORTConfig(BackendConfig):
name: str = "torch-ort"
version: Optional[str] = torch_ort_version
version: Optional[str] = torch_ort_version()
_target_: str = "optimum_benchmark.backends.torch_ort.backend.TorchORTBackend"

# load options
no_weights: bool = False
torch_dtype: Optional[str] = None
# sdpa, which has became default of many architectures, fails with torch ort
attn_implementation: Optional[str] = "eager"

# peft options
peft_type: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/_text_encoders_.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ hydra:
sweeper:
params:
backend.task: fill-mask,text-classification,token-classification,question-answering
backend.model: hf-internal-testing/tiny-random-bert,hf-internal-testing/tiny-random-roberta
backend.model: hf-internal-testing/tiny-random-BertModel,hf-internal-testing/tiny-random-RobertaModel

0 comments on commit dd02f26

Please sign in to comment.