Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Apply Uniform Attention Masks Explicitly #152

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JakobEliasWagner
Copy link
Collaborator

@JakobEliasWagner JakobEliasWagner commented Jul 24, 2024

Fix: Apply Uniform Attention Masks Explicitly

Description

This PR changes the attention base class implementation to an explicit assumption that the attention mask is applied uniformly accross a single sample. This ensures consistency in which parts of the input are masked out or attended to across all queries. Without this assumption the mask needs to be repeated for every query, leading to big overheads. In its current state all queries should have acess to all key/value pairs. While there is potential impplementations utilizing a more efficient/distributed matching, this approach will be not followed for now.

Which issue does this PR tackle?

  • Handling of query-specific key/value masks is too restricting for simple attention based neural operator implementations.

How does it solve the problem?

  • Restricts the attention mask to be uniform across all queries.

How are the changes tested?

  • Modified unit tests to match the new assumption.
  • All unit-tests run without errors.

Checklist for Contributors

  • Scope: This PR tackles exactly one problem.
  • Conventions: The branch follows the feature/title-slug convention.
  • Conventions: The PR title follows the Bugfix: Title convention.
  • Coding style: The code passes all pre-commit hooks.
  • Documentation: All changes are well-documented.
  • Tests: New features are tested and all tests pass successfully.
  • Changelog: Updated CHANGELOG.md for new features or breaking changes.
  • Review: A suitable reviewer has been assigned.

Checklist for Reviewers:

  • The PR solves the issue it claims to solve and only this one.
  • Changes are tested sufficiently and all tests pass.
  • Documentation is complete and well-written.
  • Changelog has been updated, if necessary.

@JakobEliasWagner JakobEliasWagner self-assigned this Jul 24, 2024
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.

2 participants