acceptodds
Under review as a conference paper at ICLR 2027

Understanding Brittleness to Variable Renaming in Decoder-only Code Models

Abstract

Transformer-based code models increasingly support compiler and programming- language tasks, including program analysis, performance prediction, and code generation. Recent work has shown that Transformer-based models for code are sensitive to simple semantics-preserving edits such as variable renaming. For example, a simple variable renaming can induce sizable prediction shifts in these models. The mechanisms that underlie this brittleness to variable renaming are not well understood, though. In this paper, we aim to investigate such mechanisms. In particular, we investigate where failures arise in the model, which components are involved in such failures, and whether the diversity of variable names in the training set affects the robustness of models to variable renaming. To enable our controlled experiments, we introduce TINYTRACER, a framework that generates synthetic Python programs and their execution traces under controlled training and test distributions. We use this framework to train small decoder-only Transformers from scratch to predict execution traces, while varying the diversity of variable names in the training set. We test the robustness of the trained models by taking programs that the models trace correctly and consistently replacing their variable names with other names. In these small scale models trained with low variable-name diversity, the first error in a failed trace most often occurs where a variable name should end: the model generates another identifier character instead of the required delimiter. Increasing variable-name diversity during training reduces these termination errors and improves robustness to variable names in this setting. We identify attention heads that attend to delimiters following earlier occurrences of a variable name, and find that ablating these heads reduces accuracy at name endings, supporting a causal role for these heads in identifying where variable names end. Higher training-name diversity is also associated with stronger attention to these delimiters. Experiments with another larger-scale decoder-only model (158M-parameter) trained on real Python code also show improved robustness with increased variable name diversity. Complementary analyses identify a shared difficulty in generating unfamiliar names, with errors concentrated at the initial tokens of variable names.

Primary area:
other topics in machine learning (i.e., none of the above)
Keywords:
mechanistic interpretability, code models, variable renaming, robustness, training data diversity

Reviews

Among:
Shape:
1234this paper, Top 30%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 2.60 over 5 reviews, above 70% of the others.
Reviewer_ndVkOpenReview ↗
Rating
2
Confidence
2
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper investigates why decoder-only code models are brittle to variable renaming. It introduces TinyTracer to generate synthetic Python programs and execution traces under controlled distributions. Experiments vary the diversity of variable names in training and show improved robustness with greater diversity. The paper also studies a 158M-parameter StarCoder model trained on real Python code. Its error analysis identifies difficulties in generating unfamiliar names. Attention interventions provide evidence that particular heads contribute to predicting name endings in the tracing models and initial name tokens in StarCoder. The experiments connect controlled changes in training data with analyses of specific prediction failures.

Critical strengths

1. Controlled experiments on variable name diversity

The controlled experiments provide evidence that greater diversity of variable names in training improves robustness to renaming. The control experiment applies the same renaming procedure but draws names from a small pool. This helps separate the effect of diversity from the removal of semantic naming cues.

2. Causal evidence from attention interventions

The attention interventions provide causal evidence that the identified heads contribute to identifier prediction. In StarCoder, directing these heads to earlier occurrences of the target variable repairs many errors on the first token. The comparisons with random heads and other target variables strengthen this evidence.

Critical weaknesses

1. The specificity of retrieval and its link to name diversity remain unclear

Table 5 shows substantial repair when the selected heads attend to delimiters after other variables. On the same probes, this repairs 62–73% as many errors as attending to the matching variable. Although the matching variable is more effective, it remains unclear how much of the repair depends on identifying its boundary. A general signal to end the name may also contribute. The paper acknowledges this possibility. Reporting the overlap between the repaired cases, together with attention patterns before intervention, would help clarify the role of these heads.

The connection between name diversity and attention routing remains correlational. Similar repair rates in StarCoder show that both models benefit from forced retrieval. They do not explain why greater diversity improves predictions without intervention. Figure 7A reports average copy scores from only one training seed. An analysis of individual examples could test whether improved predictions are associated with stronger attention to the target variable before intervention. Repeating this analysis across all three training seeds would strengthen the evidence.

2. The effect of local repairs on task accuracy remains unclear

The error analysis shows that many failures begin during variable name generation. However, the interventions measure repairs at individual token positions. They do not show how often these repairs recover a correct identifier or execution trace. For StarCoder, the existing benchmark already scores complete identifiers under teacher forcing, requiring every token to be correct. Applying this scoring rule after intervention would connect the repair results to identifier accuracy. An additional evaluation of generated traces would help quantify how much of the accuracy loss caused by renaming can be recovered in the tracing model.

The mechanistic analysis focuses on identifier generation. The paper also reports benefits from greater name diversity on variable misuse localization and cloze prediction. These results do not establish that the same mechanism explains those benefits. The conclusions should distinguish the mechanism examined here from the broader effects of diversity training.

Questions for authors

1. Clarifying the role of attention

Please report the overlap between the two sets of repaired errors in Table 5. For StarCoder, please examine whether examples improved by greater name diversity also show stronger attention to the target variable before intervention.

2. Measuring the effect on task accuracy

For StarCoder, please apply the existing identifier scoring rule after intervention, requiring every token to be correct under teacher forcing. For the tracing model, please evaluate the accuracy of complete generated traces. Both evaluations should include any errors introduced on examples that were correct before intervention. Any use of reference information to select intervention positions or targets should be stated explicitly.

4 comments
AuthorsOpenReview ↗

Response Part 1

Thank you for the precise requests. Below, "baseline" is the model trained on the original code, and "high-diversity" is the model trained with our renaming. For the tracing model, "0.5% diversity" and "1% diversity" are the two lowest levels of name diversity, as in Table 5. Section and appendix numbers refer to the revised PDF.

Part 1

W1, first paragraph / Q1, first part (overlap between the two sets of repaired errors in Table 5; attention before intervention). The two sets overlap largely, and the overlap shows that both effects are present: a general signal to end the name, and a repair that needs the matching name. The submitted Table 5 gave only the number of repairs in each condition. During the discussion period, we ran the experiment of Table 5 again and recorded the outcome of each probe. The new run reproduces the matching-name and different-name counts of Table 5 exactly.

  • Overlap (counts pooled over the three seeds, on the 98-99% of the errors for which a different name occurs earlier). Of the errors repaired with a different name, 87% (0.5% diversity) and 88% (1% diversity) are also repaired with the matching name. Of the errors repaired with the matching name, 58% and 59% are also repaired with a different name, and the other 42% and 41% are repaired only with the matching name.
  • Attention before intervention. On the same probes, without any intervention, the three heads put .31 to .45 of their attention on the delimiters of the matching name, and .02 to .04 on the delimiters of all other names (means per group of probes, pooled over the seeds). The attention on the matching name does not differ consistently between the repaired errors and the errors that are not repaired: the sign of the difference varies across the six models. These results answer your question as follows. Most of the errors that a different name repairs (87% and 88%) are also repaired with the matching name. For these errors, a general signal to end the name is therefore enough, as you suggest. About 4 in 10 of the matching-name repairs are obtained only with the matching name, so this part of the repair needs the delimiters of the matching variable. The attention before intervention is consistent with this second part: the heads already attend far more to the matching name than to the other names. We do not find, however, that the attention before intervention tells which errors the redirection repairs. The new analysis agrees with the reading of Section 4.4 in the submitted paper (the heads retrieve the boundary of the matching name, and part of the repair comes from a general end-of-name cue), and it gives an estimate of the size of each part. We have added these results to App. E.1 (new Table 5b), and we have updated Section 4.4 to reflect this.
AuthorsOpenReview ↗

Response Part 2

W1, second paragraph / Q1, second part (link between name diversity and attention; Fig 7A uses one seed; do improved examples show stronger attention before intervention?). We ran two new analyses during the discussion period to answer these two questions. For the submission, we had trained each of the two 158M models (baseline and high-diversity) three times, with three different training seeds, but Fig 7A showed the copy score for one of these seeds only. The new analyses use these six trained models, and no model was retrained. In the first analysis, we computed the copy score of Fig 7A for the two other seeds, and the observation of Fig 7A holds in all three seeds. In the second analysis, we measured, for each test example and before any intervention, how much attention the copy heads put on the earlier occurrence of the variable. Improved examples (examples that only the high-diversity model gets right) have stronger attention in the high-diversity model, when each model is measured with its own top-3 copy heads. Both results are correlations, and we agree that the link between diversity and attention is not shown to be causal.

  • Fig 7A over three seeds. On renamed code, the copy score is .209 for the baseline and .256 for the high-diversity model. The copy score is higher for the high-diversity model in all three seeds. For each seed, the difference is the copy score of the high-diversity model minus the copy score of the baseline, so a positive value means that the copy heads of the high-diversity model attend more to the earlier occurrence of the name. The mean difference over the three seeds is +.046, with a 95% interval of [-.055, +.148]. The interval is wide and includes zero: the difference is positive in each of the three seeds, but three seeds are not enough to establish its size.
  • Attention before intervention, per example. Within each model, examples with more attention to the earlier occurrence of the variable are more often correct (AUROC .80 to .86). We then took the examples that only the high-diversity model gets right. On these examples, we compare the attention that the top-3 copy heads of each model put on the target variable. The difference is the attention of the high-diversity model minus the attention of the baseline, so a positive value means that the high-diversity model attends more to the target variable on the examples that it alone gets right. The mean difference is +.073, and the difference is positive in all three seeds. This result is not robust to the choice of heads: with 12 heads the difference is close to zero, and with the baseline's heads used for both models it is negative in two of three seeds (the baseline then attends more). We have updated Section 4.5 and the caption of Fig 7 in the revised paper to reflect this. App. E.3 of the revised paper gives the three-seed values (new Table 7) and the per-example analysis.
AuthorsOpenReview ↗

Response Part 3

W2, first paragraph / Q2 (effect of the repairs on complete identifiers and on complete traces; errors introduced; use of the reference). We ran two new experiments during the discussion period to answer this question. The submitted paper measured a repair on a single token, and only at positions where the model fails. The new experiments measure whether complete outputs become correct, and whether the intervention introduces errors where the model was right. In both experiments, the intervention is the attention redirection of the submitted paper: we force the copy heads to attend to the earlier occurrence of the variable. We deduce three things from the two experiments. First, the effect of the repairs is not limited to one token: the repairs lead to complete outputs that are correct, for most identifiers in the 158M model and for a part of the failed traces in the tracing model. Second, the copy heads are needed to produce complete correct traces, not only to make one prediction. Third, the redirection helps where the model fails, but it can disturb predictions that were already correct (rarely in the 158M model, more often in the tracing model). The redirection is therefore a diagnostic of the mechanism, not a method to improve accuracy.

Experiment 1: 158M model, complete identifiers. We apply the redirection at all names of the renamed test code, including the names that the model already writes correctly. An identifier counts as correct only if every one of its tokens is predicted correctly.

  • Complete identifiers recovered. The share of renamed identifiers that are completely correct rises from 32.2% to 70.7% for the baseline, and from 40.8% to 84.6% for the high-diversity model. The gain of the repair is therefore not limited to one token: it holds for complete identifiers.
  • Errors introduced. Of the names that were correct before the redirection, 4% (baseline) and 6% (high-diversity) become wrong (counts pooled over the three seeds). The redirection therefore repairs many more names than it breaks.
  • Use of the reference. The reference gives the position where each name starts and the earlier occurrences of the same variable (the tokens that the heads are forced to attend to).

Experiment 2: tracing model, complete generated traces. Each model generates the complete trace of 5,120 held-out renamed programs (greedy decoding). A trace counts as correct only if it is identical to the reference trace, so one wrong token makes the trace wrong. Below, each result is given first for the models trained with 0.5% diversity, then for 1% diversity (3 seeds each; accuracies are means over the seeds, and shares of traces use counts pooled over the seeds). Without intervention, 21.5% and 37.7% of the traces are correct; we call the other traces failed traces.

  • Removing the three copy heads tests whether the model needs these heads to generate a complete trace. The share of correct traces falls to 1.2% and 0.3%: 95% and 99% of the correct traces become wrong. As a control, removing three random heads leaves 17.8% and 30.5% of correct traces on average. The effect of random heads varies widely between the 18 random draws (share of correct traces that become wrong: median 7%, from 2% to 100%).
  • Redirection at every name ending, whether the model was right or wrong there. Of the failed traces, 10% and 20% become correct. Of the correct traces, 25% and 32% become wrong (errors introduced). The two effects nearly cancel: the share of correct traces becomes 23.8% and 37.9%, a small change on average, and the direction of the change varies across seeds.
  • Redirection only at the name endings where the model makes an error (1.0 to 1.6 positions per failed trace on average). Of the failed traces, 13% and 28% become completely correct, and the share of correct traces rises to 31.7% and 54.9%. This intervention introduces no error by construction, because a correct trace contains no such position.
  • Use of the reference. The reference trace gives the positions where a name ends and the delimiters to attend to. In the last intervention, the reference also tells where the model makes an error.
AuthorsOpenReview ↗

Response Part 4

What these results show. The three heads are needed to generate complete traces, not only to make one prediction: without them, almost no trace is correct. Repairing the failing name endings is enough to make 13% and 28% of the failed traces completely correct. The redirection is a diagnostic, not a way to improve accuracy: it uses the reference, and it replaces all the attention of the three heads, so at a position where the model was already right it can only keep or disturb the prediction. These results do not change the claim of Section 4.4, which is that the three heads contribute to the prediction that ends a name and that redirecting them repairs this prediction. App. E.1 of the submitted paper already stated that a repair is a local measure and does not imply a correct trace. In the revised paper, the results on complete identifiers are in Section 4.5 and App. E.3 (new Table 8), and the results on complete traces are in Section 4.4 and App. E.1 (new Table 5c).

W2, second paragraph (the conclusions should distinguish the mechanism examined here from the broader effects of diversity training). We agree. Our mechanistic analysis concerns the generation of identifiers only. The gains on misuse localization and on the cloze test are shown empirically, and we do not claim that the copy heads explain them. We have updated the conclusion of the revised paper to state this distinction.

Reviewer_KEuVOpenReview ↗
Rating
3
Confidence
3
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper investigates the brittleness of decoder-only code models to variable renaming. The authors introduce TINYTRACER, a framework for controlling variable-name diversity during training. They find that errors in the small models occur predominantly at the ends of variable names, whereas errors in the 158M-parameter StarCoder model occur predominantly at the first token of variable names. Attention-head ablation and attention-redirection experiments provide evidence that contextual copying contributes causally to these predictions.

Critical strengths

1.TINYTRACER enables controlled variation in variable-name diversity and localizes failures to specific generation positions, providing a clear experimental setting for investigating the internal mechanisms underlying brittleness to variable renaming. 2.Beyond analyzing attention patterns, the authors conduct head-ablation and attention-redirection experiments, with controls involving random heads and other variables as attention targets. In the StarCoder experiments, directing the selected heads to earlier occurrences of the correct variable repairs many first-token errors, whereas directing them to other variables shifts predictions toward those variables’ first tokens. These results support the interpretation that the selected heads participate in retrieving variable names from context. 3.The authors evaluate a 158M-parameter model trained on real Python code on three tasks: identifier reproduction, variable-misuse localization, and cloze prediction of non-variable tokens. Results across multiple levels of renaming and three training seeds provide complementary evidence for the findings from the synthetic setting. 4.The study includes careful controls for variable-name diversity, helping separate its effects from those of semantic cues carried by variable names. These controls strengthen the evidence for the diversity intervention. 5.The evaluation reports both robustness and accuracy, providing a more complete assessment of the robustness gains.

Critical weaknesses

1.The paper demonstrates that increasing variable-name diversity improves robustness and that certain copying heads contribute causally to variable-name generation. However, it does not sufficiently establish how much of the robustness improvement is mediated by these heads. A more direct connection between the training intervention and the internal mechanism remains to be established. 2.The paper finds that the dominant errors occur at the ends of variable names in the small models and at the beginnings of variable names in StarCoder, but provides limited explanation for this difference. Since model size, tokenization, data domain, and task format all change simultaneously, it remains difficult to determine which factors drive the difference in error location. 3.The StarCoder ablation experiments do not fully rule out layer position as a confounding factor. All selected copying heads are located in the final five layers, but the layer distribution of the random heads used in the mean-ablation control in Figure 7B is not clearly specified. Consequently, the observed difference in performance degradation may partly reflect differences in the importance of different layers, rather than solely the copying function of the selected heads. 4.The comparison with directly relevant prior work could be more detailed. For example, discussing CodeFort, which directly studies robust training for decoder-only code generation, would help clarify the new insights provided by this paper through failure localization and interventions on copying heads.

Questions for authors

1.Are the robustness gains from increasing variable-name diversity primarily mediated by these copying heads? 2.Why do the small models tend to fail at the ends of variable names, whereas StarCoder tends to fail at the beginnings? Is this difference primarily attributable to model size, tokenization, or task differences? 3.Is the small decrease in accuracy on the original code consistent across training seeds, or does it reflect random variation? Could the authors further explain how the training renaming probability balances accuracy on the original code against robustness to variable renaming?

2 comments
AuthorsOpenReview ↗

Response Part 1

Thank you for the detailed review. Below, "baseline" is the model trained on the original code, and "high-diversity" is the model trained with our renaming. Section and appendix numbers refer to the revised PDF.

Part 1

W1 / Q1 (are the gains mediated by the copy heads?). The submitted paper does not establish this, and it contains no direct test. During the discussion period, we ran a new, direct test on the 158M models: we removed the top-3 copy heads from both models, and, as a control, 3 random heads from the same layers. Compared with the control, removing the copy heads reduces the advantage of the high-diversity model in all three seeds. But the size of this reduction varies from 0.4 to 19.8 points across seeds, so it is not statistically reliable (details in our reply to Reviewer 2J4P, Q1). The result goes in the direction of a role for these heads, but it is not conclusive. This result does not weaken the claims of the paper. The paper claims that more diverse names in training improve robustness, that the errors start at a specific position of the name, and that the copy heads are needed to write unfamiliar names. Each of these claims rests on its own experiment, and none of them depends on this test. The test asks one further question: is the gain from diversity produced through these heads? The submitted paper already described this link as correlational (Section 4.3). The new test is consistent with such a link, but it does not establish it, and the revised paper now says so explicitly. We have added this test to Section 4.5 (details in App. E.3), and we have updated the conclusion to reflect this.

W2 / Q2 (why do small models fail at the end of a name and the 158M model at its start? model size, tokenization or task?). We ran new experiments on this question during the discussion period (details in the general comment, part D). In brief: model size, the tokenizer and the tracing task do not explain the difference. The name-ending error of the tracing model comes from its low-diversity training data, which contain very few distinct short names (3 two-letter names and 87 three-letter names at 0.5% diversity). The error is concentrated at these name lengths, and it nearly disappears when the training data contain many more distinct short names. The name-ending error is therefore another effect of low name diversity. This result explains the failure of the tracing model. It does not explain why the models trained on real code fail at the first token, and we do not claim that the two failures share one mechanism. For model size, we located the errors in more models:

  • new: in our 19M-parameter models trained on real code, 97-98% of the errors caused by renaming start at the first token;
  • already in the submitted paper: in our 158M baseline and high-diversity models, 90% and 97% of the errors caused by renaming start at the first token;
  • new: in the three pretrained models of 0.5B to 3B parameters, about 99% of the errors caused by renaming start at the first token. Our 19M models have about the size of the tracing model (21M parameters), and they fail at the first token, like the larger models. Size therefore does not explain the difference. We have updated Section 4.5 to reflect this. App. E.3 gives the measurements for the 19M models, and the new App. E.4 gives the experiments on the name-ending error.

W3 (layer position in Fig 7B). Layer position does not explain the result. Your concern is valid for the original figure: its random heads came from all layers, while the 12 top-ranked copy heads are in layers 15-19. During the discussion period, we ran a new control with random heads from the same layers as the copy heads. After removing 12 copy heads, first-token accuracy on renamed code is .023 (baseline) and .009 (high-diversity). After removing 12 random heads from the same layers, it is .342 and .380. Removing the copy heads therefore hurts far more than removing other heads of the same layers. We have added this result to Section 4.5. App. E.3 shows the new control next to the original one (new Figure 17).

W4 (CodeFort). CodeFort (Zhang et al., Findings of EMNLP 2024) trains robust code-generation models by adding many kinds of code perturbations to the training data. Our paper asks a different question: how the diversity of variable names in the training data affects robustness, where the failures start, and which attention heads are involved. We added CodeFort and this comparison to the related-work section.

AuthorsOpenReview ↗

Response Part 2

Here is our 2nd part of our response to reviewer KEuV.

Q3, first part (is the decrease on original code consistent across seeds?). Yes, for two tasks. The submitted paper gave only the means over seeds, so we computed the differences seed by seed. For each seed, the difference is the accuracy of the high-diversity model minus the accuracy of the baseline, both measured on original code. A negative value means that the high-diversity model is less accurate. The mean difference is -.028 on identifier reproduction and -.031 on misuse localization (the high-diversity model loses about 3 accuracy points), and both differences are negative in all three seeds. For each pair of models trained with the same seed, the difference is also statistically reliable over test items: in all three seeds for identifier reproduction, and in two of three for misuse localization. The decrease is therefore unlikely to be random variation, although with three seeds the interval over seeds still includes zero. On the cloze test there is no consistent decrease. We have updated Section 4.5 and App. D.4 (new Table 4b) to reflect this.

Q3, second part (how does the renaming probability trade accuracy against robustness?). Renaming half of the variables, as in the paper, is a better setting than renaming all of them. The submitted paper compared the two settings only briefly (App. D.5), so we ran a new comparison on the three tasks of the paper, with 19M-parameter models. Renaming all variables lowers accuracy on original code (by .080 on identifier reproduction and .108 on misuse localization). After renaming 8 variables, it keeps a larger share of its correct answers (retention is higher by .060 and .040). But because it starts from a lower accuracy, its accuracy after renaming is not higher (the difference is below .01). A higher probability therefore costs accuracy on original code without a gain in accuracy after renaming. We do not know whether this also holds at 158M. We have added this comparison to App. D.5.

Reviewer_WuNGOpenReview ↗
Rating
3
Confidence
2
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper studies why code models are sensitive to variable renaming that preserves program behavior. The authors vary variable-name diversity during training and use error localization, attention-head ablation, and attention redirection to investigate the mechanisms involved. In the low-diversity synthetic setting, the first errors in failed traces mostly occur at the ends of variable names. In the model trained on real Python code, renaming-induced name-generation errors mostly begin at the first token. Increasing training-name diversity improves robustness in both settings. The attention interventions support a causal role for heads that retrieve information from earlier occurrences of variable names.

Critical strengths
  1. The effect of name diversity is supported by convincing controlled experiments. The authors compare the original training data with high-diversity data and introduce a small-name-pool control in Appendix D.7. This control keeps the renamed variables and replacement-name lengths fixed, helping distinguish the effect of name diversity from that of removing semantic cues. The absolute accuracy results in Appendix D.4 further show that the robustness gains cannot be explained solely by the different sets of examples used to calculate retention. These controls strengthen the main conclusion about the training intervention.

  2. The mechanistic analysis goes beyond observing attention patterns. The authors first identify specific failure positions during name generation, then test the role of relevant components through ablations of selected versus random heads, attention redirection, and controls using incorrect target positions. These experiments provide evidence that retrieving contextual name information contributes causally to correct generation, giving the paper greater explanatory value than simply reporting accuracy drops after renaming.

Critical weaknesses
  1. The interventions do not fully explain why errors occur during normal generation. The researchers redirect selected attention heads to earlier occurrences of the correct variable name or its following delimiter. The repair results show that these components can use the relevant contextual information. However, they do not fully distinguish whether the model originally selected the wrong variable, failed to retrieve the correct name, or failed to generate it correctly. The experiments also do not establish whether the changes in attention explain the robustness gains from increased training-name diversity. The authors acknowledge some of these limitations, but they still limit the depth of the mechanistic explanation.

  2. The shared mechanism across the two settings remains broad. Errors in the synthetic tracing model mainly occur at name endings, whereas renaming-induced name-generation errors in the model trained on real Python code mainly begin at the first token. The authors analyze both patterns, but the model architecture, tokenization, task, and data all differ between the settings. The current comparison therefore does not isolate what causes this difference. Both sets of results support the importance of retrieving contextual information when generating unfamiliar names. However, it remains unclear what more specific shared mechanism they establish beyond existing work on symbolic copying and data diversity. This limits the conceptual contribution and the scope of generalization.

Questions for authors
  1. Mechanistic clarification: For first-token errors in the model trained on real code, is there existing evidence that distinguishes variable selection or binding errors from failures to retrieve or generate the target name? This distinction would affect my assessment of the depth of the mechanistic explanation.
  2. Interpretation across settings: Beyond the observation that generating unfamiliar names relies on contextual information, what more specific mechanism is supported by both settings? Which links between the mechanisms have experimental support, and which remain hypotheses?
  3. Statistical clarification: Could you report per-task accuracy differences between models trained with the same seed, together with uncertainty estimates, for Table 4, particularly on the original code? This would help assess whether robustness gains come at a cost to performance on unmodified code and clarify the claim that the models have comparable original accuracy.
1 comment

Thank you for the careful review. Below, "baseline" is the model trained on the original code, and "high-diversity" is the model trained with our renaming. Section and appendix numbers refer to the revised PDF.

W1 / Q1 (when the first token is wrong, did the model select the wrong variable, or fail to retrieve or generate the name?). You are right that the experiments of the submitted paper (head ablation and attention redirection) do not separate these cases. To answer your question, we ran a new analysis during the discussion period. This new analysis separates the cases in part. It shows that selecting the wrong variable explains at most about a third of the errors. In another third of the errors, the model does not write a variable at all (it writes a keyword or punctuation, for example), so the model did not select a wrong variable. In this new analysis, for each first-token error caused by renaming, we looked at the token that the model wrote in place of the correct one:

  • in 34% of the errors for the baseline and 38% for the high-diversity model, this token is the first token of another variable of the function. This is what selecting the wrong variable looks like. The share of wrong selections can be lower than 34% and 38%, because a token can also match another variable by coincidence;
  • in 37% and 34% of the errors, this token is a keyword, a builtin, punctuation or a literal, so the model did not select a wrong variable;
  • in the remaining errors, this token does not start the name of another variable of the function either. In most cases it is another identifier, and the analysis does not tell what causes these errors. The mix is similar for the two models. Diversity therefore mainly reduces the number of errors, not their type. We have added this analysis to App. E.3 (new Table 9).

W2 / Q2 (what more specific mechanism do the two settings share, and which links are supported?). Three statements are supported in both settings:

  1. the failures arise when the model must generate an unfamiliar name;
  2. attention heads that look back at earlier occurrences of the name contribute causally to generating it (ablation and attention redirection in both settings);
  3. more diverse names in training reduce the failures. Statement 3 now also holds for a pretrained model (general comment, part B). Two statements remain hypotheses: that these heads mediate the benefit of diversity (our direct test is inconclusive; see our reply to Reviewer 2J4P, Q1), and that the end-of-name failures and the first-token failures share one mechanism. On the difference between the two failures, new experiments show that the tokenizer does not explain it, and that the end-of-name failure of the tracing model comes from the very small number of distinct short names in its low-diversity training data (details in the general comment, part D). The shared mechanism is therefore the one of statements 1 to 3. We do not show the link between 2 and 3, that is, that diversity helps through these heads. We have updated the conclusion and Section 4.5 to reflect this.

Q3 (per-task, seed-paired differences on original code, with uncertainty). We computed the paired differences that you ask for; the submitted paper gave only the means over seeds. These new paired differences show a cost on original code for two of the three tasks. For each seed, we computed the accuracy of the high-diversity model minus the accuracy of the baseline. On original code, the difference is -.028 for identifier reproduction, -.031 for misuse localization and +.003 for cloze. The first two differences are negative in all three seeds. The 95% intervals of these two differences, computed over the three seeds, include zero ([-.063, +.007] and [-.096, +.033]). These results indicate that the robustness gain has a cost on unmodified code for identifier reproduction and misuse localization (about 3 points in these three seeds), and no cost on the cloze test. For each pair of models trained with the same seed, the difference is also statistically reliable over test items (in all three seeds for identifier reproduction, in two of three for misuse localization). The two models therefore do not have comparable accuracy on original code for these two tasks. We have updated Section 4.5 and App. D.4 (new Table 4b) to reflect this.

Reviewer_BTC4OpenReview ↗
Rating
2
Confidence
3
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper investigates why decoder-only code models are sensitive to variable renaming. The authors introduce TinyTracer, a controlled framework for studying code execution tracing, and show that limited variable-name diversity contributes to this brittleness. Through attention-head ablation and intervention experiments, they identify mechanisms involved in reproducing unfamiliar identifiers. The findings are further examined using a 158M-parameter StarCoder model trained on real Python code.

Critical strengths

Clear motivation and well-controlled experiments. The paper addresses an important robustness issue in code models. TinyTracer provides a useful setting for isolating the effect of variable-name diversity while controlling other factors.

Interesting mechanistic findings. The attention ablation and redirection experiments go beyond observing correlations. In particular, the ability to repair some incorrect predictions by redirecting attention to earlier identifier occurrences is compelling.

Validation on real code. The StarCoder experiments strengthen the paper by showing that increased name diversity also improves robustness on several real-code evaluation tasks.

Critical weaknesses

Limited generalizability. The main mechanistic analysis relies on a relatively small model and a simplified programming language. Although the StarCoder experiments help, it remains unclear whether the same findings hold for modern, larger code LLMs.

Incomplete explanation of the underlying mechanism. The dominant failure occurs at variable-name endings in TinyTracer but at initial tokens in StarCoder. This difference is interesting, but the paper does not fully explain why it arises or whether the two models share the same underlying failure mechanism.

Questions for authors

What explains the different error locations between TinyTracer and StarCoder? Could this difference mainly come from tokenization or the training objective?

Have you considered evaluating the proposed findings on a larger pretrained code model to better establish their generality?

The attention interventions repair individual token predictions. Do these local repairs translate into meaningful improvements in complete identifier generation or downstream task accuracy?

2 comments
AuthorsOpenReview ↗

Response Part 1

Thank you for the review. Below, "baseline" is the model trained on the original code, and "high-diversity" is the model trained with our renaming. Section and appendix numbers refer to the revised PDF.

Part 1

W1 and Q2 (generality; evaluation on a larger pretrained code model). The brittleness and the position of the errors also hold for pretrained models of up to 3B parameters, and the benefit of more diverse names holds for the pretrained model that we trained further. We ran two new experiments (details in the general comment, parts A and B).

  • We evaluated three pretrained models of 0.5B, 1.5B and 3B parameters. All three are brittle to renaming: for example, identifier reproduction falls from .776 to .678, from .820 to .736 and from .841 to .763 after renaming 8 variables. The errors of these three models start at the first token of the name, as in our 158M model.
  • We applied our training intervention to a pretrained model (continued pretraining of a 0.5B model, 3 seeds). Compared with the same training on unmodified code, training on code with more diverse names improves accuracy after renaming by about 6 points on identifier reproduction and misuse localization, with no measurable cost on original code. The mechanistic analysis of the paper remains limited to the tracing model and the 158M models. We have added these results to Section 4.5 (new paragraph "Pretrained code models") and to a new App. F.

W2 / Q1 (what explains the different error locations? tokenization or the training objective?). We ran new experiments on this question during the discussion period (details in the general comment, part D). In brief: model size, the tokenizer and the tracing task do not explain the difference. The name-ending error of the tracing model comes from its low-diversity training data, which contain very few distinct short names (3 two-letter names and 87 three-letter names at 0.5% diversity). The error is concentrated at these name lengths, and it nearly disappears when the training data contain many more distinct short names. The name-ending error is therefore another effect of low name diversity. This result explains the failure of the tracing model. It does not explain why the models trained on real code fail at the first token, and we do not claim that the two failures share one mechanism.

  • The training objective is the same in both settings (next-token prediction).
  • New measurement: our 19M-parameter models trained on real code have about the size of the tracing model (21M parameters). 97-98% of their errors caused by renaming start at the first token, as in the 158M models of the submitted paper and in the pretrained models of up to 3B parameters that we evaluated during the discussion period. We have updated Section 4.5 to reflect this. App. E.3 gives the measurements for the 19M models, and the new App. E.4 gives the experiments on the name-ending error.
AuthorsOpenReview ↗

Response Part 2

Part 2

Q3 (do the local repairs give complete identifiers, or better downstream accuracy?). Yes for complete identifiers in the 158M models, and in part for complete traces in the tracing model. The submitted paper scored the repair of a single token only. During the discussion period, we ran two new evaluations.

  • Complete identifiers (158M models). We applied the attention redirection to all names, not only to the failures, and we counted a name as correct only if all of its tokens are correct. On renamed code, the accuracy on complete identifiers rises from .322 to .707 for the baseline and from .408 to .846 for the high-diversity model. Only 4% and 6% of the names that were correct become wrong (counts pooled over the three seeds). The same redirection on random heads, or toward other variables, breaks most of the correct names.
  • Complete traces (tracing model). The task of the tracing model is to generate the complete execution trace of a program, and a trace is correct only if it matches the reference trace exactly. Redirecting the three copy heads at the name endings where the model makes an error recovers 13% (0.5% diversity) and 28% (1% diversity) of the failed traces, and accuracy on renamed programs rises from 21.5% to 31.7% and from 37.7% to 54.9%. These are the two lowest diversity levels of the sweep (0.5% and 1%), where renaming hurts the tracing model most. Redirecting the heads at every name ending also breaks correct traces, so this second variant changes accuracy little on average, and the direction of the change varies across seeds (details in our reply to Reviewer ndVk, W2 / Q2). Repairing the first token therefore does give complete, correct identifiers, and this effect is specific to the copy heads. In the tracing model, repairing the failing name endings recovers a part of the failed traces. In both models, the redirection uses the reference to choose the position and the target, so the redirection is a diagnostic and not a usable repair. For the other tasks on real code (misuse localization and the cloze test), the redirection does not apply, because it is defined for name generation only. We have added these results to Sections 4.4 and 4.5, with the details in App. E.1 (new Table 5c) and App. E.3 (new Table 8).
Reviewer_2J4POpenReview ↗
Rating
3
Confidence
3
Informativeness
3
Presentation
3
Soundness
2
Read review
Paper summary

The paper investigates failures of decoder-only code models under semantics-preserving variable renaming. Synthetic tracing experiments vary training-name diversity, locate first errors, and identify attention heads that retrieve earlier identifier occurrences. Ablation and forced-attention experiments test these heads’ contribution. Further experiments train 158M-parameter models on Python code and evaluate identifier reproduction, variable-misuse localization, and cloze prediction. Greater diversity improves robustness, while the dominant failure position shifts from name endings in the tracing setting to initial tokens in the real-code setting.

Critical strengths
  1. Appendix D.7 includes a strong control for the loss of meaningful variable names. The control renames the same variables in the same documents using a small name pool. At N=8N=8, meaning up to eight eligible variables per function, high-diversity training exceeds its retention by 0.225 for identifier reproduction and 0.106 for misuse localization.
  2. The head analysis goes beyond attention correlations. Selected-head ablations damage performance more than random-head controls, and attention redirection repairs local errors. In the real-code setting, redirecting 12 copying heads repairs 75.6% and 77.5% of eligible first-token errors under the two training conditions, supporting a causal contribution to identifier generation.
  3. Table 4 checks absolute accuracy on identical test items, addressing the different denominators used by retention. At N=8N=8, identifier accuracy rises from 0.298 to 0.382 and misuse-localization accuracy from 0.241 to 0.311. Thus, the robustness benefit cannot be explained solely by comparing different sets of initially correct predictions.
Critical weaknesses

I have two substantive concerns.

  1. The causal explanation for the diversity benefit remains incomplete. Ablation shows that the selected heads matter, and forced attention shows that providing the correct retrieval target can repair local errors. However, the latter uses oracle knowledge of which earlier identifier to retrieve. These experiments do not establish that changes in this pathway mediate the advantage of high-diversity training. The authors acknowledge the correlation and local nature of repair, which appropriately limits the interpretation.
  2. The clean-accuracy tradeoff is not estimated precisely enough. Table 4 reports lower original-code accuracy with high-diversity training on identifier reproduction, 0.477 versus 0.505, and misuse localization, 0.550 versus 0.581. Appendix D.4 states that these differences are smaller than seed variation, but gives only an upper bound on standard deviations. Task-specific paired uncertainty would help determine whether the robustness gains come with a meaningful cost on unmodified code.
Questions for authors
  1. After accounting for general task-accuracy damage, does disrupting the identified copying pathway reduce the robustness advantage of high-diversity training?
  2. Can you report seed-paired differences and uncertainty intervals for original-code and renamed-code accuracy in Table 4?
1 comment

Thank you for the careful review. Below, "baseline" is the model trained on the original code, and "high-diversity" is the model trained with our renaming. Section and appendix numbers refer to the revised PDF.

W1 (forced attention uses the reference; mediation is not established). We agree with both points. In the forced-attention experiments of the submitted paper, the reference tells the heads which earlier occurrence to attend to. The experiment therefore shows that the heads can use the right information when they are pointed at it. The experiment does not show that the model points them there by itself, or that this pathway produces the benefit of diversity. We have updated Sections 4.4 and 4.5 and the conclusion to reflect this.

Q1 (does disrupting the copying pathway reduce the advantage of high-diversity training?). The submitted paper does not contain this test. We ran it on the 158M models during the discussion period. The result goes in the direction that your question describes, but it is not conclusive.

  • The test. We removed the top-3 copy heads from both models and measured the accuracy gap between the two models. As a control for general damage, we removed 3 random heads from the same layers.
  • The result. Without removal, the high-diversity model is 5.2 points more accurate than the baseline. After removing the copy heads, the advantage is -2.7 points on average: it shrinks in two seeds and is unchanged in the third. After removing the control heads, it remains (+6.2 points). Compared with the control, removing the copy heads therefore reduces the advantage in all three seeds. But the size of this reduction varies from 0.4 to 19.8 points across seeds, so with three seeds it is not statistically reliable. Why this result does not weaken the paper. The paper makes three claims, and each one rests on its own experiment:
  1. More diverse variable names in training make the model more robust to renaming (Figures 2 and 6, the small-pool control of App. D.7, and now also a pretrained model).
  2. After renaming, the errors start at a specific position of the name: its end in the tracing model, and its first token in the models trained on real code (Sections 4.2 and 4.5).
  3. The copy heads are needed to write unfamiliar names: removing them breaks these names far more than removing other heads, and redirecting them repairs many of the errors (Figures 4, 5 and 7B; Sections 4.4 and 4.5). None of these claims depends on the test above. The test asks one further question: is the gain of claim 1 produced through the heads of claim 3? The submitted paper already described this link as correlational (Section 4.3), and your review notes this. The new test is consistent with such a link, since, compared with the control, removing the copy heads reduces the advantage in every seed. But it does not establish it. The three claims therefore stand as they were, and the link between claims 1 and 3 remains an open question, which the revised paper now states explicitly. We have added this test to Section 4.5, with the details in App. E.3.

W2 / Q2 (seed-paired differences with uncertainty for Table 4). We computed the paired differences that you ask for; the submitted Table 4 gave only the means over seeds. These new paired differences show a cost on original code for two of the three tasks. For each seed, we computed the accuracy of the high-diversity model minus the accuracy of the baseline. A negative value means that the high-diversity model is less accurate.

  • On original code: identifier reproduction -.028, misuse localization -.031, cloze +.003. The first two differences are negative in all three seeds. The 95% intervals of these two differences, computed over the three seeds, are ([-.063, +.007] and [-.096, +.033]).
  • After renaming 8 variables: +.084 [-.030, +.199], +.069 [+.022, +.117] and +.023 [-.008, +.054]. All three are positive in all three seeds. These results indicate that the robustness gain has a cost on unmodified code: about 3 points on identifier reproduction and misuse localization in these three seeds, and none on the cloze test. After renaming 8 variables, the high-diversity model is more accurate on all three tasks in every seed. One more result helps to interpret this cost. In our new experiment on a pretrained model (general comment, part B), the same renaming has no measurable cost: on original code, the models trained on renamed code are as accurate as the models trained on unmodified code (differences of -.002, -.003 and .000). The cost is therefore not a necessary consequence of the renaming. We observe it when a model is trained from scratch, and we do not observe it when a pretrained model is trained further. This second result comes from one model, so we report it as an observation. We have updated Section 4.5 and App. D.4 to reflect this. The new Table 4b gives the paired differences for every N, with their confidence intervals.

Comments on the paper

1 comment
AuthorsOpenReview ↗

GENERAL COMMENT TO ALL REVIEWERS - New experiments on pretrained code models, and changes in the revised paper

We thank all reviewers. We uploaded a revised PDF (changes in red). This comment reports new experiments on pretrained code models (A to C) and on why the errors start at different positions in the two settings (D), then lists the changes in the paper (E).

A. Pretrained models are also brittle to renaming. We evaluated Qwen2.5-Coder-0.5B, Qwen2.5-Coder-1.5B and StarCoder2-3B, without further training, on the three tasks of the paper. After renaming 8 variables, accuracy drops for every model on every task (original -> renamed code, three models in order):

  • identifier reproduction: .776 -> .678; .820 -> .736; .841 -> .763
  • misuse localization: .968 -> .695; .983 -> .778; .983 -> .818
  • cloze: .622 -> .556; .673 -> .602; .673 -> .613 In all three models, about 99% of the errors caused by renaming start at the first token of the name, as in our 158M model. The brittleness is therefore not specific to small models trained from scratch.

B. Training on more diverse names also makes a pretrained model more robust. We continued the pretraining of Qwen2.5-Coder-0.5B on unmodified code, and on the same code with our renaming (900M tokens, 3 seeds each). Each number below is the accuracy with renamed-code training minus the accuracy with unmodified-code training (mean over 3 seeds; 95% interval in brackets). A positive value means that renamed-code training is better; an interval without zero means a reliable difference.

  • After renaming 8 variables: identifier reproduction +.059 [+.035, +.082]; misuse localization +.060 [+.042, +.077]; cloze +.022 [+.003, +.041]. All three gains are reliable.
  • On original code: -.002, -.003 and .000, and each interval contains zero, so the renaming has no measurable cost compared with the same training on unmodified code.
  • The gain does not come from the extra training itself: continued pretraining on unmodified code makes the model slightly more brittle.

C. Scope of A and B. These experiments measure behaviour (accuracy, robustness, position of the errors). The mechanistic analysis of the paper remains limited to the tracing model and the 158M models. Experiment B uses one pretrained model and a short continued pretraining.

D. Why the errors start at the end of the name in the tracing model, and at the first token in the models trained on real code (Reviewers KEuV, WuNG and BTC4). New experiments rule out three explanations and identify the cause of the name-ending error.

  • Model size: our 19M models trained on real code have about the size of the tracing model (21M), and 97-98% of their errors caused by renaming start at the first token.
  • Tokenizer: tracing models trained with a subword (BPE) tokenizer still fail at the name ending (56% to 66% of the first errors; 4% to 10% on the first token of the name).
  • Tracing task: the name-ending error is still present when we train the same architecture on the same programs without execution traces.
  • Cause supported by the experiments: too few distinct short names in the low-diversity data. The diversity level is the share of the possible names used at each name length. At 0.5% diversity, the data contain only 3 two-letter names and 87 three-letter names, against 2,276 four-letter and 59,047 five-letter names. We measure, among the names written correctly in the original program, the share whose first error after renaming is at the name ending. This share is about 52% and 33% for two- and three-letter names, against 7% and 5% for four- and five-letter names. With more distinct short names in training (166 two-letter and 1,750 three-letter names), it falls to 1% and 2%. Conversely, a model trained with highly diverse long names (70% diversity) but only the original 3 and 87 short names still makes the error on two- and three-letter names (28% and 30%), and not on longer names (6%). The name-ending error is therefore itself an effect of low name diversity, which agrees with the main claim of the paper. This explanation concerns the tracing data only: it does not explain the first-token failure on real code, and we do not claim that the two failures share one mechanism. These measurements use models trained without traces. Details are in the new App. E.4.

E. Changes in the revised paper.

  1. Section 4.5 and the conclusion state that our experiments do not establish that the copy heads mediate the benefit of diversity; Section 4.5 reports a direct test.
  2. Sections 4.4 and 4.5 state that the attention redirection uses the reference to choose the target.
  3. Section 4.5 reports the cost on original code (new Table 4b in App. D.4).
  4. Section 4.5 states why the tracing model fails at the name ending (new App. E.4).
  5. Section 4.4 and App. E.1: overlap of the repairs of Table 5 (new Table 5b) and complete generated traces (new Table 5c).
  6. Also new: pretrained models (Section 4.5, App. F); analyses of the 158M models (App. E.3); renaming probability (App. D.5); CodeFort (related work).

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.