Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @omarequalmars,
This PR addresses a performance issue in the Segformer decoder caused by unnecessary
.contiguous()
operations. These operations significantly slowed down the training process. By removing the redundant.contiguous()
calls, the throughput has been restored to the expected level.Fixes #996
I ran the following experiments and checks to replicate the anomaly under your configuration:
os: linux
gpu: v100
reference: transformers/segformer
Issue
resolve #996
Fix up
The slowdown was caused by an unnecessary .contiguous() call in the decoder pipeline.
segmentation_models.pytorch/segmentation_models_pytorch/decoders/segformer/decoder.py
Line 18 in 5ee19b0
This PR removes the redundant operation, as shown below:
Transformers & SMP
Since our implementation references Transformers, I directly compared the throughput after applying the fix.
The throughput of both implementations aligns after the fix:
test code
Custom hyperparameters
Tested your hyperparameters:
test code
Default hyperparameters
test code