qgon
Tracks experiments, datasets and models, and sends runs to the device's GPU queue.
import qgon
run = qgon.init(project="Sandbox", name="hello") # team="vision" sets the team the run counts against (empty: the server decides)cfg = run.params({"lr": 0.05, "epochs": 10}) # hyperparameters (editable in the web app before a rerun)run.log("loss", 0.31, step=3) # curverun.log_metrics({"acc": acc}, step=ep, prefix="val") # grouped metrics (named val/acc; use this name as the HPO objective)run.save("result", {"acc": 0.93}) # artifact (file, dict, numpy, DataFrame and more)path = qgon.dataset("shapes", version="1.0.2") # dataset path (the mounted folder if mounted, else a downloaded copy; the version is recorded)m = qgon.model("resnet18-best") # find a registered model (name or id; recorded as an input model while a run is active)qgon.checkpoint({"model": net.state_dict(), "optimizer": opt.state_dict()}, epoch=ep + 1) # checkpointqgon.progress(step, total_steps) # progress (Hugging Face and Lightning: qgon.integrations)rp = qgon.resume_point() # the checkpoint if started with "Resume training" in the web app, else None# GPU yield: on request, the run exits with code 75 right after the next qgon.checkpoint and rejoins the queue to resumeqgon.on_yield(lambda: qgon.checkpoint({"model": net.state_dict()}, epoch=ep)) # or: if qgon.yield_requested(): ...path = m.get_local_copy() # download the model file
# Hyperparameter search: from a finished base run, in a separate script that does not call qgon.init()opt = qgon.hpo.optimize(base_run="<base run id>", space=[qgon.hpo.log_uniform("lr", 1e-4, 1e-1)], objective="val/acc", mode="max", max_runs=8)opt.wait(); print(opt.best())# Pipelines: @qgon.pipeline.step functions plus a @qgon.pipeline.pipeline(name=..., project=...) function# or finished experiments as steps: qgon.pipeline.run_spec({...spec...}) / qgon pipeline --spec spec.json# script steps (code folder and entry file) · create a draft only: qgon run --draft --queue gpu -- python prep.py
# Send to a GPU agent: uploads the code in the current folder and runs it from a queue (default gpu). CLI: qgon run --queue gpu -- python train.pyr = qgon.submit(["python", "train.py", "--lr", "0.01"], queue="gpu", project="Sandbox") # team="vision"print(r.id, r.url); code = r.wait() # follows the log and returns the exit code when the run ends
# Inference code (predict.py) for custom inference code in the Playgroundfrom qgon import servedef load(model_dir): ... # once; serve.model_file(model_dir) gives the model filedef predict(model, inp): return serve.labels(["cat", "dog"], [0.9, 0.1]) # or serve.boxes, masks, values# also: serve.keypoints(..., names="coco17") · serve.image(picture) · serve.text("...") · serve.combine(boxes, picture)# test locally before deploying: qgon serve test --entry predict.py --model best.pt --image a.jpg
# GPU queue: reorder, urgent requests, yield requests (admin actions need your own API key). CLI: qgon queue -hfrom qgon import queue as qq.order(); q.move("3fa8c2d1", "up"); q.urgent("3fa8c2d1", reason="demo in 30 minutes"); q.yield_task("5c77e0a9")After init(), argparse arguments, print output, PyTorch and TensorFlow model saves, and GPU utilization are recorded automatically.
import qgoninit
functionStarts a run, after which hyperparameters, console output, plots, models and GPU utilization are recorded on the server; team= sets the team the run counts against (empty: the server decides).
init( project: str = 'Default', name: Optional[str] = None, tags: Optional[Iterable[str]] = None, auto_log: bool = True, reuse: bool = False, team: Optional[str] = None,) -> RunFull description (Korean original)
team- 이 실행을 셀 팀, 하이퍼파라미터 qgon/team 에 남긴다. 비우면 서버가 정한다(워크스페이스 팀 → 주 팀). 이 실행을 화면에서 복제해 큐에 넣을 때 서버가 읽는다(소속이 아니면 거부). 에이전트에서 도는 중이면(원격) 바꾸지 않는다. 큐로 보낼 때의 팀은 qgon run --team 으로 정한다.
In the app · Build › Experiments
Returns the run started in this process (qgon.init or qgon run), or None if none has started; it still returns that run after run.finish() closes it, but nothing more is recorded to a closed run.
current() -> Optional[Run]Full description (Korean original)
run.finish() 로 닫은 뒤에도 그 실행을 돌려준다(닫힌 실행에는 더 기록하지 않는다).
In the app · Build › Experiments
Run
classA single run (experiment), wrapping the engine's task object.
Run(task: Task)| Member | What it does |
|---|---|
id -> str | The run id. |
url -> str | Address of this run in the qgon web app; it opens this run's details on the Experiments page. |
remote -> bool | True when an agent (remote GPU worker) is executing the run. |
params(values: Union[Mapping, Any], name: str='General') -> Any | Registers hyperparameters; when the run is executed again remotely, the values edited in the web app come back. |
log(name: str, value: float, step: int, series: Optional[str]=None) -> None | Records a scalar as a point on a curve; series draws several lines (such as train and val) on one plot. |
log_metrics(metrics: Mapping[str, float], step: int, prefix: Optional[str]=None) -> None | Records several scalars at one step. With prefix they become lines of the plot named prefix, called 'prefix/key' (prefix="val" gives val/acc, the name an HPO objective uses too). Without prefix each key gets its own plot. |
summary(name: str, value: float) -> None | Records a final single value, handy as a column when comparing experiments. |
log_table(name: str, rows: Sequence[Sequence[Any]], step: int=0) -> None | Records a table, given as a list of rows, under the given name. |
log_image(name: str, image: Any, step: int=0, caption: Optional[str]=None) -> None | Records an image (such as a PIL image or NumPy array) under the given name, with an optional caption. |
log_confusion(name: str, matrix: Any, labels: Optional[Sequence[str]]=None, step: int=0) -> None | Records a confusion matrix, with optional class labels on both axes (predicted and true). |
text(msg: str) -> None | Writes a line of text to the run's console log. |
save(name: str, obj: Any) -> None | Uploads an artifact: a file path, dict, NumPy array, pandas object and more. |
save_model(path: Union[str, Path], name: Optional[str]=None, tags: Optional[Iterable[str]]=None, publish: bool=False) -> str | Registers a model file in the model store and returns the model id. |
checkpoint(state=None, **kw) | Saves a checkpoint; the same as qgon.checkpoint. |
tag(*tags: str) -> None | Adds tags to the run. |
finish() -> None | Closes the run and stops recording to it. |
engine -> Task | The underlying engine task object, for advanced use. |
In the app · Build › Experiments
dataset
functionReturns a local path to a dataset version and records that version on the active run; a version the device has mounted (Use in workspace on the Datasets screen) is returned as a read-only folder instead of a downloaded copy.
dataset( name: str, version: Optional[str] = None, project: str = 'Datasets',) -> strFull description (Korean original)
장비가 그 버전을 펼쳐 두었으면(데이터 화면 '워크스페이스에서 쓰기') 내려받지 않고 읽기 전용 폴더를, 아니면 내려받은 사본 경로를.
In the app · Start › Datasets
publish_dataset
functionUploads a folder as a new dataset version and returns the dataset id; with parent_version, only changed files are uploaded.
publish_dataset( name: str, path: Union[str, Path], version: Optional[str] = None, project: str = 'Datasets', parent_version: Optional[str] = None, description: str = '',) -> strIn the app · Start › Datasets
model
functionFinds a model in the model store; download its file with m.get_local_copy().
model( name: Optional[str] = None, project: Optional[str] = None, tags: Optional[Iterable[str]] = None, published: Union[str, bool] = 'any', id: Optional[str] = None,) -> ModelFull description (Korean original)
name- 모델 이름 (화면 모델 목록의 이름). 32자리 id 를 주면 id 로 찾는다
project- 이 프로젝트에서만 (하위 프로젝트는 포함하지 않음). 없으면 모든 프로젝트
tags- 이 태그를 모두 가진 모델만
published- "any"(기본, 가장 최근 것) · "only"(확정된 것만, True 도 같음) · "prefer"(확정된 것이 있으면 그중 최근, 없으면 가장 최근)
id- 모델 id (화면 모델 상세의 ID), 주면 다른 조건은 보지 않는다
같은 조건의 모델이 여럿이면 가장 최근에 만든 것을 고르고 한 줄 경고를 낸다.
실행 중(qgon.init() 뒤)이면 그 실행의 입력 모델로 기록된다.
In the app · Deploy › Models
Model
classA model in the model store (read-only), returned by qgon.model().
Model(engine: InputModel, project_name: Optional[str]=None)| Member | What it does |
|---|---|
id -> str | The model id. |
name -> str | The model name. |
project -> Optional[str] | Name of the project the model belongs to. |
tags -> List[str] | The model's tags. |
published -> bool | True if the model is published. |
framework -> Optional[str] | The framework recorded with the model, if any. |
uri -> Optional[str] | Where the model file is stored (the URI on the model detail page). |
run_id -> Optional[str] | Id of the run that created this model. |
labels -> Dict[str, int] | The class-label-to-index mapping stored with the model. |
url -> str | Address of this model in the qgon web app; it opens this model's details on the Models page. |
get_local_copy(force: bool=False) -> str | Downloads the model file and returns its local path, reusing files already in the cache folder; a model saved as several files (a package) comes back as an extracted folder. |
engine -> InputModel | The underlying engine model object, for advanced use. |
In the app · Deploy › Models
default_queue
functionReturns the default queue for trials and pipeline steps: the QGON_QUEUE environment variable if set, otherwise gpu (the GPU queue members can use).
default_queue() -> strIn the app · Build › Scheduling
submit
functionUploads the code in the current folder and runs it on an agent through a queue (default gpu).
submit( command: Union[str, Sequence[str]], queue: Optional[str] = None, project: Optional[str] = None, name: Optional[str] = None, tags: Optional[Iterable[str]] = None, packages: Optional[Iterable[str]] = None, requirements: bool = True, image: Optional[str] = None, cwd: Optional[Union[str, Path]] = None, wait: bool = False, logs: bool = True, quiet: bool = False, env: Optional[str] = None, draft: bool = False, task_type: str = 'training', keep_args: bool = False, hyperparams: Optional[Dict[str, str]] = None, team: Optional[str] = None,) -> RemoteRunFull description (Korean original)
command- ["python", "train.py", "--lr", "0.01"] 또는 "python train.py --lr 0.01" (-m 모듈도 됨).
packages- 추가로 설치할 패키지. requirements=False 면 requirements.txt·pyproject 를 설치하지 않는다.
image- 작업 이미지 (고급, 관리자가 허용한 이미지만, 기본은 장비 작업 이미지).
env- 워크스페이스 저장 환경 버전, "3"·"v3"(지금 워크스페이스) 또는 "team-a:v3". image 와 함께 쓸 수 없다.
wait=True 면 끝날 때까지 기다린다(로그 출력). 반환: RemoteRun (.id · .url · .wait()).
draft=True- 큐에 넣지 않는다(상태 created). 숨김 하위 프로젝트 '<project>/.qgon-pipeline-steps', 태그 qgon-pipe-step. 큐 확인은 그대로 한다(그 큐로 보낼 단계의 원본). task_type: training | data_processing | custom.
keep_args=True- 명령줄 인자를 고정 인자로 둔다(실행에 Args 가 기록돼 있어도 넘긴다, 파이프라인 스크립트 단계).
hyperparams- 기록용 파라미터 {"구역/이름": 값} (예: qgon/datasets).
team- 이 실행을 셀 팀, 하이퍼파라미터 qgon/team. 비우면 서버가 정한다(워크스페이스 팀 → 주 팀). 소속이 아니거나 그 팀에 이 큐의 풀이 허용되지 않으면 큐에 넣을 때 거부된다(SubmitError).
In the app · Build › Scheduling
RemoteRun
classA run sent to a queue, with .id, .url, .status(), .wait() and .engine.
RemoteRun(task: Task, queue: str)| Member | What it does |
|---|---|
id -> str | The run id. |
url -> str | Address of this run in the qgon web app; it opens this run's details on the Experiments page. |
engine -> Task | The underlying engine task object, for advanced use. |
status() -> str | Fetches the run's current status from the server, such as queued, in_progress or completed. |
exit_code() -> Optional[int] | Returns the exit code once the run has ended (completed 0, failed the script's exit code or 1 if unknown, stopped 130), or None while it has not ended. |
wait(logs: bool=True, poll: float=3.0, timeout: Optional[float]=None, out: Optional[TextIO]=None) -> int | Waits for the run to end and returns its exit code, following the run log when logs=True; it raises TimeoutError after timeout seconds, returns EXIT_DEQUEUED (5) if the run is taken out of the queue back to a draft, and Ctrl-C stops only the waiting, not the run. |
In the app · Build › Scheduling
SubmitError
exceptionRaised when a remote run cannot be sent; the message (in Korean) says why.
SubmitError()In the app · Build › Scheduling
checkpoint
functionSaves a checkpoint and uploads it to the model store, where it appears in the run's checkpoint list in the web app.
checkpoint( state: Optional[Mapping[str, Any]] = None, *, epoch: Optional[int] = None, step: Optional[int] = None, metrics: Optional[Mapping[str, Any]] = None, path: Optional[Union[str, Path]] = None, name: Optional[str] = None, rng: bool = True, wait: bool = True, keep_local: int = 1, strict: bool = False,) -> CheckpointFull description (Korean original)
state- 저장할 dict (보통 {"model": …state_dict(), "optimizer": …, "scheduler": …}), torch.save 로 쓴다
path- state 대신, 이미 만든 파일 하나를 그대로 올린다 (다른 프레임워크)
epoch·step- 지금까지 끝낸 에폭 수·스텝 수, 이어서 학습할 때 rp.epoch 로 돌아온다
metrics- 이 시점 지표 {"val/accuracy": 0.91}, 화면 목록에 보인다 (최대 20개)
rng- 난수 상태(Python·NumPy·torch·CUDA)를 함께 저장 (state 일 때만)
wait- 올라갈 때까지 기다린다 (기본). False 면 백그라운드로 하나씩 올리고(끝날 때 기다림) ck.ok 는 None
keep_local- 로컬에 남길 최근 체크포인트 수 (기본 1, 올라간 뒤 정리)
strict- 올리기가 RETRIES(3)번 모두 실패하면 예외 (기본은 경고하고 학습 계속, ck.ok=False·ck.error, 모델에 qgon_ckpt_error 를 남기고 화면엔 '업로드 미완료')
In the app · Build › Experiments
resume_point
functionReturns the checkpoint to resume training from, or None if there is none.
resume_point( path: Optional[Union[str, Path]] = None, weights_only: bool = True,) -> Optional[ResumePoint]Full description (Korean original)
- 화면·API 의 '이 체크포인트부터 이어서 학습'으로 시작한 실행이면 그 체크포인트를 받아(엔진 캐시) 돌려준다. (그 실행을 다시 복제하거나 HPO 기준으로 쓰면 복제본은 처음부터, 이어 받기는 화면이 정한 그 실행에서만)
- path 를 주면(직접 실행 때 --resume 인자 등) 그 로컬 파일. 파일이 없으면 None 이 아니라 오류.
In the app · Build › Experiments
wait_uploads
functionWaits until background uploads (wait=False) finish; it is also called automatically at exit.
wait_uploads() -> NoneIn the app · Build › Experiments
Checkpoint
dataclassThe result of qgon.checkpoint().
Checkpoint()| Field | Type | Notes |
|---|---|---|
id | Optional[str] | 모델 id (실행 없이 로컬에만 저장했으면 None) |
name | str | - |
path | str | 로컬 파일 (keep_local 을 넘으면 나중에 지워진다) |
uri | Optional[str] | 모델 저장소 위치 |
epoch | Optional[int] | - |
step | Optional[int] | - |
ok | Optional[bool] | 다 올라감(True) · 실패(False) · 백그라운드 진행 중(None) |
error | Optional[str] | - |
In the app · Build › Experiments
ResumePoint
dataclassA checkpoint to resume training from, returned by qgon.resume_point().
ResumePoint()| Field | Type | Notes |
|---|---|---|
path | str | - |
epoch | Optional[int] | - |
step | Optional[int] | - |
metrics | Dict[str, float] | - |
checkpoint_id | Optional[str] | 모델 id |
run_id | Optional[str] | 체크포인트를 만든(원래) 실행 |
source | str | server(화면 '이어서 학습') | path(직접 준 파일) |
| Member | What it does |
|---|---|
load(map_location: Any=None, restore_rng: bool=True, weights_only: bool=True) -> Any | Loads the file with torch.load, safely by default (weights_only=True); for a dict saved by qgon.checkpoint it also restores the random-number states and returns the dict without qgon's own entries. |
In the app · Build › Experiments
progress
functionReports progress: step is the number of finished steps, total the overall count (optional) and epoch the current epoch (optional).
progress(step, total=None, *, epoch=None) -> NoneIn the app · Build › Scheduling
on_yield
functionRegisters fn to be called at the next qgon.progress() after a yield request arrives (also usable as a decorator); the process then exits with code 75, right after the upload if fn calls qgon.checkpoint(...), otherwise so that the run resumes from the last checkpoint.
on_yield(fn: Callable[[], None]) -> Callable[[], None]In the app · Build › Scheduling
yield_requested
functionTells whether a GPU yield request has arrived for this run, using the value a background thread last read; calling it does not ask the server.
yield_requested() -> boolIn the app · Build › Scheduling