| DeepRBFKernel |
Ran ran on a synthesized input |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("83a90dd71ef26edf") How it ranRan 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 4, dtype family float, shape (2, 2, 3, 5) 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 torch.distributions as dist
from torch.distributions.kl import kl_divergence
class RBFKernel(nn.Module):
def __init__(self, in_size, prior_log_mean=None, prior_log_logvar=None, map_est=False):
super().__init__()
self.map_est = map_est
log_init = torch.tensor(0.5).log() * torch.ones(in_size + 1) + 0.05 * torch.randn(in_size + 1)
self.log_mean = nn.Parameter(log_init)
self.log_logvar = nn.Parameter(-2 * torch.ones(in_size + 1))
self.register_buffer('prior_log_mean', prior_log_mean if prior_log_mean is not None else torch.zeros_like(self.log_mean))
self.register_buffer('prior_log_logvar', prior_log_logvar if prior_log_logvar is not None else torch.zeros_like(self.log_logvar))
def compute(self, kern_samples, x, y=None):
"""
Generic batch kernel evaluation. Send
y = None for efficient re-use of computations
in case x = y.
Arguments:
kern_samples: n_hypers x (in_size + 1)
x: ...batches x M x D
y: ...batches x N x D, if None, assumed equals x
Returns:
n_hypers x ...batches x M x N
"""
n_hypers = kern_samples.size(0)
kern_samples = kern_samples.view(n_hypers, 1, *[1] * len(x.shape[:-2]), -1)
sigma = kern_samples[..., :-1].exp()
gamma2 = (kern_samples[..., -1:] * 2.0).exp()
sx = x.unsqueeze(0) / sigma
xx = torch.einsum('...ji,...ki->...jk', sx, sx)
if y is None:
yy = xy = xx
else:
sy = y.unsqueeze(0) / sigma
yy = torch.einsum('...ji,...ki->...jk', sy, sy)
xy = torch.einsum('...ji,...ki->...jk', sx, sy)
dnorm2 = -2.0 * xy + xx.diagonal(dim1=-2, dim2=-1).unsqueeze(-1) + yy.diagonal(dim1=-2, dim2=-1).unsqueeze(-2)
return gamma2 * (-0.5 * dnorm2).exp()
def compute_diag(self, kern_samples):
gamma2 = (kern_samples[..., -1:] * 2.0).exp().unsqueeze(-2)
return gamma2
def sample_hypers(self, n_hypers):
if self.map_est:
return self.log_mean.unsqueeze(0)
log_dist = dist.Normal(self.log_mean, self.log_logvar.exp().sqrt())
log_hypers = log_dist.rsample(torch.Size([n_hypers]))
return log_hypers
def kl_hypers(self):
if self.map_est:
return torch.tensor(0.0, device=self.log_mean.device)
var_dist = dist.Normal(self.log_mean, self.log_logvar.exp().sqrt())
prior_dist = dist.Normal(self.prior_log_mean, self.prior_log_logvar.exp().sqrt())
total_kl = kl_divergence(var_dist, prior_dist).sum(dim=0)
return total_kl
class DeepRBFKernel(RBFKernel):
def __init__(self, in_size, feature_size=64, **kwargs):
super().__init__(feature_size, **kwargs)
self.phi = nn.Sequential(nn.Linear(in_size, 256), nn.ReLU(), nn.Linear(256, 256), nn.ReLU(), nn.Linear(256, feature_size))
def compute(self, kern_samples, x, y=None):
x = self.phi(x)
if y is not None:
y = self.phi(y)
return super().compute(kern_samples, x, y=y)
INIT_ARGS = {
'in_size': 4,
'feature_size': 8,
'map_est': False,
}
ARGS = {
'kern_samples': torch.randn(2, 9),
'x': torch.randn(2, 3, 4),
'y': torch.randn(2, 5, 4),
}
METHOD = 'compute'
if __name__ == '__main__':
model = DeepRBFKernel(**INIT_ARGS)
result = getattr(model, METHOD)(**ARGS)
print(f"Result shape: {result.shape}")
print(f"Result: {result}")
- 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 4, dtype family float, shape (2, 2, 3, 5) — shape (2, 2, 3, 5) 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)
|
| MulticlassSoftmax |
Ran ran on a synthesized input |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("7054eeeb5bbdcb29") How it ranRan 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 4, dtype family float, shape (2, 3, 4, 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
import torch.nn as nn
import torch.nn.functional as F
class MulticlassSoftmax(nn.Module):
def __init__(self, n_f=1):
super().__init__()
self.n_f = n_f
def forward(self, mu, var):
"""
Arguments:
mu: n_hypers x out_size x B
var: n_hypers x out_size x B
Returns:
Predictions for function samples.
y_f: n_hypers x n_f x out_size x B
"""
n_hypers, out_size, B = mu.shape
eps = torch.randn(n_hypers, self.n_f, out_size, B, device=mu.device)
f_samples = mu.unsqueeze(1) + var.sqrt().unsqueeze(1) * eps
y_f = F.log_softmax(f_samples, dim=-2)
return y_f
def loss(self, pred_mu, pred_var, y):
"""
Arguments:
pred_mu: n_hypers x out_size x B
pred_var: n_hypers x out_size x B
y: B
Returns:
Total loss scalar value.
"""
pred_y = self(pred_mu, pred_var).permute(3, 2, 0, 1)
target_y = y.view(-1, 1, 1).expand(-1, *pred_y.shape[-2:])
lik_loss = F.nll_loss(pred_y, target_y, reduction='none').mean(dim=-1).mean(dim=-1).sum(dim=0)
return lik_loss
def predict(self, mu, var):
"""
Arguments:
mu: n_hypers x out_size x B
var: n_hypers x out_size x B
Returns
output probabilities B x out_size
"""
y_f = self(mu, var)
y = y_f.view(-1, *mu.shape[-2:])
probs = y.logsumexp(dim=0).exp() / y.size(0)
return probs.T
INIT_ARGS = {
'n_f': 3
}
ARGS = {
'mu': torch.randn(2, 4, 2),
'var': torch.abs(torch.randn(2, 4, 2)) + 0.1
}
METHOD = 'forward'
if __name__ == '__main__':
model = MulticlassSoftmax(**INIT_ARGS)
output = model(**ARGS)
print("Output shape:", output.shape)
print("Output:", output)
- 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 4, dtype family float, shape (2, 3, 4, 2) — shape (2, 3, 4, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| RBFKernel |
Ran ran on a synthesized input |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("bcc66d9ddfa88032") How it ranRan 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 4, 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
INIT_ARGS = {
"in_size": 4,
"prior_log_mean": torch.tensor([0.1, -0.2, 0.3, -0.1, 0.0]),
"prior_log_logvar": torch.tensor([-1.0, -1.5, -2.0, -2.5, -3.0]),
"map_est": False,
}
# Create input tensors for computation
x = torch.randn(2, 3, 4) # batch=2, M=3, D=4
y = torch.randn(2, 5, 4) # batch=2, N=5, D=4
ARGS = {
"kern_samples": torch.randn(2, 5), # n_hypers=2, in_size+1=5
"x": x,
"y": y,
}
METHOD = "compute"
- 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 4, 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)
|
| cholesky |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("09e7ee9467bbb608") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
torch.manual_seed(0)
# Create a small positive definite matrix for Cholesky decomposition
# M should be symmetric positive definite
# Using a simple approach: create a random matrix and multiply by its transpose
batch_size = 2
dim = 4
random_matrix = torch.randn(batch_size, dim, dim)
M = torch.bmm(random_matrix, random_matrix.transpose(-2, -1)) + torch.eye(dim).unsqueeze(0)
ARGS = {
"M": M,
"eps": 0.0001
}
- 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 Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 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
|
| gp_cond |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("3c32ec62ac281327") How it ranRan 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
torch.manual_seed(0)
# Parameters for gp_cond function
# u: ... x M x 1
# Kzz: ... x M x M
# Kzx: ... x M x N
# Kxx: ... x N x N
M = 4 # inducing points dimension
N = 5 # data points dimension
batch_size = 2
# u: batch x M x 1
u = torch.randn(batch_size, M, 1)
# Kzz: batch x M x M (covariance matrix, must be positive definite)
Kzz_base = torch.randn(batch_size, M, M)
Kzz = torch.bmm(Kzz_base, Kzz_base.transpose(-2, -1)) + 0.1 * torch.eye(M).unsqueeze(0)
# Kzx: batch x M x N
Kzx = torch.randn(batch_size, M, N)
# Kxx: batch x N x N (covariance matrix, must be positive definite)
Kxx_base = torch.randn(batch_size, N, N)
Kxx = torch.bmm(Kxx_base, Kxx_base.transpose(-2, -1)) + 0.1 * torch.eye(N).unsqueeze(0)
# Optional pre-computed Cholesky decomposition
Lz = None
# Optional pre-computed triangular solve result
Lz_Kzx = None
ARGS = {
'u': u,
'Kzz': Kzz,
'Kzx': Kzx,
'Kxx': Kxx,
'Lz': Lz,
'Lz_Kzx': Lz_Kzx,
}
- 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
|
| linear_joint |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("5bbde606973fa2d6") How it ranRan 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
torch.manual_seed(0)
# Dimensions:
# M = 4 (latent dimension)
# N = 3 (observation dimension)
# Batch size = 2
M = 4
N = 3
batch_size = 2
# m: ... x M x 1
m = torch.randn(batch_size, M, 1)
# S: ... x M x M (covariance, must be positive definite)
S_temp = torch.randn(batch_size, M, M)
S = S_temp @ S_temp.transpose(-2, -1) + 0.1 * torch.eye(M).unsqueeze(0)
# Kzz: ... x M x M (covariance, must be positive definite)
Kzz_temp = torch.randn(batch_size, M, M)
Kzz = Kzz_temp @ Kzz_temp.transpose(-2, -1) + 0.1 * torch.eye(M).unsqueeze(0)
# Kzx: ... x M x N
Kzx = torch.randn(batch_size, M, N)
# V: ... x N x N (covariance, must be positive definite)
V_temp = torch.randn(batch_size, N, N)
V = V_temp @ V_temp.transpose(-2, -1) + 0.1 * torch.eye(N).unsqueeze(0)
# b: ... x N x 1
b = torch.randn(batch_size, N, 1)
# cache: optional dict
cache = {}
ARGS = {
"m": m,
"S": S,
"Kzx": Kzx,
"Kzz": Kzz,
"V": V,
"b": b,
"cache": cache,
}
- 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
|
| linear_marginal_diag |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("b2df6ebf5ba61d4d") How it ranRan 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 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 torch
torch.manual_seed(0)
# Parameters for linear_marginal_diag
# m: ... x M x 1
# S: ... x M x M
# Kzx: ... x M x N
# Kzz: ... x M x M
# Kxx_diag: ... x N
M = 4 # latent dimension
N = 3 # output dimension
batch_shape = (2,) # batch dimensions
# m: batch x M x 1
m = torch.randn(*batch_shape, M, 1)
# S: batch x M x M (must be positive definite)
S_temp = torch.randn(*batch_shape, M, M)
S = torch.matmul(S_temp, S_temp.transpose(-2, -1)) + 0.1 * torch.eye(M)
# Kzz: batch x M x M (must be positive definite)
Kzz_temp = torch.randn(*batch_shape, M, M)
Kzz = torch.matmul(Kzz_temp, Kzz_temp.transpose(-2, -1)) + 0.1 * torch.eye(M)
# Kzx: batch x M x N
Kzx = torch.randn(*batch_shape, M, N)
# Kxx_diag: batch x N (diagonal elements, must be positive)
Kxx_diag = torch.abs(torch.randn(*batch_shape, N)) + 0.1
# cache parameter (optional dict)
cache = {}
ARGS = {
"m": m,
"S": S,
"Kzz": Kzz,
"Kzx": Kzx,
"Kxx_diag": Kxx_diag,
"cache": cache,
}
- 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 3, 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
|
| mat2trilvec |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("c00b44c81cb07664") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 2, dtype family float, shape (2, 10) 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)
# Create a batch of lower triangular matrices
# K=2 (batch size), m=4 (matrix dimension)
K = 2
m = 4
mat = torch.randn(K, m, m)
ARGS = {
"mat": mat
}
- 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 Tensor, ndim 2, dtype family float, shape (2, 10) — shape (2, 10) 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
|
| rev_cholesky |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("07328e40f0f0f5dd") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
torch.manual_seed(0)
# L should be a lower triangular matrix or batch of lower triangular matrices
# The function computes M = LL^T using einsum
# Shape: (..., i, j) where the last two dimensions are the matrix dimensions
L = torch.randn(2, 4, 4)
# Make it lower triangular for a valid Cholesky decomposition
L = torch.tril(L)
ARGS = {
'L': L
}
- 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 Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 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
|
| vec2tril |
Ran ran; our contract draft was wrong, not the code |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("ecbc8bc8c4ea9420") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 3) 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.functional as F
torch.manual_seed(0)
# The function vec2tril takes a vector of shape K x ((m * (m + 1)) // 2)
# and converts it to lower triangular matrices of shape K x m x m.
#
# We need to construct:
# 1. vec: a tensor of shape K x ((m * (m + 1)) // 2)
# 2. m: an integer (optional, can be None)
# Let's choose m = 3 (a small lower triangular matrix)
# For m=3, the number of elements in lower triangular part is (3 * 4) // 2 = 6
m_val = 3
num_elements = (m_val * (m_val + 1)) // 2 # = 6
# Create a batch of vectors
# K = 2 (batch size)
K = 2
vec = torch.randn(K, num_elements)
ARGS = {
"vec": vec,
"m": m_val
}
- 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 Tensor, ndim 3, dtype family float, shape (2, 3, 3) — shape (2, 3, 3) 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
|
| VARGP |
Not yet run unverified (harvested, no recorded run) |
uber-research/vargp/var_gp/vargp.py code served (permissive licence) · get_code("c01a80178407fc13") How it ran |