Project-MONAI / Project-MONAI/MONAI

Transformer block local window attention

Open
#7,349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Feature request
Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Is your feature request related to a problem? Please describe.
Add local window attention in transformer block as used in transformers based networkds (SAM for instance, https://arxiv.org/abs/2304.02643)

Describe the solution you'd like
int arg specifying window size in TransformerBlock constructor https://github.com/Project-MONAI/MONAI/blob/b3d7a48afb15f6590e02302d3b048a4f62d1cdee/monai/networks/blocks/transformerblock.py#L26C1-L34C15. If 0, global attention is used instead (no change).

See PR #7348 as suggestion

Describe alternatives you've considered

Additional context
Should help to add monai flexibility to implement more easily ViT with slightly different architectures. Could help for #6357

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The target is monai/networks/blocks/transformerblock.py, with PR #7348 as the suggested reference; start by reading the TransformerBlock constructor and its current attention behavior. Done means the constructor accepts a window-size argument, preserves global attention when the value is 0, and supports local-window attention for positive sizes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.