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

[TorchAcc] Update padding strategy when using persistent cache #2464

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

eedalong
Copy link
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Optimize padding strategy when persistent cache is enabled, so we can enjoy performance boost with little extra compilaiton.

Experiment results

Around 10% e2e performance improvement for TorchAcc backend.

@@ -30,6 +30,15 @@ def get_bucket_sizes(max_length: int) -> List[int]:
if os.getenv('TORCHACC_DATA_BUCKETS') is not None:
bucket_sizes = [int(x) for x in os.getenv('TORCHACC_DATA_BUCKETS').split(',')]
bucket_sizes.append(max_length)
elif os.getenv('TORCHACC_CACHE_PATH') is not None: # padding strategy when persistent cache is enabled
p = 1.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add an environment variable for the p.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -30,6 +30,15 @@ def get_bucket_sizes(max_length: int) -> List[int]:
if os.getenv('TORCHACC_DATA_BUCKETS') is not None:
bucket_sizes = [int(x) for x in os.getenv('TORCHACC_DATA_BUCKETS').split(',')]
bucket_sizes.append(max_length)
elif os.getenv('TORCHACC_CACHE_PATH') is not None: # padding strategy when persistent cache is enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace the else block with this logic as defualt bucketing strategy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@eedalong eedalong force-pushed the optimize_pad branch 2 times, most recently from 8f81c68 to ebf50a2 Compare November 18, 2024 03:31
Copy link
Contributor

@anw90 anw90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jintao-Huang Jintao-Huang merged commit 5521907 into modelscope:main Nov 18, 2024
2 checks passed
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