SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2502.15805 · ICLR · 2025

FragFM: Hierarchical Framework for Efficient Molecule Generation via Fragment-Level Discrete Flow Matching

Hyunwoo Kim, Seonghwan Kim, Kim, Seokhyun Moon, Youn Woo, Joongwon Lee

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 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 7 have no contract verdict; 1 failure of our instrument; 6 no recorded run), measured 2026-11-24; 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/2502.15805.json · badge: /api/ran/2502.15805.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
wengong-jin/icml18-jtnn canonical (classifier label)
classifier basis not recorded on the link
4 ran · 2 no recorded run
datamol-io/safe canonical (classifier label)
classifier basis not recorded on the link
3 ran · 2 no recorded run
wengong-jin/hgraph2graph canonical (classifier label)
classifier basis not recorded on the link
1 ran · 2 no recorded run
FunctionStatusWhere it lives
avg_pool Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
wengong-jin/icml18-jtnn/fast_jtnn/nnutils.py
code served (permissive licence) · get_code("ae8276a108a62271")
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. 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, 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
from torch.autograd import Variable

torch.manual_seed(0)

# Analyze the function:
# - all_vecs: used with .sum(dim=dim), so it's a tensor
# - scope: iterated over with unpacking (_, le), so it's a list of tuples
# - dim: passed to .sum(dim=dim), so it's an integer

# Create all_vecs as a tensor with shape suitable for summing
# Using batch=2, features=4, but we need a dimension to sum over
all_vecs = torch.randn(2, 4, 3)  # shape: (batch=2, features=4, seq_len=3)

# Create scope as a list of tuples where second element is a length
# The lengths will be used to create a size tensor for normalization
scope = [("token_a", 5), ("token_b", 3)]

# dim is the dimension to sum over
dim = 2

ARGS = {
    "all_vecs": all_vecs,
    "scope": scope,
    "dim": dim
}
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
create_var Ran
ran on a synthesized input
wengong-jin/icml18-jtnn/fast_jtnn/nnutils.py
code served (permissive licence) · get_code("e09eb05126a7c40e")
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. 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, 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
from torch.autograd import Variable

torch.manual_seed(0)

# Create a small tensor for testing
tensor = torch.randn(2, 4)

# Define ARGS dict with all parameters
ARGS = {
    'tensor': tensor,
    'requires_grad': None
}
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
find_partition_edges Ran
ran on a synthesized input
datamol-io/safe/safe/utils.py
code served (permissive licence) · get_code("1b9306ad1c77d4dd")
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 list, ndim 2, dtype family int; 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 networkx as nx

# Create a small test graph
G = nx.Graph()
G.add_edges_from([(0, 1), (1, 2), (2, 3), (0, 3), (1, 4), (4, 5)])

# Create a partition of the graph nodes into subgraphs
partition = [[0, 1, 2], [3, 4, 5]]

ARGS = {
    "G": G,
    "partition": partition
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list 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
index_select_ND Ran
ran on a synthesized input
wengong-jin/icml18-jtnn/fast_jtnn/nnutils.py
code served (permissive licence) · get_code("6cfa3e07a37cd10c")
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 4, dtype family float, shape (2, 3, 3, 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 torch

torch.manual_seed(0)

# Construct valid arguments for index_select_ND
# The function takes:
# - source: a tensor that will have index_select applied along dim
# - dim: the dimension along which to select
# - index: a tensor of indices to select

# Create a source tensor with shape (5, 3, 2) - batch dim 5, other dims 3 and 2
source = torch.randn(5, 3, 2)

# dim should be a valid dimension in source (0, 1, or 2)
dim = 0

# index should be a 1D or multi-dimensional tensor of indices
# Valid indices range from 0 to source.size(dim)-1
# Create a 2D index tensor for demonstration
index = torch.tensor([[0, 2, 4], [1, 3, 0]])

ARGS = {
    "source": source,
    "dim": dim,
    "index": index
}
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 4, dtype family float, shape (2, 3, 3, 2) — shape (2, 3, 3, 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
onek_encoding_unk Ran
ran on a synthesized input
wengong-jin/icml18-jtnn/fast_jtnn/jtmpn.py
code served (permissive licence) · get_code("c0968545f446bb6a")
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 map. 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

torch.manual_seed(0)

# The function onek_encoding_unk takes two parameters:
# 1. x - a value to check against allowable_set
# 2. allowable_set - a list/set of allowable values to compare against

# The function checks if x is in allowable_set, and if not, uses the last element
# Then it returns a map object that compares x against each element in allowable_set

# Simple setup with strings
x = "carbon"
allowable_set = ["hydrogen", "carbon", "nitrogen", "oxygen", "unknown"]

ARGS = {
    "x": x,
    "allowable_set": allowable_set
}
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 map — a map output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a map 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
ring_label Ran
ran on a synthesized input
datamol-io/safe/safe/_connect.py
code served (permissive licence) · get_code("a56074a6bdbb7678")
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 int, ndim 0, dtype family int, shape () 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
from typing import Optional

# Define the function
_DIGITS = frozenset('0123456789')

def ring_label(token: str) -> Optional[int]:
    """Return the ring-closure label an atom-glue token encodes, else ``None``.

    Handles bare single digits, the two-digit ``%NN`` form and RDKit's extended
    ``%(nnn)`` form. Bracket atoms (``[13C]``, ``[NH3+]``, ``[*:12]``) are single
    tokens whose inner digits are never ring closures, so they return ``None``.
    """
    if len(token) == 1 and token in _DIGITS:
        return int(token)
    if token.startswith('%(') and token.endswith(')'):
        inner = token[2:-1]
        return int(inner) if inner.isdigit() else None
    if token.startswith('%') and token[1:].isdigit():
        return int(token[1:])
    return None

# Test cases to validate the function behavior
test_cases = [
    "5",           # bare single digit
    "0",           # bare single digit
    "%42",         # two-digit %NN form
    "%(123)",      # extended %(nnn) form
    "[13C]",       # bracket atom - should return None
    "[NH3+]",      # bracket atom - should return None
    "[*:12]",      # bracket atom - should return None
    "abc",         # non-digit string
    "%",           # incomplete form
    "%(abc)",      # extended form with non-digits
]

# Construct ARGS with the token parameter
ARGS = {
    "token": "5"
}
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 int, ndim 0, dtype family int, shape () — shape () 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
split Ran
ran on a synthesized input
datamol-io/safe/safe/_tokenizer_utils.py
code served (permissive licence) · get_code("3f2fce2269e966e4")
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 list, ndim 1, 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 re
from loguru import logger

class SAFESplitter:
    """Split a SAFE string into notation tokens."""
    REGEX_PATTERN = '(\\[[^\\]]+]|Br?|Cl?|N|O|S|P|F|I|b|c|n|o|s|p|\\(|\\)|\\.|=|#|-|\\+|\\\\|\\/|:|~|@|\\?|>>?|\\*|\\$|\\%\\([0-9]{1,5}\\)|\\%[0-9]{2}|[0-9])'
    name = 'safe'

    def __init__(self, pattern=None):
        if pattern is None:
            pattern = self.REGEX_PATTERN
        self.regex = re.compile(pattern)

    def tokenize(self, line):
        """Tokenize a SAFE string."""
        if isinstance(line, str):
            tokens = list(self.regex.findall(line))
            reconstruction = ''.join(tokens)
            if line != reconstruction:
                logger.error(f'Tokens different from sample:\ntokens {reconstruction}\nsample {line}.')
                raise ValueError(line)
        else:
            idxs = re.finditer(self.regex, str(line))
            tokens = [line[match.start(0):match.end(0)] for match in idxs]
        return tokens

    def detokenize(self, chars):
        """Reconstruct a SAFE string from tokens."""
        if isinstance(chars, str):
            chars = chars.split(' ')
        return ''.join((value.strip() for value in chars))

    def split(self, _index, normalized):
        """Pretokenize a value for Hugging Face Tokenizers."""
        return self.tokenize(normalized)

    def pre_tokenize(self, pretok):
        """Apply this splitter to a Hugging Face pretokenizer."""
        pretok.split(self.split)

def split(safe_str: str):
    """Split a SAFE string into notation tokens."""
    return SAFESplitter().tokenize(safe_str)

# Valid SAFE string examples
ARGS = {
    'safe_str': 'CCO'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
loguru — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
to_numpy Ran
ran on a synthesized input
wengong-jin/hgraph2graph/preprocess.py
code served (permissive licence) · get_code("1c18207a5e5c2fac")
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. 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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - tensors is unpacked into (a, b, c)
# - a is returned as-is
# - b is a tuple of two lists
# - b[0] and b[1] are lists where each element is either a torch.Tensor or something else
# - c is returned as-is
# - The convert function checks if x is a torch.Tensor and calls .numpy() on it

# Create test tensors
tensor1 = torch.randn(2, 4)
tensor2 = torch.randn(3, 4)
tensor3 = torch.randn(2, 5)

# Create a simple value for a (not a tensor, just returned as-is)
a_value = "metadata"

# Create lists for b with mixed tensor and non-tensor types
b_list_0 = [tensor1, tensor2]
b_list_1 = [tensor3, 42]

# Create value for c (not a tensor, just returned as-is)
c_value = {"config": "value"}

# Construct the tensors tuple argument
tensors_arg = (a_value, (b_list_0, b_list_1), c_value)

ARGS = {
    "tensors": tensors_arg
}
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 — a tuple 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
analyze Not yet run
unverified (harvested, no recorded run)
datamol-io/safe/safe/_connect.py
code served (permissive licence) · get_code("520a0786e56b4db4")
How it ran

no invocation recorded.

atom_features Not yet run
unverified (harvested, no recorded run)
wengong-jin/icml18-jtnn/fast_jtnn/jtmpn.py
code served (permissive licence) · get_code("ce9a23f3afe1e874")
How it ran

no invocation recorded.

atom_features Not yet run
unverified (harvested, no recorded run)
wengong-jin/icml18-jtnn/fast_jtnn/mpn.py
code served (permissive licence) · get_code("dd7d3d25a676ebb4")
How it ran

no invocation recorded.

process Not yet run
unverified (harvested, no recorded run)
wengong-jin/hgraph2graph/get_vocab.py
pointer only (licence: MIT); the stored copy get_code serves, from einae-nd/moama-dev, is pointer only (licence: NONE) · get_code("d33c6045784db272")
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 einae-nd/moama-dev, 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. No invocation recorded.

set_atommap Not yet run
unverified (harvested, no recorded run)
wengong-jin/hgraph2graph/hgraph/chemutils.py
pointer only (licence: MIT); the stored copy get_code serves, from einae-nd/moama-dev, is pointer only (licence: NONE) · get_code("64031117dac3cd1d")
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 einae-nd/moama-dev, 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. No invocation recorded.

split Not yet run
unverified (harvested, no recorded run)
datamol-io/safe/safe/tokenizer.py
code served (permissive licence) · get_code("1d75b0fe2361c83d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 7 are also present in other papers whose code we hold (7 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
index_select_ND 3 other papers
3 dated earlier
2002.04720 (2020-02)
Improving Molecular Design by Stochastic Iterative Target Augmentation
2010.03951 (2020-10)
MolDesigner: Interactive Design of Efficacious Drugs with Deep Learning
2110.09681 (2021-10)
Permutation invariant graph-to-sequence model for template-free retrosynthesis and reaction prediction
atom_features 2 other papers
2 dated earlier
1812.01070 (2018-12)
Learning Multimodal Graph-to-Graph Translation for Molecular Optimization
2107.00096 (2021-07)
Improving black-box optimization in VAE latent space using decoder uncertainty
set_atommap 2 other papers
2 dated earlier
2002.04720 (2020-02)
Improving Molecular Design by Stochastic Iterative Target Augmentation
2309.04589 (2023-09)
Motif-aware Attribute Masking for Molecular Graph Pre-training
atom_features 1 other paper
1 dated earlier
2010.03951 (2020-10)
MolDesigner: Interactive Design of Efficacious Drugs with Deep Learning
avg_pool 1 other paper
1 dated earlier
2002.04720 (2020-02)
Improving Molecular Design by Stochastic Iterative Target Augmentation
onek_encoding_unk 1 other paper
1 dated earlier
1812.01070 (2018-12)
Learning Multimodal Graph-to-Graph Translation for Molecular Optimization
process 1 other paper
1 dated earlier
2309.04589 (2023-09)
Motif-aware Attribute Masking for Molecular Graph Pre-training

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

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 FragFM, a novel hierarchical framework via fragment-level discrete flow matching for efficient molecular graph generation. FragFM generates molecules at the fragment level, leveraging a coarse-to-fine autoencoder to reconstruct details at the atom level. Together with a stochastic fragment bag strategy to effectively handle a large fragment space, our framework enables more efficient, scalable molecular generation. We demonstrate that our fragment-based approach achieves better property control than the atom-based method and additional flexibility through conditioning the fragment bag. We also propose a Natural Product Generation benchmark (NPGen) to evaluate the ability of modern molecular graph generative models to generate natural product-like molecules. Since natural products are biologically prevalidated and differ from typical drug-like molecules, our benchmark provides a more challenging yet meaningful evaluation relevant to drug discovery. We conduct a comparative study of FragFM against various models on diverse molecular generation benchmarks, including NPGen, demonstrating superior performance. The results highlight the potential of fragment-based generative modeling for large-scale, property-aware molecular design, paving the way for more efficient exploration of chemical space.

For agents

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

get_harvested_code_for_paper("2502.15805")
get_code_for_paper("2502.15805")
have("2502.15805")

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

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

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

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

Connect an agent — have() is free.