Skip to content

Conversation

@MarcSzafraniec
Copy link

@MarcSzafraniec MarcSzafraniec commented Sep 18, 2024

The attention mask was not passed correctly to the Attention in TransformerBlock.forward.

One problem it caused was that when passing two images in the image encoder, the attention would be done on all images at the same time, thus taking more resources and returning an incorrect result.

This PR fixes this problem.
Tested by passing two images separately to the encoder, and checking that passing them as a batch gives "almost" the same thing.
Also tested on classic vision benchmarks where the results were very low (and inference very slow), now considerably better:
ImageNet KNN:

  • was 7.27% accuracy and took 5h
  • now is 63.79% accuracy and takes 35 min (8.6 times faster)

…layers.py

The attention mask was not passed correctly to the `Attention` in `TransformerBlock.forward`.

One problem it caused was that when passing two images in the image encoder, the attention would be done on all images at the same time, thus taking more resources and returning an incorrect result.

This PR fixes this problem.
@baldassarreFe
Copy link

I observed the same bug, this PR fixes the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants