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

feat(singleton): ensure singleton thread safety and no performance degradation #205

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

zigzagcai
Copy link
Collaborator

@zigzagcai zigzagcai commented Apr 18, 2024

Motivation

During very large-scale training (especially gpus numer >=1024), it would be a high probability that we get stuck when launching training processes. We found the root cause a deadlock within singleton implementation in multhreading scenarios.

Modification

Refine singleton implementation to ensure thread-safety and no performance degradation.
We use the double checked locking algorithm for singleton metaclass.

BC-breaking (Optional)

None

Use cases (Optional)

None

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects.
  • CLA has been signed and all committers have signed the CLA in this PR.

@zigzagcai zigzagcai changed the title feat(singleton): ensure singleton thread safety and guarantee no performance degradation feat(singleton): ensure singleton thread safety and ensure no performance degradation Apr 24, 2024
@zigzagcai zigzagcai changed the title feat(singleton): ensure singleton thread safety and ensure no performance degradation feat(singleton): ensure singleton thread safety and no performance degradation Apr 24, 2024
@zigzagcai
Copy link
Collaborator Author

zigzagcai commented Apr 25, 2024

This enhancement has also been adopted and merged by ColossalAI

hpcaitech/ColossalAI#5625

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.

None yet

2 participants