arXiv:2611.07876cs.SENov 2026

Manuscript Offprint

arXiv:2611.07876

Which Signals of Code Correctness Survive Distribution Shift? Hidden-State and Causal Predictors of Program and Verdict Correctness

Viola Campos, Thomas Klassert, Adrian Ulges

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

Viola Campos, Thomas Klassert, and Adrian Ulges

RheinMain University of Applied Sciences

Wiesbaden, Germany

{viola.campos, adrian.ulges}@hs-rm.de

thomas.klassert@student.hs-rm.de

Abstract—Large language models increasingly judge code, yet without external feedback such judgments are unreliable, and verifying them by executing tests or by extended reasoning is costly. Instead, execution-free correctness predictors use signals from the model's output probabilities, sampled solutions, or hidden states to identify judgments that warrant further verification. However, these predictors may degrade under distribution shifts when generalizing across projects and languages.

We compare six execution-free predictors from four families on Qwen3-Coder-30B and gpt-oss-20b under benchmark shift between LiveCodeBench and BigCodeBench and language shift across Python, C++ and Java. We evaluate two targets: whether the model's own verdict on a program can be trusted, and whether the program itself is correct. Besides established approaches, we adapt two novel causal localization methods to code, which have been shown to be more robust out-of-distribution on natural language tasks.

For verdict correctness, causal localization improves robustness to language shift. For Qwen3-Coder a probe on the causally localized subspace stays 0.09 AUROC ahead of output confidence under language shift (0.11 in distribution), significantly outperforming the best non-causal predictor by 0.04 AUROC on average. This advantage, however, does not generalize consistently to gpt-oss or to benchmark shift. For program correctness, predictors transfer more successfully between benchmarks, largely by identifying problems on which the model tends to fail. However, their ability to rank candidates within the same problem is limited.

Index Terms—code correctness prediction, uncertainty estimation, LLM-as-a-judge, distribution shift, causal interpretability

I. INTRODUCTION

LLMs are increasingly used to judge code, including their own. They determine whether a candidate solves its task, whether a change is safe to accept, and which of several candidates to keep. Without external feedback, such judgments are unreliable. Models rarely improve by verifying their own outputs [18], [26], favor their own generations [37], and remain inconsistent as code judges [23]. Reliable verification is costly: executing tests requires an environment and a test suite [41], and reasoning about a candidate involves generating many additional tokens. A cheap signal indicating when a judgment can be trusted could gate these costlier checks rather than replace them [24], [42]. Execution-free correctness predictors provide such a signal from the model itself, such as the probability of its answer [4], [48], the agreement among sampled solutions [2], [5], [47], or its hidden states [3], [45], [51]. Probes on hidden states are particularly cheap, since they reuse activations the model computes anyway, and are already deployed as first-stage monitors [27], [33]. Such a predictor serves two purposes: it can estimate whether a program is correct, and whether the model's own verdict on it can be trusted.

Although predictors trained on hidden states are accurate in distribution, their acknowledged weakness is distribution shift [27], [36]. For code this is critical, as a predictor fitted on one benchmark or programming language will usually be applied to other projects and languages. For natural-language question answering, Huang et al. [19] proposed causal localization as a remedy: they use counterfactual interventions, which copy part of the hidden state from one input into another and observe how the model's answer changes, to find the subspace that robustly determines the answer under shift. Whether this promise holds for code correctness assessment remains open. Instead, prior work on code has considered only a subset of predictor families and shift settings, and has largely focused on predicting program correctness [12], [15], [20], [44]. To our knowledge, none includes causal methods or asks whether the model's own verdict can be trusted.

We therefore ask which execution-free signals of code correctness survive a change of benchmark or programming language, and what explains those that do. We adapt two causal methods of Huang et al., counterfactual simulation and value probing, to code and compare them with output confidence, a probe on the hidden state, LAT [45] and EigenScore [5]. To do so, we use Qwen3-Coder-30B and gpt-oss-20b for candidate generation and as judges; we apply shifts between LiveCodeBench and BigCodeBench and between Python, C++ and Java. We then answer four research questions: RQ1 asks how well the methods tell whether the model's verdict can be trusted, the target the causal methods were designed for; RQ2 asks which part of the causal methods carries their signal; RQ3 asks how well the methods predict whether the program is correct, the target of most prior work; and

RQ4 asks whether agreement across samples, which requires no supervised training, tells better than a single pass which problems the model will solve.

Our results show that causal localization pays off where it was designed to: under language shift, a probe on the localized subspace is the most robust predictor of Qwen3-Coder's verdict, significantly ahead of every non-causal method, and the learned subspace itself, not the intervention, carries this gain. On gpt-oss, no method stands out. Beyond the causal methods, generalization depends on the target and the type of shift: no verdict predictor transfers reliably between benchmarks, program correctness transfers largely because the predictors recognize difficult problems, and agreement across samples gives no consistent advantage over a single pass.

Our contributions are:

  • To our knowledge, the first comparison of execution-free correctness predictors for code across four families, including causal methods, under both benchmark and language shift and for two targets.

  • An adaptation of causal localization [19] to code correctness prediction.

  • An analysis showing that the learned subspace carries the advantage of the causal methods, and a distinction between candidate-level prediction and problem-level reliability: pooled AUROC must be read alongside a predictor's ability to rank the candidates of one problem.

References (52)