Skip to content

[Refactor] Schedule primitives#68

Merged
comaniac merged 6 commits intoawslabs:mainfrom
comaniac:refactor
Feb 22, 2023
Merged

[Refactor] Schedule primitives#68
comaniac merged 6 commits intoawslabs:mainfrom
comaniac:refactor

Conversation

@comaniac
Copy link
Contributor

Description

This PR refactors the schedule primitives to make them more systematic and extensible:

  • Now all primitives derived the base class Primitive that defines the required APIs (name, apply, and optional init_metadata).
  • The apply function takes the schedule as the first argument, followed by any primitive specific arguments.
  • The init_metadata allows each primitive to register their metadata, so the original schedule metadata only defines tie_weights metadata now. Meanwhile, we currently also put some metadata, such as the original shape before sharding, directly to nn.Parameter. I'll send a follow-up PR to better organize them.
  • All primitives are registered and maintained in a table, and they will be dynamically set to a schedule when it is constructed. In other words, users can register their primitives outside of the Slapo code base.

In addition this PR also

  • Move build related functions to build.py.
  • Rename get_output_type_after_sharding to postproc_sharding, because this function not only infers the output type but also changes the attributes (e.g., in_feature) after sharding.

Checklist

  • PR's title starts with a category (e.g. [Bugfix], [Model], [Tutorial], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

cc @chhzh123

Copy link
Contributor

@chhzh123 chhzh123 left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@comaniac comaniac merged commit 40fb031 into awslabs:main Feb 22, 2023
@comaniac
Copy link
Contributor Author

Thanks @chhzh123

@comaniac comaniac deleted the refactor branch February 22, 2023 23:39
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