arXiv:2610.10395cs.LGOct 2026

Manuscript Offprint

arXiv:2610.10395

Executing Causal Structure Learning with Linear-Attention Transformers

Amartya Roy, Sayar Karmakar

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Transformers can execute algorithms on data given in their input. We ask whether they can do the same for causal discovery. We study a standard continuous method that repeatedly updates a candidate causal graph while enforcing acyclicity. We explicitly construct a fixed-weight transformer whose forward pass exactly reproduces one update of this method, so repeated blocks reproduce its optimization trajectory. The transformer carries the current graph and the algorithm's multiplier between updates. We show that retaining the multiplier is essential for exact execution, since different multiplier values can lead to different next updates. We also give conditions under which, within a fixed stage, the number of updates needed to reach a target accuracy can be computed in advance and rounding errors stay bounded as depth grows. Experiments show that the constructed block agrees with a reference update to floating-point precision, while arithmetic replay on synthetic data and seven published benchmark network topologies inherits the reference solver's successes and failures. This separates accurate algorithm execution from accurate causal recovery. In contrast, the ordinary attention models tested under our training budgets do not reliably execute the update or transfer to larger graphs. Whether gradient training can learn an executor in the architecture class of the construction remains open.

Keywords Transformers · Causal discovery · Algorithm execution · Linear attention · Continuous DAG learning · Augmented Lagrangian.

1 Introduction

Can a transformer carry out causal discovery by executing a known solver, with weights fixed before seeing the data? The question grows out of a line of work on what transformers can compute from their prompt. Constructive studies of in-context learning show how a transformer can compute on examples it is shown (Garg et al., 2022) and even implement gradient descent in its forward pass (Akyürek et al., 2022; von Oswald et al., 2022; Ahn et al., 2023). Later constructions go further, building networks that carry out proximal updates, looped programs and graph algorithms (Bai et al., 2023; Giannou et al., 2023). What these results share is that the weights are specified rather than fitted, so the forward pass is a known computation and one can say exactly what it computes, how deep it must be and where it loses precision.

Causal discovery looks like a natural next test, and a harder one. A weighted directed graph over p variables is a causal graph only if it contains no directed cycle, and this global requirement couples every edge to every other. Continuous formulations turn the requirement into a smooth constraint: NOTEARS replaces the combinatorial search over acyclic graphs by an equality constraint on the weighted adjacency matrix (Zheng et al., 2018), and polynomial variants have the same acyclic zeros (Yu et al., 2019; Wei et al., 2020). The resulting solvers alternate between a gradient-and-threshold step on the edge weights and an update of a multiplier that tightens the acyclicity penalty. A transformer that is to execute such a solver must do more than evaluate a gradient. It must evaluate a matrix-power constraint, apply a sparse proximal step, respect an allowed-edge mask, and keep a second piece of state, the multiplier, available for the next update.

Roy and Karmakar

This is the problem we take on. We study the complete update of a continuous DAG solver, which combines a least-squares gradient, a polynomial acyclicity penalty, a sparse proximal step and a multiplier update. Each ingredient is established; the question is how to execute their composition in a transformer and retain the state the next update needs. The state is the crux. The next update depends on both the weighted adjacency matrix W and the multiplier α\alpha, so we encode this complete state in the prompt and build a fixed-weight block that maps it to the next state, leaving the penalty schedule and stopping rule external. Figure 1 shows the resulting correspondence between the solver and transformer trajectories.

(a)

Figure

(b)

Figure

Figure 1: One update, run two ways. The solver carries the edge matrix WℓW_\ell and multiplier αℓ\alpha_\ell; the fixed-weight transformer carries the same state in ZℓZ_\ell. With identical controls, the two transitions agree exactly (Theorem 4.1). The surfaces are schematic.

Our answer is an explicit construction. A single set of weights, shared by all graphs with up to pmax⁡p_{\max} variables, executes one update exactly with depth O(log⁡pmax⁡)O(\log p_{\max}) and width O(pmax⁡)O(p_{\max}), and we prove a matching depth order for linear attention with bilinear/ReLU sublayers and affine encoding and readout (Section 4). Because the multiplier is carried from one block to the next rather than recomputed, it is the quantity most easily lost, and we show that losing it changes the next update; we also bound the error this causes and explain why constraint evaluations need care as the graph approaches acyclicity (Section 5). Within a fixed penalty stage we give conditions under which the number of updates needed for a target accuracy can be computed in advance (Section 6), and we relate the solver's output to the true graph (Section 7).

The experiments then ask whether this works in practice. 1^{1} The constructed block agrees with an independent reference implementation of the update to floating-point precision, and repeated blocks reproduce the solver's trajectory. Replaying the updates on synthetic data and on seven published benchmark network topologies gives the same graphs as the reference solver, including its mistakes: reproducing the solver's updates also reproduces its statistical and optimization errors, so accurate execution should not be confused with accurate causal recovery (Section 8). Ordinary attention models trained under our budgets, by contrast, do not reliably execute the update or transfer to larger graphs, and whether gradient training can find an executor in the architecture class of the construction remains open. We stress the scope of the claim. The block executes the Poly-prox update for supplied controls; it does not choose the schedule, run line searches or decide when to stop, and the reference solver serves as a well-defined target rather than a state-of-the-art estimator.

The rest of the paper follows this story. Section 2 reviews related work and Section 3 states the solver and its reference update. Section 4 builds the block, and Sections 5–7 study what is lost through the multiplier, the constraint and finite precision, and how exact execution relates to recovery. Section 8 reports the experiments and Section 9 concludes. Proofs and experimental details are in the appendices.

References (44)