SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.16683 · ICML · 2023

Future-conditioned Unsupervised Pretraining for Decision Transformer

Zichuan Lin, Shuai Li, Deheng Ye, Qiang Fu, Wei Yang, Zhihui Xie

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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 4 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/2305.16683.json · badge: /api/ran/2305.16683.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
fffffarmer/pdt canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
create_vec_eval_episodes_fn Ran
ran on a synthesized input
fffffarmer/pdt/src/evaluation.py
code served (permissive licence) · get_code("efb54634216653b2")
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 function. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import numpy as np
from gym import Env
from gym.spaces import Box, Discrete

torch.manual_seed(0)
np.random.seed(0)

# Define minimal model that satisfies the function's requirements
class MinimalModel(nn.Module):
    def __init__(self, state_dim, act_dim, z_dim=8):
        super().__init__()
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.z_dim = z_dim
        self.stochastic_policy = True
        self.action_range = (-1.0, 1.0)
        
        # Minimal layers for get_predictions
        self.fc = nn.Linear(state_dim + act_dim + 1 + z_dim, act_dim)
        
    def get_predictions(self, states, actions, timesteps, futures=None, num_envs=None, pretrain=True):
        # states shape: (num_envs, seq_len, state_dim)
        # actions shape: (num_envs, seq_len, act_dim)
        # timesteps shape: (num_envs, seq_len)
        # futures shape: (num_envs, seq_len, z_dim)
        
        batch_size = states.shape[0]
        seq_len = states.shape[1]
        
        # Get last timestep prediction
        last_state = states[:, -1, :]  # (num_envs, state_dim)
        last_action = actions[:, -1, :]  # (num_envs, act_dim)
        last_future = futures[:, -1, :] if futures is not None else torch.zeros(batch_size, self.z_dim, device=states.device)  # (num_envs, z_dim)
        last_timestep = timesteps[:, -1:].float()  # (num_envs, 1)
        
        combined = torch.cat([last_state, last_action, last_timestep, last_future], dim=-1)
        action_logits = self.fc(combined)
        
        # Create a mock distribution with mean and sample methods
        class MockDist:
            def __init__(self, mean_val, act_dim):
                self.mean = mean_val
                self._act_dim = act_dim
            
            def sample(self):
                return self.mean + 0.01 * torch.randn_like(self.mean)
        
        action_dist = MockDist(action_logits, self.act_dim)
        
        return {
            'action_dist': action_dist,
            'future': torch.randn(batch_size, self.z_dim, device=states.device) if futures is not None else None
        }

# Define minimal vectorized environment
class MinimalVecEnv:
    def __init__(self, num_envs=2, state_dim=4, act_dim=3):
        self.num_envs = num_envs
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.step_count = 0
    
    def reset(self):
        return np.random.randn(self.num_envs, self.state_dim).astype(np.float32)
    
    def step(self, actions):
        # actions shape: (num_envs, act_dim)
        state = np.random.randn(self.num_envs, self.state_dim).astype(np.float32)
        reward = np.random.randn(self.num_envs).astype(np.float32)
        done = np.zeros(self.num_envs, dtype=bool)
        self.step_count += 1
        if self.step_count > 5:
            done[:] = True
        info = {}
        return state, reward, done, info

# Create instances
state_dim = 4
act_dim = 3
num_envs = 2

vec_env = MinimalVecEnv(num_envs=num_envs, state_dim=state_dim, act_dim=act_dim)
model = MinimalModel(state_dim=state_dim, act_dim=act_dim, z_dim=8)

state_mean = np.zeros(state_dim, dtype=np.float32)
state_std = np.ones(state_dim, dtype=np.float32)

ARGS = {
    'vec_env': vec_env,
    'state_dim': state_dim,
    'act_dim': act_dim,
    'state_mean': state_mean,
    'state_std': state_std,
    'device': 'cpu',
    'use_mean': False,
    'record_video': False,
    'pretrain': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
gym, numpy, stable_baselines3, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
discount_cumsum Ran
ran on a synthesized input
fffffarmer/pdt/src/data.py
code served (permissive licence) · get_code("7ae6e29065b3cc4b")
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 ndarray, ndim 1, dtype family float, shape (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 numpy as np

# Construct a small numpy array for the discount_cumsum function
# The function expects:
# - x: a numpy array (used with .size, .shape, indexing)
# - gamma: a scalar discount factor

x = np.array([1.0, 2.0, 3.0, 4.0])
gamma = 0.99

ARGS = {
    "x": x,
    "gamma": gamma,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (4,) — shape (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
sample_trajs Ran
ran on a synthesized input
fffffarmer/pdt/src/data.py
code served (permissive licence) · get_code("7b736de4e98be469")
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 ndarray, ndim 1, dtype family int, shape (2,) 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 numpy as np

# Create sample trajectories with the expected structure
trajectories = [
    {
        'observations': np.array([[1, 2, 3, 4], [5, 6, 7, 8]]),
        'rewards': np.array([1.0, 2.0])
    },
    {
        'observations': np.array([[9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]),
        'rewards': np.array([0.5, 1.5, 2.5])
    },
    {
        'observations': np.array([[21, 22, 23, 24]]),
        'rewards': np.array([3.0])
    }
]

ARGS = {
    'trajectories': trajectories,
    'sample_size': 2,
    'weighted_by': 'return'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family int, shape (2,) — shape (2,) 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
to_np Ran
ran; our contract draft was wrong, not the code
fffffarmer/pdt/src/utils.py
code served (permissive licence) · get_code("a80c3e8402f8384e")
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 ndarray, 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
import numpy as np

torch.manual_seed(0)

# Test case 1: A normal torch tensor
tensor_1 = torch.randn(2, 4)

# Test case 2: None value
tensor_2 = None

# Test case 3: Empty tensor
tensor_3 = torch.tensor([])

# Create ARGS dict with the parameter 't' mapped to a valid tensor
ARGS = {
    "t": tensor_1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
vec_evaluate_episode_rtg Ran
ran on a synthesized input
fffffarmer/pdt/src/evaluation.py
code served (permissive licence) · get_code("4993fce8e75a1879")
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 tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim 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
import numpy as np
from collections import namedtuple

torch.manual_seed(0)

# Create a minimal VecEnv mock
class MockVecEnv:
    def __init__(self, num_envs, state_dim, act_dim):
        self.num_envs = num_envs
        self.state_dim = state_dim
        self.act_dim = act_dim
        self._step_count = 0
    
    def reset(self):
        return np.random.randn(self.num_envs, self.state_dim).astype(np.float32)
    
    def step(self, actions):
        self._step_count += 1
        state = np.random.randn(self.num_envs, self.state_dim).astype(np.float32)
        reward = np.random.randn(self.num_envs).astype(np.float32)
        done = np.zeros(self.num_envs, dtype=bool)
        if self._step_count > 5:
            done[:] = True
        info = [{}] * self.num_envs
        return state, reward, done, info

# Create a minimal Distribution mock
class MockDistribution:
    def __init__(self, mean_tensor):
        self.mean = mean_tensor
    
    def sample(self):
        return self.mean + torch.randn_like(self.mean) * 0.01

# Create a minimal model
class MockModel(nn.Module):
    def __init__(self, state_dim, act_dim, z_dim=8):
        super().__init__()
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.z_dim = z_dim
        self.stochastic_policy = True
        self.action_range = (-1.0, 1.0)
        self.linear = nn.Linear(state_dim + act_dim + z_dim + 1, act_dim)
    
    def get_predictions(self, states, actions, timesteps, futures=None, num_envs=2, pretrain=True):
        # states: (num_envs, seq_len, state_dim)
        # actions: (num_envs, seq_len, act_dim)
        # timesteps: (num_envs, seq_len)
        # futures: (num_envs, seq_len, z_dim)
        
        seq_len = states.shape[1]
        batch_size = states.shape[0]
        
        # Simple forward pass to get action predictions
        last_state = states[:, -1, :]  # (num_envs, state_dim)
        last_action = actions[:, -1, :] if actions.shape[1] > 0 else torch.zeros(batch_size, self.act_dim, device=states.device)
        last_future = futures[:, -1, :] if futures is not None else torch.zeros(batch_size, self.z_dim, device=states.device)
        last_timestep = timesteps[:, -1:].float()
        
        combined = torch.cat([last_state, last_action, last_future, last_timestep], dim=-1)
        action_logits = self.linear(combined)
        
        action_dist = MockDistribution(action_logits)
        
        future_pred = None
        if futures is not None:
            future_pred = torch.randn(batch_size, self.z_dim, device=states.device)
        
        return {
            'action_dist': action_dist,
            'future': future_pred
        }

# Set up arguments
state_dim = 4
act_dim = 3
z_dim = 8
num_envs = 2
max_ep_len = 10

vec_env = MockVecEnv(num_envs=num_envs, state_dim=state_dim, act_dim=act_dim)
model = MockModel(state_dim=state_dim, act_dim=act_dim, z_dim=z_dim)

state_mean = np.zeros(state_dim, dtype=np.float32)
state_std = np.ones(state_dim, dtype=np.float32)

ARGS = {
    'vec_env': vec_env,
    'state_dim': state_dim,
    'act_dim': act_dim,
    'model': model,
    'max_ep_len': max_ep_len,
    'state_mean': state_mean,
    'state_std': state_std,
    'device': 'cpu',
    'use_mean': False,
    'record_video': False,
    'pretrain': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, stable_baselines3, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
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
create_dataloader Not yet run
unverified (harvested, no recorded run)
fffffarmer/pdt/src/data.py
code served (permissive licence) · get_code("b43888879a4dc247")
How it ran

no invocation recorded.

load_tf_weights_in_gpt2 Not yet run
unverified (harvested, no recorded run)
fffffarmer/pdt/src/models/trajectory_gpt2.py
pointer only (licence: MIT); the stored copy get_code serves, from tencentarc/moto, is pointer only (licence: NOASSERTION) · get_code("00a33466c69c5705")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from tencentarc/moto, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 2 later) and 5 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
load_tf_weights_in_gpt2 22 other papers
7 dated earlier, 2 the same month, 13 later
2106.01345 (2021-06)
Decision Transformer: Reinforcement Learning via Sequence Modeling
2110.06206 (2021-10)
StARformer: Transformer with State-Action-Reward Representations for Visual Reinforcement Learning
2202.11705 (2022-02)
COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamics
and 19 more not named here
to_np 9 other papers
3 dated earlier, 6 later · 2 only as an assembly brick
1812.05905 (2018-12)
Soft Actor-Critic Algorithms and Applications
2004.13649 (2020-04)
Image Augmentation Is All You Need: Regularizing Deep Reinforcement Learning from Pixels
2110.04935 (2021-10)
Learning Temporally-Consistent Representations for Data-Efficient Reinforcement Learning
and 6 more not named here

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

Recent research in offline reinforcement learning (RL) has demonstrated that return-conditioned supervised learning is a powerful paradigm for decision-making problems. While promising, return conditioning is limited to training data labeled with rewards and therefore faces challenges in learning from unsupervised data. In this work, we aim to utilize generalized future conditioning to enable efficient unsupervised pretraining from reward-free and sub-optimal offline data. We propose Pretrained Decision Transformer (PDT), a conceptually simple approach for unsupervised RL pretraining. PDT leverages future trajectory information as a privileged context to predict actions during training. The ability to make decisions based on both present and future factors enhances PDT's capability for generalization. Besides, this feature can be easily incorporated into a return-conditioned framework for online finetuning, by assigning return values to possible futures and sampling future embeddings based on their respective values. Empirically, PDT outperforms or performs on par with its supervised pretraining counterpart, especially when dealing with suboptimal data. Further analysis reveals that PDT can extract diverse behaviors from offline data and controllably sample high-return behaviors by online finetuning. Code is available at here.

For agents

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

get_harvested_code_for_paper("2305.16683")
get_code_for_paper("2305.16683")
have("2305.16683")

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

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

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

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

Connect an agent — have() is free.