Skip to main content

Aquin SDK

Record your training runs locally and observe them with Aquin — loss curves, learning rate, grad norm, epoch summaries, and web mirror sync via aquin session start + aquin watch.

License

The Aquin CLI and Aquin Engine are proprietary software owned by Aquin Labs Private Limited. Licensor retains all right, title, and interest in the Software; no ownership is transferred to you.

Use requires a valid API key that is personal to you and must not be shared. Licensor grants a limited, non-exclusive, non-transferable, revocable license for your own internal use only. You may not use the Software without an API key, redistribute or sublicense it, reverse engineer it, modify or create derivative works, or use it to build a competing product. API keys may be revoked at any time; upon revocation you must cease all use immediately. You must keep the Software confidential and not disclose it without prior written consent from Aquin Labs. This license terminates automatically on breach, API key revocation, or any attempt to circumvent license enforcement; upon termination you must cease use and destroy all copies. The Software is provided "as is" without warranty; liability is limited to fees paid in the prior twelve months.

Licensing inquiries: aquin@aquin.app, ash@aquin.app — https://aquin.app, aquinlabs.com

See the full AQUIN ENGINE — PROPRIETARY SOFTWARE LICENSE or run:

aquin license

On first use, aquin displays the license and requires you to accept (y) before any other command runs. Non-interactive acceptance after review: aquin --accept-license or AQUIN_LICENSE_ACCEPTED=1.

Install

pip install aquin

Quickstart

import aquin

run = aquin.init(
    base_model="meta-llama/Llama-3.2-1B-Instruct",
    run_name="my-lora-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 epoch in range(3):
    for step, batch in enumerate(dataloader):
        loss = train_step(batch)
        grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0).item()
        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()

Then replay or sync to the web mirror:

aquin session start --id my-run --model llama-3.2-1b   # register engine + session
aquin watch <run_id>              # local replay / live tail
aquin watch ingest --run <run_id> --file aquin_run/metrics.jsonl

With an active session, watch events appear on the Aquin web mirror in real time.

Post-training SAE (checkpoint diff, temp train, align)

After run.checkpoint() saves aquin_run/checkpoints/checkpoint.pt, run SAE tools on the real merged weights (not simulate's synthetic checkpoint):

aquin session start --id my-run --model llama-3.2-1b
aquin load sae llama-3.2-1b-l8

aquin sae diff --model llama-3.2-1b \
  --checkpoint aquin_run/checkpoints/checkpoint.pt \
  --prompts probes.jsonl --name my-run

aquin sae train --model llama-3.2-1b --layer 8 \
  --checkpoint aquin_run/checkpoints/checkpoint.pt \
  --quick --name my-run

aquin sae align \
  --sae-a ~/.aquin/sae/llama-3.2-1b/sae_layer8.pt \
  --sae-b ~/.aquin/sae/user/llama-3.2-1b/my-run/sae_layer8.pt

Docs: Checkpoint SAE. Watch ingests metrics only; simulate diffs a synthetic NTK checkpoint at forecast end.

API

aquin.init(base_model, run_name, config)

Starts a new run. Creates aquin_run/ in the current directory.

Param Description
base_model HuggingFace model ID, e.g. "meta-llama/Llama-3.2-1B-Instruct"
run_name Display name for the run
config Dict of training hyperparameters (optional, can also pass to finish())

run.log(step, *, loss, ...)

Record metrics for one training step. Call every step inside your loop.

Param Description
step Global training step (required)
loss Scalar training loss (required)
learning_rate Current LR — enables LR chart
grad_norm Gradient norm — enables grad norm chart
epoch Current epoch — enables epoch summary table
momentum_norm Optimizer momentum norm — enables momentum chart
step_ms Wall-clock time for this step in ms

run.checkpoint(model, step)

Saves the model checkpoint locally. One checkpoint per run — always replaces the previous save. Call once at the end of training. Stored under aquin_run/checkpoints/ for local analysis.

run.finish(config)

Flushes all metrics to disk. Pass config here if you didn't pass it to aquin.init().

CLI

aquin login       # save your API key
aquin session start --id <name> --model <id>   # connect engine + load model
aquin watch list  # list observed training runs
aquin sae help    # checkpoint SAE diff / train / align
aquin help        # full command list (mode-filtered)
aquin status      # account, API key, and session state

Using with HuggingFace Trainer / TRL

Use a TrainerCallback to hook into the training loop:

import time
from transformers import TrainerCallback

class AquinCallback(TrainerCallback):
    def __init__(self, run):
        self.run = run
        self._step_start = 0.0

    def on_step_begin(self, args, state, control, **kwargs):
        self._step_start = time.time()

    def on_log(self, args, state, control, logs=None, **kwargs):
        if not logs or "loss" not in logs:
            return
        self.run.log(
            step=state.global_step,
            loss=float(logs["loss"]),
            learning_rate=float(logs["learning_rate"]) if "learning_rate" in logs else None,
            grad_norm=float(logs["grad_norm"]) if "grad_norm" in logs else None,
            epoch=int(state.epoch) if state.epoch is not None else None,
            step_ms=round((time.time() - self._step_start) * 1000),
        )

    def on_train_end(self, args, state, control, **kwargs):
        model = kwargs.get("model")
        if model:
            self.run.checkpoint(model, step=state.global_step)

Building and publishing a new release

Prerequisites: Python 3.13, Nuitka, MSVC (Visual Studio Build Tools with Desktop C++ workload).

1. Compile to native extensions

cd cli
python scripts/build_nuitka.py
# Compiles engine/ + compute/ to .pyd, removes .py source, audits on finish

2. Build the wheel

python -m build --wheel
# Output: dist/aquin-<version>-py3-none-any.whl

3. Audit — confirm no source leaked

python scripts/build_nuitka.py --check
# Must print: Audit passed

4. Bump version before releasing Edit version in pyproject.toml, then repeat steps 1–3.

5. Distribute Send the wheel directly to users (pip install aquin-*.whl) or upload to R2 and share a signed link.

Notes:

  • .pyd files and dist/ are gitignored — never commit compiled artifacts
  • After building, engine/ and compute/ have no .py source locally either — keep a clean git working tree by running builds in a separate branch or restoring source from git after building
  • To rebuild from scratch: git restore cli/aquin/engine cli/aquin/compute then repeat from step 1

Metadata

Release files for aquin 3.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aquin 3.0.7
File Size Uploaded Provenance Actions
aquin-3.0.7.tar.gz 425.7 kB Without provenance Details for aquin-3.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aquin 3.0.7
File Interpreter ABI Platform Actions
aquin-3.0.7-py3-none-any.whl Python 3 none any Details for aquin-3.0.7-py3-none-any.whl

Total release size: 934.9 kB

Release files / aquin-3.0.7.tar.gz

Download URL aquin-3.0.7.tar.gz
Size 425.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7ff01080d3380dd20491bd52b89554af5de22750bcd469678b865130d5e24440
BLAKE2b-256 checksum
How to use checksums
d39cfabeaad7c5d4cbb6c4cf5f3ca77e66e61f8c8ef8b0603d8df75d49b36a34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / aquin-3.0.7-py3-none-any.whl

Download URL aquin-3.0.7-py3-none-any.whl
Size 509.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7027408feef8b3578ca7c25e43724a308afaddc99094867655712172dc386356
BLAKE2b-256 checksum
How to use checksums
5ee288330bc3fa1c3da2e8cee0f9df8d5e2ea8c49eea99b8b8e5cd2df9258207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for aquin 3.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page