SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01345 · 2021

Decision Transformer: Reinforcement Learning via Sequence Modeling

Pieter Abbeel, Michael Laskin, Igor Mordatch, Aravind Rajeswaran, Kimin Lee, Aravind Srinivas, Kevin Lu, Aditya Grover, Lili Chen

arXiv · PDF · Open in the Atlas

Code that ran

17 of 26 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (10 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 12 have no contract verdict; 5 failures of our instrument; 9 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-22; 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/2106.01345.json · badge: /api/ran/2106.01345.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
facebookresearch/salina community
Papers with Code archive
3 ran · 1 no recorded run
LAS1520/Gato-A-Generalist-Agent community
Papers with Code archive
3 ran · 0 no recorded run
zzmtsvv/rl_task community
Papers with Code archive
3 ran · 0 no recorded run
opendilab/DI-engine community
Papers with Code archive
2 ran · 1 no recorded run
Amadeus979/decision-transformer community (classifier label)
classifier basis not recorded on the link
2 ran · 1 no recorded run
corl-team/CORL community
Papers with Code archive
2 ran · 0 no recorded run
HzcIrving/DecisionTransformer_StepbyStep community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
nikhilbarhate99/min-decision-transformer community
Papers with Code archive
1 ran · 0 no recorded run
yun-kwak/decision-transformer-jax community
Papers with Code archive
0 ran · 4 no recorded run
Delavari-Alireza/Decision_Transformer_Sequence-Modeling_Deep_Reinforcement_Learning community
Papers with Code archive
0 ran · 1 no recorded run
pytorch/rl community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
discount_cumsum Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HzcIrving/DecisionTransformer_StepbyStep/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from bkkgbkjb/oppo, is pointer only (licence: NONE) · get_code("0161b27cbe3cc58d")
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 bkkgbkjb/oppo, and GitHub detected no licence in that repository when it was checked. 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. A run is recorded.

Agent Ran
ran on a synthesized input · constructed an object; no result was computed
facebookresearch/salina/salina_examples/offline_rl/decision_transformer/agents.py
code served (permissive licence) · get_code("89113bc52fb73297")
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 an instance of its own class, Agent: the run constructed the object and did not call it, so no result was computed. 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
import copy

torch.manual_seed(0)

# Create a minimal Workspace stand-in class
class MockWorkspace:
    def __init__(self):
        self.data = {}
    
    def get_full(self, var_name):
        return self.data.get(var_name, torch.zeros(2, 4))
    
    def get(self, var_name, time_idx):
        if var_name in self.data:
            return self.data[var_name][time_idx] if len(self.data[var_name].shape) > 1 else self.data[var_name]
        return torch.zeros(4)
    
    def set_full(self, var_name, value):
        self.data[var_name] = value
    
    def set(self, var_name, time_idx, value):
        if var_name not in self.data:
            self.data[var_name] = torch.zeros(2, 4)
        self.data[var_name][time_idx] = value
    
    def get_time_truncated(self, var_name, from_time, to_time):
        if var_name in self.data:
            return self.data[var_name][from_time:to_time]
        return torch.zeros(2, 4)

# Create a minimal concrete Agent subclass for testing
class ConcreteAgent(nn.Module):
    def __init__(self, name=None):
        super().__init__()
        self._name = name
        self._Agent__trace_file = None
        self.workspace = None
    
    def seed(self, seed):
        pass
    
    def set_name(self, n):
        self._name = n
    
    def get_name(self):
        return self._name
    
    def set_trace_file(self, filename):
        pass
    
    def forward(self, **kwargs):
        pass
    
    def clone(self):
        self.workspace = None
        self.zero_grad()
        return copy.deepcopy(self)
    
    def get(self, index):
        if isinstance(index, str):
            return self.workspace.get_full(index)
        else:
            return self.workspace.get(index[0], index[1])
    
    def set(self, index, value):
        if isinstance(index, str):
            self.workspace.set_full(index, value)
        else:
            self.workspace.set(index[0], index[1], value)
    
    def get_by_name(self, n):
        if n == self._name:
            return [self]
        return []
    
    def get_time_truncated(self, var_name, from_time, to_time):
        return self.workspace.get_time_truncated(var_name, from_time, to_time)

ARGS = {
    "name": "test_agent"
}
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 Agent — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Agent 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
Block Ran
ran on a synthesized input · constructed an object; no result was computed
LAS1520/Gato-A-Generalist-Agent/Gato_models/model.py
pointer only (licence: NONE) · get_code("e3c3fcca273a8e47")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, LAS1520/Gato-A-Generalist-Agent when it was checked. 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. A run is recorded.

Block Ran
ran on a synthesized input
opendilab/DI-engine/ding/model/template/decision_transformer.py
code served (permissive licence) · get_code("25243005f892c666")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float; no output shape is stated. The image it ran in was 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 math
import torch
import torch.nn as nn
import torch.nn.functional as F

class MaskedCausalAttention(nn.Module):
    def __init__(self, h_dim: int, max_T: int, n_heads: int, drop_p: float) -> None:
        super().__init__()
        self.n_heads = n_heads
        self.max_T = max_T
        self.q_net = nn.Linear(h_dim, h_dim)
        self.k_net = nn.Linear(h_dim, h_dim)
        self.v_net = nn.Linear(h_dim, h_dim)
        self.proj_net = nn.Linear(h_dim, h_dim)
        self.att_drop = nn.Dropout(drop_p)
        self.proj_drop = nn.Dropout(drop_p)
        ones = torch.ones((max_T, max_T))
        mask = torch.tril(ones).view(1, 1, max_T, max_T)
        self.register_buffer('mask', mask)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        B, T, C = x.shape
        N, D = (self.n_heads, C // self.n_heads)
        q = self.q_net(x).view(B, T, N, D).transpose(1, 2)
        k = self.k_net(x).view(B, T, N, D).transpose(1, 2)
        v = self.v_net(x).view(B, T, N, D).transpose(1, 2)
        weights = q @ k.transpose(2, 3) / math.sqrt(D)
        weights = weights.masked_fill(self.mask[..., :T, :T] == 0, float('-inf'))
        normalized_weights = F.softmax(weights, dim=-1)
        attention = self.att_drop(normalized_weights @ v)
        attention = attention.transpose(1, 2).contiguous().view(B, T, N * D)
        out = self.proj_drop(self.proj_net(attention))
        return out

class Block(nn.Module):
    def __init__(self, h_dim: int, max_T: int, n_heads: int, drop_p: float) -> None:
        super().__init__()
        self.attention = MaskedCausalAttention(h_dim, max_T, n_heads, drop_p)
        self.mlp = nn.Sequential(nn.Linear(h_dim, 4 * h_dim), nn.GELU(), nn.Linear(4 * h_dim, h_dim), nn.Dropout(drop_p))
        self.ln1 = nn.LayerNorm(h_dim)
        self.ln2 = nn.LayerNorm(h_dim)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        x = x + self.attention(x)
        x = self.ln1(x)
        x = x + self.mlp(x)
        x = self.ln2(x)
        return x

INIT_ARGS = {
    'h_dim': 8,
    'max_T': 6,
    'n_heads': 2,
    'drop_p': 0.1,
}

ARGS = {
    'x': torch.randn(2, 4, 8),
}

if __name__ == '__main__':
    model = Block(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: {ARGS['x'].shape}")
    assert output.shape == ARGS['x'].shape, f"Shape mismatch: {output.shape} != {ARGS['x'].shape}"
    print("Test passed!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
DecisionTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
LAS1520/Gato-A-Generalist-Agent/Gato_models/model.py
pointer only (licence: NONE) · get_code("6daf6f8401bed739")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, LAS1520/Gato-A-Generalist-Agent when it was checked. 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. A run is recorded.

DecisionTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
corl-team/CORL/algorithms/offline/dt.py
code served (permissive licence) · get_code("a437b4b107300a41")
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 an instance of its own class, DecisionTransformer: the run constructed the object and did not call it, so no result was computed. 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)

# Define parameters for DecisionTransformer
state_dim = 4
action_dim = 3
seq_len = 2
episode_len = 100
embedding_dim = 16
num_layers = 2
num_heads = 4
attention_dropout = 0.1
residual_dropout = 0.1
embedding_dropout = 0.1
max_action = 1.0

# Create sample tensors
batch_size = 2
states = torch.randn(batch_size, seq_len, state_dim)
actions = torch.randn(batch_size, seq_len, action_dim)
returns_to_go = torch.randn(batch_size, seq_len)
time_steps = torch.randint(0, episode_len, (batch_size, seq_len))
padding_mask = torch.zeros(batch_size, seq_len, dtype=torch.bool)

ARGS = {
    "state_dim": state_dim,
    "action_dim": action_dim,
    "seq_len": seq_len,
    "episode_len": episode_len,
    "embedding_dim": embedding_dim,
    "num_layers": num_layers,
    "num_heads": num_heads,
    "attention_dropout": attention_dropout,
    "residual_dropout": residual_dropout,
    "embedding_dropout": embedding_dropout,
    "max_action": max_action,
}

# Test forward pass arguments
forward_args = {
    "states": states,
    "actions": actions,
    "returns_to_go": returns_to_go,
    "time_steps": time_steps,
    "padding_mask": padding_mask,
}
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 DecisionTransformer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a DecisionTransformer 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
DecisionTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
zzmtsvv/rl_task/decision_transformer/model.py
pointer only (licence: NONE) · get_code("dfabbac8bf8010df")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zzmtsvv/rl_task when it was checked. 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. A run is recorded.

DecisionTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
nikhilbarhate99/min-decision-transformer/decision_transformer/model.py
code served (permissive licence) · get_code("815b0c86f32c99cc")
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 an instance of its own class, DecisionTransformer: the run constructed the object and did not call it, so no result was computed. 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 = {
    "state_dim": 4,
    "act_dim": 3,
    "n_blocks": 2,
    "h_dim": 8,
    "context_len": 2,
    "n_heads": 2,
    "drop_p": 0.1,
    "max_timestep": 4096,
}
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 DecisionTransformer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a DecisionTransformer 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
MaskedCausalAttention Ran
ran on a synthesized input · constructed an object; no result was computed
LAS1520/Gato-A-Generalist-Agent/Gato_models/model.py
pointer only (licence: NONE) · get_code("621a87d0ebc957c4")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, LAS1520/Gato-A-Generalist-Agent when it was checked. 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. A run is recorded.

MaskedCausalAttention Ran
ran on a synthesized input
opendilab/DI-engine/ding/model/template/decision_transformer.py
code served (permissive licence) · get_code("23842a66d5113ef0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 8) 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 torch.nn as nn
import math
import torch.nn.functional as F

class MaskedCausalAttention(nn.Module):
    """
    Overview:
        The implementation of masked causal attention in decision transformer. The input of this module is a sequence         of several tokens. For the calculated hidden embedding for the i-th token, it is only related the 0 to i-1         input tokens by applying a mask to the attention map. Thus, this module is called masked-causal attention.
    Interfaces:
        ``__init__``, ``forward``
    """

    def __init__(self, h_dim: int, max_T: int, n_heads: int, drop_p: float) -> None:
        """
        Overview:
            Initialize the MaskedCausalAttention Model according to input arguments.
        Arguments:
            - h_dim (:obj:`int`): The dimension of the hidden layers, such as 128.
            - max_T (:obj:`int`): The max context length of the attention, such as 6.
            - n_heads (:obj:`int`): The number of heads in calculating attention, such as 8.
            - drop_p (:obj:`float`): The drop rate of the drop-out layer, such as 0.1.
        """
        super().__init__()
        self.n_heads = n_heads
        self.max_T = max_T
        self.q_net = nn.Linear(h_dim, h_dim)
        self.k_net = nn.Linear(h_dim, h_dim)
        self.v_net = nn.Linear(h_dim, h_dim)
        self.proj_net = nn.Linear(h_dim, h_dim)
        self.att_drop = nn.Dropout(drop_p)
        self.proj_drop = nn.Dropout(drop_p)
        ones = torch.ones((max_T, max_T))
        mask = torch.tril(ones).view(1, 1, max_T, max_T)
        self.register_buffer('mask', mask)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        """
        Overview:
            MaskedCausalAttention forward computation graph, input a sequence tensor             and return a tensor with the same shape.
        Arguments:
            - x (:obj:`torch.Tensor`): The input tensor.
        Returns:
            - out (:obj:`torch.Tensor`): Output tensor, the shape is the same as the input.
        Examples:
            >>> inputs = torch.randn(2, 4, 64)
            >>> model = MaskedCausalAttention(64, 5, 4, 0.1)
            >>> outputs = model(inputs)
            >>> assert outputs.shape == torch.Size([2, 4, 64])
        """
        B, T, C = x.shape
        N, D = (self.n_heads, C // self.n_heads)
        q = self.q_net(x).view(B, T, N, D).transpose(1, 2)
        k = self.k_net(x).view(B, T, N, D).transpose(1, 2)
        v = self.v_net(x).view(B, T, N, D).transpose(1, 2)
        weights = q @ k.transpose(2, 3) / math.sqrt(D)
        weights = weights.masked_fill(self.mask[..., :T, :T] == 0, float('-inf'))
        normalized_weights = F.softmax(weights, dim=-1)
        attention = self.att_drop(normalized_weights @ v)
        attention = attention.transpose(1, 2).contiguous().view(B, T, N * D)
        out = self.proj_drop(self.proj_net(attention))
        return out


INIT_ARGS = {
    'h_dim': 8,
    'max_T': 5,
    'n_heads': 2,
    'drop_p': 0.1,
}

ARGS = {
    'x': torch.randn(2, 3, 8),
}

if __name__ == '__main__':
    model = MaskedCausalAttention(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Input shape: {ARGS['x'].shape}")
    print(f"Output shape: {output.shape}")
    assert output.shape == ARGS['x'].shape, f"Shape mismatch: {output.shape} != {ARGS['x'].shape}"
    print("Test passed!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family float, shape (2, 3, 8) — shape (2, 3, 8) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
TransformerBlock Ran
ran on a synthesized input · constructed an object; no result was computed
corl-team/CORL/algorithms/offline/dt.py
code served (permissive licence) · get_code("d879368facd3289e")
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 an instance of its own class, TransformerBlock: the run constructed the object and did not call it, so no result was computed. 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)

# Define parameters for TransformerBlock.__init__
seq_len = 8
embedding_dim = 4
num_heads = 2
attention_dropout = 0.1
residual_dropout = 0.1

ARGS = {
    'seq_len': seq_len,
    'embedding_dim': embedding_dim,
    'num_heads': num_heads,
    'attention_dropout': attention_dropout,
    'residual_dropout': residual_dropout
}
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 TransformerBlock — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a TransformerBlock 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
TransformerBlock Ran
ran on a synthesized input · constructed an object; no result was computed
zzmtsvv/rl_task/decision_transformer/model.py
pointer only (licence: NONE) · get_code("12cc4b7038955563")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zzmtsvv/rl_task when it was checked. 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. A run is recorded.

dt_config Ran
ran on a synthesized input · constructed an object; no result was computed
zzmtsvv/rl_task/decision_transformer/model.py
pointer only (licence: NONE) · get_code("30bf51af033aeb98")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, zzmtsvv/rl_task when it was checked. 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. A run is recorded.

evaluate_episode Ran
ran; our contract draft was wrong, not the code
Amadeus979/decision-transformer/gym/decision_transformer/evaluation/evaluate_episodes.py
code served (permissive licence) · get_code("1ed718456cb9f7a0")
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 1, 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

torch.manual_seed(0)

# Create a mock environment
class MockEnv:
    def __init__(self, state_dim):
        self.state_dim = state_dim
        self.step_count = 0
    
    def reset(self):
        self.step_count = 0
        return np.random.randn(self.state_dim).astype(np.float32)
    
    def step(self, action):
        self.step_count += 1
        state = np.random.randn(self.state_dim).astype(np.float32)
        reward = float(np.random.randn())
        done = self.step_count >= 5
        info = {}
        return state, reward, done, info

# Create a minimal model that implements get_action method
class MockModel(nn.Module):
    def __init__(self, state_dim, act_dim):
        super().__init__()
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.linear = nn.Linear(state_dim, act_dim)
    
    def get_action(self, states, actions, rewards, target_return=None):
        # states shape: (seq_len, state_dim)
        # actions shape: (seq_len, act_dim)
        # rewards shape: (seq_len,)
        # Returns action of shape (act_dim,)
        output = self.linear(states[-1:])  # Use last state
        return output.squeeze(0)

state_dim = 4
act_dim = 3
env = MockEnv(state_dim)
model = MockModel(state_dim, act_dim)
state_mean = np.zeros(state_dim, dtype=np.float32)
state_std = np.ones(state_dim, dtype=np.float32)

ARGS = {
    'env': env,
    'state_dim': state_dim,
    'act_dim': act_dim,
    'model': model,
    'max_ep_len': 1000,
    'device': 'cpu',
    'target_return': 0.0,
    'mode': 'normal',
    'state_mean': state_mean,
    'state_std': state_std,
}
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 tuple, ndim 1, 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
evaluate_episode_rtg Ran
ran; our contract draft was wrong, not the code
Amadeus979/decision-transformer/gym/decision_transformer/evaluation/evaluate_episodes.py
code served (permissive licence) · get_code("9c904f0602da78d7")
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) and returned tuple, ndim 1, 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

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

# Create a minimal environment mock
class MockEnv:
    def __init__(self, state_dim, act_dim):
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.step_count = 0
    
    def reset(self):
        self.step_count = 0
        return np.random.randn(self.state_dim).astype(np.float32)
    
    def step(self, action):
        self.step_count += 1
        state = np.random.randn(self.state_dim).astype(np.float32)
        reward = np.random.randn()
        done = self.step_count >= 5
        info = {}
        return state, reward, done, info

# Create a minimal model that has get_action method
class MockDecisionTransformer(nn.Module):
    def __init__(self, state_dim, act_dim):
        super().__init__()
        self.state_dim = state_dim
        self.act_dim = act_dim
        self.linear = nn.Linear(state_dim, act_dim)
    
    def get_action(self, states, actions, rewards, returns_to_go, timesteps):
        # states: (seq_len, state_dim)
        # returns_to_go: (1, seq_len)
        # timesteps: (1, seq_len)
        # Output: (act_dim,)
        batch_size = states.shape[0]
        action = self.linear(states[-1:])  # Take last state
        return action.squeeze(0)

state_dim = 4
act_dim = 3
device = 'cpu'

env = MockEnv(state_dim, act_dim)
model = MockDecisionTransformer(state_dim, act_dim)

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

ARGS = {
    'env': env,
    'state_dim': state_dim,
    'act_dim': act_dim,
    'model': model,
    'max_ep_len': 10,
    'scale': 1000.0,
    'state_mean': state_mean,
    'state_std': state_std,
    'device': device,
    'target_return': 100.0,
    'mode': 'normal'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
instantiate_class Ran
ran; our contract draft was wrong, not the code
facebookresearch/salina/salina_examples/offline_rl/decision_transformer/agents.py
code served (permissive licence) · get_code("77a7fd5bc546c3a1")
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 Linear. 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 importlib import import_module

torch.manual_seed(0)

# The function instantiate_class takes an 'arguments' parameter
# It expects a dict with 'classname' key and other kwargs for the class constructor
# The classname should be a full module path like 'module.path.ClassName'

# Let's create a simple test class to instantiate
class SimpleModel(nn.Module):
    def __init__(self, input_dim=4, output_dim=3):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        return self.linear(x)

# Build arguments dict for instantiate_class
# We'll instantiate a torch.nn.Linear layer as an example
ARGS = {
    'arguments': {
        'classname': 'torch.nn.Linear',
        'in_features': 4,
        'out_features': 3
    }
}
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 Linear — a Linear output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Linear 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
mlp Ran
ran; our contract draft was wrong, not the code
facebookresearch/salina/salina_examples/offline_rl/decision_transformer/agents.py
code served (permissive licence) · get_code("4e4aebc21d42fb20")
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)

# The mlp function takes:
# - sizes: a list of integers representing layer dimensions
# - activation: a callable that returns an activation module (default nn.ReLU)
# - output_activation: a callable that returns an activation module (default nn.Identity)

# Create a simple sizes list for a small MLP
sizes = [4, 8, 6, 2]

# Use default activations
activation = nn.ReLU
output_activation = nn.Identity

ARGS = {
    "sizes": sizes,
    "activation": activation,
    "output_activation": output_activation
}
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
ActionMLPAgentFromTransformer Not yet run
unverified (harvested, no recorded run)
facebookresearch/salina/salina_examples/offline_rl/decision_transformer/agents.py
code served (permissive licence) · get_code("81de786f2fb6de0b")
How it ran

no invocation recorded.

CausalSelfAttention Not yet run
unverified (harvested, no recorded run)
yun-kwak/decision-transformer-jax/dt_jax/gpt.py
code served (permissive licence) · get_code("143914639aea2cb9")
How it ran

no invocation recorded.

DecisionTransformer Not yet run
unverified (harvested, no recorded run)
Delavari-Alireza/Decision_Transformer_Sequence-Modeling_Deep_Reinforcement_Learning/HalfCheetah/model.py
code served (permissive licence) · get_code("e8829585a4a05826")
How it ran

no invocation recorded.

DecisionTransformer Not yet run
unverified (harvested, no recorded run)
pytorch/rl/torchrl/modules/models/decision_transformer.py
code served (permissive licence) · get_code("5cbb6e8c7b3ba6c7")
How it ran

no invocation recorded.

DecisionTransformer Not yet run
unverified (harvested, no recorded run)
opendilab/DI-engine/ding/model/template/decision_transformer.py
code served (permissive licence) · get_code("d6dc19545c453079")
How it ran

no invocation recorded.

Dropout Not yet run
unverified (harvested, no recorded run)
yun-kwak/decision-transformer-jax/dt_jax/gpt.py
code served (permissive licence) · get_code("2a9e66156b160093")
How it ran

no invocation recorded.

GPT Not yet run
unverified (harvested, no recorded run)
yun-kwak/decision-transformer-jax/dt_jax/gpt.py
code served (permissive licence) · get_code("b1501ba16b463b22")
How it ran

no invocation recorded.

TransformerBlock Not yet run
unverified (harvested, no recorded run)
yun-kwak/decision-transformer-jax/dt_jax/gpt.py
code served (permissive licence) · get_code("9b48d1222dabdd2c")
How it ran

no invocation recorded.

load_tf_weights_in_gpt2 Not yet run
unverified (harvested, no recorded run)
Amadeus979/decision-transformer/gym/decision_transformer/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 26 samples lifted from this paper's linked repositories, 26 carry a function identity and 0 do not. Of the 26 distinct functions with an identity, 7 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 7 later) and 19 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
22 later
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
2205.05128 (2022-05)
Human Language Modeling
and 19 more not named here
discount_cumsum 17 other papers
17 later
2110.06206 (2021-10)
StARformer: Transformer with State-Action-Reward Representations for Visual Reinforcement Learning
2111.10364 (2021-11)
Generalized Decision Transformer for Offline Hindsight Information Matching
2201.12122 (2022-01)
Can Wikipedia Help Offline Reinforcement Learning?
and 14 more not named here
evaluate_episode 3 other papers
3 later
2202.05607 (2022-02)
Online Decision Transformer
2206.08353 (2022-06)
Towards Understanding How Machines Can Learn Causal Overhypotheses
2403.07309 (2024-03)
Reinforced Sequential Decision-Making for Sepsis Treatment: The POSNEGDM Framework with Mortality Classifier and Transformer
evaluate_episode_rtg 3 other papers
3 later
2202.05607 (2022-02)
Online Decision Transformer
2206.08353 (2022-06)
Towards Understanding How Machines Can Learn Causal Overhypotheses
2403.07309 (2024-03)
Reinforced Sequential Decision-Making for Sepsis Treatment: The POSNEGDM Framework with Mortality Classifier and Transformer
Agent
brick of this paper's assembly: helper
1 other paper
1 later
2110.14457 (2021-10)
Direct then Diffuse: Incremental Unsupervised Skill Discovery for State Covering and Goal Reaching
Block
brick of this paper's assembly: model
1 other paper
1 later
2502.02834 (2025-02)
Task-Aware Virtual Training: Enhancing Generalization in Meta-Reinforcement Learning for Out-of-Distribution Tasks
TransformerBlock
brick of this paper's assembly: model
1 other paper
1 later
2302.07351 (2023-02)
Constrained Decision Transformer for Offline Safe Reinforcement Learning

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-22.

Repositories linked to this paper

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

Abstract

We introduce a framework that abstracts Reinforcement Learning (RL) as a sequence modeling problem. This allows us to draw upon the simplicity and scalability of the Transformer architecture, and associated advances in language modeling such as GPT-x and BERT. In particular, we present Decision Transformer, an architecture that casts the problem of RL as conditional sequence modeling. Unlike prior approaches to RL that fit value functions or compute policy gradients, Decision Transformer simply outputs the optimal actions by leveraging a causally masked Transformer. By conditioning an autoregressive model on the desired return (reward), past states, and actions, our Decision Transformer model can generate future actions that achieve the desired return. Despite its simplicity, Decision Transformer matches or exceeds the performance of state-of-the-art model-free offline RL baselines on Atari, OpenAI Gym, and Key-to-Door tasks.

For agents

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

get_harvested_code_for_paper("2106.01345")
get_code_for_paper("2106.01345")
have("2106.01345")

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

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

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

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

Connect an agent — have() is free.