Skip to content

Commit

Permalink
Fix GroundingDINO, DPR after BERT SDPA update (#30506)
Browse files Browse the repository at this point in the history
Fix GroundingDINO, DPR after BET SDPA update
  • Loading branch information
amyeroberts authored Apr 26, 2024
1 parent 38b53da commit e7d52a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/source/en/perf_infer_gpu_one.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ For now, Transformers supports SDPA inference and training for the following arc
* [Bert](https://huggingface.co/docs/transformers/model_doc/bert#transformers.BertModel)
* [Cohere](https://huggingface.co/docs/transformers/model_doc/cohere#transformers.CohereModel)
* [Dbrx](https://huggingface.co/docs/transformers/model_doc/dbrx#transformers.DbrxModel)
* [Dpr](https://huggingface.co/docs/transformers/model_doc/dpr#transformers.DprReader)
* [Falcon](https://huggingface.co/docs/transformers/model_doc/falcon#transformers.FalconModel)
* [Gemma](https://huggingface.co/docs/transformers/model_doc/gemma#transformers.GemmaModel)
* [GPTBigCode](https://huggingface.co/docs/transformers/model_doc/gpt_bigcode#transformers.GPTBigCodeModel)
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/dpr/modeling_dpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class DPRReaderOutput(ModelOutput):


class DPRPreTrainedModel(PreTrainedModel):
_supports_sdpa = True

def _init_weights(self, module):
"""Initialize the weights"""
if isinstance(module, nn.Linear):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,9 @@ def __init__(self, config: GroundingDinoConfig):
)

# Create text backbone
self.text_backbone = AutoModel.from_config(config.text_config, add_pooling_layer=False)
self.text_backbone = AutoModel.from_config(
config.text_config, add_pooling_layer=False, attn_implementation=config._attn_implementation
)
self.text_projection = nn.Linear(config.text_config.hidden_size, config.d_model)

if config.embedding_init_target or not config.two_stage:
Expand Down

0 comments on commit e7d52a1

Please sign in to comment.