The Problem
Training agents to interact with a real operating system is slow, serial, and hard to parallelize: every rollout needs a live desktop, and failures are expensive. NeuralOS replaces the OS with a neural model that predicts the next screen frame from mouse, click, and keyboard events, so policies can be trained and evaluated against a GPU-resident, differentiable environment instead of a physical machine.
What This Does
The repo is a fork of yuntian-group/neural-os and contains three training pipelines. autoencoder/ trains a VQ/KL autoencoder that compresses 512×384×3 frames into 64×48×16 latents (an 8x reduction). latent_diffusion/ is the CompVis latent-diffusion framework, adapted to render those latents back into images. computer/ trains the main model: an RNN tracking OS state plus a diffusion renderer, driven by configs in computer/configs/. data/ generates and aggregates the Ubuntu XFCE training recordings.
How It Is Wired
Execution starts at three real entry points. process_video in data/data_processing/main.py:65 aggregates recordings; its traced path reaches the filesystem in one hop via Image.open inside compute_distance. main in autoencoder/visualize_reconstruction_kl_f16.py:108 reaches 64 functions and leaves the process via os.makedirs. The training entry points are autoencoder/main.py and computer/main.py, both driven by YAML configs.
Three modules are hubs with wide blast radius: computer/util (32 modules depend on it), data/data_processing/datasets.py (31), and latent_diffusion/ldm/util (20). The core of the system is latent_diffusion/ldm/models/diffusion/ddpm.py: 72 functions, 4 classes, called from 11 files, 1772 lines — a change there ripples everywhere. The most-called functions are exists (27 call sites), sample (20), and instantiate_from_config (11). latent_diffusion/ldm/models/diffusion/ddim.py (16 callers) and latent_diffusion/ldm/modules/attention.py (20 callers) are also widely referenced. No circular dependencies were found in the 150-module import graph.
How To Use It
The README documents the full pipeline; commands are used verbatim:
# 1. Data generation (build the collection environment)
cd data/data_collection
docker build -t synthetic_data_generator .
# 2. Data processing
cd data/data_processing
python main.py
# 3. Autoencoder training
cd autoencoder/
python main.py --config config_kl4_lr4.5e6_load_acc1_512_384_mar10_keyboard_init_16_contmar15_acc1_cont1e6.yaml
# 4. Image preprocessing to latent WebDataset tars
python preprocess_dataset.py
# 5. Main model training (8 GPUs, FSDP)
cd computer/
python main.py --config configs/fb_computecanada_challengingandsample_pretrainrnn_balanced_lr5e6_contbest_samplercover_newd_contfreezernn_newnewd_origunet_nospatial_online_x0_joint_onlineonly_7.yaml
Training the autoencoder takes roughly a week on one H200. Config paths must be edited to point at your data; multi-stage training is controlled by flags like "pretrain": true and "freezernn": true in the YAML.
Real-World Use
A practical fit: training a GUI agent policy in the loop. Generate 40K random and agent-driven Ubuntu sessions via the Docker container, encode them to latents, train the autoencoder, then train the RNN+diffusion model to predict frames. The trained model becomes a fast, parallelizable surrogate for evaluation — useful for RL and for testing agents without provisioning desktops.
Code Health & Issues
Static analysis (measured, not opinion) found 99 issues: 32 high, 65 medium, 2 low. Key findings:
- High - deep nesting (x37) —
data/data_processing/datasets.py,latent_diffusion/ldm/models/diffusion/ddpm.py— max indentation depth 10; flatten with guard clauses. - High - oversized files —
ddpm.py(1772 lines),latent_diffusion/ldm/modules/diffusionmodules/model.py— split by responsibility. - High - hub modules —
computer/util.py,datasets.py,latent_diffusion/ldm/util.py— churn here is high-blast-radius. - High - duplicated code — 2079 repeated 6-line blocks across 136 files; extract shared helpers.
- Medium - broad exception handling (x2) — bare
exceptindatasets.py,ddpm.py. - Medium - file handles without context managers (x14) — use
with open(...).
SDLC observations: High — no LICENSE file (all rights reserved by default, blocking reuse). High — no CI workflow for 150 source files. High — data/data_collection/Dockerfile is a deployable artifact with no build gate. Medium — no Dependabot/Renovate; base image ubuntu:20.04 unpinned; no non-root USER in the Dockerfile; test ratio is 2 test files to 150 source files (0.013), so the suite cannot cover this codebase.
The Bottom Line
This is a serious research codebase that reproduces a published pipeline end-to-end, but it is a fork of a fork: heavy config sprawl (287 YAML files, many near-duplicate experiment configs), no CI, and no license. Use it if you need a working neural-OS simulator for agent training and can tolerate a research-grade build; harden it before any production or client deployment.