|
AQIT 0.1.0
|
Public Member Functions | |
| None | __init__ (self, str|None base_model=None, str|None run_name=None, dict[str, Any]|None config=None, *, str quant="none", str mode="external", str|Path|None run_dir=None) |
| None | log (self, int step, *, float loss, float|None learning_rate=None, float|None grad_norm=None, float|None momentum_norm=None, int|None epoch=None, int|None batch=None, int|None total_batches=None, float|None step_ms=None, **float extra) |
| None | observe (self, int step, str channel, float value) |
| None | signal (self, int step, str message, *, str severity="info") |
| None | checkpoint (self, Any model, int step) |
| None | finish (self, dict[str, Any]|None config=None) |
| str | run_id (self) |
Protected Member Functions | |
| None | _write_meta (self) |
| None | _write_metrics (self) |
| None | _write_obs (self) |
| None | _write_signals (self) |
| None | _write_config (self, dict[str, Any] config) |
Protected Attributes | |
| _run_id = str(uuid.uuid4()) | |
| str | _run_name = run_name or f"run-{self._run_id[:8]}" |
| str | _base_model = base_model or os.environ.get("AQUIN_BASE_MODEL") or "" |
| _started_at = time.time() | |
| str | _run_dir = Path(run_dir) if run_dir is not None else Path.cwd() / "aquin_run" |
| list | _metrics = [] |
| list | _obs = [] |
| list | _signals = [] |
| _metrics_lock = threading.Lock() | |
Records metrics and checkpoints locally during training.
Call aquin.init() to create one.
Writes under ``./aquin_run/`` (metrics, config, checkpoint).
Example
-------
run = aquin.init(
base_model="meta-llama/Llama-3.2-1B-Instruct",
run_name="my-run",
config={"lr": 2e-4, "epochs": 3, "rank": 16, "lora_alpha": 32,
"method": "qlora", "per_device_train_batch_size": 2,
"gradient_accumulation_steps": 8, "dataset": "data.jsonl"},
)
for step, batch in enumerate(dataloader):
loss = train_step(batch)
run.log(step, loss=loss.item(), learning_rate=scheduler.get_last_lr()[0],
grad_norm=grad_norm, epoch=epoch)
run.checkpoint(model, step=step)
run.finish()
| None aquin.run.Run.__init__ | ( | self, | |
| str | None | base_model = None, | ||
| str | None | run_name = None, | ||
| dict[str, Any] | None | config = None, | ||
| * | , | ||
| str | quant = "none", | ||
| str | mode = "external", | ||
| str | Path | None | run_dir = None ) |
|
protected |
|
protected |
Definition at line 169 of file run.py.
References _base_model, _run_dir, _run_id, _run_name, and _started_at.
|
protected |
Definition at line 179 of file run.py.
References _metrics, _metrics_lock, and _run_dir.
Referenced by checkpoint(), finish(), and log().
|
protected |
|
protected |
| None aquin.run.Run.checkpoint | ( | self, | |
| Any | model, | ||
| int | step ) |
Save the final model checkpoint. One per run : replaces the previous save.
Definition at line 142 of file run.py.
References _run_dir, _write_metrics(), and signal().
| None aquin.run.Run.finish | ( | self, | |
| dict[str, Any] | None | config = None ) |
Finalise the run. Flushes metrics and optional config to disk.
Definition at line 156 of file run.py.
References _started_at, _write_config(), and _write_metrics().
| None aquin.run.Run.log | ( | self, | |
| int | step, | ||
| * | , | ||
| float | loss, | ||
| float | None | learning_rate = None, | ||
| float | None | grad_norm = None, | ||
| float | None | momentum_norm = None, | ||
| int | None | epoch = None, | ||
| int | None | batch = None, | ||
| int | None | total_batches = None, | ||
| float | None | step_ms = None, | ||
| **float | extra ) |
Record metrics for one training step. Call every step inside your loop.
Definition at line 86 of file run.py.
References _metrics, _metrics_lock, and _write_metrics().
| None aquin.run.Run.observe | ( | self, | |
| int | step, | ||
| str | channel, | ||
| float | value ) |
Emit a custom scalar observation (eval metrics, etc.).
Definition at line 123 of file run.py.
References _metrics_lock, _obs, and _write_obs().
| None aquin.run.Run.signal | ( | self, | |
| int | step, | ||
| str | message, | ||
| * | , | ||
| str | severity = "info" ) |
Emit a non-scalar training signal (checkpoint saved, OOM, etc.).
Definition at line 130 of file run.py.
References _metrics_lock, _signals, and _write_signals().
Referenced by checkpoint().
|
protected |
Definition at line 67 of file run.py.
Referenced by _write_meta().
|
protected |
Definition at line 74 of file run.py.
Referenced by _write_metrics(), and log().
|
protected |
Definition at line 77 of file run.py.
Referenced by _write_metrics(), _write_obs(), _write_signals(), log(), observe(), and signal().
|
protected |
Definition at line 75 of file run.py.
Referenced by _write_obs(), and observe().
|
protected |
Definition at line 70 of file run.py.
Referenced by _write_config(), _write_meta(), _write_metrics(), _write_obs(), _write_signals(), and checkpoint().
|
protected |
Definition at line 65 of file run.py.
Referenced by _write_meta(), and run_id().
|
protected |
Definition at line 66 of file run.py.
Referenced by _write_meta().
|
protected |
Definition at line 76 of file run.py.
Referenced by _write_signals(), and signal().
|
protected |
Definition at line 68 of file run.py.
Referenced by _write_meta(), and finish().