MCPcopy Index your code
hub / github.com/Ugness/ELF-pytorch

github.com/Ugness/ELF-pytorch @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
125 symbols 429 edges 18 files 22 documented · 18% updated 54d ago★ 33
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ELF: Embedded Language Flows (Unofficial PyTorch Reproduction)

[!CAUTION]

The OpenWebText results are not directly comparable with baselines (MDLM, Duo, FLM, ...) due to tokenization and preprocessing differences used in the ELF paper.

Specifically, ELF uses a custom preprocessed OpenWebText dataset (see openwebtext-t5). This is tokenized with the T5 tokenizer, not the GPT-2 tokenizer which is used in the standard setting in the literature. In addition, the paper's preprocessing pipeline includes a custom packing scheme with full details not disclosed in the paper.


This is an unofficial PyTorch reproduction (OpenWebText Only) of ELF: Embedded Language Flows.\ The official JAX/TPU implementation is at https://github.com/lillian039/ELF, and the official checkpoints are in HuggingFace at embedded-language-flows.

This repository was developed using Claude Code.

Reproduction status

OpenWebText (unconditional), ELF-B (105M), 32-step SDE, γ=1.5, SC-CFG=3:

Metric Paper (TPU v5p-64) Reproduction (8× B200 DDP, Lightning)
Gen. PPL ↓ 24.1 25.61
Entropy 5.15 5.20

Per-epoch results (32-step SDE, 256 samples):

Epoch Step Gen. PPL Entropy
1 38 034 2.73 0.70
2 76 068 37.11 5.17
3 114 102 28.63 5.21
4 152 136 25.00 5.16
5 190 170 25.58 5.19
6 228 204 26.11 5.21

All samples used for the measurements can be found in reproduction/elf_b-owt/eval1000/metrics.jsonl and reproduction/elf_b-owt/per_epoch/metrics.jsonl.

TODO

  • [ ] Train ELF and/or some of the baselines (MDLM, Duo, FLM, ...) in a directly comparable setting (https://huggingface.co/datasets/Skylion007/openwebtext).

What's in this repo

  • pytorch_lightning/: model, training script (train_lightning.py), eval (eval_lightning.py), and utilities. 8-GPU CUDA DDP via PyTorch Lightning.
  • reproduction/elf_b-owt/: config snapshot, 1000 final samples, and per-epoch samples. The checkpoint is hosted separately (see Quickstart).

Quickstart — evaluate the reproduced checkpoint

# 1. Environment (conda)
conda env create -f environment.yml -n elf-pytorch && conda activate elf-pytorch

# 2. Download the reproduced final EMA checkpoint (1.4 GB)
pip install huggingface_hub
huggingface-cli download Ugness/elf-torch last.ckpt \
    --local-dir reproduction/elf_b-owt/

# 3. Run the 1000-sample evaluation
cd pytorch_lightning/
torchrun --nproc_per_node=8 --master_port=29510 eval_lightning.py \
    --config configs/training_configs/train_owt_ELF-B.yml \
    --checkpoint_path ../reproduction/elf_b-owt/last.ckpt \
    --num_samples 1000
# Expected: Gen. PPL ≈ 25.6, sample entropy ≈ 5.20.

Per-epoch checkpoints

The checkpoints are under this HF repo: checkpoints/.

# Example: pull epoch 4 ckpt.
huggingface-cli download Ugness/elf-torch \
    checkpoints/checkpoint_epoch03_step00152136.ckpt \
    --local-dir reproduction/elf_b-owt/

Quickstart — train from scratch

cd pytorch_lightning/
torchrun --nproc_per_node=8 --master_port=29501 train_lightning.py \
    --config configs/training_configs/train_owt_ELF-B.yml

Reproduction details

  • Hardware: 8× NVIDIA B200 (sm_100), CUDA 12.8. broadcast_buffers=False. See pytorch_lightning/train_lightning.py.
  • Wall-clock: ~3 hours per epoch.

Differences vs the paper run

Aspect Paper This reproduction
Hardware TPU v5p-64 8× B200 DDP
Framework JAX/Flax PyTorch Lightning
Epochs 5 6 (one extra to reach entropy ≈ 5.20)
Optimizer / objective Muon + L2 denoise + CE decode (decoder_prob=0.2) Unchanged
Schedule, noise scale, time schedule, SC, CFG Unchanged Unchanged

Core symbols most depended-on inside this repo

restore_cond
called by 13
pytorch_lightning/utils/sampling_utils.py
_make_linear
called by 9
pytorch_lightning/modules/layers.py
net_out_to_v_x
called by 8
pytorch_lightning/utils/sampling_utils.py
log_for_0
called by 7
pytorch_lightning/utils/logging_utils.py
_restore_vx
called by 6
pytorch_lightning/utils/sampling_utils.py
load_state_dict
called by 3
pytorch_lightning/lightning_module.py
_normal_002_
called by 3
pytorch_lightning/modules/layers.py
_aligned
called by 2
pytorch_lightning/lightning_module.py

Shape

Method 54
Function 52
Class 19

Languages

Python100%

Modules by API surface

pytorch_lightning/modules/layers.py29 symbols
pytorch_lightning/lightning_module.py21 symbols
pytorch_lightning/utils/sampling_utils.py12 symbols
pytorch_lightning/modules/model.py10 symbols
pytorch_lightning/utils/data_utils.py9 symbols
pytorch_lightning/configs/config.py8 symbols
pytorch_lightning/utils/muon.py5 symbols
pytorch_lightning/utils/metrics_utils.py5 symbols
pytorch_lightning/utils/generation_utils.py5 symbols
pytorch_lightning/encoders/base.py4 symbols
pytorch_lightning/callbacks/gen_eval.py4 symbols
pytorch_lightning/train_lightning.py3 symbols

For agents

$ claude mcp add ELF-pytorch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact