
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SSKJr  S	rS
 r\R                   \R"                  " \R$                  R&                  5       " S S\R(                  5      5       5       rg)zCLists compatible accelerator profiles for GKE Inference Quickstart.    )util)base)commands)profiles_printer)
exceptions)log)resource_printerzx
To list compatible accelerator profiles for a model, run:

$ {command} --model=deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
c                 >    [        U 5      n[        X-
  S-  5      nX4$ )z5Converts a decimal representation to an Amount proto.g    eA)int)decimal_valueunitsnanoss      6lib/surface/container/ai/profiles/accelerators/list.pydecimal_to_amountr       s(     m
%
}$+
,%
    c                   .    \ rS rSrSr\S 5       rS rSrg)List)   a  List compatible accelerator profiles.

This command lists all supported accelerators with their performance details.
By default, the supported accelerators are displayed in a table format with
select information for each accelerator. To see all details, use
--format=yaml.

To get supported model, model servers, and model server versions, run `gcloud
alpha container ai profiles models list`, `gcloud alpha container ai
profiles model-servers list`, and `gcloud alpha container ai profiles
model-server-versions list`.
Alternatively, run `gcloud alpha container ai profiles
model-and-server-combinations list` to get all supported model and server
combinations.
c                 2   U R                  SSSS9  U R                  SSS9  U R                  SS	S9  U R                  S
[        SS9  U R                  SS[        SSS9  U R                  SS[        SSS9  U R                  SSS[        SS9  U R                  S[        SS9  [        R
                  " [        R                  [        R                  5        U R                  R                  [        R                  5        U R                  R                  S5        g )Nz--modelTz
The model.)requiredhelpz--model-serverzFThe model server. If not specified, this defaults to any model server.)r   z--model-server-versionzPThe model server version. If not specified, this defaults to the latest version.z--max-ntpot-millisecondsa  The maximum normalized time per output token (NTPOT) in milliseconds. NTPOT is measured as the request_latency / output_tokens. If this field is set, the command will only return accelerators that can meet the target ntpot milliseconds and display their throughput performance at the target latency. Otherwise, the command will return all accelerators and display their highest throughput performance.)typer   z'--target-cost-per-million-output-tokensFzfThe target cost per million output tokens to filter profiles by, unit is 1 USD up to 5 decimal places.)hiddenr   r   r   z&--target-cost-per-million-input-tokenszeThe target cost per million input tokens to filter profiles by, unit is 1 USD up to 5 decimal places.z--pricing-modelzsThe pricing model to use to calculate token cost. Currently, this supports on-demand, spot, 3-years-cud, 1-year-cud)r   r   r   r   z--formatz>The format to use for the output. Default is table. yaml|tableztable(acceleratorType,modelAndModelServerInfo.modelName,modelAndModelServerInfo.modelServerName,modelAndModelServerInfo.modelServerVersion,resourcesUsed.acceleratorCount,performanceStats.outputTokensPerSecond,performanceStats.ntpotMilliseconds))add_argumentr   floatstrr	   RegisterFormatterr   PROFILES_PRINTER_FORMATProfilePrinterdisplay_info	AddFormat)parsers    r   Args	List.Args<   sa   
  
        "5	   15  	 05  	 A  	 M   &&00'' !!"2"J"JK
!!	
r   c                 H   [         R                  " [        R                  R                  5      n[         R
                  " [        R                  R                  5      n UR                  UR                  UR                  UR                  UR                  UR                  S9nUR                  (       a%  [        UR                  5      u  pVUUl        UUl        UR                   (       a%  [        UR                   5      u  pVUUl        UUl        UR&                  R)                  U5      nUR*                  U l        U(       a  U$ / $ ! [,        R.                   aG  n[0        R2                  " SU 35        [0        R4                  R7                  SU 35        / s S nA$ S nAff = f)N)	modelNamemodelServerNamemodelServerVersion,performanceRequirements_maxNtpotMilliseconds)performanceRequirements_cost_pricingModelzAn error has occurred: )r   GetClientInstancer   ReleaseTrackALPHAGetMessagesModule%GkerecommenderAcceleratorsListRequestmodelmodel_servermodel_server_versionmax_ntpot_millisecondspricing_model%target_cost_per_million_output_tokensr   GperformanceRequirements_cost_costPerMillionNormalizedOutputTokens_unitsGperformanceRequirements_cost_costPerMillionNormalizedOutputTokens_nanos$target_cost_per_million_input_tokens<performanceRequirements_cost_costPerMillionInputTokens_units<performanceRequirements_cost_costPerMillionInputTokens_nanosacceleratorsr   commentsr   Errorr   errorstatusPrint)	selfargsclientmessagesrequestr   r   responsees	            r   RunList.Run   sn   ##D$5$5$;$;<F%%d&7&7&=&=>H%>>JJ++!667;7R7R484F4F ? g 
	3	3(66
  	W  	W 
	2	2(55
  	L  	L $$))'2h''dm		 	ii)!-.	jj045is%   C%E E F!<FF!F!)r<   N)	__name__
__module____qualname____firstlineno____doc__staticmethodr#   rH   __static_attributes__ r   r   r   r   )   s#      V Vp)r   r   N)rN   %googlecloudsdk.api_lib.ai.recommenderr   googlecloudsdk.callioper   googlecloudsdk.command_lib.runr   'googlecloudsdk.command_lib.run.printersr   googlecloudsdk.corer   r   googlecloudsdk.core.resourcer	   	_EXAMPLESr   DefaultUniverseOnlyReleaseTracksr,   r-   r   rQ   r   r   <module>r[      ss    J 6 ( 3 D * # 9	 D%%++,S8== S - Sr   