SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.02347 · 2024

Riemannian Preconditioned LoRA for Fine-Tuning Foundation Models

arXiv · PDF · Open in the Atlas

Code that ran

15 of 21 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; 3 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 9 failures of our instrument; 6 no recorded run), 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/2402.02347.json · badge: /api/ran/2402.02347.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
pilancilab/Riemannian_Preconditioned_LoRA canonical (classifier label)
classifier basis: census
12 ran · 6 no recorded run
copy not recorded community
not in the paper's declared repositories
3 ran · 0 no recorded run
FunctionStatusWhere it lives
convert_vae_state_dict Ran
ran; our contract draft was wrong, not the code
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/to_ckpt_v2.py
code served (permissive licence) · get_code("0e6846a624e7d973")
How it ran

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

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a mock VAE state dict with various keys that will be transformed
vae_state_dict = {
    'encoder.conv_in.weight': torch.randn(4, 3, 3, 3),
    'encoder.down.0.block.0.norm_out.weight': torch.randn(8),
    'encoder.down.0.block.0.nin_shortcut.weight': torch.randn(8, 4, 1, 1),
    'decoder.up.0.block.0.conv_norm_out.weight': torch.randn(8),
    'decoder.up.0.block.0.conv_shortcut.weight': torch.randn(8, 4, 1, 1),
    'mid_block.attentions.0.norm.weight': torch.randn(8),
    'mid_block.attentions.0.q.weight': torch.randn(8, 8),
    'mid_block.attentions.0.k.weight': torch.randn(8, 8),
    'mid_block.attentions.0.v.weight': torch.randn(8, 8),
    'mid_block.attentions.0.proj_out.weight': torch.randn(8, 8),
    'decoder.conv_out.weight': torch.randn(3, 4, 3, 3),
}

ARGS = {
    'vae_state_dict': vae_state_dict,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
gelu Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from UCDvision/NOLA
pointer only · get_code("8d23fbe2b99b840b")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

gelu_fast Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from UCDvision/NOLA
pointer only · get_code("a4475703ff58ecf9")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

gelu_new Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from UCDvision/NOLA
pointer only · get_code("dc9ffc0f29e7fa3d")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

image_grid Ran
ran; our contract draft was wrong, not the code
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/utils.py
code served (permissive licence) · get_code("2dda05eee1b6e0f7")
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 Image. 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.

from PIL import Image
import math

# Create a list of small PIL Images
img1 = Image.new('RGB', size=(64, 48), color='red')
img2 = Image.new('RGB', size=(64, 48), color='blue')
img3 = Image.new('RGB', size=(64, 48), color='green')
img4 = Image.new('RGB', size=(64, 48), color='yellow')

_imgs = [img1, img2, img3, img4]

ARGS = {
    '_imgs': _imgs,
    'rows': None,
    'cols': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
inject_trainable_lora Ran
ran; our contract draft was wrong, not the code
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/lora.py
code served (permissive licence) · get_code("4b4a8984a2737ae5")
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. 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)

# Build a minimal model that contains modules matching the search criteria
class SimpleAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 8)
        self.linear2 = nn.Linear(8, 4)
    
    def forward(self, x):
        return self.linear2(self.linear1(x))

class CrossAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.linear(x)

class Attention(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.linear(x)

class GEGLU(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.linear(x)

class TestModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.cross_attn = CrossAttention()
        self.attn = Attention()
        self.geglu = GEGLU()
        self.other_linear = nn.Linear(4, 8)
    
    def forward(self, x):
        x = self.cross_attn(x)
        x = self.attn(x)
        x = self.geglu(x)
        x = self.other_linear(x)
        return x

# Create model instance
model = TestModel()

# Define ARGS dictionary with all parameters for inject_trainable_lora
ARGS = {
    'model': model,
    'target_replace_module': {'CrossAttention', 'Attention', 'GEGLU'},
    'r': 2,
    'loras': None,
    'verbose': False,
    'dropout_p': 0.1,
    'scale': 1.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
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
inject_trainable_lora_extended Ran
ran, honoured the contract we drafted
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/lora.py
code served (permissive licence) · get_code("3aec51ff694c19af")
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 2, 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 torch
import torch.nn as nn
from typing import Set, Optional

torch.manual_seed(0)

# Create a minimal model that mimics a UNet structure with target modules
class SimpleResnetBlock2D(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 8)
        self.linear2 = nn.Linear(8, 4)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

class SimpleCrossAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.to_q = nn.Linear(4, 4)
        self.to_k = nn.Linear(4, 4)
        self.to_v = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.to_q(x)

class SimpleAttention(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

class SimpleGEGLU(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def forward(self, x):
        return self.linear(x)

class SimpleUNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.resnet_block = SimpleResnetBlock2D()
        self.cross_attention = SimpleCrossAttention()
        self.attention = SimpleAttention()
        self.geglu = SimpleGEGLU()
    
    def forward(self, x):
        x = self.resnet_block(x)
        x = self.cross_attention(x)
        x = self.attention(x)
        x = self.geglu(x)
        return x

# Create model instance
model = SimpleUNet()

# Define ARGS dictionary with all parameters for inject_trainable_lora_extended
ARGS = {
    'model': model,
    'target_replace_module': {'ResnetBlock2D', 'CrossAttention', 'Attention', 'GEGLU'},
    'r': 2,
    'loras': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
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
inpainting_dataloader Ran
ran on a synthesized input
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/cli_lora_pti.py
code served (permissive licence) · get_code("d793962f13865771")
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 DataLoader. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.utils.data import Dataset

torch.manual_seed(0)

# Create a minimal tokenizer that has the required interface
class MinimalTokenizer:
    def __init__(self):
        self.model_max_length = 77
    
    def pad(self, token_dict, padding=None, max_length=None, return_tensors=None):
        input_ids = token_dict['input_ids']
        # Pad sequences to max_length
        padded_ids = []
        for ids in input_ids:
            if len(ids) < max_length:
                ids = ids + [0] * (max_length - len(ids))
            else:
                ids = ids[:max_length]
            padded_ids.append(ids)
        
        result_dict = {'input_ids': torch.tensor(padded_ids)}
        # Return object with input_ids attribute
        class PadResult:
            pass
        pad_result = PadResult()
        pad_result.input_ids = torch.tensor(padded_ids)
        return pad_result

# Create a minimal VAE (not actually used in collate_fn but passed as arg)
class MinimalVAE(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)

# Create a minimal text encoder (not actually used in collate_fn but passed as arg)
class MinimalTextEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)

# Create a minimal dataset
class InpaintingDataset(Dataset):
    def __init__(self, num_samples=2):
        self.num_samples = num_samples
    
    def __len__(self):
        return self.num_samples
    
    def __getitem__(self, idx):
        # Return example dict with required keys
        example = {
            'instance_prompt_ids': [101, 2054, 2003, 102],  # tokenized text
            'instance_images': torch.randn(3, 4, 4),  # 3 channels, 4x4 image
            'instance_masks': torch.ones(1, 4, 4),    # 1 channel mask
            'instance_masked_images': torch.randn(3, 4, 4),  # 3 channels, 4x4 image
        }
        return example

# Construct arguments
train_dataset = InpaintingDataset(num_samples=2)
train_batch_size = 2
tokenizer = MinimalTokenizer()
vae = MinimalVAE()
text_encoder = MinimalTextEncoder()

ARGS = {
    'train_dataset': train_dataset,
    'train_batch_size': train_batch_size,
    'tokenizer': tokenizer,
    'vae': vae,
    'text_encoder': text_encoder,
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
prepare_clip_model_sets Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/utils.py
code served (permissive licence) · get_code("298713e11f263fda")
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. 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
from transformers import CLIPProcessor, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionModelWithProjection
from unittest.mock import Mock, MagicMock

torch.manual_seed(0)

# Mock the from_pretrained class methods to avoid downloads
def mock_from_pretrained(cls, model_id):
    instance = Mock(spec=cls)
    instance.config = Mock()
    return instance

CLIPTextModelWithProjection.from_pretrained = classmethod(lambda cls, model_id: mock_from_pretrained(cls, model_id))
CLIPTokenizer.from_pretrained = classmethod(lambda cls, model_id: mock_from_pretrained(cls, model_id))
CLIPVisionModelWithProjection.from_pretrained = classmethod(lambda cls, model_id: mock_from_pretrained(cls, model_id))
CLIPProcessor.from_pretrained = classmethod(lambda cls, model_id: mock_from_pretrained(cls, model_id))

ARGS = {
    'eval_clip_id': 'openai/clip-vit-large-patch14'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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
reshape_weight_for_sd Ran
ran, honoured the contract we drafted
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/to_ckpt_v2.py
code served (permissive licence) · get_code("a1d506dd99d38923")
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 (4, 3, 1, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function reshape_weight_for_sd takes a tensor w and reshapes it
# by appending two dimensions of size 1 at the end
# It uses w.reshape() and w.shape, so w must be a torch.Tensor

w = torch.randn(4, 3)

ARGS = {
    "w": w
}
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 (4, 3, 1, 1) — shape (4, 3, 1, 1) 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
safe_open Ran
ran; our contract draft was wrong, not the code
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/safe_open.py
code served (permissive licence) · get_code("f999bed53b70c3ab")
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 SafetensorsWrapper. 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 tempfile
import json
import os

torch.manual_seed(0)

# Create a temporary safetensors file for testing
temp_dir = tempfile.mkdtemp()
filename = os.path.join(temp_dir, "test.safetensors")

# Create a minimal safetensors file
# Format: [8 bytes header with metadata length][metadata json][tensor data]

# Create some test tensors
tensor1 = torch.randn(2, 4, dtype=torch.float32)
tensor2 = torch.randn(3, 5, dtype=torch.float16)

# Serialize tensors to bytes
tensor1_bytes = tensor1.numpy().tobytes()
tensor2_bytes = tensor2.half().numpy().tobytes()

# Build metadata
metadata = {
    "tensor1": {
        "dtype": "F32",
        "shape": [2, 4],
        "data_offsets": [0, len(tensor1_bytes)]
    },
    "tensor2": {
        "dtype": "F16",
        "shape": [3, 5],
        "data_offsets": [len(tensor1_bytes), len(tensor1_bytes) + len(tensor2_bytes)]
    },
    "__metadata__": {}
}

metadata_json = json.dumps(metadata)
metadata_bytes = metadata_json.encode('utf-8')
header = len(metadata_bytes).to_bytes(8, 'little')

# Write the file
with open(filename, 'wb') as f:
    f.write(header)
    f.write(metadata_bytes)
    f.write(tensor1_bytes)
    f.write(tensor2_bytes)

ARGS = {
    'filename': filename,
    'framework': 'pt',
    'device': 'cpu'
}
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 SafetensorsWrapper — a SafetensorsWrapper output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SafetensorsWrapper 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
swin_ir_sr Ran
ran, honoured the contract we drafted
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/preprocess_files.py
code served (permissive licence) · get_code("ec4e915ba607e9c9")
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 4, dtype family int; 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 numpy as np
from PIL import Image
from unittest.mock import Mock, MagicMock

torch.manual_seed(0)

# Create small test images
def create_test_image(width=8, height=6):
    """Create a small PIL image for testing"""
    arr = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
    return Image.fromarray(arr)

# Create mock model and processor
class MockSwin2SRModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(1, 1)
    
    def forward(self, pixel_values):
        # Simulate model output
        batch_size = pixel_values.shape[0]
        # Return reconstruction with shape [batch, 3, height, width]
        reconstruction = torch.rand(batch_size, 3, 16, 16)
        output = Mock()
        output.reconstruction = reconstruction
        return output
    
    def to(self, device):
        super().to(device)
        return self

class MockSwin2SRProcessor:
    def __call__(self, image, return_tensors=None):
        # Simulate processor output
        pixel_values = torch.rand(1, 3, 8, 8)
        output = Mock()
        output.pixel_values = pixel_values
        
        def to_device(device):
            output.pixel_values = output.pixel_values.to(device)
            return output
        
        output.to = to_device
        output.__iter__ = lambda self: iter([('pixel_values', self.pixel_values)])
        output.keys = lambda: ['pixel_values']
        output.__getitem__ = lambda self, key: self.pixel_values
        
        return output

# Mock the transformers imports
import sys
from unittest.mock import MagicMock

mock_transformers = MagicMock()
mock_transformers.Swin2SRForImageSuperResolution.from_pretrained.return_value = MockSwin2SRModel()
mock_transformers.Swin2SRImageProcessor.return_value = MockSwin2SRProcessor()

sys.modules['transformers'] = mock_transformers

# Build arguments
ARGS = {
    'images': [create_test_image(8, 6), create_test_image(10, 12)],
    'model_id': 'caidas/swin2SR-classical-sr-x2-64',
    'target_size': None,
    'device': torch.device('cpu'),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, tqdm, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 4, 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
test_xformers_backwards Ran
ran, violated the contract we drafted
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/xformers_utils.py
code served (permissive licence) · get_code("bdf6d68955356de7")
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 bool, ndim 0, dtype family float, shape () 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
import functools

torch.manual_seed(0)

# The function test_xformers_backwards takes a single parameter 'size'
# which is used as a dimension for creating tensors in the inner function
# The function attempts to call xformers.ops.memory_efficient_attention
# We need to provide a small integer size value

ARGS = {
    'size': 8
}
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 bool, ndim 0, dtype family float, 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
text2img_dataloader Ran
ran on a synthesized input
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/cli_lora_pti.py
code served (permissive licence) · get_code("aa63f591fb2e9bd7")
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 DataLoader. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.utils.data import Dataset

torch.manual_seed(0)

# Mock VAE model
class MockVAE(nn.Module):
    def __init__(self):
        super().__init__()
        self.device = torch.device('cpu')
        self.dtype = torch.float32
        self.linear = nn.Linear(4, 4)
    
    def encode(self, x):
        # Returns an object with latent_dist that has a sample() method
        class LatentDist:
            def sample(self):
                return torch.randn(1, 4, 4, 4)
        return type('obj', (object,), {'latent_dist': LatentDist()})()

# Mock Text Encoder
class MockTextEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)

# Mock Tokenizer
class MockTokenizer:
    def __init__(self):
        self.model_max_length = 77
    
    def pad(self, input_dict, padding=None, max_length=None, return_tensors=None):
        input_ids = input_dict['input_ids']
        # Pad each sequence to max_length
        padded = []
        for ids in input_ids:
            if len(ids) < max_length:
                ids = ids + [0] * (max_length - len(ids))
            else:
                ids = ids[:max_length]
            padded.append(ids)
        padded_tensor = torch.tensor(padded)
        return type('obj', (object,), {'input_ids': padded_tensor})()

# Mock Dataset
class MockDataset(Dataset):
    def __init__(self, size=2):
        self.size = size
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        return {
            'instance_prompt_ids': [1, 2, 3],
            'instance_images': torch.randn(3, 4, 4),  # 3 channels, 4x4 image
            'mask': torch.randn(4, 4)
        }

vae = MockVAE()
text_encoder = MockTextEncoder()
tokenizer = MockTokenizer()
train_dataset = MockDataset(size=2)
train_batch_size = 2

ARGS = {
    'train_dataset': train_dataset,
    'train_batch_size': train_batch_size,
    'tokenizer': tokenizer,
    'vae': vae,
    'text_encoder': text_encoder,
    'cached_latents': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
text_img_alignment Ran
ran; our contract draft was wrong, not the code
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/utils.py
code served (permissive licence) · get_code("8dbc9878c5043ebc")
How it ran

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

import torch

torch.manual_seed(0)

# Create small tensors for the function
# img_embeds: batch of image embeddings
# text_embeds: batch of text embeddings (same batch size as img_embeds)
# target_img_embeds: batch of target image embeddings (can be different size)

batch_size = 2
embed_dim = 4
target_batch_size = 3

img_embeds = torch.randn(batch_size, embed_dim)
text_embeds = torch.randn(batch_size, embed_dim)
target_img_embeds = torch.randn(target_batch_size, embed_dim)

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

no invocation recorded.

clipseg_mask_generator Not yet run
unverified (harvested, no recorded run)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/preprocess_files.py
code served (permissive licence) · get_code("98530605dba303f0")
How it ran

no invocation recorded.

convert_unet_state_dict Not yet run
unverified (harvested, no recorded run)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/to_ckpt_v2.py
code served (permissive licence) · get_code("f2b2f19d941175af")
How it ran

no invocation recorded.

create_tensor Not yet run
unverified (harvested, no recorded run)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/safe_open.py
code served (permissive licence) · get_code("effb6d8bd6b936e2")
How it ran

no invocation recorded.

extract_lora_ups_down Not yet run
unverified (harvested, no recorded run)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/lora.py
code served (permissive licence) · get_code("2f9880b526ff277e")
How it ran

no invocation recorded.

lora_join Not yet run
unverified (harvested, no recorded run)
pilancilab/Riemannian_Preconditioned_LoRA/Object_Generation/lora_diffusion/lora_manager.py
code served (permissive licence) · get_code("47566c65ffdc7fa2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 21 samples lifted from this paper's linked repositories, 21 carry a function identity and 0 do not. Of the 21 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 0 the same month, 6 later) and 11 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
gelu 51 other papers
46 dated earlier, 4 later, 1 same year, order not determinable · 8 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
and 48 more not named here
gelu_new 24 other papers
20 dated earlier, 4 later
2004.10964 (2020-04)
Don't Stop Pretraining: Adapt Language Models to Domains and Tasks
2104.08066 (2021-04)
Effect of Visual Extensions on Natural Language Understanding in Vision-and-Language Models
2104.08400 (2021-04)
Structure-Aware Abstractive Conversation Summarization via Discourse and Action Graphs
and 21 more not named here
gelu_fast 22 other papers
18 dated earlier, 4 later
2010.03957 (2020-10)
Transformers for Modeling Physical Systems
2104.08066 (2021-04)
Effect of Visual Extensions on Natural Language Understanding in Vision-and-Language Models
2104.08400 (2021-04)
Structure-Aware Abstractive Conversation Summarization via Discourse and Action Graphs
and 19 more not named here
inject_trainable_lora 10 other papers
5 dated earlier, 4 later, 1 same year, order not determinable
2208.01618 (2022-08)
An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion
2208.12242 (2022-08)
DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation
2308.06571 (2023-08)
ModelScope Text-to-Video Technical Report
and 7 more not named here
extract_lora_ups_down 8 other papers
3 dated earlier, 4 later, 1 same year, order not determinable
2208.12242 (2022-08)
DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation
2312.07315 (2023-12)
NVS-Adapter: Plug-and-Play Novel View Synthesis from a Single Image
2312.17250 (2023-12)
iFusion: Inverting Diffusion for Pose-Free Reconstruction from Sparse Views
and 5 more not named here
inject_trainable_lora_extended 6 other papers
2 dated earlier, 4 later
2208.12242 (2022-08)
DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation
2312.07315 (2023-12)
NVS-Adapter: Plug-and-Play Novel View Synthesis from a Single Image
2403.07860 (2024-03)
Bridging Different Language Models and Generative Vision Models for Text-to-Image Generation
and 3 more not named here
inpainting_dataloader 2 other papers
2 dated earlier
2106.05744 (2021-06)
Pivotal Tuning for Latent-based Editing of Real Images
2310.04687 (2023-10)
Targeted Attack Improves Protection against Unauthorized Diffusion Customization
text2img_dataloader 2 other papers
2 dated earlier
2106.05744 (2021-06)
Pivotal Tuning for Latent-based Editing of Real Images
2310.04687 (2023-10)
Targeted Attack Improves Protection against Unauthorized Diffusion Customization
create_tensor 1 other paper
1 dated earlier
2312.07315 (2023-12)
NVS-Adapter: Plug-and-Play Novel View Synthesis from a Single Image
safe_open 1 other paper
1 dated earlier
2312.07315 (2023-12)
NVS-Adapter: Plug-and-Play Novel View Synthesis from a Single Image

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

Low-Rank Adaptation (LoRA) emerges as a popular parameter-efficient fine-tuning (PEFT) method, which proposes to freeze pretrained model weights and update an additive low-rank trainable matrix. In this work, we study the enhancement of LoRA training by introducing an $r \times r$ preconditioner in each gradient step where $r$ is the LoRA rank. We theoretically verify that the proposed preconditioner stabilizes feature learning with LoRA under infinite-width NN setting. Empirically, the implementation of this new preconditioner requires a small change to existing optimizer code and creates virtually minuscule storage and runtime overhead. Our experimental results with both large language models and text-to-image diffusion models show that with this new preconditioner, the convergence and reliability of SGD and AdamW can be significantly enhanced. Moreover, the training process becomes much more robust to hyperparameter choices such as learning rate. The new preconditioner can be derived from a novel Riemannian metric in low-rank matrix field. Code can be accessed at https://github.com/pilancilab/Riemannian_Preconditioned_LoRA.

For agents

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

get_harvested_code_for_paper("2402.02347")
get_code_for_paper("2402.02347")
have("2402.02347")

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

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

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

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

Connect an agent — have() is free.