SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.00653 · ICLR · 2025

Discrete Codebook World Models for Continuous Control

Arno Solin, Joni Pajarinen, Kevin Luck, Kalle Kujanpää, Aidan Scannell, Yi Zhao, Mohammadreza Nakhaei

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2503.00653.json · badge: /api/ran/2503.00653.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
aidanscannell/dcmpc canonical (classifier label)
classifier basis not recorded on the link
6 ran · 2 no recorded run
FunctionStatusWhere it lives
calc_mean_opt_moments Ran
ran on a synthesized input
aidanscannell/dcmpc/utils/helper.py
code served (permissive licence) · get_code("f1acb525c0929888")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.optim import Adam

torch.manual_seed(0)

# Create a small model with parameters
model = nn.Linear(4, 3)

# Create an optimizer
optimizer = Adam(model.parameters(), lr=0.01)

# Simulate a forward pass and backward pass to populate optimizer state
x = torch.randn(2, 4)
y = torch.randn(2, 3)
loss_fn = nn.MSELoss()

output = model(x)
loss = loss_fn(output, y)
loss.backward()

# Step the optimizer to populate exp_avg and exp_avg_sq in state
optimizer.step()

ARGS = {
    'opt': optimizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
calc_rank Ran
ran on a synthesized input
aidanscannell/dcmpc/utils/helper.py
code served (permissive licence) · get_code("238266345b37c6dc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from torch.linalg import cond, matrix_rank

torch.manual_seed(0)

# Create a small matrix for rank calculation
# Shape: (batch=2, features=4)
z = torch.randn(2, 4)

# Define ARGS with all parameters
ARGS = {
    'name': 'test_latent',
    'z': z
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate Ran
ran on a synthesized input
aidanscannell/dcmpc/utils/evaluate.py
code served (permissive licence) · get_code("1d3835836ba9076b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from tensordict.nn import TensorDictModule
from tensordict import TensorDict

torch.manual_seed(0)

# Create a minimal policy module that takes observations and returns actions
class SimplePolicy(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, td):
        # Expects tensordict with 'observation' key
        # Returns tensordict with 'action' key
        obs = td['observation']
        action = self.linear(obs)
        td_out = TensorDict({'action': action}, batch_size=obs.shape[:-1])
        return td_out

policy_module = TensorDictModule(SimplePolicy(), in_keys=['observation'], out_keys=['action'])

# Create a mock environment that has a rollout method
class MockEnv:
    def rollout(self, max_steps, policy):
        # Return a tensordict with the expected structure
        batch_size = 2
        
        # Create episode_reward: [batch, steps, 1]
        episode_reward = torch.randn(batch_size, max_steps, 1)
        
        # Create step_count: [batch, steps, 1]
        step_count = torch.arange(max_steps).unsqueeze(0).unsqueeze(-1).expand(batch_size, max_steps, 1).float()
        
        # Create success: [batch, steps, 1]
        success = torch.randint(0, 2, (batch_size, max_steps, 1)).bool()
        
        # Build the nested tensordict structure
        next_td = TensorDict({
            'episode_reward': episode_reward,
            'step_count': step_count,
            'success': success
        }, batch_size=[batch_size, max_steps])
        
        eval_data = TensorDict({'next': next_td}, batch_size=[batch_size, max_steps])
        return eval_data

env = MockEnv()

# Create a mock video environment with rollout and transform
class MockVideoEnv:
    def __init__(self):
        self.transform = MockTransform()
    
    def rollout(self, max_steps, policy):
        batch_size = 2
        episode_reward = torch.randn(batch_size, max_steps, 1)
        step_count = torch.arange(max_steps).unsqueeze(0).unsqueeze(-1).expand(batch_size, max_steps, 1).float()
        success = torch.randint(0, 2, (batch_size, max_steps, 1)).bool()
        
        next_td = TensorDict({
            'episode_reward': episode_reward,
            'step_count': step_count,
            'success': success
        }, batch_size=[batch_size, max_steps])
        
        eval_data = TensorDict({'next': next_td}, batch_size=[batch_size, max_steps])
        return eval_data

class MockTransform:
    def dump(self):
        pass

video_env = MockVideoEnv()

ARGS = {
    'env': env,
    'eval_policy_module': policy_module,
    'max_episode_steps': 16,
    'action_repeat': 2,
    'video_env': video_env
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensordict, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
flatten_batch Ran
ran on a synthesized input
aidanscannell/dcmpc/utils/buffers.py
code served (permissive licence) · get_code("5463329fd15b6ca9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ReplayBufferSamples. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from tensordict import TensorDict
from typing import NamedTuple, Optional

torch.manual_seed(0)

class ReplayBufferSamples(NamedTuple):
    observations: TensorDict
    actions: torch.Tensor
    next_observations: TensorDict
    dones: torch.Tensor
    terminateds: torch.Tensor
    rewards: torch.Tensor
    next_state_gammas: torch.Tensor
    zs: Optional[TensorDict]
    next_zs: Optional[TensorDict]

# Create sample tensors with distinct sizes
batch_size = 2
seq_len = 3
obs_dim = 4
action_dim = 5

# Create observations TensorDict
observations = TensorDict({
    "state": torch.randn(batch_size, seq_len, obs_dim)
}, batch_size=[batch_size, seq_len])

# Create next_observations TensorDict
next_observations = TensorDict({
    "state": torch.randn(batch_size, seq_len, obs_dim)
}, batch_size=[batch_size, seq_len])

# Create actions tensor with shape (batch_size, seq_len, action_dim)
actions = torch.randn(batch_size, seq_len, action_dim)

# Create dones tensor
dones = torch.randint(0, 2, (batch_size, seq_len), dtype=torch.float32)

# Create terminateds tensor
terminateds = torch.randint(0, 2, (batch_size, seq_len), dtype=torch.float32)

# Create rewards tensor
rewards = torch.randn(batch_size, seq_len)

# Create next_state_gammas tensor
next_state_gammas = torch.randn(batch_size, seq_len)

# Create zs TensorDict
zs = TensorDict({
    "z": torch.randn(batch_size, seq_len, 6)
}, batch_size=[batch_size, seq_len])

# Create next_zs TensorDict
next_zs = TensorDict({
    "z": torch.randn(batch_size, seq_len, 6)
}, batch_size=[batch_size, seq_len])

# Create the batch
batch = ReplayBufferSamples(
    observations=observations,
    actions=actions,
    next_observations=next_observations,
    dones=dones,
    terminateds=terminateds,
    rewards=rewards,
    next_state_gammas=next_state_gammas,
    zs=zs,
    next_zs=next_zs
)

ARGS = {
    "batch": batch
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensordict, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ReplayBufferSamples — a ReplayBufferSamples output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mlp Ran
ran on a synthesized input
aidanscannell/dcmpc/utils/layers.py
code served (permissive licence) · get_code("9acd81aa05192bdb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Sequential. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "in_dim": 8,
    "mlp_dims": [16, 32],
    "out_dim": 4,
    "act_fn": nn.Tanh(),
    "dropout": 0.1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
symlog Ran
ran; our contract draft was wrong, not the code
aidanscannell/dcmpc/utils/helper.py
code served (permissive licence) · get_code("7fb5eb47c3b273d5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The symlog function takes a single argument 'x' which is used with:
# - torch.sign(x)
# - torch.log(1 + torch.abs(x))
# So x should be a tensor that supports these operations

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mlp_ensemble Not yet run
unverified (harvested, no recorded run)
aidanscannell/dcmpc/utils/layers.py
code served (permissive licence) · get_code("6c36e9ed51bed5c6")
How it ran

no invocation recorded.

to_nstep Not yet run
unverified (harvested, no recorded run)
aidanscannell/dcmpc/utils/buffers.py
code served (permissive licence) · get_code("9babf91705bd55e7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
symlog 1 other paper
1 dated earlier
2310.17805 (2023-10)
Reward Scale Robustness for Proximal Policy Optimization via DreamerV3 Tricks

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In reinforcement learning (RL), world models serve as internal simulators, enabling agents to predict environment dynamics and future outcomes in order to make informed decisions. While previous approaches leveraging discrete latent spaces, such as DreamerV3, have demonstrated strong performance in discrete action settings and visual control tasks, their comparative performance in state-based continuous control remains underexplored. In contrast, methods with continuous latent spaces, such as TD-MPC2, have shown notable success in state-based continuous control benchmarks. In this paper, we demonstrate that modeling discrete latent states has benefits over continuous latent states and that discrete codebook encodings are more effective representations for continuous control, compared to alternative encodings, such as one-hot and label-based encodings. Based on these insights, we introduce DCWM: Discrete Codebook World Model, a self-supervised world model with a discrete and stochastic latent space, where latent states are codes from a codebook. We combine DCWM with decision-time planning to get our model-based RL algorithm, named DC-MPC: Discrete Codebook Model Predictive Control, which performs competitively against recent state-of-the-art algorithms, including TD-MPC2 and DreamerV3, on continuous control benchmarks. See our project website www.aidanscannell.com/dcmpc.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2503.00653")
get_code_for_paper("2503.00653")
have("2503.00653")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2503.00653.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2503.00653.svg)](https://syntology.ai/paper/2503.00653)

Connect an agent — have() is free.