ó
    �®žjp  ã                   ó²   • S SK r S SKrS SKrS SKJr  S SKJrJrJr  S SK	J
r
JrJr  S SKJrJr  \ R                   " \5      r " S S\\5      r " S S	\5      rg)
é    N)ÚEnum)Ú	AnnotatedÚAnyÚUnion)ÚFieldÚfield_validatorÚmodel_validator)ÚBaseSettingsÚSettingsConfigDictc                   ó,   • \ rS rSrSrSrSrSrSrSr	Sr
g	)
ÚAcceleratorDeviceé   zDevices to run model inferenceÚautoÚcpuÚcudaÚmpsÚxpu© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚAUTOÚCPUÚCUDAÚMPSÚXPUÚ__static_attributes__r   ó    Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docling/datamodel/accelerator_options.pyr   r      s   † Ù(à€DØ
€CØ€DØ
€CØ
ƒCr    r   c                   óÞ   • \ rS rSr% Sr\" SSSS9rSr\\	\
" SS	94   \S
'   Sr\\\\4   \
" SS	94   \S'   Sr\\\
" SS	94   \S'   \" S5      S 5       r\" SS9\S\S\4S j5       5       rSrg)ÚAcceleratorOptionsé   z|Hardware acceleration configuration for model inference.

Can be configured via environment variables with DOCLING_ prefix.
ÚDOCLING_Ú_T)Ú
env_prefixÚenv_nested_delimiterÚpopulate_by_nameé   a  Number of CPU threads to use for model inference. Higher values can improve throughput on multi-core systems but may increase memory usage. Can be set via DOCLING_NUM_THREADS or OMP_NUM_THREADS environment variables. Recommended: number of physical CPU cores.)ÚdescriptionÚnum_threadsr   a  Hardware device for model inference. Options: `auto` (automatic detection), `cpu` (CPU only), `cuda` (NVIDIA GPU), `cuda:N` (specific GPU), `mps` (Apple Silicon), `xpu` (Intel GPU). Auto mode selects the best available device. Can be set via DOCLING_DEVICE environment variable.ÚdeviceFa  Enable Flash Attention 2 optimization for CUDA devices. Provides significant speedup and memory reduction for transformer models on compatible NVIDIA GPUs (Ampere or newer). Requires flash-attn package installation. Can be set via DOCLING_CUDA_USE_FLASH_ATTENTION2 environment variable.Úcuda_use_flash_attention2c                 ó¦   • U[          Vs1 s H  o"R                  iM     sn;   d  [        R                  " SU5      (       a  U$ [	        S5      es  snf )Nz^cuda(:\d+)?$zLInvalid device option. Use `auto`, `cpu`, `mps`, `xpu`, `cuda`, or `cuda:N`.)r   ÚvalueÚreÚmatchÚ
ValueError)Úclsr0   Úds      r!   Úvalidate_deviceÚ"AcceleratorOptions.validate_deviceH   sS   € ð Õ&7Ó8Ò&7 —W”WÑ&7Ñ8Ó8¼B¿HºHØ˜e÷=
ñ =
ð ˆLÜðó
ð 	
ùò	 9s   ŠAÚbefore)ÚmodeÚdataÚreturnc                 ó,  • [        U[        5      (       aW  UR                  S5      nUcC  [        R                  " S5      n[        R                  " S5      nUc  Ub   [        U5      US'   U$ U$ ! [         a    [        R                  SU5         U$ f = f)aü  
Set num_threads from the "alternative" envvar OMP_NUM_THREADS.
The alternative envvar is used only if it is valid and the regular
envvar is not set.

Notice: The standard pydantic settings mechanism with parameter
"aliases" does not provide the same functionality. In case the alias
envvar is set and the user tries to override the parameter in settings
initialization, Pydantic treats the parameter provided in __init__()
as an extra input instead of simply overwriting the evvar value for
that parameter.
r,   ÚDOCLING_NUM_THREADSÚOMP_NUM_THREADSz1Ignoring misformatted envvar OMP_NUM_THREADS '%s')	Ú
isinstanceÚdictÚgetÚosÚgetenvÚintr3   Ú_logÚerror)r4   r:   Úinput_num_threadsÚdocling_num_threadsÚomp_num_threadss        r!   Úcheck_alternative_envvarsÚ,AcceleratorOptions.check_alternative_envvarsT   s™   € ô �dœD×!Ñ!Ø $§¡¨Ó 7Ðà Ñ(Ü&(§i¢iÐ0EÓ&FÐ#Ü"$§)¢)Ð,=Ó">�Ø&Ñ.°?Ñ3NðÜ.1°/Ó.B˜˜]Ñ+ð ˆˆtˆøô &ó ÜŸ
™
ØOØ+õð ˆðús   ÁA/ Á/ BÂBr   N)r   r   r   r   r   r   Úmodel_configr,   r   rD   r   Ú__annotations__r-   r   Ústrr   r.   Úboolr   r6   r	   Úclassmethodr   rJ   r   r   r    r!   r#   r#      sï   ‡ ññ
 &Ø°CÈ$ñ€Lð 	
ð �ØÙð&ñ	
ð		ñó 
ð. 	ð ˆIØˆcÐ$Ð$Ñ%Ùð;ñ	
ð		ñó ð. 	ð ˜yØÙðJñ	
ð		ñ ó ñ �XÓñ	
ó ð	
ñ ˜(Ñ#Øð¨Sð °Só ó ó $ór    r#   )ÚloggingrB   r1   Úenumr   Útypingr   r   r   Úpydanticr   r   r	   Úpydantic_settingsr
   r   Ú	getLoggerr   rE   rN   r   r#   r   r    r!   Ú<module>rW      sN   ðó Û 	Û 	Ý ß (Ñ (ç <Ñ <ß >à×Ò˜Ó"€ô˜˜Tô ôW˜õ Wr    