Repository navigation
fix: Update token budget limits - Microsoft.AIInfraOptimization #10580
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
6 commits
Select commit
Hold shift + click to select a range
4bcc5ce
Update token budget limits
kkarmakarMS 6f2a74c
Update history and version
kkarmakarMS fb0d471
Update example and add test
kkarmakarMS 7d9828c
Add recording based test
kkarmakarMS f5f753d
Update description
kkarmakarMS 2eb3807
Fix descriptions
kkarmakarMS 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
65 changes: 65 additions & 0 deletions
65
...ization/tests/latest/recordings/test_aiinfraoptimization_recommendvmsku_long_context.yaml
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,65 @@ | ||
| interactions: | ||
| - request: | ||
| body: '{"model": {"headDim": 128, "maxContextLength": 1048576, "numKeyValueHeads": | ||
| 8, "numLayers": 32, "parameterCount": 8000000000, "weightPrecision": "BF16"}, | ||
| "targetVmSizes": ["Standard_NC24ads_A100_v4", "Standard_NC40ads_H100_v5"], "workload": | ||
| {"maxConcurrentRequestsPerReplica": 1, "tokenBudget": {"maxOutputTokens": 131073, | ||
| "promptTokens": 262144}}}' | ||
| headers: | ||
| Accept: | ||
| - application/json | ||
| Accept-Encoding: | ||
| - gzip, deflate | ||
| CommandName: | ||
| - aiinfraoptimization recommendvmsku | ||
| Connection: | ||
| - keep-alive | ||
| Content-Length: | ||
| - '348' | ||
| Content-Type: | ||
| - application/json | ||
| ParameterSetName: | ||
| - --location --model --workload --target-vm-sizes | ||
| User-Agent: | ||
| - AZURECLI/2.92.0 azsdk-python-core/1.37.0 Python/3.12.10 (Windows-11-10.0.26300-SP0) | ||
| method: POST | ||
| uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AIInfraOptimization/locations/eastus2/recommendVmSku?api-version=2026-06-01-preview | ||
| response: | ||
| body: | ||
| string: '{"options":[{"vmSize":"Standard_NC24ads_A100_v4","recommendationRank":1,"readiness":{"status":"VerificationRequired","reason":"Quota | ||
| or placement evidence must be verified before attempting deployment."},"topology":{"estimatedNodeCountPerReplica":1,"estimatedTotalNodeCount":1,"accelerator":{"model":"A100","countPerVm":1,"memoryGiBPerAccelerator":80}},"cost":{"currencyCode":"USD","vmHourly":3.673,"deploymentHourly":3.673,"source":"AzureRetail"},"documentationUrl":"https://learn.microsoft.com/en-us/azure/virtual-machines/sizes/gpu-accelerated/nca100v4-series"},{"vmSize":"Standard_NC40ads_H100_v5","recommendationRank":2,"readiness":{"status":"VerificationRequired","reason":"Quota | ||
| or placement evidence must be verified before attempting deployment."},"topology":{"estimatedNodeCountPerReplica":1,"estimatedTotalNodeCount":1,"accelerator":{"model":"H100 | ||
| NVL","countPerVm":1,"memoryGiBPerAccelerator":94}},"cost":{"currencyCode":"USD","vmHourly":6.98,"deploymentHourly":6.98,"source":"AzureRetail"},"documentationUrl":"https://learn.microsoft.com/en-us/azure/virtual-machines/sizes/gpu-accelerated/ncadsh100v5-series"}],"sizing":{"model":{"parameterCount":8000000000,"weightPrecision":"BF16"},"workload":{"maxConcurrentRequestsPerReplica":1,"contextLength":393217},"memory":{"modelWeightsGiB":14.9,"kvCacheGiBPerRequest":48.03,"kvCacheGiBTotal":48.03,"modelAndKvCacheGiB":62.93},"basis":{"parameterCountSource":"Request","modelWeightsCalculation":"EstimatedFromParameterCount","contextLengthSource":"Request"}}}' | ||
| headers: | ||
| cache-control: | ||
| - no-cache | ||
| content-length: | ||
| - '1515' | ||
| content-type: | ||
| - application/json; charset=utf-8 | ||
| date: | ||
| - Tue, 17 Nov 2026 06:45:46 GMT | ||
| expires: | ||
| - '-1' | ||
| pragma: | ||
| - no-cache | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains | ||
| x-cache: | ||
| - CONFIG_NOCACHE | ||
| x-content-type-options: | ||
| - nosniff | ||
| x-ms-operation-identifier: | ||
| - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=9e0b0df5-1f15-45f7-8e9f-e1be2997e32e/japaneast/5308e04f-0715-4b33-95a7-8776f1b9d1d5 | ||
| x-ms-providerhub-traffic: | ||
| - 'True' | ||
| x-ms-ratelimit-remaining-subscription-global-writes: | ||
| - '11999' | ||
| x-ms-ratelimit-remaining-subscription-writes: | ||
| - '799' | ||
| x-msedge-ref: | ||
| - 'Ref A: 0EB4B7219E7B46F7A0C98FD82A7F74A3 Ref B: TYO601100902042 Ref C: 2026-11-17T06:45:45Z' | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
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
50 changes: 50 additions & 0 deletions
50
...infraoptimization/azext_aiinfraoptimization/tests/latest/test_aiinfraoptimization_unit.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,50 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import json | ||
| import unittest | ||
| from types import SimpleNamespace | ||
| from unittest import mock | ||
|
|
||
| from azure.cli.core.aaz._command_ctx import AAZCommandCtx | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError | ||
| from azure.cli.core.mock import DummyCli | ||
| from azure.core import PipelineClient | ||
| from azure.core.pipeline.policies import ContentDecodePolicy | ||
|
|
||
| from azext_aiinfraoptimization.aaz.latest.aiinfraoptimization import Recommendvmsku | ||
|
|
||
|
|
||
| class RecommendvmskuTokenBudgetTest(unittest.TestCase): | ||
| # Checks the CLI's own token budget limits with the HTTP call stubbed, so it needs no recording. | ||
|
|
||
| @staticmethod | ||
| def _send(prompt_tokens, max_output_tokens): | ||
| client = PipelineClient(base_url='https://management.azure.com') | ||
| session = SimpleNamespace(http_response=SimpleNamespace(status_code=200), | ||
| context={ContentDecodePolicy.CONTEXT_NAME: {}}) | ||
| with mock.patch.object(AAZCommandCtx, 'get_http_client', return_value=client), \ | ||
| mock.patch.object(client, 'send_request', return_value=session) as send_request: | ||
| Recommendvmsku(cli_ctx=DummyCli())({ | ||
| 'subscription': '00000000-0000-0000-0000-000000000000', | ||
| 'location': 'eastus2', | ||
| 'workload': {'token_budget': {'prompt_tokens': prompt_tokens, | ||
| 'max_output_tokens': max_output_tokens}}, | ||
| }) | ||
| return json.loads(send_request.call_args.kwargs['request'].body) | ||
|
|
||
| def test_accepts_maximum_token_budget(self): | ||
| for prompt_tokens, max_output_tokens in ((2147483647, 0), (0, 2147483647)): | ||
| with self.subTest(prompt_tokens=prompt_tokens, max_output_tokens=max_output_tokens): | ||
| self.assertEqual(self._send(prompt_tokens, max_output_tokens)['workload']['tokenBudget'], | ||
| {'promptTokens': prompt_tokens, 'maxOutputTokens': max_output_tokens}) | ||
|
|
||
| def test_rejects_token_budget_above_maximum(self): | ||
| for option, prompt_tokens, max_output_tokens in (('prompt-tokens', 2147483648, 0), | ||
| ('max-output-tokens', 0, 2147483648)): | ||
| with self.subTest(option=option): | ||
| with self.assertRaisesRegex(InvalidArgumentValueError, | ||
| f"{option}: Invalid format: '2147483648' is greater than 2147483647"): | ||
| self._send(prompt_tokens, max_output_tokens) |
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.