-
Notifications
You must be signed in to change notification settings - Fork 1
Fixes accelerator node counts and adds 3D topology support #43
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
12cde97
Fixes accelerator node counts and adds 3D topo support
JyotinderSingh 974d2db
single host tpu node pool requests should not include tpu_topology
JyotinderSingh 9e873aa
Improves error messages
JyotinderSingh df83dea
test fixes
JyotinderSingh 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| """Tests for keras_remote.cli.infra.program — TPU node pool creation.""" | ||
|
|
||
| from unittest import mock | ||
|
|
||
| from absl.testing import absltest, parameterized | ||
|
|
||
| from keras_remote.core.accelerators import TpuConfig | ||
|
|
||
| # Patch the pulumi_gcp module before importing program, so the module-level | ||
| # import inside program.py picks up the mock. | ||
| with mock.patch.dict("sys.modules", {"pulumi_gcp": mock.MagicMock()}): | ||
| from keras_remote.cli.infra import program | ||
|
|
||
|
|
||
| class TestCreateTpuNodePool(parameterized.TestCase): | ||
| """Verify _create_tpu_node_pool sets placement_policy correctly.""" | ||
|
|
||
| @parameterized.named_parameters( | ||
| dict( | ||
| testcase_name="v5p_multi_host", | ||
| tpu=TpuConfig("v5p", 8, "2x2x2", "tpu-v5p-slice", "ct5p-hightpu-4t", 2), | ||
| expect_placement=True, | ||
| ), | ||
| dict( | ||
| testcase_name="v6e_multi_host", | ||
| tpu=TpuConfig("v6e", 8, "2x4", "tpu-v6e-slice", "ct6e-standard-4t", 2), | ||
| expect_placement=True, | ||
| ), | ||
| dict( | ||
| testcase_name="v3_single_host", | ||
| tpu=TpuConfig("v3", 4, "2x2", "tpu-v3-podslice", "ct3-hightpu-4t", 1), | ||
| expect_placement=False, | ||
| ), | ||
| dict( | ||
| testcase_name="v5litepod_single_host", | ||
| tpu=TpuConfig( | ||
| "v5litepod", 4, "2x2", "tpu-v5-lite-podslice", "ct5lp-hightpu-4t", 1 | ||
| ), | ||
| expect_placement=False, | ||
| ), | ||
| ) | ||
| @mock.patch.object(program, "gcp") | ||
| def test_placement_policy(self, gcp_mock, tpu, expect_placement): | ||
| cluster = mock.MagicMock() | ||
| cluster.name = "test-cluster" | ||
|
|
||
| program._create_tpu_node_pool(cluster, tpu, "us-central2-b", "my-project") | ||
|
|
||
| call_kwargs = gcp_mock.container.NodePool.call_args | ||
| placement = call_kwargs.kwargs.get( | ||
| "placement_policy", call_kwargs[1].get("placement_policy") | ||
| ) | ||
|
|
||
| if expect_placement: | ||
| self.assertIsNotNone(placement) | ||
| gcp_mock.container.NodePoolPlacementPolicyArgs.assert_called_once_with( | ||
| type="COMPACT", | ||
| tpu_topology=tpu.topology, | ||
| ) | ||
| else: | ||
| self.assertIsNone(placement) | ||
|
|
||
| @mock.patch.object(program, "gcp") | ||
| def test_node_count_matches_config(self, gcp_mock): | ||
| tpu = TpuConfig("v5p", 16, "2x2x4", "tpu-v5p-slice", "ct5p-hightpu-4t", 4) | ||
| cluster = mock.MagicMock() | ||
| cluster.name = "test-cluster" | ||
|
|
||
| program._create_tpu_node_pool(cluster, tpu, "us-central2-b", "my-project") | ||
|
|
||
| call_kwargs = gcp_mock.container.NodePool.call_args | ||
| node_count = call_kwargs.kwargs.get( | ||
| "node_count", call_kwargs[1].get("node_count") | ||
| ) | ||
| self.assertEqual(node_count, 4) | ||
|
|
||
| @mock.patch.object(program, "gcp") | ||
| def test_pool_name_includes_tpu_name(self, gcp_mock): | ||
| tpu = TpuConfig("v5p", 8, "2x2x2", "tpu-v5p-slice", "ct5p-hightpu-4t", 2) | ||
| cluster = mock.MagicMock() | ||
| cluster.name = "test-cluster" | ||
|
|
||
| program._create_tpu_node_pool(cluster, tpu, "us-central2-b", "my-project") | ||
|
|
||
| positional_args = gcp_mock.container.NodePool.call_args[0] | ||
| self.assertEqual(positional_args[0], "tpu-v5p-pool") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| absltest.main() |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.