Skip to main content

hermes-train

PyTorch training for Hermes LLMs. Architectures are defined in MAL (the Rust-side DSL in hermes-llm); this package trains them and emits safetensors checkpoints that hermes-llm serves directly — the tensor naming contract is shared (embedding.*, layers.{i}.attention.*, layers.{i}.feed_forward.*, final_norm.*, lm_head.*).

Pipeline

# 1. Export the architecture from MAL (Rust side owns the parser)
hermes-llm export --model tiny --output config.json          # preset
hermes-llm export --model my_model.mal --output config.json  # or MAL file

# 2. Train a BPE tokenizer (optional — any HF tokenizer.json works)
hermes-train train-tokenizer --input data.jsonl --output tokenizer.json --vocab-size 32000

# 3. Train (bf16, Muon+AdamW, grad accumulation, resumable)
hermes-train train --config config.json --tokenizer tokenizer.json \
    --data data.jsonl.zst --output checkpoints --batch-size 32 --epochs 1

# multi-GPU: same command under torchrun
torchrun --nproc-per-node 8 -m hermes_train.cli train --config config.json ...

# 4. DPO fine-tuning
hermes-train dpo --config config.json --tokenizer tokenizer.json \
    --data prefs.jsonl --checkpoint checkpoints/weights.safetensors --output checkpoints-dpo

# 5. Serve with the Rust side
hermes-llm generate --checkpoint checkpoints/weights.safetensors \
    --config config.json --tokenizer tokenizer.json --prompt "hello"

Training stack

  • Precision: bf16 autocast with fp32 master weights (fp32 fallback on CPU/MPS)
  • Optimizer: Muon (Newton–Schulz orthogonalized momentum) for 2D weight matrices, AdamW for embeddings/norms/head — the hybrid scheme used by Kimi K2 / GLM-scale runs
  • Schedule: WSD (warmup–stable–decay, the 2026 default) or cosine via --schedule; the flat plateau makes run extension and curricula sane
  • Data: JSONL with a text field; .gz / .zst supported; documents are tokenized, EOS-joined and packed into fixed windows
  • Document masking (default on): attention is block-diagonal across packed-document boundaries, SSM recurrent state resets at doc starts, and the reference path uses a segment-aware causal conv — doc 2 is provably independent of doc 1 (tested). The fused CUDA kernel (Mamba-1) has no seq_idx, so under the fused path SSM state crosses boundaries (warned once); attention layers still mask correctly. --no-doc-masking disables.
  • Curriculum stages: repeat -d — each file trains sequentially under one LR schedule, so with WSD the decay lands on your final (highest-quality / task-specific) stage
  • QK-Norm: qk_norm: true in a MAL attention def adds per-head RMSNorm on Q/K before RoPE (OLMo2/Gemma-style stabilizer); tensors layers.{i}.attention.{q,k}_norm.weight in both engines
  • Checkpoints: weights.safetensors (Candle-compatible names) + training_state.json; Ctrl+C saves and exits, --resume continues
  • Distributed: DDP via torchrun (gradient sync); FSDP is a planned upgrade

Hybrid Transformer + Mamba

MAL expresses heterogeneous layer stacks: blocks whose mixer is a Mamba-1 selective SSM instead of attention, cycled via pattern::

ssm my_ssm { state_dim: 16, conv_kernel: 4, expand: 2 }
block mamba_block { ssm: my_ssm, ffn: my_ffn, norm: rmsnorm { eps: 1e-5 } }
model hybrid { ..., pattern: [mamba_block, mamba_block, attn_block] }

The Mamba state is a compact persistent memory (fixed size, O(1)/token); the attention layers provide exact retrieval. Training uses a reference fp32 scan by default; install the mamba extra (uv sync --extra mamba, CUDA only) and the fused selective_scan_fn kernel is used automatically on CUDA. SSM tensors live under layers.{i}.ssm.* (mamba-ssm naming) and load directly into hermes-llm generate, which serves incrementally: prompt prefill once, then one step per token (Mamba recurrent state + attention KV cache — no full recompute).

Metadata

Release files for hermes-train 1.8.57

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

Source distribution (sdist)

Source distribution for hermes-train 1.8.57
File Size Uploaded Provenance
hermes_train-1.8.57.tar.gz 103.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hermes-train 1.8.57
File Interpreter ABI Platform
hermes_train-1.8.57-py3-none-any.whl Python 3 none any Details

Total release size: 129.3 kB

Release files / hermes_train-1.8.57.tar.gz

Download URL hermes_train-1.8.57.tar.gz
Size 103.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5986a53d4cd927b807a947770dc8bfe738ac7f8e1afd4da17d42dcbd1249e857
BLAKE2b-256 checksum
How to use checksums
c1f7afeb5cc750d887c69d9dd793fd15530e24408b78376d5ace1e136eea59bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hermes_train-1.8.57-py3-none-any.whl

Download URL hermes_train-1.8.57-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99afb82f76ad338cc955185d923e95595a07fb073e5864cbb8033e8cdf2cd8c3
BLAKE2b-256 checksum
How to use checksums
59489bef1d01248823325bf52a4c2be25aaf0481dd3c87f92b4ff2999b404f4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for hermes-train 1.8.57

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.

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