<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammed Enes Duran</title>
    <description>The latest articles on DEV Community by Muhammed Enes Duran (@muend).</description>
    <link>https://dev.to/muend</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3955086%2F5f1cd487-ae94-40cd-9672-3f78bf4408ad.jpeg</url>
      <title>DEV Community: Muhammed Enes Duran</title>
      <link>https://dev.to/muend</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muend"/>
    <language>en</language>
    <item>
      <title>benchfck: an LLM evaluation where a program, not a judge, decides the answer</title>
      <dc:creator>Muhammed Enes Duran</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:44:48 +0000</pubDate>
      <link>https://dev.to/muend/benchfck-an-llm-evaluation-where-a-program-not-a-judge-decides-the-answer-15pj</link>
      <guid>https://dev.to/muend/benchfck-an-llm-evaluation-where-a-program-not-a-judge-decides-the-answer-15pj</guid>
      <description>&lt;p&gt;Every time I read a benchmark score, I end up asking two questions. Did the model see these items during training? And who, or what, decided that an answer was correct?&lt;/p&gt;

&lt;p&gt;For most evaluation sets neither question has a clean answer. A fixed public set can leak into training data, and after that a high score may measure memory. Free-form answers are often graded by another model or by a rubric, so the score carries the grader's uncertainty too. I wanted to see how far I could get by removing both problems at the source, in one deliberately narrow domain. The result is &lt;a href="https://github.com/muend/benchfck" rel="noopener noreferrer"&gt;benchfck&lt;/a&gt;, a Rust tool that generates machine-state tasks and grades every answer by execution.&lt;/p&gt;

&lt;p&gt;The most important sentence first: &lt;strong&gt;no model has been run on these tasks, and there is no leaderboard.&lt;/strong&gt; benchfck is a v0.4.0-alpha engineering project. This post is about the instrument and the engineering problems inside it, not about any model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fak0thnlfjb66cgf7rzbf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fak0thnlfjb66cgf7rzbf.png" alt="From a seed to a graded item" width="799" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pinning the semantics so there is exactly one right answer
&lt;/h2&gt;

&lt;p&gt;The programs are Brainfuck: eight instructions, a tape and a pointer. That is small enough to pin every edge case, which is the whole point. The harness fixes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;8-bit unsigned cells that wrap;&lt;/li&gt;
&lt;li&gt;a 30,000-cell tape where moving left of cell 0 or right of cell 29,999 is a hard error;&lt;/li&gt;
&lt;li&gt;reading past the end of the input yields 0;&lt;/li&gt;
&lt;li&gt;a run that exceeds 8,000,000 steps is classified as non-terminating.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every task prompt prints these semantics (the left-edge error included), and the interpreter enforces all of them, including a hard error at the right edge. The step cap is not arbitrary: across 600 candidates the largest tier-9 program needed 5,678,676 steps, so 8M leaves a 40.9% margin. The interpreter checks the cap before every instruction, and wrapping is explicit in the code rather than left to overflow behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;stop_after&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_none_or&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;step_cap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BfError&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;NonTerminating&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'+'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wrapping_add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pointer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BfError&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;PointerUnderflow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Brackets are matched once at parse time into a jump table, and the same interpreter can stop after an exact number of steps. That second ability is what produces the ground truth for "what is the machine state at step N" questions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating programs instead of shipping a dataset
&lt;/h2&gt;

&lt;p&gt;A seed and a constructor produce a typed intermediate representation with ten statement kinds (set, copy, add, sub, scaled drain, input, output, while, if, and a drain-if-nonzero). A compiler then turns the IR into Brainfuck. Two choices in the compiler matter for evaluation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Equivalent templates.&lt;/strong&gt; For each statement a seeded ChaCha20 RNG picks one of three equivalent code templates, so the same IR can become different surface code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cell layouts.&lt;/strong&gt; Scratch cells are placed with a contiguous, interleaved or strided layout, with a fourth layout held out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An adjacent-statement swap is also applied, but only when the two statements' read and write sets are disjoint and neither has side effects, so the reordering cannot change behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four encodings that must agree on every input
&lt;/h2&gt;

&lt;p&gt;The same program is rendered four ways:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Encoding&lt;/th&gt;
&lt;th&gt;What it looks like&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;E0&lt;/td&gt;
&lt;td&gt;canonical Brainfuck&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E1&lt;/td&gt;
&lt;td&gt;per-item random permutation of the 8 symbols, with a legend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E2&lt;/td&gt;
&lt;td&gt;compact explicit operations, e.g. &lt;code&gt;M23*18&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;E3&lt;/td&gt;
&lt;td&gt;verbose explicit operations, e.g. &lt;code&gt;MOVE cell 23 count 18&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The point is to change surface form while keeping behavior fixed, so that a future difference in model behavior can be attributed to representation rather than to the task. That only works if the encodings are truly equivalent, so equivalence is a gate, not an assumption:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;E0 Brainfuck is the reference. The typed IR, E2 and E3 must produce the same output on &lt;strong&gt;all 256 inputs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;E2 and E3 are parsed back by &lt;strong&gt;independent decoders&lt;/strong&gt;. Reusing the in-memory bytecode that produced them would test the same executor twice.&lt;/li&gt;
&lt;li&gt;The full input/output table is hashed into a semantic fingerprint, which later drives duplicate detection.&lt;/li&gt;
&lt;li&gt;E1 is a pure symbol permutation of E0, so it is equivalent by construction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The property suite pushes this further: a release-build run over 10,000 deterministic IR programs and 2,560,000 complete-domain bindings checks IR, E0, E2 and E3 against each other. In CI a 500-program shard runs on every push, and the full 10,000 run is split into four shards on pull requests and a weekly schedule. (These property programs use their own 1,000,000-step cap and are synthetic IR programs, not generator items.)&lt;/p&gt;

&lt;p&gt;Two limits on the encodings: E2 prompts are rendered only for size tiers 0–5 and E3 only for tiers 0–3, because longer programs become impractically long in the explicit forms. And encodings are not free of confounds. In one engineering diagnostic on 2026-08-11 (a private smoke test of a single constructor, &lt;code&gt;cl100k_base&lt;/code&gt; tokenizer, before a later compiler compaction), the E3 prompt was about 7.07 times as long as E0 and the E2 prompt about 3.36 times. That is a diagnostic, not release evidence. Raw encodings therefore cannot be compared directly; more on that below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gates that reject trivial or degenerate items
&lt;/h2&gt;

&lt;p&gt;Most generated programs should not become test items. A candidate is accepted only if it passes a chain of gates, each designed against a specific failure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Avalanche ≥ 0.60.&lt;/strong&gt; At least 64 executed positions holding data or I/O instructions (&lt;code&gt;+ - , .&lt;/code&gt;) are sampled, and each is replaced by each of the three other symbols in that group. A mutant counts as "changed" if its output differs, it fails differently, or it no longer terminates. Pointer moves and brackets are excluded so that broken syntax cannot inflate the score. A program where most single-character edits change nothing is not testing state tracking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-argument sensitivity.&lt;/strong&gt; Each input is perturbed by +1, +17, +63, +127 and +255 (wrapping); at least one perturbation must change the output. An input the program ignores is a free answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Off-idiom rate &amp;lt; 0.08.&lt;/strong&gt; The five canonical idioms (&lt;code&gt;[-]&lt;/code&gt;, &lt;code&gt;[-&amp;gt;+&amp;lt;]&lt;/code&gt;, &lt;code&gt;[-&amp;gt;+&amp;gt;+&amp;lt;&amp;lt;]&lt;/code&gt;, &lt;code&gt;[&amp;lt;+&amp;gt;-]&lt;/code&gt;, &lt;code&gt;[-&amp;gt;++&amp;lt;]&lt;/code&gt;) are counted, weighted by length. A program made of textbook idioms can be pattern-matched instead of traced.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trace semantic density ≥ 0.30.&lt;/strong&gt; At least 30% of executed steps must be something other than pointer movement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Worst-case preflight.&lt;/strong&gt; The program is run on input 255 against the step cap before it is admitted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;T2 nontriviality&lt;/strong&gt;, the most involved gate. T2 asks for an arithmetic formula equivalent to the program, so the formula must not be trivially short.

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Layer 1&lt;/em&gt; enumerates parser-valid expression trees bottom-up by observational equivalence, within a budget of 1,000,000 semantics and 1,000,000 operator applications. It targets depth 7, requires at least depth 3 to be proven exhaustively, and records the depth reached.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Layer 2&lt;/em&gt; tries named analytical families: polynomials via Newton interpolation, exact and additive periods, minimal affine pieces by dynamic programming, and bitwise-pointwise functions. It rejects an item only if it can synthesize an actual witness expression under 25 grammar tokens.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkypu4wzct7lbbrt77a1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkypu4wzct7lbbrt77a1t.png" alt="Acceptance by size tier" width="799" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a 500-candidate probe with seed 42, 376 candidates were accepted (75.2%). Each rejection is attributed to its first failing gate only: the off-idiom rate rejected 82 candidates and duplicate semantics 42, and the other 16 gate categories were never the first failure in that sample. The smallest size tier is the hardest to fill: 8 of 50 tier-0 candidates were accepted, against 44 to 46 of 50 from tier 4 up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gates can be wrong too.&lt;/strong&gt; The repository keeps a ledger of gates that were demoted to recorded covariates, each because of a measurement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A maximum E2/E0 prompt-length ratio of 3.5 was biasing the accepted items against larger programs: of 7 items accepted after its removal, 6 had ratios between 3.55 and 3.94 and would have been rejected.&lt;/li&gt;
&lt;li&gt;A minimum text density of 0.35 was worse. Density falls from 0.463 at tier 0 to 0.076 at tier 7, so the floor admitted only tiers 0–1. Their E0 prompts (226 to 466 tokens) did not overlap the E2 prompts (1,102 to 2,182 tokens) at all, so no matched pair could exist and the main hypothesis became unanswerable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rule that came out of it: any gate defined as a ratio over program length selects on length, so it must be calibrated per tier, reformulated, or demoted. The ledger also says that a further demotion should be read as a sign that the acceptance design, not a single gate, needs review. The off-idiom gate is also a length-normalized rate and is still active, so it is exactly the kind of gate that rule tells me to watch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three task families, all graded by execution
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;T1, state tracking.&lt;/strong&gt; Given a program, an input and an interior step, return the requested machine-state fields. Three probes per item sit at roughly 1/4, 2/4 and 3/4 of the execution trace, with the order rotated by seed. The truth comes from the interpreter stopping at that exact step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;T2, computation compression.&lt;/strong&gt; Return a formula that matches the program over its whole input domain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;T3, causal mutation.&lt;/strong&gt; Predict what happens after one specified instruction is replaced. The mutation position is drawn from an early, middle or late region of the program, and the answer is one of &lt;code&gt;OUTPUT&lt;/code&gt;, &lt;code&gt;IDENTICAL&lt;/code&gt;, &lt;code&gt;NON_TERMINATING&lt;/code&gt; or &lt;code&gt;ERROR&lt;/code&gt;, compared by exact JSON equality.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;T2 is where safe grading is hardest, because the model writes code. benchfck never executes it. The response must have the exact shape &lt;code&gt;def solve(inputs): return [ ... ]&lt;/code&gt;, and each list element goes through a hand-written recursive-descent parser into a small expression tree. The only variable is &lt;code&gt;inputs[N]&lt;/code&gt;, literals are limited to 0–256, and calls, attributes and names do not exist in the grammar. Constant subtrees are folded &lt;em&gt;before&lt;/em&gt; the length cap is applied, so equivalent spellings are not penalized. Evaluation uses checked arithmetic and returns nothing on overflow or division by zero:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;FloorDiv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;divisor&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kc"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;div_euclid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;divisor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;Expr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Binary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s1"&gt;'+'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checked_add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'*'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checked_mul&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'%'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rem_euclid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parsed formula is then evaluated on all 256 inputs, every value must fit in a byte, and each is compared with the Brainfuck run under the pinned step cap.&lt;/p&gt;

&lt;p&gt;Each item also carries its own T2 and T3 answer-token budgets, derived from structure (nesting, working set, trace length) and shared by all four encodings, so no encoding gets a larger budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Duplicates and leaks
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Near-duplicates.&lt;/strong&gt; The protocol is written as a markdown block embedded in the binary, and its SHA-256 is part of the output, so the definition cannot drift after results are seen. Two items are flagged only when they are semantically close (they disagree on at most 4 of 256 inputs) &lt;em&gt;and&lt;/em&gt; close in either their IR features (Sørensen-Dice distance ≤ 0.10) or their reference expressions (normalized Levenshtein ≤ 0.10). Over all 4,950 pairs of a 100-item batch: zero exact-semantic pairs and zero flagged pairs. The IR and expression axes alone each matched about 1,350 pairs, which is exactly why neither is used alone; the closest pair semantically still disagreed on 205 of 256 inputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Leaks.&lt;/strong&gt; The public files must not contain anything that reveals an answer. The scanner reads every raw JSONL line as untyped JSON and walks every object and array recursively, counting any of 28 forbidden keys (&lt;code&gt;seed&lt;/code&gt;, &lt;code&gt;ir&lt;/code&gt;, &lt;code&gt;e0&lt;/code&gt;, &lt;code&gt;trace&lt;/code&gt;, &lt;code&gt;expected_answer&lt;/code&gt;, &lt;code&gt;reference_solution&lt;/code&gt; and others). It does this before typed deserialization, so an extra field cannot slip past a schema. Result on the public batch: 1,610 records (100 metadata, 1,510 tasks), no private records, no forbidden keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing encodings without comparing lengths
&lt;/h2&gt;

&lt;p&gt;Because E3 prompts are several times longer than E0, a raw E0-versus-E3 comparison would mostly measure prompt length. benchfck builds token-matched pairs instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;token counts use &lt;code&gt;cl100k_base&lt;/code&gt; on the full T2 prompt;&lt;/li&gt;
&lt;li&gt;two prompts may pair only if their relative gap, |a − b| / max(a, b), is at most 10%;&lt;/li&gt;
&lt;li&gt;the E0 side must come from a strictly larger size tier, so that the shorter encoding has a longer program to match;&lt;/li&gt;
&lt;li&gt;pairs are chosen greedily by smallest gap and never reuse an item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foq0lmcbpmhptf6z4a1ef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foq0lmcbpmhptf6z4a1ef.png" alt="Matched-pair prompt-length gaps" width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The public batch yields 39 E0–E2 pairs and 31 E0–E3 pairs, all within the 10% limit. The design has an honest cost: matched pairs are two different programs from different tiers, not the same program in two encodings. The preregistration says so explicitly and adjusts for prompt length, trace length, tier, nesting depth, working set and density in a sensitivity model.&lt;/p&gt;

&lt;h2&gt;
  
  
  A preregistration frozen before any model call
&lt;/h2&gt;

&lt;p&gt;The model pilot was written down and frozen on 2026-08-16, before any provider response existed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Systems:&lt;/strong&gt; three model families, one each from OpenAI, Anthropic and Google, with reasoning settings and model snapshots fixed. Substituting a model requires an amendment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One confirmatory hypothesis (H1):&lt;/strong&gt; at roughly equal total prompt length, compact explicit operations (E2) give a higher exact-T2 rate than Brainfuck (E0). It is tested on 34 matched pairs from a separate &lt;em&gt;private&lt;/em&gt; item set, not the public pairs above. The estimate is a paired cluster bootstrap with 10,000 draws, and H1 counts as supported only if the whole 95% interval is above zero.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secondary contrasts&lt;/strong&gt; (E0–E3, E0–E1 and a per-family E2–E0) use a Holm correction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational rules:&lt;/strong&gt; task order is fixed by a hash; there is no outcome-based early stopping; a system with more than 2% operationally missing cells is invalidated, not selectively refilled; parse failures, refusals and truncations count as wrong.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget:&lt;/strong&gt; 2,160 calls with a $40 ceiling (the local token estimate is $25.78).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Amendments are allowed but must record the old hash, new hash and reason, and an amendment motivated by outcomes invalidates confirmatory status. Freezing the plan does not authorize a single call, and none has been made.&lt;/p&gt;

&lt;p&gt;The runner that will eventually execute this is already built and tested offline. It turns an answer-stripped task packet into request records and hashes each one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;every request is serialized and hashed;&lt;/li&gt;
&lt;li&gt;each run gets an ID derived from the system, repeat and task;&lt;/li&gt;
&lt;li&gt;loading a plan re-derives all of those hashes and rejects any mismatch;&lt;/li&gt;
&lt;li&gt;the resume log rejects a changed request, a duplicate or non-contiguous attempt, a retry after delivery, and a delivered response without a provider request ID, model snapshot, finish reason, token usage and cost.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Running it twice on the same inputs must produce byte-identical JSONL. It has no provider client and needs no credentials.&lt;/p&gt;

&lt;h2&gt;
  
  
  The open-generator problem
&lt;/h2&gt;

&lt;p&gt;If the generator is public, anyone can study the constructor family and train on it. benchfck's answer is a scoring epoch: official scores are meant to come from a separate, unpublished set of constructors plugged in through a narrow provider interface, which cannot bypass the acceptance gates. Each epoch is committed in advance with a salted hash of its exact bytes. That commitment detects later substitution, though it does not prove the gates passed. Epochs move one way (planned, active, closed, retired), a disclosed constructor is never reused, and the epoch record validator is fail-closed. The first private epoch is recorded as &lt;em&gt;planned&lt;/em&gt;, not active.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I keep this honest in CI
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;formatting and &lt;code&gt;clippy -D warnings&lt;/code&gt; on every push;&lt;/li&gt;
&lt;li&gt;unit tests, then a script that checks every evidence file against its SHA-256 manifest and re-verifies the Phase 2 package;&lt;/li&gt;
&lt;li&gt;the 500-program property shard on every push and the full 10,000-program run on pull requests and weekly;&lt;/li&gt;
&lt;li&gt;CodeQL for the Rust code, with all CI actions pinned by commit SHA.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can try the local path with Rust only, no API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo build --release
cargo run --release -- generate --seed 42 --count 1 --difficulty hard --arity 1 --output target/benchfck-public.jsonl
cargo run --release -- validate --input target/benchfck-public.jsonl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is not done
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No model has been evaluated. No leaderboard or aggregate score exists.&lt;/li&gt;
&lt;li&gt;The official scope is one-input programs. Two-input programs are a deferred research path.&lt;/li&gt;
&lt;li&gt;The public items come from four structural families. That is a narrow development subset.&lt;/li&gt;
&lt;li&gt;The private constructor epoch is planned, not active.&lt;/li&gt;
&lt;li&gt;Human review, the statistical analysis and an independent clean-checkout reproduction are all still outstanding.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where I would like feedback
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Is exact, execution-graded state tracking a useful complement to the benchmarks you already use, or is the domain too narrow to say anything?&lt;/li&gt;
&lt;li&gt;Is a private constructor set with one-way rotation and published commitments a credible answer to the open-generator problem?&lt;/li&gt;
&lt;li&gt;Cross-item, length-matched pairs trade one confound for another. Is there a better control for encoding length?&lt;/li&gt;
&lt;li&gt;What would you need to see in the preregistration before you trusted a first result?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I built this, so read my framing with that in mind. The code, the evidence files and the preregistration are at &lt;a href="https://github.com/muend/benchfck" rel="noopener noreferrer"&gt;https://github.com/muend/benchfck&lt;/a&gt;. Criticism of the design is welcome in the comments or as an issue.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>rust</category>
      <category>testing</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Building GPT-2 (124M) in PyTorch: weight parity, a speed ladder and about 150 GPU-minutes of my own training</title>
      <dc:creator>Muhammed Enes Duran</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:39:30 +0000</pubDate>
      <link>https://dev.to/muend/building-gpt-2-124m-in-pytorch-weight-parity-a-speed-ladder-and-about-150-gpu-minutes-of-my-own-18dn</link>
      <guid>https://dev.to/muend/building-gpt-2-124m-in-pytorch-weight-parity-a-speed-ladder-and-about-150-gpu-minutes-of-my-own-18dn</guid>
      <description>&lt;p&gt;"I implemented GPT-2" can mean three very different things. You can load OpenAI's weights into your own code and show it computes the same function. You can make the training loop fast. Or you can start from random weights and train a model that actually learns something. All three happened in my repository &lt;a href="https://github.com/muend/neuron-to-gpt" rel="noopener noreferrer"&gt;neuron-to-gpt&lt;/a&gt;, my weekly submissions for a 12-week AI program that went from a single neuron to GPT-2. Keeping their numbers apart turned out to be harder than producing them.&lt;/p&gt;

&lt;p&gt;The GPT-2 weeks follow the outline of Andrej Karpathy's "Let's reproduce GPT-2 (124M)" lecture, so the model itself will look familiar. This post is about what I added around it: a full-logit parity test on English, Turkish and emoji prompts that guards the weight import, a speed ladder where every stage is timed on its own and the flash stage cannot silently fall back, a resumable training run with its interruption written into the record, and a paired comparison against GPT-2 on a held-out HellaSwag cohort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Headline number&lt;/th&gt;
&lt;th&gt;What it proves&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Week 10&lt;/td&gt;
&lt;td&gt;My GPT-2 holding OpenAI's weights&lt;/td&gt;
&lt;td&gt;max logit diff 5.3e-05 to 8.4e-05 on an A100 (rtol = atol = 1e-4 per logit)&lt;/td&gt;
&lt;td&gt;my code computes the reference function&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Week 11&lt;/td&gt;
&lt;td&gt;Cumulative speed stages on an L4&lt;/td&gt;
&lt;td&gt;53.75 → 36.23 ms per update, 1.48×&lt;/td&gt;
&lt;td&gt;which change actually helped, at one small shape&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Week 12&lt;/td&gt;
&lt;td&gt;Random init, 60 min on an NVIDIA L4&lt;/td&gt;
&lt;td&gt;validation NLL 11.01 → 4.98; HellaSwag 27.6%&lt;/td&gt;
&lt;td&gt;my training pipeline learns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;G4&lt;/td&gt;
&lt;td&gt;That checkpoint, 90 more minutes on an RTX PRO 6000&lt;/td&gt;
&lt;td&gt;NLL 4.98 → 3.67; HellaSwag 27.6% → 32.3% on the first 1,000 examples, 30.5% vs GPT-2's 33.7% on a held-out 1,000&lt;/td&gt;
&lt;td&gt;real progress; below GPT-2 on both cohorts' point estimates&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frofar9mwqkpsh08leth8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frofar9mwqkpsh08leth8.png" alt="Validation loss across the L4 run and the G4 continuation" width="799" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The model
&lt;/h2&gt;

&lt;p&gt;Standard GPT-2 small: 12 blocks, 12 heads, width 768, 1,024 positions, pre-LayerNorm, tanh-approximate GELU, learned absolute positions and a fused Q/K/V projection. The token embedding and the output layer share one matrix (weight tying), which saves 50,257 × 768 = 38,597,376 parameters: the tied model has 124,439,808 unique parameters, the untied one would have 163,037,184.&lt;/p&gt;

&lt;p&gt;Initialization follows GPT-2: std 0.02 for weight matrices, and std 0.02/√(2L) for the two residual output projections in each block. Every block adds two contributions to the residual stream, so without the smaller scale the variance of the stream grows with depth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 10: weight parity is a correctness test, not training
&lt;/h2&gt;

&lt;p&gt;To check the implementation, I import the published OpenAI weights (the Hugging Face copy, pinned to a fixed revision) into my own modules and compare outputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trap is in the import.&lt;/strong&gt; Hugging Face's GPT-2 uses a historical &lt;code&gt;Conv1D&lt;/code&gt; layer that stores weights as (input, output). &lt;code&gt;nn.Linear&lt;/code&gt; expects (output, input). So four weight matrices per block must be transposed. For three of them a forgotten transpose fails loudly with a shape error. The attention output projection is 768 × 768, so a missing transpose there loads without complaint and silently computes a different function.&lt;/p&gt;

&lt;p&gt;From &lt;code&gt;load_hf_weights&lt;/code&gt; in &lt;code&gt;week10/model.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;transposed_suffixes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;".attn.c_attn.weight"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".attn.c_proj.weight"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;".mlp.c_fc.weight"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".mlp.c_proj.weight"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;tensor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transposed_suffixes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loader validates every key and every shape before copying anything, so a late mismatch cannot leave a half-loaded model behind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The parity check compares full logits, not a sample.&lt;/strong&gt; Both models get the same input in FP32, with eager attention, TF32 off and dropout off, and every logit must agree within rtol = atol = 1e-4. I used three prompts on purpose: an English sentence, a Turkish one, and a mixed string with an emoji, so that multi-byte BPE paths are exercised too. On an A100 the largest absolute difference per prompt was between 5.3e-05 and 8.4e-05, and all three passed; the same check also passed on a T4.&lt;/p&gt;

&lt;p&gt;That proves my code computes the same function as the reference when it holds the same weights. It says nothing about whether my code can learn. For that, Week 10 has a deliberately narrow diagnostic: 300 updates on one fixed batch (4 × 32 tokens) from random weights. Loss went from 11.056 to about 0.0001 and token accuracy reached 100%. That is memorization of a single batch. It shows gradients flow and the optimizer steps; it is not evidence of generalization, and I never report it as such.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 11: a speed ladder where every rung is measured
&lt;/h2&gt;

&lt;p&gt;The question for Week 11 was simple: which of the usual speed-ups actually helps on the GPU I have? Instead of switching everything on at once, each stage is added on top of the previous one and timed separately.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx713ahgdmsp1xi4rakg5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx713ahgdmsp1xi4rakg5.png" alt="Week 11 speed stages on an NVIDIA L4" width="799" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage (cumulative)&lt;/th&gt;
&lt;th&gt;Median ms / update&lt;/th&gt;
&lt;th&gt;Tokens/s&lt;/th&gt;
&lt;th&gt;vs previous&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;baseline, FP32, eager attention&lt;/td&gt;
&lt;td&gt;53.750&lt;/td&gt;
&lt;td&gt;4,762.8&lt;/td&gt;
&lt;td&gt;1.000×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ TF32 matmul&lt;/td&gt;
&lt;td&gt;53.043&lt;/td&gt;
&lt;td&gt;4,826.3&lt;/td&gt;
&lt;td&gt;1.013×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ BF16 autocast&lt;/td&gt;
&lt;td&gt;59.097&lt;/td&gt;
&lt;td&gt;4,331.9&lt;/td&gt;
&lt;td&gt;0.898×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ &lt;code&gt;torch.compile&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;36.790&lt;/td&gt;
&lt;td&gt;6,958.4&lt;/td&gt;
&lt;td&gt;1.606×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ SDPA, flash kernel only&lt;/td&gt;
&lt;td&gt;36.171&lt;/td&gt;
&lt;td&gt;7,077.4&lt;/td&gt;
&lt;td&gt;1.017×&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;+ vocabulary padded to 50,304&lt;/td&gt;
&lt;td&gt;36.227&lt;/td&gt;
&lt;td&gt;7,066.6&lt;/td&gt;
&lt;td&gt;0.998×&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The conditions matter as much as the numbers: B = 2, T = 128, 5 warmup updates, 20 timed updates per stage, one run, on an NVIDIA L4. Each timed update includes data transfer, forward, backward, unscale/clip and the AdamW step, with a CUDA synchronization per step. Compile time and warmup are excluded (compilation plus warmup took about 42 seconds for that stage).&lt;/p&gt;

&lt;p&gt;What I took from it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;torch.compile&lt;/code&gt; stage was the largest single step:&lt;/strong&gt; 1.606× on top of the TF32 and BF16 stages. The whole ladder came to 1.48× against the FP32 baseline. Compile was not measured in isolation, so part of that step may simply be recovering what the BF16 stage lost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BF16 autocast made things slower here&lt;/strong&gt; (0.898×). I did not profile why. At B = 2, T = 128 the step is small enough that overheads can outweigh faster math, but that is a hypothesis, not a measurement. Either way it is a fact about this shape on an L4, not about mixed precision in general, and it is exactly the kind of result that disappears if you only compare "everything on" with "everything off".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No fake FlashAttention.&lt;/strong&gt; The flash stage runs inside &lt;code&gt;sdpa_kernel(SDPBackend.FLASH_ATTENTION)&lt;/code&gt;, which disallows the math and memory-efficient fallbacks. If the flash kernel cannot run, the stage fails instead of quietly measuring something else under the flash label.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vocabulary padding showed no measurable gain in this single run&lt;/strong&gt; (0.998×). Padding 50,257 to 50,304 (a multiple of 64) is a common trick; I would need repeated runs to say more. The padded model has 124,475,904 parameters, and the 47 extra classes are implementation-only: they are excluded from sampling and from evaluation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gradient accumulation also gets a correctness rule: K micro-batches with equal token counts each contribute loss / K, so the summed gradient equals the gradient of the mean loss over the combined batch. Clipping and the AdamW step happen once per update, after unscaling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 12: a real dataset, from random weights
&lt;/h2&gt;

&lt;p&gt;Week 12 is a separate model. It starts from random weights, not from OpenAI's.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data pipeline
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source:&lt;/strong&gt; FineWeb-Edu &lt;code&gt;sample-10BT&lt;/code&gt;, pinned to a fixed dataset revision, so the run can be traced back to exact documents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split by document, not by token.&lt;/strong&gt; Validation documents are filled first and never appear in training; exact duplicates are removed. Near-duplicate cleaning and benchmark contamination scans were &lt;em&gt;not&lt;/em&gt; done, and the report says so.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget in tokens, not documents:&lt;/strong&gt; 20,000,000 training tokens in 20 shards and a 131,072-token validation shard, all counted with the GPT-2 tokenizer, with an end-of-text token at each document boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage:&lt;/strong&gt; 1M-token &lt;code&gt;uint16&lt;/code&gt; NPY shards, each with a SHA-256 in the manifest. The loader memory-maps the shards and builds windows that cross shard boundaries, so no tail of a shard is silently dropped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed validation:&lt;/strong&gt; every check measures exactly the same first 32 batches = 32,768 target tokens. A validation number that moves because the slice moved is worthless.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Training setup
&lt;/h3&gt;

&lt;p&gt;B = 4, T = 256, accumulation 4 (4,096 tokens per update), BF16, SDPA, &lt;code&gt;torch.compile&lt;/code&gt;, a 100-update warmup and a 60-minute wall-clock budget. The checkpoint (&lt;code&gt;last.pt&lt;/code&gt;) stores not just weights but the AdamW and scaler state, the data loader position and the RNG state, so a Colab disconnect does not silently restart the data stream or the schedule.&lt;/p&gt;

&lt;p&gt;The run made 19,586 updates and processed 80,224,256 tokens in 60.20 minutes. Validation NLL went from 11.013 to 4.984965.&lt;/p&gt;

&lt;h3&gt;
  
  
  HellaSwag, done carefully
&lt;/h3&gt;

&lt;p&gt;HellaSwag gives a context and four endings; the model picks the ending it finds most likely. Small protocol choices move the score by points, so I pinned all of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dataset:&lt;/strong&gt; the deprecated GitHub JSONL URL now returns 404, so I use &lt;code&gt;Rowan/hellaswag&lt;/code&gt; from the Hugging Face Hub, pinned to a revision.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scoring:&lt;/strong&gt; only the ending tokens are scored, using mean token NLL (acc_norm). The context is encoded once, each ending is encoded separately with its leading space, and nothing is cleaned up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long contexts&lt;/strong&gt; are left-trimmed by the same amount for all four endings, so no ending gets an advantage from extra context.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Same vocabulary for both models:&lt;/strong&gt; logits are sliced to the 50,257 real GPT-2 IDs, removing my model's 47 padding classes before the softmax.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Same numerics:&lt;/strong&gt; FP32, TF32 off, for my model and for OpenAI GPT-2 (weights pinned to a revision and loaded into my own implementation).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;losses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;F&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cross_entropy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;logits&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;50257&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reshape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50257&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;logits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reshape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reduction&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"none"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reshape_as&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;losses&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# mask: ending positions only&lt;/span&gt;
&lt;span class="n"&gt;means&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# acc_norm uses the mean&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the first 1,000 validation examples, my 60-minute model scored 27.6% (chance is 25%). OpenAI GPT-2, under the identical protocol, scored 33.6%. Eighty million tokens is a small experiment, not a pretraining reproduction; a gap is expected, though this run does not isolate its causes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A note on the absolute numbers.&lt;/strong&gt; Karpathy's build-nanogpt script, with the same completion-style acc_norm, reports 29.55% for GPT-2 124M on all 10,042 validation examples. My 1,000-example slices give GPT-2 33.6% and 33.7%, and the Wilson interval for 33.6% (about 30.7% to 36.6%) does not reach 29.55%. So the first 2,000 examples of the pinned &lt;code&gt;Rowan/hellaswag&lt;/code&gt; split look easier than the full set, or something in the data source differs; I did not run the full set to find out. The scores in this post are therefore comparable with each other, under one protocol and on the same indices, and not with published full-set numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  G4: continuing my own checkpoint on a bigger GPU
&lt;/h2&gt;

&lt;p&gt;The last experiment takes that exact L4 checkpoint, verifies its hash, and continues training on an NVIDIA RTX PRO 6000 Blackwell GPU for 90 minutes. It is not started from OpenAI weights.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Settings:&lt;/strong&gt; B = 8, T = 1,024, accumulation 4 (32,768 tokens per update), BF16, SDPA, &lt;code&gt;torch.compile&lt;/code&gt; and fused AdamW with β = (0.9, 0.95), ε = 1e-8, weight decay 0.1 on matrices and gradient clipping at 1.0. The learning rate warms up over 30 successful updates and then follows a cosine envelope tied to wall-clock time, from 3e-4 down to 3e-5, so the schedule ends when the budget ends regardless of throughput.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fresh data, checked against the old run.&lt;/strong&gt; A new 200M-token training pool was drawn from the same pinned FineWeb-Edu revision. Every document whose SHA-256 exactly matches a document in the earlier L4 training &lt;em&gt;or&lt;/em&gt; validation set was removed. The 131,072-token validation shard was carried over byte for byte, so the L4 and G4 validation numbers measure the same 32,768 targets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resume bookkeeping is part of the result.&lt;/strong&gt; The first session was planned against a clock deadline. It was interrupted after 3,989 committed updates and resumed from the verified checkpoint; on resume the deadline-based limit was removed and the total budget across both sessions set to 90 minutes (the pause between sessions is not counted). The 3,989 updates were kept and 16,384 tokens from an unfinished micro-batch were read again. The source version, the old and new budget settings and the checkpoint hash are all recorded under &lt;code&gt;resumes&lt;/code&gt; in &lt;code&gt;training.json&lt;/code&gt;. A loss curve without its resume history is hard to trust.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; 38,061 updates, 1,247,182,848 processed tokens, 90.01 minutes, about 230,933 tokens/s over wall time. Validation NLL fell from 4.984965 to 3.665616.&lt;/p&gt;

&lt;p&gt;Two caveats travel with those numbers. Processed tokens are not unique data: the 200M-token pool was seen about 6.24 times. And the throughput is not a controlled comparison with the L4 run, because context length, batch, data and hardware all changed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two HellaSwag cohorts, chosen before looking
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkplon9oskppyjmniurut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkplon9oskppyjmniurut.png" alt="HellaSwag accuracy with Wilson intervals" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Evaluation&lt;/th&gt;
&lt;th&gt;L4 checkpoint&lt;/th&gt;
&lt;th&gt;G4 continuation&lt;/th&gt;
&lt;th&gt;OpenAI GPT-2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;FineWeb validation NLL (fixed 32,768 targets)&lt;/td&gt;
&lt;td&gt;4.984965&lt;/td&gt;
&lt;td&gt;3.665616&lt;/td&gt;
&lt;td&gt;not measured&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HellaSwag, indices 0–999&lt;/td&gt;
&lt;td&gt;27.6%&lt;/td&gt;
&lt;td&gt;32.3%&lt;/td&gt;
&lt;td&gt;33.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HellaSwag, indices 1,000–1,999&lt;/td&gt;
&lt;td&gt;not measured&lt;/td&gt;
&lt;td&gt;30.5%&lt;/td&gt;
&lt;td&gt;33.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Indices 0–999 were already used in Week 12, so they only show continuity: the same examples went from 27.6% to 32.3%. Indices 1,000–1,999 were reserved in advance as the main comparison, and the checkpoint was selected by validation loss, never by HellaSwag. On that held-out cohort my model scores 30.5% and GPT-2 33.7%.&lt;/p&gt;

&lt;p&gt;Both models answer the same questions, so I compare them pairwise instead of treating the two accuracies as independent:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cohort&lt;/th&gt;
&lt;th&gt;Only mine correct&lt;/th&gt;
&lt;th&gt;Only GPT-2 correct&lt;/th&gt;
&lt;th&gt;Paired bootstrap 95% CI (mine − GPT-2)&lt;/th&gt;
&lt;th&gt;Exact McNemar p&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0–999&lt;/td&gt;
&lt;td&gt;88&lt;/td&gt;
&lt;td&gt;101&lt;/td&gt;
&lt;td&gt;[−4.00, +1.40] points&lt;/td&gt;
&lt;td&gt;0.383&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1,000–1,999&lt;/td&gt;
&lt;td&gt;58&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;[−5.60, −0.80] points&lt;/td&gt;
&lt;td&gt;0.0106&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The bootstrap uses 20,000 resamples with seed 20261108 and assumes independent examples, so it is a rough uncertainty measure. Read plainly: on the first cohort the data cannot separate the two models; on the held-out cohort GPT-2 is ahead. There is no equivalence claim to make, and nothing here says anything about chat, code or reasoning.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the text looks like
&lt;/h3&gt;

&lt;p&gt;Same prompt, seed 42, temperature 0.8, top-k 50, at most 48 new tokens. At the start of G4:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The children walked into the way, which is called the "Kak," they take into account their own needs and can be taught in the form of "Rarm," ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At the end of G4:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The children walked into the school and enjoyed the music. As the summer started to get underway, the teacher was amazed at the new songs. A young man was still amazed by the songs. ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The sentences are better formed, but the model still repeats itself and loses the thread a few lines later. One sample is an illustration, not an evaluation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons I would apply to any training project
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Compare full logits, not shapes.&lt;/strong&gt; A missing transpose on the square attention projection passes a shape check. Include non-ASCII text so multi-byte BPE paths are exercised too.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure optimizations one at a time.&lt;/strong&gt; The ladder showed BF16 slowing things down at a small shape and the &lt;code&gt;torch.compile&lt;/code&gt; stage as the largest single step (1.606× on top of TF32 and BF16). An all-on versus all-off comparison would have hidden both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make silent fallbacks impossible.&lt;/strong&gt; If the flash kernel is not allowed to fall back, a flash number really is a flash number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin everything that can drift.&lt;/strong&gt; Dataset revision, model revision, the validation slice, the HellaSwag source, the scoring code. Otherwise a later number is not comparable to an earlier one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose the held-out set before you look.&lt;/strong&gt; It is the reason I treat 30.5% as the result and 32.3% as continuity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep claims apart in the repository, not only in the prose.&lt;/strong&gt; Week 10 imports weights to verify code; Week 12 starts from random; G4 continues Week 12; OpenAI GPT-2 is only an evaluation reference.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Week 12 and G4 are single runs. I did not measure seed-to-seed variance.&lt;/li&gt;
&lt;li&gt;G4 processed 1.25B tokens but only 200M unique ones (about 6.24 passes), so its token count overstates the data it saw. I did not compare against a no-repeat run.&lt;/li&gt;
&lt;li&gt;HellaSwag was run on two 1,000-example slices, not on the full 10,042-example set.&lt;/li&gt;
&lt;li&gt;GPU inference was not rerun locally. I verified the exported file hashes, the token and update accounting, and the predictions reconstructed from the saved per-example NLL scores.&lt;/li&gt;
&lt;li&gt;Rerunning G4 needs my backed-up checkpoint and token shards. A fresh clone contains the evidence, not the weights.&lt;/li&gt;
&lt;li&gt;G4 run environment: PyTorch 2.14.1+cu130, CUDA 13.0, Python 3.13.16. Requirements use version ranges, not a lockfile.&lt;/li&gt;
&lt;li&gt;This is a base language model study, not a chat assistant or a production service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The evidence check runs without a GPU, a checkpoint or a dataset download:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/muend/neuron-to-gpt
&lt;span class="nb"&gt;cd&lt;/span&gt; neuron-to-gpt
python experiments/g4/analyze_results.py --check
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The check recomputes file hashes, token and update accounting, and the correct counts from the saved per-example NLL scores; it does not rerun the model. The G4 report and its per-example evaluation files are in &lt;code&gt;experiments/g4/results/nvidia_rtx_pro6000/&lt;/code&gt;, the speed ladder in &lt;code&gt;week11/results/nvidia_l4/&lt;/code&gt;, and the parity report in &lt;code&gt;week10/results/&lt;/code&gt;. The Week 12 README lists build-nanogpt's HellaSwag script as the reference evaluation protocol.&lt;/p&gt;

&lt;p&gt;If you spot a flaw in the evaluation setup, I would like to hear about it in the comments.&lt;/p&gt;

</description>
      <category>pytorch</category>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>python</category>
    </item>
    <item>
      <title>Why AI-Generated GIS Code Can Run Successfully and Still Be Wrong</title>
      <dc:creator>Muhammed Enes Duran</dc:creator>
      <pubDate>Thu, 23 Jul 2026 15:01:21 +0000</pubDate>
      <link>https://dev.to/muend/why-ai-generated-gis-code-can-run-successfully-and-still-be-wrong-473k</link>
      <guid>https://dev.to/muend/why-ai-generated-gis-code-can-run-successfully-and-still-be-wrong-473k</guid>
      <description>&lt;p&gt;Geospatial code has an unusual failure mode: it can execute without errors, produce a clean-looking result, and still be &lt;strong&gt;methodologically wrong&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This problem is becoming more important as AI coding agents generate complete GIS workflows from short natural-language instructions.&lt;/p&gt;

&lt;p&gt;The issue is not always that an AI agent does not know GeoPandas, rasterio, PostGIS, Earth Engine, or ArcPy. In many cases, it knows the correct API and can produce executable code.&lt;/p&gt;

&lt;p&gt;The problem is that API correctness is not the same as geospatial correctness.&lt;/p&gt;

&lt;h2&gt;
  
  
  A silent CRS failure
&lt;/h2&gt;

&lt;p&gt;Consider a simple buffer operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="sb"&gt;`buffered = gdf.buffer(1000)`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code looks reasonable. It runs successfully and produces new geometries.&lt;/p&gt;

&lt;p&gt;But what does 1000 mean?&lt;/p&gt;

&lt;p&gt;When the dataset uses a geographic coordinate reference system such as &lt;strong&gt;EPSG:4326&lt;/strong&gt;, its coordinate units are degrees rather than metres. The operation may still return valid geometries, but they do not represent a &lt;strong&gt;1,000-metre buffer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A safer workflow makes the spatial assumptions explicit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;crs&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The input dataset has no CRS.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;crs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_geographic&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;projected_crs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;estimate_utm_crs&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;projected_crs&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A suitable projected CRS could not be determined.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;gdf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_crs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;projected_crs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;buffered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gdf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even this pattern is not universally correct. A locally estimated UTM projection may be unsuitable for datasets that span multiple zones, countries, or continents.&lt;/p&gt;

&lt;p&gt;The important point is not one specific code snippet. A defensible workflow must ask:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is the CRS defined?&lt;/strong&gt;&lt;br&gt;
Are the coordinate units appropriate?&lt;br&gt;
Is the projection suitable for the geographic extent?&lt;br&gt;
How will the output be verified?&lt;/p&gt;

&lt;p&gt;Without those checks, plausible output can hide an invalid spatial operation.&lt;/p&gt;
&lt;h2&gt;
  
  
  A machine-learning result that looks better than it is
&lt;/h2&gt;

&lt;p&gt;Spatial machine learning has a similar problem.&lt;/p&gt;

&lt;p&gt;A common model evaluation starts with a random train/test split:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;train_test_split&lt;/span&gt;

&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For independent observations, this can be a reasonable starting point.&lt;/p&gt;

&lt;p&gt;Spatial observations, however, are often correlated with nearby observations. A random split can place neighbouring samples in both the training and test sets.&lt;/p&gt;

&lt;p&gt;The model then appears to generalize, while it may only be exploiting local spatial similarity.&lt;/p&gt;

&lt;p&gt;This can produce an impressive accuracy score that collapses when the model is applied to a genuinely new region.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A more defensible evaluation may require:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spatial blocks or geographic groups&lt;/li&gt;
&lt;li&gt;region-level holdouts&lt;/li&gt;
&lt;li&gt;distance-based separation&lt;/li&gt;
&lt;li&gt;temporal separation for future prediction&lt;/li&gt;
&lt;li&gt;maps of residuals and prediction errors&lt;/li&gt;
&lt;li&gt;comparison between random and spatial validation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spatially blocked validation often produces a lower score.&lt;/p&gt;

&lt;p&gt;That lower score may be the more honest result.&lt;/p&gt;

&lt;p&gt;Rendering is not verification&lt;/p&gt;

&lt;p&gt;Maps introduce another form of silent failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A map can render correctly while using:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an unsuitable projection&lt;/li&gt;
&lt;li&gt;misleading classification boundaries&lt;/li&gt;
&lt;li&gt;inconsistent scales across dates&lt;/li&gt;
&lt;li&gt;inaccessible colour choices&lt;/li&gt;
&lt;li&gt;unreported missing values&lt;/li&gt;
&lt;li&gt;geometries silently removed during processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A change-detection map can look convincing even when the source rasters are misregistered, collected in different seasons, or processed at incompatible levels.&lt;/p&gt;

&lt;p&gt;Successful rendering proves that the software produced an image.&lt;/p&gt;

&lt;p&gt;It does not prove that the analysis is valid.&lt;/p&gt;

&lt;p&gt;What an AI agent needs beyond API knowledge&lt;/p&gt;

&lt;p&gt;A general-purpose coding agent may know which function to call. It does not necessarily know when a workflow should stop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For geospatial tasks, an agent needs explicit operational rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never calculate area or distance in a geographic CRS.&lt;/li&gt;
&lt;li&gt;Treat spatial leakage as a default risk in predictive modelling.&lt;/li&gt;
&lt;li&gt;Validate geometries and account for input and output row counts.&lt;/li&gt;
&lt;li&gt;Preserve georeferencing through raster and deep-learning pipelines.&lt;/li&gt;
&lt;li&gt;Report uncertainty when the analytical method supports it.&lt;/li&gt;
&lt;li&gt;Verify outputs numerically and visually.&lt;/li&gt;
&lt;li&gt;Refuse invalid spatial or temporal comparisons instead of producing a misleading result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are not optional improvements added after the analysis.&lt;/p&gt;

&lt;p&gt;They are part of the analytical method itself.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Building GeoAI Skills
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;I built GeoAI Skills to encode these safeguards as reusable Agent Skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The current public preview contains 18 skills covering:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;geospatial data engineering&lt;/li&gt;
&lt;li&gt;PostGIS and spatial SQL&lt;/li&gt;
&lt;li&gt;remote sensing&lt;/li&gt;
&lt;li&gt;Google Earth Engine&lt;/li&gt;
&lt;li&gt;geospatial deep learning&lt;/li&gt;
&lt;li&gt;spatial statistics&lt;/li&gt;
&lt;li&gt;geostatistics and interpolation&lt;/li&gt;
&lt;li&gt;terrain and hydrology&lt;/li&gt;
&lt;li&gt;suitability analysis&lt;/li&gt;
&lt;li&gt;point clouds and LiDAR&lt;/li&gt;
&lt;li&gt;network accessibility&lt;/li&gt;
&lt;li&gt;movement trajectories&lt;/li&gt;
&lt;li&gt;change detection&lt;/li&gt;
&lt;li&gt;cartography and geovisualization&lt;/li&gt;
&lt;li&gt;guarded ArcGIS Pro automation&lt;/li&gt;
&lt;li&gt;machine-learning experiment standards&lt;/li&gt;
&lt;li&gt;software engineering and DevOps practices&lt;/li&gt;
&lt;li&gt;multi-stage GeoAI workflow orchestration
The objective is not to make an AI agent sound like a GIS expert.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective is to make assumptions visible, require verification, and fail loudly when a workflow is not defensible.&lt;/p&gt;

&lt;p&gt;A land-suitability request, for example, may involve data preparation, remote sensing, terrain analysis, multi-criteria decision analysis, and cartographic delivery.&lt;/p&gt;

&lt;p&gt;GeoAI Skills uses a central orchestrator to route each stage to the relevant specialist skill while maintaining shared safeguards such as CRS checks, leakage prevention, uncertainty reporting, and verification.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Guarded ArcGIS Pro automation
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;The suite also includes an arcgis-pro-automation skill.&lt;/p&gt;

&lt;p&gt;It works with my open-source &lt;strong&gt;arcgis-mcp-bridge&lt;/strong&gt; project to support controlled local ArcPy execution.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The integration covers workflows involving:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ArcGIS Pro projects&lt;/li&gt;
&lt;li&gt;file and enterprise geodatabases&lt;/li&gt;
&lt;li&gt;vector and raster geoprocessing&lt;/li&gt;
&lt;li&gt;spatial and statistical analysis&lt;/li&gt;
&lt;li&gt;network analysis&lt;/li&gt;
&lt;li&gt;maps and layouts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because ArcPy operations can modify real projects and datasets, the execution model includes path restrictions and confirmation gates for mutating or destructive actions.&lt;/p&gt;

&lt;p&gt;The goal is not unrestricted automation.&lt;/p&gt;

&lt;p&gt;It is controlled automation with explicit boundaries.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing whether the correct skills activate
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;A skill is not useful if the agent does not activate it for the right request—or activates it for unrelated requests.&lt;/p&gt;

&lt;p&gt;The repository currently contains 131 typed evaluation scenarios across the 18 skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These scenarios include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;positive activation cases&lt;/li&gt;
&lt;li&gt;negative cases&lt;/li&gt;
&lt;li&gt;ambiguous requests&lt;/li&gt;
&lt;li&gt;collisions between related skills&lt;/li&gt;
&lt;li&gt;artifact-oriented evaluations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a frozen 17-skill, 120-case routing suite using Claude Code 2.1.214 and Claude Sonnet 5, the published results were:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;100% routing precision&lt;br&gt;
92.86% routing recall&lt;br&gt;
92.5% full-route accuracy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These results have an important limitation.&lt;/p&gt;

&lt;p&gt;They measure whether the expected skills were selected for that exact runtime, model, and evaluation suite. They do not prove that every generated analysis is correct, and they are not universal compatibility or answer-quality claims.&lt;/p&gt;

&lt;p&gt;The eighteenth skill, arcgis-pro-automation, was added after the frozen benchmark and is not included in those headline figures.&lt;/p&gt;

&lt;p&gt;Routing evidence, behavioural correctness, and real-world analytical quality should be evaluated separately.&lt;/p&gt;

&lt;p&gt;Trying the public preview&lt;/p&gt;

&lt;p&gt;The complete suite can be explored and installed interactively with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx skills add muend/geoai-skills&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A single specialist skill can also be installed independently:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx skills add muend/geoai-skills --skill postgis-spatial-sql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub repository:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/muend/geoai-skills" rel="noopener noreferrer"&gt;https://github.com/muend/geoai-skills&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Skills collection:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.skills.sh/muend/geoai-skills" rel="noopener noreferrer"&gt;https://www.skills.sh/muend/geoai-skills&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The project is still an early public preview.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I am particularly interested in reproducible examples of:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GIS code that executed successfully but produced an invalid result&lt;/li&gt;
&lt;li&gt;spatial leakage in real machine-learning projects&lt;/li&gt;
&lt;li&gt;ArcGIS Pro or ArcPy failure modes that should be guarded explicitly&lt;/li&gt;
&lt;li&gt;ambiguous requests that could activate the wrong specialist skill&lt;/li&gt;
&lt;li&gt;important verification steps that the current suite does not yet require&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is the most common silent geospatial failure you have encountered?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>showdev</category>
      <category>geospatial</category>
    </item>
    <item>
      <title>Building a Secure MCP Bridge for ArcGIS Pro and ArcPy</title>
      <dc:creator>Muhammed Enes Duran</dc:creator>
      <pubDate>Wed, 01 Jul 2026 15:44:07 +0000</pubDate>
      <link>https://dev.to/muend/building-a-secure-mcp-bridge-for-arcgis-pro-and-arcpy-511g</link>
      <guid>https://dev.to/muend/building-a-secure-mcp-bridge-for-arcgis-pro-and-arcpy-511g</guid>
      <description>&lt;p&gt;ArcGIS Pro has a powerful Python runtime through ArcPy, but it is not a lightweight dependency. It is native, licensed, Windows-bound, and tightly coupled to the ArcGIS Pro environment.&lt;/p&gt;

&lt;p&gt;That makes it awkward to connect directly to AI tooling.&lt;/p&gt;

&lt;p&gt;I built &lt;code&gt;arcgis-mcp-bridge&lt;/code&gt; as an independent open-source experiment to solve this problem through the Model Context Protocol (MCP).&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/muend/arcgis-mcp-bridge" rel="noopener noreferrer"&gt;https://github.com/muend/arcgis-mcp-bridge&lt;/a&gt;&lt;br&gt;&lt;br&gt;
PyPI: &lt;a href="https://pypi.org/project/arcgis-mcp-bridge/" rel="noopener noreferrer"&gt;https://pypi.org/project/arcgis-mcp-bridge/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
MCP Registry: &lt;code&gt;io.github.muend/arcgis-mcp-bridge&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;ArcPy is extremely useful for GIS automation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;geoprocessing&lt;/li&gt;
&lt;li&gt;feature class and geodatabase operations&lt;/li&gt;
&lt;li&gt;raster workflows&lt;/li&gt;
&lt;li&gt;map and layer management&lt;/li&gt;
&lt;li&gt;coordinate reference operations&lt;/li&gt;
&lt;li&gt;spatial statistics&lt;/li&gt;
&lt;li&gt;network analysis&lt;/li&gt;
&lt;li&gt;export and layout workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But ArcPy is not a normal pure-Python library. It depends on the licensed ArcGIS Pro Python environment and native Esri runtime components.&lt;/p&gt;

&lt;p&gt;For AI/MCP workflows, importing ArcPy directly into the host process is not a clean architecture. If the native runtime crashes, blocks, logs to stdout, or touches the wrong local path, the AI host process is affected too.&lt;/p&gt;

&lt;p&gt;So the main design goal was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep the AI/MCP host process lightweight, controlled, and separate from the licensed ArcPy execution runtime.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  What arcgis-mcp-bridge does
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;arcgis-mcp-bridge&lt;/code&gt; is a local-first MCP server that exposes ArcGIS Pro’s ArcPy engine over stdio JSON-RPC.&lt;/p&gt;

&lt;p&gt;It allows MCP-compatible clients to call a controlled set of ArcPy/geoprocessing tools without importing ArcPy directly into the MCP server process.&lt;/p&gt;

&lt;p&gt;The project currently includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;100 declarative geoprocessing tools&lt;/li&gt;
&lt;li&gt;10 GIS verticals&lt;/li&gt;
&lt;li&gt;a two-process architecture&lt;/li&gt;
&lt;li&gt;ArcPy worker-process isolation&lt;/li&gt;
&lt;li&gt;PathGuard filesystem boundaries&lt;/li&gt;
&lt;li&gt;confirmation gates for destructive operations&lt;/li&gt;
&lt;li&gt;mocked ArcPy tests for CI without an ArcGIS license&lt;/li&gt;
&lt;li&gt;optional Sketch-to-GIS / OpenCV pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not an official Esri project and not an official Anthropic project. It is an independent open-source bridge for ArcGIS Pro, ArcPy automation, and MCP-based GIS workflows.&lt;/p&gt;
&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;The project is split into two layers.&lt;/p&gt;
&lt;h3&gt;
  
  
  Layer A: MCP server
&lt;/h3&gt;

&lt;p&gt;Layer A is the MCP protocol host.&lt;/p&gt;

&lt;p&gt;It handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stdio JSON-RPC transport&lt;/li&gt;
&lt;li&gt;MCP tool registration&lt;/li&gt;
&lt;li&gt;Pydantic validation&lt;/li&gt;
&lt;li&gt;path validation before worker execution&lt;/li&gt;
&lt;li&gt;dispatching jobs to the worker process&lt;/li&gt;
&lt;li&gt;returning structured MCP tool results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Layer A does not import ArcPy.&lt;/p&gt;

&lt;p&gt;That is intentional. The MCP server should remain lightweight and should not depend on ArcGIS Pro’s native runtime being importable in the same process.&lt;/p&gt;
&lt;h3&gt;
  
  
  Layer B: ArcPy worker
&lt;/h3&gt;

&lt;p&gt;Layer B is a separate Python process running inside the licensed ArcGIS Pro Python environment.&lt;/p&gt;

&lt;p&gt;It handles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;importing ArcPy&lt;/li&gt;
&lt;li&gt;executing geoprocessing tools&lt;/li&gt;
&lt;li&gt;collecting ArcPy messages&lt;/li&gt;
&lt;li&gt;returning one structured JSON result frame&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This separation matters because ArcPy can be slow to import, can depend on license state, and can interact with native runtime components. Keeping it in a worker process protects the MCP server process from crashes and native runtime instability.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why two processes?
&lt;/h2&gt;

&lt;p&gt;The two-process model gives the project a clean failure boundary.&lt;/p&gt;

&lt;p&gt;If the ArcPy worker fails, times out, or crashes, the MCP server can return a structured error instead of dying with it.&lt;/p&gt;

&lt;p&gt;The basic flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MCP client
   ↓ stdio JSON-RPC
Layer A: MCP server
   ↓ NDJSON subprocess bridge
Layer B: ArcPy worker
   ↓
ArcGIS Pro / ArcPy runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is slower than keeping ArcPy warm in the same process, but it is much safer as a first production boundary.&lt;/p&gt;

&lt;p&gt;A future version could add a warm worker pool behind the same execution interface, but the isolation model should remain explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filesystem safety: PathGuard
&lt;/h2&gt;

&lt;p&gt;GIS workflows often touch sensitive local data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;file geodatabases&lt;/li&gt;
&lt;li&gt;enterprise connection files&lt;/li&gt;
&lt;li&gt;infrastructure datasets&lt;/li&gt;
&lt;li&gt;cadastral data&lt;/li&gt;
&lt;li&gt;client project folders&lt;/li&gt;
&lt;li&gt;personal or proprietary spatial datasets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of that, the bridge uses a PathGuard boundary.&lt;/p&gt;

&lt;p&gt;Each filesystem-touching tool declares whether a path is used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;read&lt;/li&gt;
&lt;li&gt;write&lt;/li&gt;
&lt;li&gt;read list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The server validates paths before spawning a worker, and the worker validates again before execution.&lt;/p&gt;

&lt;p&gt;The goal is not to make arbitrary AI file access convenient. The goal is to make the allowed local execution boundary narrow, explicit, and auditable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Destructive operation gates
&lt;/h2&gt;

&lt;p&gt;Some ArcPy operations mutate data.&lt;/p&gt;

&lt;p&gt;Examples include append, delete, repair geometry, calculate field, projection definition, and other state-changing workflows.&lt;/p&gt;

&lt;p&gt;For those operations, the project requires explicit confirmation in the tool input.&lt;/p&gt;

&lt;p&gt;The rule is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Destructive tools must require &lt;code&gt;confirm=true&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This gives both the MCP host and the user a clear point where mutation is intentional.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing without ArcGIS Pro in CI
&lt;/h2&gt;

&lt;p&gt;A major practical issue with ArcPy projects is CI.&lt;/p&gt;

&lt;p&gt;Hosted CI runners usually do not have ArcGIS Pro installed, and they do not have a licensed ArcPy runtime available.&lt;/p&gt;

&lt;p&gt;To keep the project testable, the automated test suite mocks ArcPy and focuses on the parts that can be verified without Esri runtime access:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pydantic contracts&lt;/li&gt;
&lt;li&gt;PathGuard behavior&lt;/li&gt;
&lt;li&gt;registry invariants&lt;/li&gt;
&lt;li&gt;destructive operation gates&lt;/li&gt;
&lt;li&gt;worker error mapping&lt;/li&gt;
&lt;li&gt;configuration validation&lt;/li&gt;
&lt;li&gt;import boundaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The current suite contains 81 unit tests and runs without ArcGIS Pro.&lt;/p&gt;

&lt;p&gt;Real geoprocessing execution still requires a licensed ArcGIS Pro environment on Windows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current tool surface
&lt;/h2&gt;

&lt;p&gt;The project currently exposes 100 tools across 10 GIS verticals:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;map and layer management&lt;/li&gt;
&lt;li&gt;data management&lt;/li&gt;
&lt;li&gt;geometry analysis&lt;/li&gt;
&lt;li&gt;coordinate reference and projection&lt;/li&gt;
&lt;li&gt;raster operations&lt;/li&gt;
&lt;li&gt;vision analytics&lt;/li&gt;
&lt;li&gt;export and layout&lt;/li&gt;
&lt;li&gt;editing and topology&lt;/li&gt;
&lt;li&gt;network analysis&lt;/li&gt;
&lt;li&gt;spatial statistics&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The optional vision component includes a Sketch-to-GIS pipeline using OpenCV. The idea is to extract hand-drawn boundaries from an image and commit them into a geodatabase workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;The package is available on PyPI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;arcgis-mcp-bridge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project also includes a setup command for preparing an ArcGIS Pro worker environment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;arcgis-mcp-setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For vision-related functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"arcgis-mcp-bridge[vision]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real ArcPy execution requires a licensed ArcGIS Pro Python environment. The server uses &lt;code&gt;ARCPY_PYTHON_PATH&lt;/code&gt; to locate the worker interpreter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example MCP use cases
&lt;/h2&gt;

&lt;p&gt;Potential workflows include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;list feature classes inside a file geodatabase&lt;/li&gt;
&lt;li&gt;buffer parcels and write outputs to a scratch geodatabase&lt;/li&gt;
&lt;li&gt;dissolve features by attribute&lt;/li&gt;
&lt;li&gt;run raster slope/aspect analysis&lt;/li&gt;
&lt;li&gt;export layouts&lt;/li&gt;
&lt;li&gt;inspect geometry errors&lt;/li&gt;
&lt;li&gt;run spatial statistics tools&lt;/li&gt;
&lt;li&gt;prepare repeatable GIS automation tasks from natural language requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The point is not to let an AI agent freely mutate GIS projects. The point is to expose a controlled, typed, auditable tool surface around common ArcPy workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/muend/arcgis-mcp-bridge" rel="noopener noreferrer"&gt;https://github.com/muend/arcgis-mcp-bridge&lt;/a&gt;&lt;br&gt;&lt;br&gt;
PyPI: &lt;a href="https://pypi.org/project/arcgis-mcp-bridge/" rel="noopener noreferrer"&gt;https://pypi.org/project/arcgis-mcp-bridge/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
MCP Registry: &lt;code&gt;io.github.muend/arcgis-mcp-bridge&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Esri Community discussion:&lt;br&gt;&lt;br&gt;
&lt;a href="https://community.esri.com/t5/python-questions/open-source-mcp-bridge-for-arcgis-pro-arcpy/m-p/1711533#M75310" rel="noopener noreferrer"&gt;https://community.esri.com/t5/python-questions/open-source-mcp-bridge-for-arcgis-pro-arcpy/m-p/1711533#M75310&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback wanted
&lt;/h2&gt;

&lt;p&gt;I am especially interested in feedback from GIS developers, ArcPy users, and people building MCP servers.&lt;/p&gt;

&lt;p&gt;The main questions are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does this architecture make sense for a local licensed runtime like ArcGIS Pro?&lt;/li&gt;
&lt;li&gt;Which ArcPy tools or workflows should be prioritized next?&lt;/li&gt;
&lt;li&gt;What safety boundaries would be required before using this with real project data?&lt;/li&gt;
&lt;li&gt;Which ArcGIS Pro versions should be tested first?&lt;/li&gt;
&lt;li&gt;Would a warm worker pool be worth the added complexity, or is spawn-per-call isolation the better default?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The project is open source, and feedback is welcome.&lt;/p&gt;

</description>
      <category>python</category>
      <category>gis</category>
      <category>opensource</category>
      <category>mcp</category>
    </item>
  </channel>
</rss>
