Fixed Tensor Testing logo

Fixed Tensor Testing

Organization
cxcscmu
fixed-tensor-testing

Test ML functions with fixed input tensors for reproducibility.

Overview

Publishercxcscmu
RepositorySkillLearnBench
Skill namefixed-tensor-testing
Stars
91
Forks
7
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by cxcscmu on GitHub. Read the source before you install it.

Installation

Install the Fixed Tensor Testing AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/cxcscmu/SkillLearnBench/tree/main/skills/b1-one-shot-claude-haiku-4-5/nlp-paper-reproduction/fixed-tensor-testing
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/cxcscmu/SkillLearnBench.git /tmp/SkillLearnBench
mkdir -p .claude/skills
cp -r /tmp/SkillLearnBench/skills/b1-one-shot-claude-haiku-4-5/nlp-paper-reproduction/fixed-tensor-testing .claude/skills/fixed-tensor-testing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Fixed Tensor Testing in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Fixed Tensor Testing on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Fixed Tensor Testing is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Testing with Fixed Input Tensors

Purpose

Fixed tensor testing ensures deterministic, reproducible results for loss functions and model outputs. Enables verification without training dependencies.

Creating Fixed Tensors

1. Deterministic Seeding

python
import torch
import numpy as np

# Set all random seeds
torch.manual_seed(42)
np.random.seed(42)
if torch.cuda.is_available():
    torch.cuda.manual_seed_all(42)

2. Creating Test Tensors

python
# Fixed log probabilities (typically negative)
log_probs = torch.randn(batch_size, seq_len)
# Ensure reasonable log prob range (e.g., -2 to 0)
log_probs = torch.clamp(log_probs, min=-5.0, max=0.0)

# Fixed sequence lengths
seq_lengths = torch.randint(10, 100, (batch_size,))

# Fixed input IDs (for masking)
input_ids = torch.randint(0, vocab_size, (batch_size, seq_len))

3. Example Test Setup

python
batch_size = 4
seq_len = 10

# Generate fixed tensors
torch.manual_seed(123)
log_probs = torch.randn(batch_size, seq_len)
log_probs = torch.clamp(log_probs, -5.0, 0.0)

# Create mask (e.g., padding)
mask = torch.ones(batch_size, seq_len, dtype=torch.bool)
mask[:, seq_len-2:] = False  # Last 2 tokens are padding

# Lengths accounting for mask
seq_lengths = mask.sum(dim=1).float()

Saving Test Results

Save as .npz (NumPy Compressed)

python
import numpy as np

results = {
    'losses': loss.cpu().detach().numpy(),
    'log_probs': log_probs.cpu().detach().numpy(),
}

np.savez_compressed('/path/to/results.npz', **results)

Load .npz Files

python
data = np.load('/path/to/results.npz')
losses = data['losses']
print(f"Shape: {losses.shape}, dtype: {losses.dtype}")

Assertions and Validation

Basic Checks

python
# Loss should be finite and positive
assert torch.isfinite(loss).all(), "Loss contains NaN or Inf"
assert loss.item() > 0, "Loss should be positive"

# Shape validation
assert loss.shape == expected_shape, f"Shape mismatch: {loss.shape}"

# Range checks
assert loss.item() < 100, "Loss unreasonably large"
assert log_probs.min() >= -6.0, "Log probs too small"

Reproducibility Checks

python
# Run computation twice, should get same result
loss1 = compute_loss(fixed_tensors)
loss2 = compute_loss(fixed_tensors)
assert torch.allclose(loss1, loss2), "Loss not reproducible"

Common Test Patterns

1. Unit Test for Loss Function

python
def test_simpo_loss():
    # Setup fixed inputs
    batch_size = 8
    torch.manual_seed(42)

    log_probs = torch.randn(batch_size, 20)
    seq_lengths = torch.full((batch_size,), 20.0)

    # Compute loss
    beta = 2.0
    gamma = 1.0

    loss = compute_simpo_loss(log_probs, seq_lengths, beta, gamma)

    # Assertions
    assert loss.shape == torch.Size([])
    assert torch.isfinite(loss)
    assert loss.item() > 0

    return loss.item()

2. Gradient Flow Test

python
# Ensure gradients can backpropagate
x = torch.randn(5, 10, requires_grad=True)
loss = some_loss_function(x)
loss.backward()
assert x.grad is not None
assert not torch.allclose(x.grad, torch.zeros_like(x.grad))

3. Numerical Stability Test

python
# Test with extreme values
extreme_inputs = [
    torch.full((5,), -100.0),  # Very negative log probs
    torch.full((5,), 0.0),      # Zero log probs
    torch.zeros(5),             # All zeros
]

for inp in extreme_inputs:
    try:
        loss = compute_loss(inp)
        assert torch.isfinite(loss), f"Loss not finite for {inp}"
    except Exception as e:
        print(f"Failed with input {inp}: {e}")

Best Practices

  1. Use consistent seeds across test runs
  2. Document expected outputs for regression testing
  3. Test edge cases (empty batches, single samples, extreme values)
  4. Validate shapes before and after operations
  5. Check numerical stability with both typical and extreme inputs
  6. Save results in standard formats (.npz, .pt, .json)

Debugging Fixed Tensor Tests

python
# Print intermediate values
def debug_loss(log_probs, seq_lengths, beta, gamma):
    rewards = beta * log_probs / seq_lengths.unsqueeze(1)
    print(f"Rewards shape: {rewards.shape}, min: {rewards.min():.4f}, max: {rewards.max():.4f}")

    # ... rest of computation

    print(f"Final loss: {loss.item():.6f}")
    return loss

Frequently asked questions

What does the Fixed Tensor Testing AI skill do?

Test ML functions with fixed input tensors for reproducibility.

Why use Fixed Tensor Testing on TypingMind?

Because you install it once and use it with any model. Fixed Tensor Testing is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Fixed Tensor Testing in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/cxcscmu/SkillLearnBench/tree/main/skills/b1-one-shot-claude-haiku-4-5/nlp-paper-reproduction/fixed-tensor-testing. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Fixed Tensor Testing?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Fixed Tensor Testing?

As many as you like. As long as a model supports skills, you can use Fixed Tensor Testing with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Fixed Tensor Testing AI skill free?

Yes. It is published on GitHub by cxcscmu under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇