tensor4all GitHub

How we check code that nobody reads line by line

Most of the tensor4all Rust stack is written by AI agents, and we do not review it line by line. This post explains what we do instead, so that users can judge for themselves how far to trust it.

by Hiroshi Shinaoka (Saitama University), for the tensor4all team

🌐 English · 日本語

Why this post exists

The tensor4all stack (tenferro-rs, tensor4all-rs, and the kernel crates underneath them) is large, and almost all of it was written by coding agents. A natural question from users is: if the authors do not read every line, why should I trust the results?

Our answer is that line-by-line review was never enough on its own to make numerical code trustworthy. Reviewers miss things, and they miss more as code grows. What we can do is move trust into machines that check the code every day, keep their results public, and fail loudly. Without that, we could not use agents at full strength. Agents produce code faster than any human can review it, so either the checks are automatic or the speed is wasted.

The introducing tenferro-rs post described the idea briefly. This post goes through the actual machinery, layer by layer. The scale: as of November 4, 2026, the stack is about 930,000 non-blank lines of Rust across nine repositories (tenferro-rs, tensor4all-rs, strided-rs, tcontract-rs, tlinalg-rs, cpueinsum-rs, hataori-rs, tidu-rs and computegraph-rs, tests included), plus about 36,000 lines we added to our fork of faer.

Principle: checks that keep running

A check that ran once proves little. Code changes every day, dependencies move, and a benchmark that was fast last month says nothing about today. So the most important property of our checks is that they run on a schedule, against the current main branch, and publish their results: audits and oracle replays every day, CPU and GPU benchmarks every weekend.

We also keep the references in their own repositories: gradient data in tensor-ad-oracles, performance comparisons in tenferro-benchmark, tensor4all-benchmark and per-library campaigns. That keeps a change to a reference visible as a change of its own, and it lets the references be rerun against any version of the libraries.

The figure below shows the loop. The super agent and the audit bots in it are described in later sections.

Checks that keep running against main

Correctness of automatic differentiation

Wrong gradients are the hardest bugs to notice: the program runs, the loss goes down, and the result is subtly off. We check gradients against a database instead of against our own reasoning.

We also decided that AD rule files are verified by numerical checks, not by line coverage. Writing tests only to raise a coverage number is explicitly forbidden there.

Correctness of linear algebra kernels

An example: a panic the SVD suite caught

In late October the SVD suite reported a panic for f32 and c32. svd stopped with “buffer is not large enough”, even though its workspace had been sized by svd_scratch with exactly the same arguments. The smallest failing case was an 8 by 8 rank-one matrix, computed by divide and conquer, with only V requested.

The fix (tensor4all/faer#73) corrects the workspace query itself instead of padding the buffer: it models the temporaries that each merge step keeps alive. A focused regression test fails before the fix and passes after it, 4,800 calls around the recursion boundaries pass for all four scalar types, and the full 18,172-call suite then completed without a call failure. The same run also exposed a separate f32 orthogonality problem, which was tracked on its own as #75. The workspace bug is also present in upstream faer 0.24.4, so a self-contained report with a reproducer was prepared for upstream.

Performance

In HPC, performance regressions are nearly as costly as wrong answers, and they are easier to miss because nothing fails. We treat them the same way.

Rules, and checks for the rules

Several collaborators, at different institutions, run their own agents on the same code. Without shared rules, each group’s agents would make the same mistakes separately and settle the same questions differently.

So the rules that hold across repositories live in one public place, tensor4all-agent-rules, for agents and human contributors alike. It covers repository structure and dependency boundaries, release safety, the performance checklist and how performance claims must be measured, documentation and test policy (for example, no doc example may be skipped), crediting third-party work, and numerical and performance rules for Rust and Julia. Each repository’s AGENTS.md stays short and points there; repository-specific rules such as REPOSITORY_RULES.md and PERFORMANCE_TIPS.md in tenferro-rs sit on top.

The first rule is that the implementation outranks the documentation: when a document and the code disagree, the document is the defect. When an agent makes a mistake that a rule could have prevented, the rule is added, and every collaborator’s agents pick it up.

Rules alone are only text, so the CI enforces what can be enforced mechanically:

A supervising agent between the workers and the maintainer

The agents that write code do not work unsupervised. Day to day, most implementation is done by worker agents running inexpensive models. Above them sits a supervising agent, the “super agent”, which plays the part a careful maintainer would:

The super agent does not replace the mechanical checks above. It decides what to build and when to stop; whether the result is correct and fast is still decided by the oracles, the benchmarks and CI.

How a supervising agent drives agents on several machines

Handling the volume of pull requests and issues

People often ask how a small group keeps up. In the 30 days up to November 4, 2026, eight of our repositories (tenferro-rs, tensor4all-rs, strided-rs, tcontract-rs, tlinalg-rs, cpueinsum-rs, our faer fork and tenferro-benchmark) merged about 920 pull requests, opened about 570 issues and closed about 600. What makes this manageable:

How one change reaches main

Auditing what is already merged

CI checks a pull request once. Code that passed last month can be wrong today because something around it changed. So we also run scheduled audits over the merged code. They are operated from a private repository, and they report through ordinary public issues:

The auditors open issues, and the regression benchmark job opens pull requests. Both go through the same gates as everything else.

What this does not guarantee

We want to be clear about the limits.

If you find a result you do not trust, please open an issue. If it reveals a gap, the fix will include a new check, not only a code change.