Skip to content

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

Merged
sunpengsdu merged 1 commit intoInternLM:developfrom
zigzagcai:singleton-thread-safety
Jul 16, 2024
Merged

feat(singleton): ensure singleton thread safety and no performance degradation#205
sunpengsdu merged 1 commit intoInternLM:developfrom
zigzagcai:singleton-thread-safety

Conversation

@zigzagcai
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

zigzagcai commented Apr 25, 2024

This enhancement has also been adopted and merged by ColossalAI

hpcaitech/ColossalAI#5625

@zigzagcai zigzagcai closed this Jul 16, 2024
@zigzagcai zigzagcai reopened this Jul 16, 2024
@sunpengsdu sunpengsdu merged commit aa3e9c4 into InternLM:develop Jul 16, 2024
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