aiauto-client 0.1.14__py3-none-any.whl → 0.1.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aiauto/core.py CHANGED
@@ -188,11 +188,24 @@ class StudyWrapper:
188
188
  parallelism: int = 2,
189
189
  requirements_file: Optional[str] = None,
190
190
  requirements_list: Optional[List[str]] = None,
191
- resources_requests: Optional[Dict[str, str]] = {"cpu": "256m", "memory": "256Mi"},
192
- resources_limits: Optional[Dict[str, str]] = {"cpu": "256m", "memory": "256Mi"},
191
+ resources_requests: Optional[Dict[str, str]] = None,
192
+ resources_limits: Optional[Dict[str, str]] = None,
193
193
  runtime_image: Optional[str] = 'ghcr.io/astral-sh/uv:python3.8-bookworm-slim',
194
194
  use_gpu: bool = False
195
195
  ) -> None:
196
+ # 리소스 기본값 설정
197
+ if resources_requests is None:
198
+ if use_gpu:
199
+ resources_requests = {"cpu": "2", "memory": "4Gi"}
200
+ else:
201
+ resources_requests = {"cpu": "1", "memory": "1Gi"}
202
+
203
+ if resources_limits is None:
204
+ if use_gpu:
205
+ resources_limits = {"cpu": "2", "memory": "4Gi"}
206
+ else:
207
+ resources_limits = {"cpu": "1", "memory": "1Gi"}
208
+
196
209
  if runtime_image is None or runtime_image == "":
197
210
  if use_gpu:
198
211
  runtime_image = "pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime"
aiauto/serializer.py CHANGED
@@ -59,9 +59,12 @@ def object_to_json(obj: Union[object, dict, None]) -> str:
59
59
 
60
60
  # __init__의 실제 파라미터인지 확인
61
61
  if param_name in valid_params:
62
- # PatientPruner의 wrapped_pruner 특별 처리
62
+ # PatientPruner의 wrapped_pruner 특별 처리
63
63
  if class_name == "PatientPruner" and param_name == "wrapped_pruner" and value is not None:
64
64
  kwargs[param_name] = json.loads(object_to_json(value))
65
+ # CmaEsSampler와 QMCSampler의 independent_sampler 특별 처리
66
+ elif param_name == "independent_sampler" and value is not None and class_name in ["CmaEsSampler", "QMCSampler"]:
67
+ kwargs[param_name] = json.loads(object_to_json(value))
65
68
  # Callable 타입은 제외 (gamma, weights 등)
66
69
  elif not callable(value):
67
70
  kwargs[param_name] = value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: AI Auto HPO (Hyperparameter Optimization) Client Library
5
5
  Author-email: AIAuto Team <ainode@zeroone.ai>
6
6
  Project-URL: Homepage, https://dashboard.common.aiauto.pangyo.ainode.ai
@@ -121,7 +121,7 @@ Jupyter Notebook이나 Python REPL에서 정의한 함수는 Serialize 할 수
121
121
  import aiauto
122
122
  import optuna
123
123
 
124
- def objective(trial: optuna.trial.Trial):
124
+ def objective(trial):
125
125
  """
126
126
  이 함수는 외부 서버에서 실행됩니다.
127
127
  모든 import는 함수 내부에 작성하세요.
@@ -170,7 +170,7 @@ time.sleep(5)
170
170
  # `https://dashboard.common.aiauto.pangyo.ainode.ai/study` 에서 생성된 study 확인 가능
171
171
 
172
172
  # objective 함수 정의
173
- def objective(trial: optuna.trial.Trial):
173
+ def objective(trial):
174
174
  """실제 실행은 사용자 로컬 컴퓨터가 아닌 서버에서 실행 될 함수"""
175
175
  x = trial.suggest_float('x', -10, 10)
176
176
  y = trial.suggest_float('y', -10, 10)
@@ -214,7 +214,7 @@ time.sleep(5)
214
214
 
215
215
  # objective 함수 정의
216
216
  # https://docs.pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html 참고
217
- def objective(trial: optuna.trial.Trial):
217
+ def objective(trial):
218
218
  """
219
219
  실제 실행은 사용자 로컬 컴퓨터가 아닌 서버에서 실행 될 함수
220
220
  모든 import는 함수 내부에 존재해야 함
@@ -224,6 +224,8 @@ def objective(trial: optuna.trial.Trial):
224
224
  from torch.utils.data import DataLoader, random_split, Subset
225
225
  from torchvision import transforms, datasets
226
226
  import torch.nn.functional as F
227
+
228
+ import optuna
227
229
 
228
230
  # 하이퍼파라미터 샘플링
229
231
  lr = trial.suggest_float('learning_rate', 1e-5, 1e-1, log=True)
@@ -315,7 +317,12 @@ study_wrapper.optimize(
315
317
  n_trials=100,
316
318
  parallelism=4,
317
319
  use_gpu=True, # GPU 사용
318
- requirements_list=['torch', 'torchvision'] # Pod에서 자동 설치
320
+ runtime_image='pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime', # default image for use_gpu True
321
+ # requirements_list=['torch', 'torchvision'] # Pod에서 자동 설치 # pip list 명시는 다운로드 받는데 느림, runtime_image 를 torch 로 명시하는게 나음
322
+ resources_requests={
323
+ "cpu": "2",
324
+ "memory": "4Gi",
325
+ },
319
326
  )
320
327
  time.sleep(5)
321
328
  ```
@@ -344,7 +351,7 @@ time.sleep(5)
344
351
 
345
352
  # objective 함수 정의
346
353
  # https://docs.pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html 참고
347
- def objective(trial: optuna.trial.Trial):
354
+ def objective(trial):
348
355
  """
349
356
  실제 실행은 사용자 로컬 컴퓨터가 아닌 서버에서 실행 될 함수
350
357
  모든 import는 함수 내부에 존재해야 함
@@ -446,7 +453,16 @@ study_wrapper.optimize(
446
453
  n_trials=100,
447
454
  parallelism=4,
448
455
  use_gpu=True, # GPU 사용
449
- requirements_list=['torch', 'torchvision', 'fvcore'] # Pod에서 자동 설치
456
+ runtime_image='pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime', # default image for use_gpu True
457
+ requirements_list=[ # pip list 명시는 다운로드 받는데 느림, runtime_image 를 torch 로 명시하는게 나음
458
+ # 'torch',
459
+ # 'torchvision',
460
+ 'fvcore',
461
+ ], # Pod에서 자동 설치
462
+ resources_requests={
463
+ "cpu": "2",
464
+ "memory": "4Gi",
465
+ },
450
466
  )
451
467
  time.sleep(5)
452
468
  ```
@@ -545,15 +561,15 @@ study = controller.create_study('exp1', direction='minimize')
545
561
  time.sleep(5)
546
562
 
547
563
  def objective(trial):
548
- import numpy as np
549
- x = trial.suggest_float('x', -10, 10)
550
- return (x - 1.23) ** 2
564
+ import numpy as np
565
+ x = trial.suggest_float('x', -10, 10)
566
+ return (x - 1.23) ** 2
551
567
 
552
568
  study.optimize(
553
- objective,
554
- n_trials=64,
555
- parallelism=8,
556
- requirements_list=['numpy'],
569
+ objective,
570
+ n_trials=64,
571
+ parallelism=8,
572
+ requirements_list=['numpy'],
557
573
  )
558
574
  time.sleep(5)
559
575
  ```
@@ -600,17 +616,17 @@ import optuna, aiauto, time
600
616
 
601
617
  controller = aiauto.AIAutoController('aiauto_xxx')
602
618
  study = controller.create_study(
603
- study_name='cnn',
604
- direction='minimize',
605
- sampler=optuna.samplers.TPESampler(seed=42),
606
- pruner=optuna.pruners.MedianPruner(n_startup_trials=5),
619
+ study_name='cnn',
620
+ direction='minimize',
621
+ sampler=optuna.samplers.TPESampler(seed=42),
622
+ pruner=optuna.pruners.MedianPruner(n_startup_trials=5),
607
623
  )
608
624
  time.sleep(5)
609
625
 
610
626
  def objective(trial):
611
- import numpy as np
612
- lr = trial.suggest_float('lr', 1e-5, 1e-1, log=True)
613
- return (np.log10(lr) + 2) ** 2
627
+ import numpy as np
628
+ lr = trial.suggest_float('lr', 1e-5, 1e-1, log=True)
629
+ return (np.log10(lr) + 2) ** 2
614
630
 
615
631
  study.optimize(objective, n_trials=50, parallelism=4)
616
632
  time.sleep(5)
@@ -0,0 +1,10 @@
1
+ aiauto/__init__.py,sha256=sF7sJaXg7-MqolSYLxsaXAir1dBzARhXLrHo7zLsupg,345
2
+ aiauto/_config.py,sha256=hTFh2bH9m-HuX6QCpNtBC0j6rEB0S97hhPKjbEjv4Tg,89
3
+ aiauto/constants.py,sha256=rBibGOQHHrdkwaai92-3I8-N0cu-B4CoCoQbG9-Cl8k,821
4
+ aiauto/core.py,sha256=Hz3HP6xJGey6LbF04cYQtPPqerf4LhDgt0BVBPPf0j4,10364
5
+ aiauto/http_client.py,sha256=v_nPdb-2tIeH1XrOYqzMGvFfXLKEDbQoSaQYPsB0Hik,2587
6
+ aiauto/serializer.py,sha256=BJmeq6uCD9D2_6bXu_sMBQLSsXCUMIMM10iX923DTXE,2749
7
+ aiauto_client-0.1.16.dist-info/METADATA,sha256=Lc0WSJ4UFunxbOLJWm-0K9thPPJl98ijomAJpvG2knI,25625
8
+ aiauto_client-0.1.16.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
9
+ aiauto_client-0.1.16.dist-info/top_level.txt,sha256=Sk2ctO9_Bf_tAPwq1x6Vfl6OuL29XzwMTO4F_KG6oJE,7
10
+ aiauto_client-0.1.16.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- aiauto/__init__.py,sha256=sF7sJaXg7-MqolSYLxsaXAir1dBzARhXLrHo7zLsupg,345
2
- aiauto/_config.py,sha256=hTFh2bH9m-HuX6QCpNtBC0j6rEB0S97hhPKjbEjv4Tg,89
3
- aiauto/constants.py,sha256=rBibGOQHHrdkwaai92-3I8-N0cu-B4CoCoQbG9-Cl8k,821
4
- aiauto/core.py,sha256=eEwit5oL8DIfglOVe2km_7MAtuZquEd5Xvkbq6EaW9o,9945
5
- aiauto/http_client.py,sha256=v_nPdb-2tIeH1XrOYqzMGvFfXLKEDbQoSaQYPsB0Hik,2587
6
- aiauto/serializer.py,sha256=cedmfJaoy-axG2jyFvUIVbyu9Fqen0hot6qDHnwSlGM,2466
7
- aiauto_client-0.1.14.dist-info/METADATA,sha256=nybQSHynZV0YCkHsqe4IZRIYPrBi3zKgHutlZXsJg8c,25022
8
- aiauto_client-0.1.14.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
9
- aiauto_client-0.1.14.dist-info/top_level.txt,sha256=Sk2ctO9_Bf_tAPwq1x6Vfl6OuL29XzwMTO4F_KG6oJE,7
10
- aiauto_client-0.1.14.dist-info/RECORD,,