Skip to content

Use fused SDPA for SVTRv2 global attention - #221

Open
kawavil wants to merge 2 commits into
Topdu:mainfrom
kawavil:feature/sdpa-attention-memory-optimization
Open

Use fused SDPA for SVTRv2 global attention#221
kawavil wants to merge 2 commits into
Topdu:mainfrom
kawavil:feature/sdpa-attention-memory-optimization

Conversation

@kawavil

@kawavil kawavil commented Sep 11, 2026

Copy link
Copy Markdown

Use fused SDPA for SVTRv2 global attention to avoid memory issue. During inference, manual attention calculation stores the metrics in the memory and it consumes lot of memory. So to avoid that we can use the pytorch SDPA. Check the comparison below:

Metric | Manual attention | SDPA attention
Test images | 200 | 200
Correct predictions | 187 | 187
Accuracy | 93.50% | 93.50%
Total inference time| 116.2 sec | 42.1 sec
Peak GPU allocated | 4936.21 MB | 245.78 MB
Peak GPU reserved | 6610.00 MB | 330.00 MB

@kawavil
kawavil marked this pull request as draft September 11, 2026 06:32
@kawavil
kawavil marked this pull request as ready for review September 11, 2026 06:32
@kawavil
kawavil marked this pull request as draft September 11, 2026 08:50
@kawavil
kawavil marked this pull request as ready for review September 11, 2026 08:53
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.

1 participant