Skip to content

About

A local simulator of a Databricks workspace, generated Delta Lake tasks with verifiers that read the final table state, and a pipeline that trains an agent on them with GRPO and ECHO

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Delta-World

Blog post: https://blog.munhou.com/2026/11/07/World-Modeling-for-LLM-Agent-Predicting-or-Acting-in-the-Environment

A local simulator of a Databricks workspace, generated Delta Lake tasks with verifiers that read the final table state, and a pipeline that trains an agent on them with GRPO and ECHO on Modal.

ECHO adds a cross-entropy loss on tool-output tokens to a reinforcement-learning loss, so the policy also learns to predict what the environment will say. This repository runs that comparison on NVIDIA Nemotron 3 Nano 4B, and contains all the code that produces its dataset and weights.

Package What it holds
src/delta_world/simulator Spark Connect and Delta Lake behind a shim that behaves like Databricks serverless, a sandbox for agent-written Python, and rendering of what the agent sees
src/delta_world/tasks Five task families, verifiers, frozen splits and reference policies
src/delta_world/sft Claude's demonstrations and the fine-tuning dataset built from them
src/delta_world/rl The ECHO loss, the NeMo RL environment, and the episode service that hosts the simulator during training
src/delta_world/evaluation The evaluation harness, paired comparisons, and held-out observation CE
modal_app/ One Modal app per pipeline step
scripts/run.py Runs the pipeline
config.yaml Every setting
graphify-out/ A knowledge graph of this repository

Setup

You need uv, a Modal account, and Java 17 to run the simulator or its tests locally.

uv sync --all-extras
uv run modal setup

Secrets

Secrets live in Modal secrets. config.yaml holds only their names.

Secret Contains Needed for
delta-world-episodes DW_SERVICE_TOKEN, any long random string training and evaluation: it guards the endpoints that run agent-written code
wandb WANDB_API_KEY training, unless tracking.enabled is false
anthropic ANTHROPIC_API_KEY generating demonstrations
huggingface HF_TOKEN, with write access publishing
uv run modal secret create delta-world-episodes DW_SERVICE_TOKEN=$(openssl rand -hex 32)

Set tracking.entity to your W&B entity. To publish your own runs, set huggingface.namespace to your Hugging Face user or organization.

Running the pipeline

uv run python scripts/run.py all
Step What it does GPU Rough cost
data Generates the demonstrations with Claude, or fetches them from Hugging Face when huggingface.namespace is set none about $2 to generate
sft Fine-tunes the base model into S0, the policy every arm starts from 2 × H100 a few dollars
train [arm...] Trains GRPO and ECHO from S0, each with its own 32-CPU episode service 1 × H200 each about $23 per arm
evaluate [run...] Scores each run on dev and test-ood-hard 1 × L40S each about $3 per run
observation-ce [run...] Scores each run's prediction of held-out tool outputs 1 × L40S each about $1 per run
gguf [run...] Converts each run for llama.cpp none under $1
download [run...] Optional, and not part of all: copies each run's Hugging Face weights and GGUF from the Modal volume to data/models/<run>/, about 16 GB per run none none
publish Optional, and not part of all: uploads your dataset and models to Hugging Face, private by default none none

Before running data: it has Claude write the demonstrations that sft trains on, and Anthropic's Usage Policy does not allow using outputs to train an AI model without prior authorization from Anthropic. Check that you have it first. For the same reason, this project does not publish its dataset or weights.

Run any step alone. Override any setting for one run with --set, and print the commands with --dry-run:

uv run python scripts/run.py train echo-020 --set rl.steps=2 --set rl.save_period=2
uv run python scripts/run.py all --dry-run

Training resumes from each arm's newest checkpoint. Evaluation results land in data/eval/:

uv run python -m delta_world.evaluation.compare grpo-dev echo-020-dev

Configuration

config.yaml holds every setting, and its values are the ones that produced the project's weights. The loader refuses missing and unknown keys. The resolved config is baked into every Modal image, so a container sees exactly what the run was launched with.

Two things stay in code on purpose, because they define the benchmark:

  • Task generators: changing one changes the instances, and evaluation refuses to start until the frozen manifest is regenerated with scripts/generate_splits.py.
  • Spark settings that shape what the agent observes (simulator/server.py): changing them breaks the simulator's agreement with Databricks.

The simulator without a GPU

uv run python scripts/serve_simulator.py

Episodes connect to sc://localhost:15002. The scripted policies in tasks/policies show how to drive one, and modal_app/teacher.py runs Claude on it.

One simulator carries 16 concurrent sessions during training. Fifty exhaust its 4 GB heap (simulator.driver_memory): the JVM exits, and clients connected to it wait rather than fail.

Tests

uv run pytest
uv run pytest -m slow
uv run modal run -m modal_app.container_tests
  • The default run needs Java 17 for the tests marked spark.
  • -m slow runs the calibration: on every family, the scripted solver scores 1, and the random and adversarial policies score 0.
  • modal_app.container_tests checks the ECHO loss against the authors' formula inside NeMo RL's image.
  • tests/test_fidelity.py diffs the simulator against frozen captures of a real workspace. Every difference carries a label (docs/fidelity-table.md).
  • tests/test_recipes.py pins the NeMo RL settings that produced the project's weights.

Code graph

graphify-out/ holds a knowledge graph of this repository, built with graphify. You or a coding assistant can use it to see how the code, config and docs connect without reading every file.

File What it is
GRAPH_REPORT.md The main components, the most connected nodes, and suggested questions
graph.html An interactive map. Open it in a browser after cloning; it loads its viewer from a CDN, so it needs internet
graph.json The full graph, which the commands below read

Install graphify (the package name has two y's), then run the commands from the repository root:

uv tool install graphifyy
graphify query "what does the episode service do"
graphify path "Pipeline" "SimulatorServer" --undirected
graphify explain "EchoLossFn"

query returns the part of the graph that matches your words, and path returns the shortest route, which can run through shared code such as argparse. Use them to find where to read, then check the source they cite. To give a coding assistant the same access, run graphify install, which detects your assistant and registers the skill.

built_at_commit in graph.json records the commit the graph describes. After changing code, graphify update . refreshes the graph without an LLM. Changes to docs need /graphify --update in an assistant. The other files graphify writes to graphify-out/ are local state and stay out of git, because some of them record absolute paths.

Known issues

These are kept as they are, because fixing them changes the frozen splits or the project's results.

  • Some family B prompts misstate the symptom. They say the job fails with an error, but Delta raises that error only when a repeated staging id is already in the target. When every repeated id is new, the job runs and inserts each copy. This affects 86 of 400 train instances, 9 of 40 on dev, 10 of 40 on test-id and 4 of 40 on test-ood-hard. The verifier checks the stated rules, not the symptom.
  • Two kinds of task are solvable but were never learned. A column widened from INT to BIGINT needs delta.enableTypeWidening first, and a table clustered on the wrong column needs OPTIMIZE ... FULL. No rollout tried either, so neither loss gets a signal. They are 16.4% of training prompts.
  • One family D instance verifies only some of the time. The scan fraction of seed 300007 after the correct fix varies between 0.236 and 0.256, against a limit of 0.25.
  • The simulator is not Databricks. docs/fidelity-table.md lists the known differences. One that is not captured there: an INSERT that overflows a column shows only TASK_WRITE_FAILED, because Spark Connect does not return the cause.

License

The code is under the Apache License 2.0; see NOTICE. Weights produced by this pipeline derive from Nemotron 3 Nano 4B and are governed by the NVIDIA Nemotron Open Model License.

About

A local simulator of a Databricks workspace, generated Delta Lake tasks with verifiers that read the final table state, and a pipeline that trains an agent on them with GRPO and ECHO

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages