-
Notifications
You must be signed in to change notification settings - Fork 657
[Feat](Mooncake) Supports multiple input suffixes for global_segment_size #3690
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
8 commits
Select commit
Hold shift + click to select a range
bde0c35
Supports multiple input suffixes for global_segment_size
Liziqi-77 a683669
change doc
Liziqi-77 08ffdfa
fix
Liziqi-77 1db3c8b
fix
Liziqi-77 7eaf89f
fix
Liziqi-77 0d4ffe6
fix
Liziqi-77 a5327d4
fix
Liziqi-77 01cc380
B
Liziqi-77 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import unittest | ||
|
|
||
| from vllm_ascend.distributed.mooncake.config_data import ( | ||
| _convert_to_bytes, _parse_global_segment_size) | ||
|
|
||
|
|
||
| class TestParseGlobalSegmentSize(unittest.TestCase): | ||
|
|
||
| def test_int_input(self): | ||
| self.assertEqual(_parse_global_segment_size(1024), 1024) | ||
| self.assertEqual(_parse_global_segment_size(0), 0) | ||
|
|
||
| def test_gb_unit(self): | ||
| self.assertEqual(_parse_global_segment_size("2GB"), 2 * 1024**3) | ||
| self.assertEqual(_parse_global_segment_size("1.5GB"), | ||
| int(1.5 * 1024**3)) | ||
| self.assertEqual(_parse_global_segment_size(" 2 GB "), 2 * 1024**3) | ||
|
|
||
| def test_gb_unit_edge_cases(self): | ||
| with self.assertRaises(ValueError): | ||
| _parse_global_segment_size("GB") | ||
| with self.assertRaises(ValueError): | ||
| _parse_global_segment_size("abcGB") | ||
|
|
||
| def test_mb_unit(self): | ||
| self.assertEqual(_parse_global_segment_size("512MB"), 512 * 1024**2) | ||
| self.assertEqual(_parse_global_segment_size("0.5MB"), | ||
| int(0.5 * 1024**2)) | ||
| self.assertEqual(_parse_global_segment_size("1024MB"), 1024 * 1024**2) | ||
|
|
||
| def test_kb_unit(self): | ||
| self.assertEqual(_parse_global_segment_size("256KB"), 256 * 1024) | ||
| self.assertEqual(_parse_global_segment_size("1.25KB"), | ||
| int(1.25 * 1024)) | ||
|
|
||
| def test_b_unit(self): | ||
| self.assertEqual(_parse_global_segment_size("4096B"), 4096) | ||
| self.assertEqual(_parse_global_segment_size("1024b"), 1024) | ||
|
|
||
| def test_no_unit(self): | ||
| self.assertEqual(_parse_global_segment_size("2048"), 2048) | ||
| self.assertEqual(_parse_global_segment_size("0"), 0) | ||
|
|
||
| def test_non_string_non_int_input(self): | ||
| self.assertEqual(_parse_global_segment_size(2048.0), 2048) | ||
| self.assertEqual(_parse_global_segment_size(True), 1) | ||
|
|
||
| with self.assertRaises(TypeError): | ||
| _parse_global_segment_size(None) | ||
|
|
||
| with self.assertRaises(TypeError): | ||
| _parse_global_segment_size({"size": 1024}) | ||
|
|
||
|
|
||
| class TestConvertToBytes(unittest.TestCase): | ||
|
|
||
| def test_valid_conversion(self): | ||
| self.assertEqual(_convert_to_bytes("10", 1, "10"), 10) | ||
| self.assertEqual(_convert_to_bytes("1.5", 1024, "1.5KB"), | ||
| int(1.5 * 1024)) | ||
| self.assertEqual(_convert_to_bytes("0", 1024**3, "0GB"), 0) | ||
|
|
||
| def test_invalid_numbers(self): | ||
| with self.assertRaises(ValueError): | ||
| _convert_to_bytes("abc", 1, "abc") | ||
|
|
||
| with self.assertRaises(ValueError): | ||
| _convert_to_bytes("1.2.3", 1024, "1.2.3KB") |
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.
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.
Should users be allowed to input "1G" instead of "1GB"?
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.
G is the colloquial form or abbreviation of GB. Would it be more appropriate to use the standard form here?
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.
It's okay to have examples