Skip to content

[zero] Refactor ZeroContextConfig class using dataclass#3186

Merged
binmakeswell merged 1 commit intohpcaitech:mainfrom
yhna940:chore/zero-ctx
Mar 21, 2023
Merged

[zero] Refactor ZeroContextConfig class using dataclass#3186
binmakeswell merged 1 commit intohpcaitech:mainfrom
yhna940:chore/zero-ctx

Conversation

@yhna940
Copy link
Copy Markdown
Contributor

@yhna940 yhna940 commented Mar 21, 2023

📌 Checklist before creating the PR

  • I have created an issue for this PR for traceability
  • The title follows the standard format: [doc/gemini/tensor/...]: A concise description
  • I have added relevant tags if possible for us to better distinguish different PRs

🚨 Issue number

Link this PR to your issue with words like fixed to automatically close the linked issue upon merge

e.g. fixed #1234, closed #1234, resolved #1234

📝 What does this PR do?

This PR refactors the ZeroContextConfig class to use the dataclass decorator from Python's standard library. This change simplifies the code, improves readability, and reduces the possibility of bugs due to human error.

Motivation:

The dataclass decorator provides a more concise way to define classes with simple attributes, such as the configuration class.
It automatically generates common special methods, such as __init__, __repr__, and __eq__, reducing the need for boilerplate code.
Using dataclass also makes the code more Pythonic and easier to maintain.

Changes:

Refactor ZeroContextConfig class to use dataclass decorator
Update constructor arguments and their documentation
Add __post_init__ method for additional assertions
Please review and let me know if any changes are required. Thanks!

💥 Checklist before requesting a review

  • I have linked my PR to an issue (instruction)
  • My issue clearly describes the problem/feature/proposal, with diagrams/charts/table/code if possible
  • I have performed a self-review of my code
  • I have added thorough tests.
  • I have added docstrings for all the functions/methods I implemented

⭐️ Do you enjoy contributing to Colossal-AI?

  • 🌝 Yes, I do.
  • 🌚 No, I don't.

Tell us more if you don't enjoy contributing to Colossal-AI.

@binmakeswell binmakeswell requested a review from 1SAA March 21, 2023 03:39
@binmakeswell binmakeswell merged commit 80aed29 into hpcaitech:main Mar 21, 2023
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