This release is a pre-release and may not be stable for production use.
Taktiny
Taktiny modules are Python objects registered as JAX PyTrees. The library does not assume a particular model architecture or dataset format, and its components can be used independently.
The project is experimental and APIs may change.
Quickstart · Guides · API reference
What’s included
- Models:
ModuleandParameter, linear and convolutional layers, embeddings, normalization, recurrent layers, attention, and other neural network components. - Data: Grain-backed data loading, transforms, batching, and packing for caller-provided records.
- Training: An Optax-based trainer with evaluation, callbacks, gradient accumulation, and Orbax checkpoints.
- Sharding: Partition specifications and logical axis mappings for JAX device meshes.
- Adapters: LoRA, DoRA, AdaLoRA, LoHa, LoKr, and VeRA.
- Quantization: Quantization utilities backed by Qwix.
The data, training, and model APIs can also be used separately with existing JAX code.
Installation
Taktiny requires Python 3.12+ and JAX 0.10.2+.
Install with uv:
uv add git+https://github.com/solitariusai/taktiny.git@experiment
Or with pip:
pip install git+https://github.com/solitariusai/taktiny.git@experiment
Define a model
Modules hold their parameters directly and are registered as JAX PyTrees.
import jax
import jax.numpy as jnp
from taktiny import nn
class MLP(nn.Module):
def __init__(self, *, rngs: nn.Rngs):
self.hidden = nn.Linear(8, 32, rngs=rngs)
self.output = nn.Linear(32, 1, rngs=rngs)
def __call__(self, x):
return self.output(jax.nn.silu(self.hidden(x)))
model = MLP(rngs=nn.Rngs(0))
jit_model = jax.jit(model)
output = jit_model(jnp.ones((4, 8)))
assert output.shape == (4, 1)
Passing the model as an argument to a compiled function makes its parameters part of the function inputs rather than capturing them in a closure.
Prepare data and train
The following example trains the model above on in-memory records.
import numpy as np
import optax
from taktiny.data import DataLoader
from taktiny.trainer import DatasetConfig, Trainer, TrainingConfig
inputs = np.random.default_rng(0).normal(size=(32, 8)).astype(np.float32)
records = [{"x": x, "y": x.sum(keepdims=True)} for x in inputs]
loader = DataLoader(
records,
batch_size=8,
shuffle=True,
seed=0,
num_epochs=None,
)
def loss_fn(model, batch):
return jnp.mean((model(batch["x"]) - batch["y"]) ** 2)
trainer = Trainer(
model=model,
loss_fn=loss_fn,
training_config=TrainingConfig(
max_steps=20,
optimizer=optax.adam(1e-3),
log_interval=10,
),
dataset_config=DatasetConfig(
train_dataloader=loader,
),
)
trainer.train()
assert trainer.global_step == 20
Trainer accepts iterables of batches. Checkpointing is optional.
See the trainer guide for evaluation, saving, and resuming.
Apply an adapter
Adapters can be applied to matching module paths.
from taktiny.takt import LoRAAdapter, Takt
adapted = MLP(rngs=nn.Rngs(1))
adapted = Takt.apply_adapter(
adapted,
LoRAAdapter(
targets="hidden",
rank=4,
alpha=8,
rngs=nn.Rngs(2),
),
)
assert adapted(jnp.ones((4, 8))).shape == (4, 1)
targets accepts module-path regex patterns. Applying an adapter freezes
existing parameters and adds trainable adapter parameters.
See the PEFT guide.
Documentation
- Quickstart
- Data loading and transforms
- Sharding
- Training and checkpoints
- PEFT and adapters
- Tutorials
Development
Run the test suite on CPU:
make test
Project layout:
src/taktiny/
├── nn/ Modules, layers, parameters, and RNG utilities
├── data/ Loading and preprocessing
├── takt/ Adapter injection
├── trainer/ Training, evaluation, callbacks, and checkpoints
└── utils/ Sharding, transforms, quantization, and typing
License
Taktiny is distributed under the Apache License 2.0.
See LICENSE.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taktiny-0.0.1rc1.tar.gz.
File metadata
- Download URL: taktiny-0.0.1rc1.tar.gz
- Upload date:
- Size: 637.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9acbfecf6f7dfb6fc2ce7b445b27ded45566dd0f338851352ca6bbeb0b0ef8e4
|
|
| MD5 |
1355a1b3105d6c7bb327bfe452148d7a
|
|
| BLAKE2b-256 |
634b70b1506587510bda2a5de1264b6db1f9da81e1b1268b6715d593769c2310
|
Provenance
The following attestation bundles were made for taktiny-0.0.1rc1.tar.gz:
Publisher:
publish.yml on solitariusai/taktiny
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taktiny-0.0.1rc1.tar.gz -
Subject digest:
9acbfecf6f7dfb6fc2ce7b445b27ded45566dd0f338851352ca6bbeb0b0ef8e4 - Sigstore transparency entry: 2769050546
- Sigstore integration time:
-
Permalink:
solitariusai/taktiny@57e6d7428327a950d0f87caf82c57edc60d78c33 -
Branch / Tag:
refs/tags/v0.0.1rc1 - Owner: https://github.com/solitariusai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e6d7428327a950d0f87caf82c57edc60d78c33 -
Trigger Event:
release
-
Statement type:
File details
Details for the file taktiny-0.0.1rc1-py3-none-any.whl.
File metadata
- Download URL: taktiny-0.0.1rc1-py3-none-any.whl
- Upload date:
- Size: 167.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69d424d89d806c52395342627c487850ab85b35d65ee2d6097ab3f006fb6c259
|
|
| MD5 |
1cc5f0948d2772377c2fa3c8eef6ebb8
|
|
| BLAKE2b-256 |
1663f86001d71970b086a5cac69153373a51d8a2348ba840cfdc1394b7729a17
|
Provenance
The following attestation bundles were made for taktiny-0.0.1rc1-py3-none-any.whl:
Publisher:
publish.yml on solitariusai/taktiny
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taktiny-0.0.1rc1-py3-none-any.whl -
Subject digest:
69d424d89d806c52395342627c487850ab85b35d65ee2d6097ab3f006fb6c259 - Sigstore transparency entry: 2769050680
- Sigstore integration time:
-
Permalink:
solitariusai/taktiny@57e6d7428327a950d0f87caf82c57edc60d78c33 -
Branch / Tag:
refs/tags/v0.0.1rc1 - Owner: https://github.com/solitariusai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e6d7428327a950d0f87caf82c57edc60d78c33 -
Trigger Event:
release
-
Statement type: