Skip to main content

A small tool package for qq

Project description

✨qqtools✨

PyPI Downloads PyPI - Monthly Downloads Python version

A lightweight library, crafted and battle-tested daily by qq, to make PyTorch life a little easier.

I’ve gathered the repetitive parts of my day-to-day work and refined them into this slim utility library. It serves as my personal toolkit for handling data, training, and experiments, designed to keep projects moving fast with cleaner code and smoother workflows (and hopefully yours too!).

Built for me, shared for you.

Requirements

  • torch>=2.0 for full functionality
    • Some components maintain backward compatibility with torch==1.x
    • Recommended: torch>=2.4
  • pyyaml>=6.0
    • Recommended to use YAML format for all configuration files.

This provides a unified approach to drive and manage all workflow operations.

To get started quickly, install it via pip:

pip install qqtools

Install with full features:

pip install qqtools[full]

Data Format Support

Non-torch formats:

qDict : Enhanced of basic Dict.
qScalaDict : Dict[str, num]. A dict that maps str to scala;
qListData : List[dict]. A list of dicts.

Torch-related data formats

qData
qBatchList

Simple Training Loop

For jupyter users

import qqtools as qt
qt.import_common(globals())

x = np.random.rand(100, 5)
y = np.random.rand(100)

# dataset wrap
xs = [ x[i] for i in range(len(x))]
ys = [ y[i] for i in range(len(y))]
data_list = [ qt.qData({'x': x[i], 'y':y[i]})  for i in range(len(x))] 
dataset = qt.qDictDataset(data_list=data_list)
dataloader = qt.qDictDataloader()

# model
model = qt.nn.qMLP([5,5,1], activation="relu")
loss_fn = torch.nn.MSELoss()
optimizer = torch.optim.AdamW(model.parameters(), lr=1.0e-4, weight_decay=0.01)

# device
device = torch.device("cuda")
model.to(device)

# loop
for epoch in range(100):
    for batch in dataloader:
        batch.to(device)
        out = model(batch.x)
        loss = loss_fn(out, batch.y)
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
    print(f"{epoch} {loss.item():4.6f}")

Individual Modules

The following modules are consumers of the core functionality provided by this package. Each is designed to be independent, allowing for sole import.

under plugins/

  • qchem
  • qpipeline
  • qhyperconnect
  • qexp (Linux only)

qexp Quick Start

qexp is a shared-root experiment queue for Linux GPU hosts.

Install optional experiment dependencies:

pip install qqtools[exp]

Basic commands:

qexp init --shared-root /mnt/share/myproject/.qexp --machine gpu-a
qexp submit --shared-root /mnt/share/myproject/.qexp --machine gpu-a --name demo -- python train.py --epochs 10
qexp agent start --shared-root /mnt/share/myproject/.qexp --machine gpu-a --background
qexp list --shared-root /mnt/share/myproject/.qexp --machine gpu-a
qexp machines --shared-root /mnt/share/myproject/.qexp --machine gpu-a
qexp top --shared-root /mnt/share/myproject/.qexp --machine gpu-a
qexp logs <task_id> --follow
qexp cancel <task_id>
qexp clean --dry-run
qexp clean --older-than-seconds 604800

Python API:

from qqtools.plugins import qexp

task = qexp.submit(
    qexp.load_root_config("/mnt/share/myproject/.qexp", "gpu-a"),
    command=["python", "train.py", "--epochs", "10"],
    name="demo",
)
print(task.task_id)

Release validation notes:

  • packaged Python API surface: from qqtools.plugins import qexp
  • packaged CLI surface: qexp
  • actual execution is supported on local Linux GPU hosts with tmux installed
  • non-Linux development is limited to parsing, rendering, and test validation flows

Test

tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qqtools-1.2.11.tar.gz (180.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qqtools-1.2.11-py3-none-any.whl (222.9 kB view details)

Uploaded Python 3

File details

Details for the file qqtools-1.2.11.tar.gz.

File metadata

  • Download URL: qqtools-1.2.11.tar.gz
  • Upload date:
  • Size: 180.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qqtools-1.2.11.tar.gz
Algorithm Hash digest
SHA256 590ad86bb4cefa1ae7d8fcd41604f3cf00b273c589e44761e83b4c6f1ea7b10a
MD5 64b542cd42ec0aa9405fd2f30264a655
BLAKE2b-256 1ce4edbeced09c7508d47735c6bf21304a656f4765c7364f39337a8686a6b331

See more details on using hashes here.

File details

Details for the file qqtools-1.2.11-py3-none-any.whl.

File metadata

  • Download URL: qqtools-1.2.11-py3-none-any.whl
  • Upload date:
  • Size: 222.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qqtools-1.2.11-py3-none-any.whl
Algorithm Hash digest
SHA256 d390c369d09ee0539ee94e06fb193ff6eea436b0fe4e22b8cadf8a43cb900c7e
MD5 7d9a5b8d2690d4e4556680f0989deb46
BLAKE2b-256 29551609d83f5f6bfb1729148b9486466cf09771f5d5dfd12ed4b7cdd3c38cdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page