Metadata-Version: 2.4
Name: arti-fit
Version: 3.2.0
Summary: Neural program graphs, tensor resources and task training workflows for PyTorch and JAX.
Author: Thiocy
License: MIT
License-File: AUTHORS.md
License-File: LICENSE
Keywords: latent-tensor,neural-networks,pytorch,representation-learning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: safetensors>=0.4
Requires-Dist: tomli>=2.0; python_version < '3.11'
Requires-Dist: torch>=2.2
Provides-Extra: all
Requires-Dist: accelerate>=0.33; extra == 'all'
Requires-Dist: build>=1.2; extra == 'all'
Requires-Dist: diffusers>=0.30; extra == 'all'
Requires-Dist: flax>=0.10; extra == 'all'
Requires-Dist: hatchling>=1.25; extra == 'all'
Requires-Dist: jax>=0.4.30; extra == 'all'
Requires-Dist: matplotlib>=3.8; extra == 'all'
Requires-Dist: mkdocs-material>=9.5; extra == 'all'
Requires-Dist: mkdocs>=1.6; extra == 'all'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'all'
Requires-Dist: numpy>=2.0; extra == 'all'
Requires-Dist: onnx>=1.16; extra == 'all'
Requires-Dist: onnxruntime<1.24,>=1.22; (python_version < '3.11') and extra == 'all'
Requires-Dist: onnxruntime>=1.22; (python_version >= '3.11') and extra == 'all'
Requires-Dist: onnxscript>=0.3; extra == 'all'
Requires-Dist: pandas>=2.0; extra == 'all'
Requires-Dist: peft>=0.12; extra == 'all'
Requires-Dist: pillow>=10.0; extra == 'all'
Requires-Dist: pytest>=8.0; extra == 'all'
Requires-Dist: ruff>=0.15.21; extra == 'all'
Requires-Dist: safetensors>=0.4; extra == 'all'
Requires-Dist: torch>=2.2; extra == 'all'
Requires-Dist: torchvision>=0.26; extra == 'all'
Requires-Dist: transformers>=4.51; extra == 'all'
Provides-Extra: bench
Requires-Dist: matplotlib>=3.8; extra == 'bench'
Requires-Dist: numpy>=2.0; extra == 'bench'
Requires-Dist: pandas>=2.0; extra == 'bench'
Requires-Dist: pillow>=10.0; extra == 'bench'
Requires-Dist: tensorboard>=2.18; extra == 'bench'
Requires-Dist: torch>=2.2; extra == 'bench'
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: hatchling>=1.25; extra == 'dev'
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: jsonschema<5,>=4.23; extra == 'dev'
Requires-Dist: numpy>=2.0; extra == 'dev'
Requires-Dist: onnx>=1.16; extra == 'dev'
Requires-Dist: onnxruntime<1.24,>=1.22; (python_version < '3.11') and extra == 'dev'
Requires-Dist: onnxruntime>=1.22; (python_version >= '3.11') and extra == 'dev'
Requires-Dist: onnxscript>=0.3; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.15.21; extra == 'dev'
Requires-Dist: tensorboard>=2.18; extra == 'dev'
Requires-Dist: torch>=2.2; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs>=1.6; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
Provides-Extra: flax
Requires-Dist: flax>=0.10; extra == 'flax'
Requires-Dist: jax>=0.4.30; extra == 'flax'
Provides-Extra: font
Requires-Dist: pillow>=10.0; extra == 'font'
Provides-Extra: jax
Requires-Dist: jax>=0.4.30; extra == 'jax'
Provides-Extra: peft
Requires-Dist: accelerate>=0.33; extra == 'peft'
Requires-Dist: peft>=0.12; extra == 'peft'
Requires-Dist: transformers>=4.51; extra == 'peft'
Provides-Extra: qwen
Requires-Dist: accelerate>=0.33; extra == 'qwen'
Requires-Dist: safetensors>=0.4; extra == 'qwen'
Requires-Dist: transformers>=4.51; extra == 'qwen'
Provides-Extra: sd
Requires-Dist: accelerate>=0.33; extra == 'sd'
Requires-Dist: diffusers>=0.30; extra == 'sd'
Requires-Dist: numpy>=2.0; extra == 'sd'
Requires-Dist: peft>=0.12; extra == 'sd'
Requires-Dist: pillow>=10.0; extra == 'sd'
Requires-Dist: safetensors>=0.4; extra == 'sd'
Requires-Dist: torchvision>=0.26; extra == 'sd'
Requires-Dist: transformers>=4.51; extra == 'sd'
Provides-Extra: serve
Requires-Dist: fastapi>=0.115; extra == 'serve'
Requires-Dist: uvicorn>=0.30; extra == 'serve'
Provides-Extra: torch
Requires-Dist: torch>=2.2; extra == 'torch'
Provides-Extra: web
Requires-Dist: onnx>=1.16; extra == 'web'
Requires-Dist: onnxscript>=0.3; extra == 'web'
Description-Content-Type: text/markdown

# ARTI

ARTI = AI x RT.

ARTI is a programmable neural runtime for PyTorch and JAX. Compose neural
programs with Formula Fabric, explicit tensor resources, learned connections,
local iteration and forward plasticity. Adapt an existing model or build a
standalone model, then train, resume, evaluate and deploy the same asset.

The PyPI distribution is `arti-fit`; the Python import is `arti`.

## Install

```bash
pip install "arti-fit==3.2.0"
pip install "arti-fit[qwen,serve]==3.2.0"  # language recipes and optional ASGI serving
pip install "arti-fit[jax,flax]==3.2.0"    # native JAX and optional Flax integration
```

Python 3.10+ is supported. PyTorch is a core dependency; model, JAX, Flax,
documentation and serving integrations are optional extras.

## One Training Workflow

Native models, attached programs and pretrained workflows use one session:

```python
import arti

# model is a configured native model or a host with trained ARTI parameters.
session = arti.trainer(model, objective=task_objective)
print(session.plan(steps=1000))
assert session.check(example_batch)["ok"]
result = session.fit(
    train_loader,
    steps=1000,
    run=arti.ARTITrainingRunConfig(output_dir="outputs/my-task"),
)
metrics = session.evaluate(validation_loader)
```

The local Torch profile saves the first update, periodic checkpoints and a final
checkpoint. Continuation retains optimizer, scheduler, supported RNG/scaler state
and the declared data cursor. Evaluation preserves model and ARTI state. The
host's task loss is the default; tensor alignment is an explicit alternative.

Use the [training guide](docs/guides/training-workflow.md) for native, attachment
and pretrained entrances, data-resume guarantees and export.

## Real Task Recipes

The same lifecycle is available from JSON/TOML:

```bash
arti recipe plan recipe.toml --output plan.json
arti recipe check recipe.toml
arti recipe train recipe.toml --run-dir outputs/first
arti recipe train recipe.toml --resume-from-checkpoint outputs/first/checkpoints/step-00000200/model.arti.st --steps 40 --run-dir outputs/continued
arti recipe evaluate recipe.toml --model outputs/continued/model --split test --output outputs/test.json
arti recipe predict outputs/continued/model --data requests.jsonl --output outputs/predictions.jsonl
arti recipe serve outputs/continued/model --port 8080
```

- [Classification](docs/guides/task-recipes.md): explicit train/validation/test
  records, train-only preprocessing, cross-entropy, metrics and portable batched
  prediction without the original dataset.
- [Qwen SFT](docs/guides/qwen-sft-workflow.md): complete conversation input,
  final-assistant/EOS supervision, target-token-weighted accumulation, pinned
  base revision, checkpoint continuation and tokenizer-bound deployment.
- Optional FastAPI/Uvicorn serving loads the asset once per worker and exposes
  `/predict`, `/chat`, `/health` and OpenAPI. It is a local ASGI integration,
  not an authenticated gateway or a vLLM/TensorRT-LLM export.

Runnable repository examples:

```bash
uv sync --extra dev --extra qwen --extra serve
python examples/classification_workflow.py --output .tmp/digits-workflow
python examples/qwen_sft_workflow.py --prepare-only --output .tmp/qwen-sft
```

Qwen planning loads native configuration/tokenization and a meta-device model,
not base weights or CUDA allocations. `check` deliberately performs a real
gradient preflight. The recipe's fixed Formula adaptation profile is one usable
composition, not a claim that all ARTI features or architecture search are enabled.

## Compose Neural Programs

`ARTILayer` hosts a configured `FederatedProgram` or `ProgramGraph`. An empty
layer is an exact identity, not an untrained adapter that pretends to know a task.

```python
import torch
import arti

layer = arti.ARTILayer()
x = torch.randn(2, 8, 64)
assert torch.equal(layer(x), x)

# Configure the graph or federation before attaching a useful program.
layer = arti.ARTILayer(graph=graph, graph_program_id="forward",
                      graph_input_resource_id="input",
                      graph_output_resource_id="output")
model = arti.ARTI.attach(model, layer, layers="model.layers.*")
session = model.arti.trainer(objective="model_loss")
```

The [developer guide](docs/guides/new-developer.md) and
[Formula Fabric guide](docs/guides/formula-fabric.md) cover typed operations,
named ports, routes, parallel stages, joins, loops, tensor resources and
compiler boundaries. [Learning boundaries](docs/guides/learning-boundaries.md)
allow independently owned optimizer domains and region-specific objectives.

Reusable operations live in `arti.mechanisms`. Retired layered Recall APIs live
only in `arti.legacy`. Component contracts use content-addressed provenance;
package versions and component identities are independent.

## Native JAX

`arti.jax` binds the same Formula/ProgramGraph declarations to native array
execution, with explicit parameter and forward-state PyTrees. Use `jit`, `grad`,
`vmap` and fixed-horizon `scan`; integrate custom native modules or Flax without
running Torch operations in a compiled JAX invocation.

```bash
uv sync --extra dev --extra jax --extra flax
python examples/jax_native_training.py
```

Read the [native JAX guide](docs/guides/jax-backend.md) for supported atoms,
resource state, native overrides and limitations. This is not full parity with
every Torch dynamic search, custom VJP or optimizer-domain engine.

## Assets And Support

ARTI uses SafeTensors and validated component/graph metadata instead of Python
pickle for its model assets. Frozen host weights remain separate from adapter
exports. Custom Python layers still require their reconstruction code.

[Stability](STABILITY.md) distinguishes supported workflow contracts from
experimental component surfaces. [Release checks](docs/guides/release.md)
cover software correctness, installation, documentation and privacy. They do
not imply general task superiority or universal acceleration.

```bash
uv run --extra dev python scripts/quality_gate.py quick --fail-fast
uv run --extra dev --extra qwen --extra serve python scripts/quality_gate.py recipes --fail-fast
```

MIT licensed. Designed and maintained by [Thiocy](https://github.com/Thiocy).
