Skip to main content

palingenesis

palingenesis

Post-train LLMs and agents from one config: SFT, multi-turn RL in tool environments, on-policy distillation, DPO and merging, with state-of-the-art defaults.

Documentation · Quickstart · Configs

From PyPI (Linux + NVIDIA GPU):

pip install "torch>=2.11" --index-url https://download.pytorch.org/whl/cu129   # FIRST: the CUDA 12.9 build (driver >= 575)
pip install "palingenesis[train,logging]"
pgs init sft                     # writes ./sft.yaml: set your model and dataset
pgs train --config sft.yaml

Install torch from PyTorch's CUDA index first. Plain pip install palingenesis on Linux otherwise pulls PyPI's default torch, built for the newest CUDA (13.x, driver >= 580): on an older driver it installs fine and then sees no GPU. Other CUDA versions: Installation.

From source (the locked, tested versions; the CUDA torch index is configured for you):

git clone https://github.com/mii-llm/palingenesis.git && cd palingenesis
uv sync --extra train --extra logging     # .venv with CUDA-enabled torch (+ --extra hybrid for Qwen3.5: faster, needed to pack)
source .venv/bin/activate
pgs train --config configs/quickstart.yaml

In a notebook or a script: palingenesis.train.train(config) on one GPU, see Training from a notebook. AMD GPUs (ROCm): Training on AMD GPUs.

What it does

Command Guide
Supervised fine-tuning, including agentic traces with tool calls and reasoning pgs train --config configs/quickstart.yaml Data, Agentic
Reinforcement learning: verifiable rewards, multi-turn tool use, GRPO-style groups, vLLM rollouts pgs rl --config configs/rl_math.yaml RL
Agent environments: Python classes, MCP servers, OpenEnv, NeMo Gym, Harbor tasks in Docker, with emulated harness dialects (opencode, pi, OpenHands, …) pgs rl --config configs/rl_harbor.yaml Harbor, Harness profiles
On-policy distillation: the student samples, one or more teachers score those tokens, reverse KL pgs distill --config configs/distill_math.yaml Distillation
Off-policy distillation: fixed data against one or more teachers' distributions (online, or a cached top-k), context distillation, hidden-state targets, multi-GPU, plugins for QAT pgs init kd && pgs train --config kd.yaml Off-policy distillation
Preference optimization: DPO, IPO, SLiC-HF, robust and length-normalised DPO, SFT anchor pgs train --config configs/dpo_qwen35_08b.yaml DPO
FP4 / FP8 quantisation-aware training (plugin): NVFP4, MXFP4, FP8 fake quantisation while distilling from the bf16 model (SFT, KD, OPD, RL); packed checkpoints vLLM serves; pgs quantize for PTQ pgs train --config configs/qat_nvfp4_qwen35_08b.yaml QAT
LoRA (plugin): frozen base, rank-r adapters (rsLoRA, DoRA, LoRA+), merged export and PEFT adapter; full fine-tuning stays the default pgs init lora && pgs train --config lora.yaml LoRA
Model merging: interpolation, soups, task arithmetic pgs merge interpolate START END --lam 0.3 -o OUT Merging
Data preparation: drop broken rows and duplicates, hold out an eval set, with the same config you train with pgs prepare --config configs/qwen35_4b/a100_80gb.yaml Data
Autopilot: profiles the GPU, sweeps the learning rate, trains to completion pgs autopilot --model Qwen/Qwen3.5-4B --dataset data.jsonl Autopilot

Highlights

  • Correct by construction. The loss path is checked step by step against a plain reference loop; packed conversations never see each other; multi-GPU gradients equal single-GPU ones; saved models load with plain from_pretrained.
  • Masking from the chat template itself. Whole assistant turns are trained as the template renders them, tool calls and end-of-turn tokens included; tools are rendered into the prompt; "loss": false keeps a message as context only.
  • Token-exact RL. What the trainer scores is exactly what the sampler produced, tool results included; nothing is re-tokenized. Rewards are checked answers, hidden tests, LLM judges or any Python function.
  • Memory. Chunked losses (the full logits are never materialised), selective activation checkpointing, gradient release, 8-bit optimizers. A Qwen3.5-4B fine-tune (attention pathway, 36% of the weights) fits in about 16 GiB. pgs fit measures which memory settings are the fastest that fit your GPU.
  • Long sequences on one GPU (SeCO). Chunk-by-chunk training with a cache gives the exact gradient, verified against full backpropagation on 23 architectures, including the Qwen3.5 and Qwen3-Next hybrids.
  • Mixture-of-Experts models. Routers are balanced in every trainer (load-balancing loss with the expert load measured over the global batch, router z-loss, DeepSeek-V3's selection-bias update), with per-layer load and entropy in the log; RL replays the experts the rollout engine chose. Gradients tested against the written-out losses on five families.
  • Training you can inspect. wandb and trackio with grad norm, spike and clip counters, gradient noise scale, entropy and the generalisation gap on one step axis; best-checkpoint tracking on eval loss.
  • Evaluation that agrees with training. pgs eval --model X --suite core runs tasks defined in YAML (GSM8K, MATH-500, MMLU, MMLU-Pro, IFEval, BBH, HumanEval, MBPP, function calling, Italian sets, your own, agentic environments, or task files of lm-evaluation-harness as they are) with the trainer's own prompt rendering, tool parsing and rewards, in each thinking mode: one engine per run, scoring next to generation, multiple choice with one prefill per question; pgs compare gives paired tests between two checkpoints.
  • Crash-safe. Re-run the same command to resume from the last complete checkpoint, in the same tracker run.
  • Scale out. FSDP across GPUs, multi-node SLURM with sharded checkpoints, and a container image for Kubernetes.
  • Research options, one line each. DEFT / DFT / InfoSFT token weighting, Hyperball, power-decay schedules: implemented to their papers' definitions; the benefits are as reported by the papers, not reproduced here.

Hardware

GPU Model Config
A100 40 GB Qwen3.5-4B, attention pathway (36% of weights) configs/qwen35_4b/a100_40gb.yaml
A100 80 GB Qwen3.5-4B, batch 4 configs/qwen35_4b/a100_80gb.yaml
H100 80 GB Qwen3.5-4B, FP8 configs/qwen35_4b/h100_80gb.yaml
8× A100 80 GB Qwen3.5-35B MoE configs/qwen35_35b_moe/a100_80gb_multigpu.yaml
./scripts/train_multi_gpu.sh configs/qwen35_4b/a100_80gb_multigpu.yaml           # one node, all GPUs
sbatch scripts/train_slurm.sh configs/qwen35_35b_moe/a100_80gb_multigpu.yaml     # SLURM

Containers and Kubernetes: docs/containers.md.

Development

pytest tests/                 # test suite
mkdocs serve                  # docs locally (pip install mkdocs-material)

License

Apache-2.0.

A new form emerging from what came before.

Metadata

Release files for palingenesis 0.3.1

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

Source distribution (sdist)

Source distribution for palingenesis 0.3.1
File Size Uploaded Provenance Actions
palingenesis-0.3.1.tar.gz 2.2 MB With provenance Details for palingenesis-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 3.9 MB

Release files / palingenesis-0.3.1.tar.gz

Download URL palingenesis-0.3.1.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
7374fed9f7f4281d50e33cd738a3772f68578b31380aad0da9f223ed02c5417b
BLAKE2b-256 checksum
How to use checksums
110fd766e06f9cdbbd77667baea86b02961e6c231731ff6731425d77bd5ff684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / palingenesis-0.3.1-py3-none-any.whl

Download URL palingenesis-0.3.1-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d746b8876593516e7e78e2c290b9d6a121837cf40f19f244a740def42f2fe113
BLAKE2b-256 checksum
How to use checksums
9f5b404dff833903eee7648514b20a727d4d38b03460a644a7258f5fd6268433
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for palingenesis 0.3.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for palingenesis-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

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