Metadata-Version: 2.4
Name: eole
Version: 0.6.8
Summary: Open language modeling toolkit based on PyTorch
Project-URL: Source, https://github.com/eole-nlp/eole/
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: licenses/dflash-MIT.txt
Requires-Dist: configargparse
Requires-Dist: ctranslate2<5,>=4
Requires-Dist: fastapi
Requires-Dist: fasttext-wheel
Requires-Dist: huggingface_hub
Requires-Dist: datasets
Requires-Dist: numpy>=2.0
Requires-Dist: pandas
Requires-Dist: protobuf==7.36.2
Requires-Dist: pyahocorasick
Requires-Dist: pyonmttok<2,>=1.38.1
Requires-Dist: pyyaml
Requires-Dist: rapidfuzz
Requires-Dist: rich
Requires-Dist: sacrebleu
Requires-Dist: safetensors
Requires-Dist: sentencepiece<=0.2.2,>=0.1.94
Requires-Dist: six
Requires-Dist: spacy
Requires-Dist: subword-nmt>=0.3.7
Requires-Dist: tensorboard>=2.18.0
Requires-Dist: tokenizers
Requires-Dist: torch<2.16,>=2.14.1
Requires-Dist: torchcodec
Requires-Dist: torch-optimi
Requires-Dist: uvicorn
Requires-Dist: waitress
Requires-Dist: pydantic
Provides-Extra: nvfp4
Requires-Dist: flashinfer-python<0.8,>=0.7.2; extra == "nvfp4"
Provides-Extra: ui
Requires-Dist: nvidia-ml-py>=12.0.0; extra == "ui"
Requires-Dist: psutil>=5.9.0; extra == "ui"
Provides-Extra: translation
Requires-Dist: pypdf>=5.0.0; extra == "translation"
Provides-Extra: ocr
Requires-Dist: PyMuPDF>=1.24.0; extra == "ocr"
Provides-Extra: rag
Requires-Dist: sentence-transformers[image]<7,>=6.1; extra == "rag"
Requires-Dist: transformers<6,>=5.20; extra == "rag"
Requires-Dist: langchain-community<0.5,>=0.4; extra == "rag"
Requires-Dist: langchain-text-splitters<2,>=1.1; extra == "rag"
Requires-Dist: langchain-chroma<2,>=1.1; extra == "rag"
Requires-Dist: pypdf>=5.0.0; extra == "rag"
Provides-Extra: wer
Requires-Dist: jiwer>=3.0; extra == "wer"
Requires-Dist: whisper-normalizer>=0.1; extra == "wer"
Provides-Extra: trackio
Requires-Dist: trackio<0.46.0,>=0.38.1; extra == "trackio"
Requires-Dist: nvidia-ml-py>=12.0.0; sys_platform != "darwin" and extra == "trackio"
Requires-Dist: psutil>=5.9.0; extra == "trackio"
Dynamic: description
Dynamic: description-content-type
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# EOLE

[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://eole-nlp.github.io/eole)

Eole is an open language modeling toolkit built on PyTorch, originally spun off
from OpenNMT-py. Train, fine-tune, evaluate, and serve encoder, decoder, and
encoder-decoder models in a compact, modular codebase built for experimentation.

Use it for language generation, machine translation, neural translation scoring,
vision and OCR, and speech recognition. Bring supported Hugging Face checkpoints
or train your own architecture.

**Start here:** [Run a small Qwen model](#quickstart-serve-a-small-chat-model) ·
[Open the browser workspace](recipes/ui/README.md) ·
[Train a Transformer](recipes/wmt17/README.md) ·
[Fine-tune Qwen with LoRA](recipes/finetuning/README.md) ·
[Find a recipe](recipes/README.md) ·
[See inference benchmarks](#qwen38-27b-speculative-decoding)

## Qwen3.8-27B speculative decoding

DFlash2 delivered **3.4× the greedy decode throughput** on the code workload.
Measured on one **RTX 5090** with the RedHat Qwen3.8-27B INT4 target, shared
INT8 vocabulary heads. DFlash2 uses seven draft tokens unless specified;
native MTP uses three draft tokens:

| Decoding mode | Code tok/s | English tok/s | Translation tok/s |
| --- | ---: | ---: | ---: |
| Ordinary greedy | 85.9 | 85.7 | 85.3 |
| Native MTP, 3 drafts | 191.1 | 136.9 | 180.2 |
| DFlash2, BF16 drafter | 221.7 | 139.3 | 208.4 |
| DFlash2, INT8 drafter with packed projections | 252.2 | 139.0 | 217.3 |
| DFlash2, INT8 drafter, 9 draft tokens | **289.8** | **152.9** | **256.7** |

Median warmed decode throughput over three runs per fixture; batch-one greedy,
64,000-token context capacity, 2,048-token output cap. Speed depends on proposal
acceptance and workload. See the [recipe](recipes/qwen38/dflash2/README.md) for
settings, supported scope and numerical limitations. All rows were rerun with
PyTorch 2.15.0 / Triton 3.9.0 and `TRITON_DEFAULT_FP_FUSION=1`.
See the [block-size sweep](recipes/qwen38/dflash2/README.md#block-size-sweep)
for the comparison of six through ten draft tokens.

DFlash2 output is not guaranteed bit-identical to single-token decoding; these
speed measurements are not a model-quality evaluation.

## A local workspace, included

Chat with text and images, translate documents, extract OCR Markdown, and ask
questions over a local document collection. Watch GPU usage and run a warmed
benchmark from the bundled browser UI, with no frontend build step.

![Eole workspace: Chat, Translate, Documents (OCR), Knowledge (RAG), Monitor and Benchmark](recipes/ui/images/showcase.gif)

[Watch the 39-second MP4 tour](recipes/ui/images/showcase.mp4) ·
[Chat workspace](recipes/ui/README.md) ·
[Hy-MT2 translation workspace](recipes/translation/README.md) ·
[Knowledge (RAG)](recipes/rag/README.md)

The edited tour uses real local results: RedHat Qwen3.8-27B INT4 for visual chat,
RAG answers and benchmarking, Hy-MT2-7B for translation, and DeepSeek-OCR for
page extraction. The complete workspace menu stays visible. Model loading and
compilation waits are omitted; the displayed generation measurements come from
Eole's inference worker on an RTX 5090. Benchmark numbers measure post-first-token
decode speed and depend on the prompt, settings and hardware.

## Latest: 0.6.8

- Serve concurrent text requests through the OpenAI Responses API with continuous batching, greedy decoding, MTP or DFlash2. Reuse matching prompt prefixes on subsequent requests.
- Reduce KV-cache memory with opt-in FP8 storage in standalone inference and continuous serving.
- Run supported NVFP4 checkpoints on Blackwell SM120, including mixed NVFP4/FP8 checkpoints with CUDA or Marlin FP8 projections.
- Fit more MoE weights in limited VRAM with adaptive GPU expert caching and CPU expert execution. Start with the [Qwen MoE recipe](recipes/qwen35/README.md).

Eole supports **PyTorch >= 2.14.1 and < 2.16**. The default Docker image uses
PyTorch 2.15.0 with CUDA 13.2.1. Start with the [workspace UI](recipes/ui/README.md),
[Qwen3.8 recipe](recipes/qwen38/README.md), or [Docker guide](docs/docker.md).
See the [changelog](CHANGELOG.md#068) for release details.

[![Deploy on RunPod](https://img.shields.io/badge/RunPod-Deploy%20Eole-673AB7?style=for-the-badge)](https://console.runpod.io/deploy?template=e9e19ozt9c&type=gpu)

Browser-based Chat, translation and OCR on a rented GPU. See the
[RunPod quick start](recipes/runpod/README.md) for password setup, GPU choices and
the required persistent-volume attachment. The `0.6.8` deployment
uses prebuilt GPU kernels and pre-converted public Eole checkpoints. Maintainers
publish the new images and update the public template before the button selects
this release.

## Choose your workflow

| I want to… | Start here |
|---|---|
| Run a supported HF model without a separate conversion step | [Direct HF inference](recipes/hf/README.md) |
| Deploy an authenticated Chat, translation and OCR workspace on a rented GPU | [RunPod deployment recipe](recipes/runpod/README.md) |
| Chat with a local LLM in your browser | [Local workspace UI](recipes/ui/README.md) |
| Translate through a web interface: text, terminology, subtitles, and documents | [Hy-MT2 translation workspace](recipes/translation/README.md) |
| Try Qwen3.8-27B with MTP speculative decoding | [Qwen3.8 and MTP](recipes/qwen38/README.md) |
| Try DFlash2 speculative decoding with Qwen3.8-27B | [DFlash2 recipe](recipes/qwen38/dflash2/README.md) or [workspace controls](recipes/ui/README.md#choose-off-mtp-or-dflash2) |
| Use Codex with a locally served Qwen model | [Codex Responses API](recipes/codex/README.md) |
| Serve concurrent coding sessions and compare latency | [Continuous Responses serving](recipes/serving/README.md) |
| Reduce KV-cache memory with FP8 | [Standalone inference](recipes/qwen38/README.md#fp8-kv-cache-for-standalone-inference), [continuous serving](recipes/serving/README.md#fp8-target-kv-cache) |
| Use Claude Code with a locally served Qwen model | [Claude Code endpoint](recipes/claude-code/README.md) |
| Ask questions about your documents with sources | [Local Knowledge / RAG workspace](recipes/rag/README.md) |
| Chat with images in the browser | [Qwen vision Chat workspace](recipes/ui/README.md#images-in-chat) |
| Try Qwen3.5 text and image inputs | [Qwen3.5](recipes/qwen35/README.md) |
| Train an English–German Transformer from scratch | [Translation tutorial](recipes/wmt17/README.md) |
| Translate with a pretrained multilingual model | [NLLB](recipes/nllb/README.md) |
| Generate text with Mistral | [Mistral](recipes/mistral/README.md) |
| Fine-tune a small chat model on one GPU | [Qwen LoRA](recipes/finetuning/README.md) |
| Fine-tune with a scorer reward | [REINFORCE](recipes/rl/README.md) |
| Score translations or use neural metrics during training | [COMET, KIWI, XCOMET, and MetricX](recipes/scoring/README.md) |
| Extract scanned PDFs through a web interface | [DeepSeek-OCR / HunyuanOCR Documents workspace](recipes/ui/README.md#documents-pdf-and-image-ocr) |
| Extract text from images and documents | [HunyuanOCR](recipes/hunyuanocr/README.md) or [DeepSeek-OCR](recipes/deepseekocr/README.md) |
| Transcribe audio | [Whisper](recipes/whisper/README.md) |
| Train a language model from scratch | [WikiText-103](recipes/wiki_103/README.md) or [FineWeb](recipes/fineweb10B/README.md) |
| Evaluate model quality or inference speed | [LiveCodeBench coding](recipes/livecodebench/README.md), [MMLU](recipes/mmlu/README.md), [model validator](recipes/model-validator/README.md), or [benchmarks](https://github.com/eole-nlp/eole/blob/main/benchmarks/genai/README.md) |

Browse the [full recipe index](recipes/README.md) for more workflows.

## Quickstart: serve a small chat model

Run from the repository root in a Python environment with a compatible CUDA
PyTorch installation and an NVIDIA GPU. See [installation](#installation) for
requirements and optional kernels.

```bash
git clone https://github.com/eole-nlp/eole
cd eole
python -m pip install -e . --no-build-isolation
export EOLE_MODEL_DIR="$PWD/models"
mkdir -p "$EOLE_MODEL_DIR"
eole convert HF --model_dir Qwen/Qwen3.5-0.8B \
  --output "$EOLE_MODEL_DIR/qwen3.5-0.8B"
eole serve -c recipes/server/serve.example.yaml --host 127.0.0.1
```

In a second terminal:

```bash
curl --fail-with-body http://127.0.0.1:5000/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"qwen3.5-0.8B","messages":[{"role":"user","content":"Explain machine translation in one sentence."}],"max_tokens":128,"temperature":0}'
```

The response contains the generated text in `choices[0].message.content`.
Interactive API documentation is available at `http://127.0.0.1:5000/docs`.
The [server recipe](recipes/server/README.md) explains streaming and the supported API formats.

## Features

- **Training and fine-tuning:** Transformer encoder, decoder, and encoder-decoder
  architectures, RNN encoder-decoder models, LoRA, quantized fine-tuning, dynamic
  data transforms, tensor parallelism, and mixed or pure BF16 training.
- **Efficient inference:** FlashAttention KV caching, CUDA and Triton kernels,
  fused projections, quantized dense and MoE inference, chunked prefill, prefix
  caching, and optional `torch.compile` / CUDA graphs. Availability depends on
  model, hardware, installed kernels, and configuration.
- **Multi-token prediction:** Auxiliary MTP heads for decoder-only training and
  native speculative decoding for compatible checkpoints, including Qwen3.8-27B.
  The Qwen recipe covers standalone greedy decoding and sampling.
- **Serving:** FastAPI server with native inference, OpenAI-style Chat and Responses,
  and Anthropic-style Messages. The dedicated Responses backend supports continuous
  greedy text serving with optional MTP, DFlash2, and FP8 target KV.
- **Evaluation:** BLEU, chrF, TER, perplexity, native COMET/KIWI/XCOMET and MetricX
  scorers, custom scorer modules, and scorer-based early stopping.
- **Reinforcement learning:** On-policy REINFORCE with registered scorer rewards,
  batch-mean baselines, and an optional frozen reference-model KL penalty.
  DPO, GRPO, and PPO are planned, not implemented.

## Supported Hugging Face model families

| Family / task | Examples and notes |
|---|---|
| Qwen | Qwen, Qwen2, Qwen3 (including MoE); Qwen3.5 text/vision; Qwen3.8-27B with MTP |
| Gemma | [Gemma 3 text quickstart](recipes/gemma3/README.md), Gemma 3 vision, and Gemma 4 support |
| Mistral | Mistral, Mixtral, Mathstral, and supported multimodal / Ministral variants |
| Llama and Phi | Llama3.x and Phi2/3 |
| Translation | [Hy-MT2-7B](recipes/translation/README.md) is the local workspace default. See also [NLLB](recipes/nllb/README.md). |
| OCR and vision | HunyuanOCR, DeepSeek-OCR, Pixtral, and supported vision-language checkpoints |
| Speech | Whisper |
| Translation scoring | COMET, COMET-KIWI, XCOMET, MetricX, and MetricX-QE |

Support is architecture-specific; this table does not imply every checkpoint,
quantization format, or modality in a family is supported. Consult the relevant
recipe and converter for the exact configuration. Supported HF checkpoints can
also be used [directly for inference](recipes/hf/README.md); conversion creates a reusable Eole artifact.

## Performance and reproducibility

See the [inference benchmarks](https://github.com/eole-nlp/eole/blob/main/benchmarks/genai/README.md) for example scripts and historical results (with incomplete environment metadata), and the [compilation guide](https://github.com/eole-nlp/eole/blob/main/TORCHCOMPILE_README.md) for
`torch.compile` configuration. Separate compilation/warmup from repeated warm
runs. Throughput depends on model, precision, prompt length, generation length,
and batch size; benchmark results are not a universal ranking of engines.

The [MTP recipe](recipes/qwen38/README.md) includes a baseline comparison and
acceptance diagnostics. GPU speedup and production BF16/quantized token parity
must be measured on the chosen checkpoint.

## Installation

### From source

- Python >= 3.11 (current CI uses Python 3.12).
- PyTorch >= 2.14.1 and < 2.16, with a CUDA build compatible with your GPU and driver.
- To compile CUDA extensions: the CUDA toolkit (`nvcc`), a compatible C++ compiler,
  and the build dependencies below. The CUDA runtime bundled with PyTorch alone
  does not provide `nvcc`.

Install CUDA-enabled PyTorch first in your chosen environment, then run from the
repository root:

```bash
python -m pip install "setuptools<69" wheel packaging ninja psutil
python -c 'import torch; print(torch.__version__, torch.version.cuda); print("GPU available:", torch.cuda.is_available())'
nvcc --version
MAX_JOBS=2 python -m pip install -e . --no-build-isolation
```

`setup.py` builds Eole's `eole._ops` CUDA extension, including normalization,
rotary embeddings, activations, and Marlin quantization kernels. It enables
the extension when PyTorch is installed and a GPU is visible, or when an explicit
`TORCH_CUDA_ARCH_LIST` is provided for a GPU-less CUDA-toolkit build. Official
Docker builds use the latter to bundle multi-architecture ops; see
[Docker instructions](docs/docker.md).
`--no-build-isolation` lets the build use that PyTorch installation. `MAX_JOBS`
limits compilation memory use; increase it if your machine has sufficient RAM.

### Build kernels for running directly from a clone

If your environment already contains Eole's Python dependencies and you prefer
to run scripts without installing the package, build the extension in place:

```bash
# Run from the repository root, with CUDA-enabled PyTorch and build tools above.
MAX_JOBS=2 python setup.py build_ext --inplace
export PYTHONPATH="$PWD${PYTHONPATH:+:$PYTHONPATH}"
python -m eole.bin.main --help
```

This builds `eole/_ops*.so`; it does not install Python dependencies or the
`eole` console command. Use `python -m eole.bin.main` in place of `eole` in recipes.
Rebuild after changing PyTorch, CUDA, Python, or extension sources. The current
build targets the visible GPU's compute capability; it is not a universal wheel
for every GPU architecture. A successful command on a CPU-only environment may
skip the extension entirely. Check it in the GPU environment:

```bash
python -c 'import torch; from eole import _ops; assert torch.cuda.is_available(); print("Eole CUDA extension loaded")'
```

### FlashAttention and hybrid-attention kernels

Install these separately in the same Python environment. FlashAttention is
optional for the small-model quickstart, which uses `self_attn_backend: pytorch`.
For recipes selecting `self_attn_backend: flash`, follow the
[FlashAttention installation requirements](https://github.com/Dao-AILab/flash-attention#installation-and-features):

```bash
MAX_JOBS=2 python -m pip install flash-attn --no-build-isolation
python -c 'from flash_attn import flash_attn_func, flash_attn_with_kvcache; print("FlashAttention interfaces loaded")'
```

Use a release or wheel compatible with your GPU, Python, PyTorch, and CUDA
versions. The Qwen3.8 measurements used FlashAttention 2.8.3; installing a newer
package alone does not reproduce that environment.

PyTorch selects the compatible Triton version on Linux. The default Docker
image uses PyTorch 2.15.0 and Triton 3.9.x.
For Qwen3.5/Qwen3.8 fast gated-delta computation, install
[FLA kernels (`fla-core`)](https://pypi.org/project/fla-core/):

```bash
python -m pip install "fla-core==0.6.0"
python -c 'from fla.ops.gated_delta_rule import chunk_gated_delta_rule, fused_recurrent_gated_delta_rule; print("FLA gated-delta interfaces loaded")'
```

Eole also supports the separate CUDA convolution package:

```bash
MAX_JOBS=2 python -m pip install causal-conv1d --no-build-isolation
```

When `causal-conv1d` is absent, Eole can use FLA's convolution implementation;
without either, it has a PyTorch fallback. FLA uses Triton kernels compiled at
runtime. Import checks confirm availability, not kernel execution or backend
selection; inspect the recipe's backend diagnostics during a GPU run. INT4
Marlin recipes require Eole's compiled CUDA extension.

Install other optional task dependencies as needed:

```bash
python -m pip install -r requirements.opt.txt
```

Use `HF_TOKEN` with `--token "$HF_TOKEN"` for checkpoints requiring Hugging Face
authentication. See individual recipes for model-specific requirements.

### Docker

Requires Docker, a compatible NVIDIA driver, and the
[NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).

Use a [published image](https://github.com/eole-nlp/eole/pkgs/container/eole) or
build an image from your checkout (the default is PyTorch 2.15.0 / CUDA 13.2.1).
Images include the Chat, Translate, Documents and Knowledge dependencies. The [Docker guide](docs/docker.md) covers GPU
prerequisites, local builds, CUDA kernels, model/data mounts, YAML inference and
training, and serving an API endpoint.

Release images contain that release's features; use a current checkout image for
newer features such as MTP. Eole's CUDA extension must be built with GPU access,
which a normal Docker image build does not provide.

## Documentation and contributing

- [Full documentation](https://eole-nlp.github.io/eole)
- [Recipes](recipes/README.md) and [release changelog](https://github.com/eole-nlp/eole/blob/main/CHANGELOG.md)
- [Training precision](https://github.com/eole-nlp/eole/blob/main/docs/training-precision.md)
- [Contributing](https://github.com/eole-nlp/eole/blob/main/CONTRIBUTING.md)

Use [Discussions](https://github.com/eole-nlp/eole/discussions) for questions and
feature proposals, and [Issues](https://github.com/eole-nlp/eole/issues) for bugs.
