Skip to content
qgonDEV DOCSSDK 0.3.31
ENKR

qgon.integrations.lightning

In the appBuild › Scheduling

PyTorch Lightning integration that reports training progress through qgon.progress.

from qgon.integrations.lightning import QgonProgressCallback
trainer = L.Trainer(max_epochs=10, callbacks=[QgonProgressCallback()])

It reports step = trainer.global_step, total = trainer.estimated_stepping_batches (left out when infinite or unknown) and epoch = trainer.current_epoch. In distributed training only global rank 0 reports. It looks for lightning (2.x) first and then pytorch_lightning, importing it only when the class is first accessed; without either, you get a plain class with the same methods for tests and direct calls.

The same callback handles GPU yield. In single-process training it marks the run as able to yield. When a yield request arrives, it saves a checkpoint with trainer.save_checkpoint at the end of the next batch, uploads it with qgon.checkpoint(path=...) and exits with code 75. If the upload fails, it stops through trainer.should_stop and exits at the end of training so the run resumes from the last checkpoint. To resume, use rp = qgon.resume_point(); trainer.fit(model, ckpt_path=rp.path if rp else None). Multi-process (distributed) training is not marked as able to yield and does not yield automatically.

import qgon.integrations.lightning

QgonProgressCallback

classchanged in 0.3.31

Lightning callback that reports progress through qgon.progress and handles GPU yield requests.

QgonProgressCallback()
Full description (Korean original)
from qgon.integrations.lightning import QgonProgressCallback
trainer = L.Trainer(max_epochs=10, callbacks=[QgonProgressCallback()])

step = trainer.global_step, total = trainer.estimated_stepping_batches(무한·모름이면 생략), epoch = trainer.current_epoch.
분산 학습이면 global rank 0 만 쓴다. lightning(2.x) → pytorch_lightning 순으로 찾고, 클래스를 꺼낼 때 처음 import 한다. 없으면 같은 메서드를 가진 일반 클래스(가짜 trainer 로 시험·직접 호출용).

GPU 양보: 같은 콜백이 한다: 학습 시작 때 프로세스 하나(trainer.world_size == 1)면 '양보 가능' 표시. 양보 요청이 오면 다음 배치 끝에 trainer.save_checkpoint(임시 .ckpt) → qgon.checkpoint(path=…) 로 올린 직후 종료 75. 올리지 못하면 trainer.should_stop 으로 멈추고 학습 끝에서 마지막 체크포인트부터 이어지도록 끝낸다. 이어서 학습: rp = qgon.resume_point(); trainer.fit(model, ckpt_path=rp.path if rp else None). 분산 학습(trainer.world_size > 1, WORLD_SIZE>1, torch.distributed world size>1)은 표시·자동 양보를 하지 않는다.

In the app · Build › Scheduling