generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 69
Bug fixes for cluster creation and pytorch job #318
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
test/unit_tests/training/test_pytorch_job_template_model.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import unittest | ||
| from hyperpod_pytorch_job_template.v1_1.model import PyTorchJobConfig | ||
|
|
||
|
|
||
| class TestPyTorchJobConfigEFA(unittest.TestCase): | ||
| """Test EFA resource allocation in PyTorchJobConfig""" | ||
|
|
||
| def test_single_node_no_efa(self): | ||
| """Test that single-node jobs don't get EFA resources""" | ||
| config = PyTorchJobConfig( | ||
| job_name="test-single-node", | ||
| image="pytorch:latest", | ||
| node_count=1, | ||
| accelerators=2, | ||
| instance_type="ml.p4d.24xlarge" | ||
| ) | ||
|
|
||
| job = config.to_domain() | ||
| container = job.replicaSpecs[0].template.spec.containers[0] | ||
|
|
||
| # Should not have EFA resources | ||
| self.assertNotIn("vpc.amazonaws.com/efa", container.resources.requests) | ||
| self.assertNotIn("vpc.amazonaws.com/efa", container.resources.limits) | ||
|
|
||
| # Should have GPU resources | ||
| self.assertEqual(container.resources.requests["nvidia.com/gpu"], "2") | ||
|
|
||
| def test_multi_node_with_efa(self): | ||
| """Test that multi-node jobs automatically get EFA resources""" | ||
| config = PyTorchJobConfig( | ||
| job_name="test-multi-node", | ||
| image="pytorch:latest", | ||
| node_count=4, | ||
| accelerators=8, | ||
| instance_type="ml.p4d.24xlarge" | ||
| ) | ||
|
|
||
| job = config.to_domain() | ||
| container = job.replicaSpecs[0].template.spec.containers[0] | ||
|
|
||
| # Should have EFA resources | ||
| self.assertEqual(container.resources.requests["vpc.amazonaws.com/efa"], "1") | ||
| self.assertEqual(container.resources.limits["vpc.amazonaws.com/efa"], "1") | ||
|
|
||
| # Should also have GPU resources | ||
| self.assertEqual(container.resources.requests["nvidia.com/gpu"], "8") | ||
|
|
||
| def test_no_node_count_no_efa(self): | ||
| """Test that jobs without node_count don't get EFA resources""" | ||
| config = PyTorchJobConfig( | ||
| job_name="test-no-node-count", | ||
| image="pytorch:latest", | ||
| accelerators=1, | ||
| instance_type="ml.g5.xlarge" | ||
| ) | ||
|
|
||
| job = config.to_domain() | ||
| container = job.replicaSpecs[0].template.spec.containers[0] | ||
|
|
||
| # Should not have EFA resources | ||
| self.assertNotIn("vpc.amazonaws.com/efa", container.resources.requests) | ||
| self.assertNotIn("vpc.amazonaws.com/efa", container.resources.limits) | ||
|
|
||
| def test_multi_node_with_memory_and_cpu(self): | ||
| """Test EFA with other resource types""" | ||
| config = PyTorchJobConfig( | ||
| job_name="test-multi-resources", | ||
| image="pytorch:latest", | ||
| node_count=2, | ||
| accelerators=4, | ||
| vcpu=16.0, | ||
| memory=64.0, | ||
| instance_type="ml.p4d.24xlarge" | ||
| ) | ||
|
|
||
| job = config.to_domain() | ||
| container = job.replicaSpecs[0].template.spec.containers[0] | ||
|
|
||
| # Should have all resources including EFA | ||
| self.assertEqual(container.resources.requests["vpc.amazonaws.com/efa"], "1") | ||
| self.assertEqual(container.resources.requests["nvidia.com/gpu"], "4") | ||
| self.assertEqual(container.resources.requests["cpu"], "16.0") | ||
| self.assertEqual(container.resources.requests["memory"], "64.0Gi") | ||
|
|
||
| def test_accelerators_without_instance_type(self): | ||
| """Test that accelerators work without instance_type (fixes the main issue)""" | ||
| config = PyTorchJobConfig( | ||
| job_name="test-no-instance-type", | ||
| image="pytorch:latest", | ||
| accelerators=4 | ||
| # No instance_type specified | ||
| ) | ||
|
|
||
| job = config.to_domain() | ||
| container = job.replicaSpecs[0].template.spec.containers[0] | ||
|
|
||
| # Should respect accelerators value even without instance_type | ||
| self.assertEqual(container.resources.requests["nvidia.com/gpu"], "4") | ||
| # Limits should default to "0" since accelerators_limit not specified | ||
| self.assertEqual(container.resources.limits["nvidia.com/gpu"], "0") | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 1 the latest version? I think you're right, but just confirming if that's how Pintao set up cluster versioning I don't remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This task needs follow up when Pintao is back. Currently only 1 is supported as the latest version.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#285 This is the previous PR for template versioning.