Safety-Critical G-Code Errors: Designing Evals for Crash-Prone Outputs
Safety-Critical G-Code Errors: Designing Evals for Crash-Prone Outputs
G-code generation is one of the hardest, highest-stakes tasks a language model can attempt. A misplaced rapid move, a missing tool-length compensation call, or a feed rate set in the wrong modal group does not produce a wrong answer on a leaderboard. It produces a machine crash, a broken spindle, or a scrapped part. Evaluating safety-critical G-code errors requires a different methodology than evaluating code or math: the failure modes are physical, the verifiers must be simulation-backed, and the tasks must be authored by practitioners who have stood at a machine and felt the consequences. This post describes how to design evals that surface crash-prone outputs reliably.
Answer Capsule: Designing evals for safety-critical G-code errors requires four components: a taxonomy of crash-prone error classes, expert-authored tasks that target each class, a simulation-backed or rule-based verifier that flags unsafe outputs before any physical execution, and a difficulty calibration protocol that confirms frontier models fail on the task. Aggregate pass rates are insufficient; per-error-class failure analysis is the signal that matters.
Why Standard Eval Methods Fail on G-Code Safety
Most LLM evaluation frameworks were designed for tasks where a wrong answer is recoverable: a bad SQL query returns an error, a buggy Python function raises an exception. G-code does not fail gracefully. A model that generates syntactically valid but semantically unsafe G-code will pass a lexical verifier and fail in metal.
Three properties make G-code evaluation structurally different from software evals:
Modal state dependency. G-code is stateful. Whether G91 (incremental) or G90 (absolute) positioning is active changes the meaning of every subsequent coordinate. A model that forgets modal state mid-program generates coordinates that are numerically plausible but geometrically catastrophic.
Machine-specific dialects. Fanuc, Heidenhain, Siemens 840D, and Haas controllers each interpret certain codes differently. A verifier that does not model the target controller will miss dialect-specific crash conditions.
Physical context is implicit. The model never sees the fixture, the clamp, the stock boundary, or the tool assembly. Safe toolpaths require reasoning about geometry that is described in the prompt but never fully specified.
These properties mean that surface-level correctness metrics, including exact-match comparison to a reference program, will systematically miss the most dangerous error classes. Evals built on reference matching will report high scores on programs that would crash a real machine.
For a broader treatment of why benchmark scores do not transfer to operational capability, see the Chiron Data Labs post on construct validity in LLM evals.
A Taxonomy of Safety-Critical G-Code Errors
Before writing a single eval task, build a crash-error taxonomy. Without one, task authors will over-represent common errors and under-represent the rare but high-consequence ones. The taxonomy below covers the primary crash-prone error classes in 3-axis and 3+2-axis milling; turning and multi-axis add further classes.
Error Class | Mechanism | Verifier Type | Model Failure Pattern |
|---|---|---|---|
Rapid-move collision | G0 move through stock or fixture at full speed | Toolpath simulator (e.g., Vericut-class) | Omits retract to safe Z before repositioning |
Modal state corruption | G90/G91 or G94/G95 left in wrong state | State-machine parser | Fails to reset modal group after a subroutine |
Missing tool-length compensation | G43/G44 not called, or called with wrong H offset | Rule-based checker | Generates G43 without H word, or omits entirely |
Feed rate in wrong modal group | F word interpreted as mm/rev instead of mm/min | Controller-dialect parser | Copies feed rate from a turning context into a milling context |
Work offset not set | G54-G59 not called before first cut move | Rule-based checker | Assumes G54 is active without calling it |
Cutter compensation error | G41/G42 entered or exited incorrectly | Geometric verifier | Activates cutter comp on a non-linear move, or forgets G40 cancel |
Spindle not started before cut | M03/M04 missing or placed after first cut move | Rule-based checker | Places M03 after the first G1 move |
Each error class requires a distinct verifier. A single pass/fail score across all classes obscures which failure modes a model has and which it has resolved. Per-class failure rates are the diagnostic signal.
How to Author Tasks That Target Crash-Prone Outputs
Task authoring for G-code safety evals is not prompt engineering. It is manufacturing knowledge encoded as a test case. Each task must specify enough context that a competent machinist could write a correct program, while leaving the exact error class available for the model to trigger.
A well-formed G-code eval task contains five elements:
Operation specification. Part geometry description (can be verbal or a 2D sketch reference), material, machine type, and controller dialect. Ambiguity here is a task defect, not a feature.
Tool and offset table. Tool number, diameter, length offset number, and cutting data. The model must use these values correctly; any invented offset number is a verifiable error.
Fixture and stock description. Clamp positions and stock boundaries described explicitly. This is the context that makes rapid-move collision tasks tractable.
Target error class. Recorded by the task author, not shown to the model. This label drives per-class analysis downstream.
Gold program and verifier output. A reference program authored by the expert, plus the expected verifier state (pass, and the specific checks that should pass). The gold program is not used for exact-match scoring; it is used to validate the verifier.
Task authors should be practicing CNC programmers or CAM instructors, not generalist annotators. The failure modes that matter most, particularly modal state corruption and dialect-specific feed rate errors, are invisible to anyone who has not programmed a real controller. For more on how expert authoring differs from generalist labeling, see the Chiron Data Labs post on designing tasks robust to shortcut solutions.
Verifier Design for G-Code Safety Evals
A verifier for G-code safety evals must catch errors that a human reviewer would catch on inspection, without requiring a human reviewer for every sample. Three verifier tiers serve different error classes:
Tier 1: Rule-Based Static Checkers
Parse the G-code token stream and check for mandatory structural patterns: work offset called before first cut move, spindle started before first cut move, tool-length compensation active during cutting, G40 called at program end. These checks are deterministic, fast, and cover the error classes that have a fixed structural signature. They produce no false negatives for the classes they cover, but they cannot detect geometric collisions.
Tier 2: State-Machine Modal Parser
Simulate the modal state register as a controller would: track the active G-code in each modal group (motion, plane selection, distance mode, feed rate mode, cutter compensation) line by line. Flag any line where the modal state produces an operationally dangerous combination, such as a G0 move with cutter compensation active, or an incremental move immediately after a subroutine that left the distance mode undefined.
Tier 3: Toolpath Simulation
For rapid-move collision and stock-boundary violation tasks, a geometric toolpath simulator is required. Open-source options exist (such as the OpenCAMLib project), though production evals benefit from higher-fidelity simulation. The simulator receives the G-code, the stock boundary, and the fixture geometry, and returns a collision flag with the line number and move type. This tier is expensive per sample and should be reserved for tasks where geometric collision is the target error class.
Verifier bugs are a first-class failure mode. A verifier that passes unsafe programs, or rejects safe ones, corrupts the entire eval dataset. Every verifier should be validated against a set of known-safe and known-unsafe gold programs before it is used to score model outputs. For more on verifier reliability and its downstream effects, see the discussion of eval headroom and pass@k methodology.
Worked Example: A Rapid-Move Collision Task
Illustrative example. Numbers and geometry are constructed to demonstrate the method; they do not represent a specific machine or a real model evaluation result.
Task prompt (paraphrased): Write a Fanuc-dialect G-code program to drill four holes in a 100mm x 100mm aluminium plate. Holes are at X25Y25, X75Y25, X25Y75, X75Y75. Use T1 (10mm drill, H1 offset). Clamp is positioned at X90Y50, protruding 30mm above the table. Safe retract height is Z50. Cutting depth is Z-15 (absolute). Work offset G54 is active at program start.
Crash-prone output (model-generated, illustrative):
G90 G94 G17 G43 H1 M03 S2000 G54 G0 X25 Y25 G1 Z-15 F200 G0 X75 Y25 G1 Z-15 F200 G0 X25 Y75 G1 Z-15 F200 G0 X75 Y75 G1 Z-15 F200 M05 M30
Error identified by verifier: The model issues G0 moves between holes without retracting to Z50 first. The rapid move from X75Y25 to X25Y75 passes through X90Y50 at whatever Z height the previous G1 move ended (Z-15), directly into the clamp. The state-machine parser flags this: no Z retract between hole cycles. The toolpath simulator confirms a collision at approximately X90Y50 Z-15.
Correct structure: Each hole cycle should retract to Z50 before the repositioning G0 move. A canned cycle (G81) with R-plane set above the clamp height would also resolve the collision, and a competent machinist would use it. The model's failure to use a canned cycle, or to insert explicit retracts, is the target behavior this task is designed to surface.
Pass@k note: If this task is run with k=16 samples, and the model generates a safe program in 3 of 16 attempts, pass@16 is approximately 0.19. That is not a passing score for a safety-critical application. The per-class failure rate (rapid-move collision: 13/16) is the number that matters to a post-training team.
Common Failure Modes in G-Code Eval Design
1. Verifier covers only syntax, not semantics. Detection: the verifier passes programs that a machinist would immediately flag. Fix: add a state-machine modal parser and validate the verifier against known-unsafe gold programs before using it in production.
2. Tasks are too underspecified to have a correct answer. Detection: two expert authors produce programs with different safe structures, and both pass the verifier. Fix: add fixture geometry and clamp positions explicitly. Ambiguity in the task is a task defect.
3. Error class distribution is skewed toward easy errors. Detection: the model achieves high pass rates on the eval but a domain expert reviewing outputs still finds crash-prone patterns. Fix: build the taxonomy first, then sample tasks proportionally across error classes, weighting toward high-consequence classes.
4. Gold programs are used for exact-match scoring. Detection: tasks with multiple valid safe programs show low pass rates even when the model output is safe. Fix: use the verifier as the primary scoring mechanism. The gold program validates the verifier, not the model.
5. Eval saturates faster than expected. Detection: pass rates rise sharply after a single model update, suggesting the tasks were too easy or too similar to training distribution. Fix: calibrate difficulty empirically using pass@k against current frontier models before releasing the eval. See the Chiron Data Labs analysis of benchmark saturation timelines for base rates.
6. Controller dialect is not specified. Detection: the model generates valid Fanuc syntax that would crash on a Siemens 840D controller. Fix: specify the target controller dialect in the task prompt and in the verifier configuration. Dialect-agnostic evals produce dialect-ambiguous results.
Where This Approach Breaks Down
Simulation-backed verifiers for G-code safety evals are powerful but not complete. They model the cutting tool and the stock; they do not model coolant flow, chip evacuation, thermal effects, or operator error. A program that passes all three verifier tiers can still cause a machine crash in conditions the simulator did not represent.
Evals also cannot substitute for process validation on a real machine. The appropriate use of a G-code eval is to measure model capability and failure rates during development, not to certify that a model's output is safe to run without review. Any deployment of LLM-generated G-code in a production environment requires human expert review and dry-run verification, regardless of eval scores.
Finally, difficulty calibration is model-specific and date-specific. A task that is hard for current frontier models may become easy after the next training run. Evals require ongoing re-calibration. The methodology for maintaining headroom is covered in the Chiron Data Labs post on re-baselining saturated evals.
Frequently Asked Questions
What is the minimum number of tasks needed for a G-code safety eval?
There is no universal minimum, but a useful heuristic is at least 10 tasks per error class in the taxonomy. With seven error classes in the table above, that is a minimum of 70 tasks. Statistical power depends on the expected pass rate per class; for rare failure modes where the expected model pass rate is above 80%, more tasks are needed to detect meaningful differences between model versions.
Can synthetic G-code tasks replace expert-authored ones?
Synthetic tasks can cover structural patterns, such as missing M03, but they consistently fail to reproduce the contextual complexity that makes crash-prone errors hard to avoid: realistic fixture geometry, multi-tool programs with offset tables, and dialect-specific edge cases. Expert-authored tasks capture the scenarios that practitioners have actually encountered on machines. Synthetic tasks are useful for augmenting coverage of well-defined error classes, not for replacing the expert-authored core.
How should pass@k be interpreted for safety-critical tasks?
Pass@k estimates the probability that at least one of k independent model samples is correct. For safety-critical G-code, the inverse metric is more informative: the probability that at least one of k samples contains a crash-prone error. If a model produces one unsafe program in 16 samples, a post-training team needs to know that, not just the aggregate pass rate. Report both pass@k and the per-error-class failure rate across all k samples.
Should LLM-as-judge be used for G-code safety evals?
LLM-as-judge is not appropriate as the primary verifier for safety-critical G-code errors. A language model judging another language model's G-code will share the same modal-state blind spots and dialect gaps. Use deterministic verifiers (rule-based, state-machine, simulation) as the primary signal. LLM-as-judge may be useful for scoring secondary dimensions such as program readability or comment quality, where the failure mode is not physical.
How do you prevent eval contamination in G-code tasks?
Expert-authored tasks with specific fixture geometries, named offset tables, and non-standard part configurations are structurally resistant to contamination: they cannot be reconstructed from web-scraped G-code examples because the context is original. Contamination risk rises when tasks use generic geometries (drilling a square pattern of holes) that appear in public CAM tutorials. Task authors should be instructed to use non-canonical geometries and to document the source of each task. For a broader treatment of contamination controls, see the Chiron Data Labs post on private held-out eval governance.
What This Means in Practice
Safety-critical G-code errors are not an edge case in LLM evaluation. They are the central challenge for any team building or evaluating models intended for manufacturing applications. The methodology is clear: build a crash-error taxonomy, author tasks with expert practitioners, deploy tiered verifiers that match the error class, calibrate difficulty empirically, and report per-class failure rates rather than aggregate scores. Aggregate pass rates hide the failure modes that matter most.
The eval design described here is hard to build correctly. It requires CNC practitioners who understand both the machining domain and the task authoring process, verifiers that model controller behavior accurately, and ongoing re-calibration as frontier models improve. Shortcuts at any stage produce evals that overestimate model safety.
Chiron Data Labs authors expert-authored tasks and evals for domains where model failure has physical or operational consequences, including CNC and CAM programming. If you are building evals or post-training data pipelines in this domain, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
G-code generation is one of the hardest, highest-stakes tasks a language model can attempt. A misplaced rapid move, a missing tool-length compensation call, or a feed rate set in the wrong modal group does not produce a wrong answer on a leaderboard. It produces a machine crash, a broken spindle, or a scrapped part. Evaluating safety-critical G-code errors requires a different methodology than evaluating code or math: the failure modes are physical, the verifiers must be simulation-backed, and the tasks must be authored by practitioners who have stood at a machine and felt the consequences. This post describes how to design evals that surface crash-prone outputs reliably.
Answer Capsule: Designing evals for safety-critical G-code errors requires four components: a taxonomy of crash-prone error classes, expert-authored tasks that target each class, a simulation-backed or rule-based verifier that flags unsafe outputs before any physical execution, and a difficulty calibration protocol that confirms frontier models fail on the task. Aggregate pass rates are insufficient; per-error-class failure analysis is the signal that matters.
Why Standard Eval Methods Fail on G-Code Safety
Most LLM evaluation frameworks were designed for tasks where a wrong answer is recoverable: a bad SQL query returns an error, a buggy Python function raises an exception. G-code does not fail gracefully. A model that generates syntactically valid but semantically unsafe G-code will pass a lexical verifier and fail in metal.
Three properties make G-code evaluation structurally different from software evals:
Modal state dependency. G-code is stateful. Whether G91 (incremental) or G90 (absolute) positioning is active changes the meaning of every subsequent coordinate. A model that forgets modal state mid-program generates coordinates that are numerically plausible but geometrically catastrophic.
Machine-specific dialects. Fanuc, Heidenhain, Siemens 840D, and Haas controllers each interpret certain codes differently. A verifier that does not model the target controller will miss dialect-specific crash conditions.
Physical context is implicit. The model never sees the fixture, the clamp, the stock boundary, or the tool assembly. Safe toolpaths require reasoning about geometry that is described in the prompt but never fully specified.
These properties mean that surface-level correctness metrics, including exact-match comparison to a reference program, will systematically miss the most dangerous error classes. Evals built on reference matching will report high scores on programs that would crash a real machine.
For a broader treatment of why benchmark scores do not transfer to operational capability, see the Chiron Data Labs post on construct validity in LLM evals.
A Taxonomy of Safety-Critical G-Code Errors
Before writing a single eval task, build a crash-error taxonomy. Without one, task authors will over-represent common errors and under-represent the rare but high-consequence ones. The taxonomy below covers the primary crash-prone error classes in 3-axis and 3+2-axis milling; turning and multi-axis add further classes.
Error Class | Mechanism | Verifier Type | Model Failure Pattern |
|---|---|---|---|
Rapid-move collision | G0 move through stock or fixture at full speed | Toolpath simulator (e.g., Vericut-class) | Omits retract to safe Z before repositioning |
Modal state corruption | G90/G91 or G94/G95 left in wrong state | State-machine parser | Fails to reset modal group after a subroutine |
Missing tool-length compensation | G43/G44 not called, or called with wrong H offset | Rule-based checker | Generates G43 without H word, or omits entirely |
Feed rate in wrong modal group | F word interpreted as mm/rev instead of mm/min | Controller-dialect parser | Copies feed rate from a turning context into a milling context |
Work offset not set | G54-G59 not called before first cut move | Rule-based checker | Assumes G54 is active without calling it |
Cutter compensation error | G41/G42 entered or exited incorrectly | Geometric verifier | Activates cutter comp on a non-linear move, or forgets G40 cancel |
Spindle not started before cut | M03/M04 missing or placed after first cut move | Rule-based checker | Places M03 after the first G1 move |
Each error class requires a distinct verifier. A single pass/fail score across all classes obscures which failure modes a model has and which it has resolved. Per-class failure rates are the diagnostic signal.
How to Author Tasks That Target Crash-Prone Outputs
Task authoring for G-code safety evals is not prompt engineering. It is manufacturing knowledge encoded as a test case. Each task must specify enough context that a competent machinist could write a correct program, while leaving the exact error class available for the model to trigger.
A well-formed G-code eval task contains five elements:
Operation specification. Part geometry description (can be verbal or a 2D sketch reference), material, machine type, and controller dialect. Ambiguity here is a task defect, not a feature.
Tool and offset table. Tool number, diameter, length offset number, and cutting data. The model must use these values correctly; any invented offset number is a verifiable error.
Fixture and stock description. Clamp positions and stock boundaries described explicitly. This is the context that makes rapid-move collision tasks tractable.
Target error class. Recorded by the task author, not shown to the model. This label drives per-class analysis downstream.
Gold program and verifier output. A reference program authored by the expert, plus the expected verifier state (pass, and the specific checks that should pass). The gold program is not used for exact-match scoring; it is used to validate the verifier.
Task authors should be practicing CNC programmers or CAM instructors, not generalist annotators. The failure modes that matter most, particularly modal state corruption and dialect-specific feed rate errors, are invisible to anyone who has not programmed a real controller. For more on how expert authoring differs from generalist labeling, see the Chiron Data Labs post on designing tasks robust to shortcut solutions.
Verifier Design for G-Code Safety Evals
A verifier for G-code safety evals must catch errors that a human reviewer would catch on inspection, without requiring a human reviewer for every sample. Three verifier tiers serve different error classes:
Tier 1: Rule-Based Static Checkers
Parse the G-code token stream and check for mandatory structural patterns: work offset called before first cut move, spindle started before first cut move, tool-length compensation active during cutting, G40 called at program end. These checks are deterministic, fast, and cover the error classes that have a fixed structural signature. They produce no false negatives for the classes they cover, but they cannot detect geometric collisions.
Tier 2: State-Machine Modal Parser
Simulate the modal state register as a controller would: track the active G-code in each modal group (motion, plane selection, distance mode, feed rate mode, cutter compensation) line by line. Flag any line where the modal state produces an operationally dangerous combination, such as a G0 move with cutter compensation active, or an incremental move immediately after a subroutine that left the distance mode undefined.
Tier 3: Toolpath Simulation
For rapid-move collision and stock-boundary violation tasks, a geometric toolpath simulator is required. Open-source options exist (such as the OpenCAMLib project), though production evals benefit from higher-fidelity simulation. The simulator receives the G-code, the stock boundary, and the fixture geometry, and returns a collision flag with the line number and move type. This tier is expensive per sample and should be reserved for tasks where geometric collision is the target error class.
Verifier bugs are a first-class failure mode. A verifier that passes unsafe programs, or rejects safe ones, corrupts the entire eval dataset. Every verifier should be validated against a set of known-safe and known-unsafe gold programs before it is used to score model outputs. For more on verifier reliability and its downstream effects, see the discussion of eval headroom and pass@k methodology.
Worked Example: A Rapid-Move Collision Task
Illustrative example. Numbers and geometry are constructed to demonstrate the method; they do not represent a specific machine or a real model evaluation result.
Task prompt (paraphrased): Write a Fanuc-dialect G-code program to drill four holes in a 100mm x 100mm aluminium plate. Holes are at X25Y25, X75Y25, X25Y75, X75Y75. Use T1 (10mm drill, H1 offset). Clamp is positioned at X90Y50, protruding 30mm above the table. Safe retract height is Z50. Cutting depth is Z-15 (absolute). Work offset G54 is active at program start.
Crash-prone output (model-generated, illustrative):
G90 G94 G17 G43 H1 M03 S2000 G54 G0 X25 Y25 G1 Z-15 F200 G0 X75 Y25 G1 Z-15 F200 G0 X25 Y75 G1 Z-15 F200 G0 X75 Y75 G1 Z-15 F200 M05 M30
Error identified by verifier: The model issues G0 moves between holes without retracting to Z50 first. The rapid move from X75Y25 to X25Y75 passes through X90Y50 at whatever Z height the previous G1 move ended (Z-15), directly into the clamp. The state-machine parser flags this: no Z retract between hole cycles. The toolpath simulator confirms a collision at approximately X90Y50 Z-15.
Correct structure: Each hole cycle should retract to Z50 before the repositioning G0 move. A canned cycle (G81) with R-plane set above the clamp height would also resolve the collision, and a competent machinist would use it. The model's failure to use a canned cycle, or to insert explicit retracts, is the target behavior this task is designed to surface.
Pass@k note: If this task is run with k=16 samples, and the model generates a safe program in 3 of 16 attempts, pass@16 is approximately 0.19. That is not a passing score for a safety-critical application. The per-class failure rate (rapid-move collision: 13/16) is the number that matters to a post-training team.
Common Failure Modes in G-Code Eval Design
1. Verifier covers only syntax, not semantics. Detection: the verifier passes programs that a machinist would immediately flag. Fix: add a state-machine modal parser and validate the verifier against known-unsafe gold programs before using it in production.
2. Tasks are too underspecified to have a correct answer. Detection: two expert authors produce programs with different safe structures, and both pass the verifier. Fix: add fixture geometry and clamp positions explicitly. Ambiguity in the task is a task defect.
3. Error class distribution is skewed toward easy errors. Detection: the model achieves high pass rates on the eval but a domain expert reviewing outputs still finds crash-prone patterns. Fix: build the taxonomy first, then sample tasks proportionally across error classes, weighting toward high-consequence classes.
4. Gold programs are used for exact-match scoring. Detection: tasks with multiple valid safe programs show low pass rates even when the model output is safe. Fix: use the verifier as the primary scoring mechanism. The gold program validates the verifier, not the model.
5. Eval saturates faster than expected. Detection: pass rates rise sharply after a single model update, suggesting the tasks were too easy or too similar to training distribution. Fix: calibrate difficulty empirically using pass@k against current frontier models before releasing the eval. See the Chiron Data Labs analysis of benchmark saturation timelines for base rates.
6. Controller dialect is not specified. Detection: the model generates valid Fanuc syntax that would crash on a Siemens 840D controller. Fix: specify the target controller dialect in the task prompt and in the verifier configuration. Dialect-agnostic evals produce dialect-ambiguous results.
Where This Approach Breaks Down
Simulation-backed verifiers for G-code safety evals are powerful but not complete. They model the cutting tool and the stock; they do not model coolant flow, chip evacuation, thermal effects, or operator error. A program that passes all three verifier tiers can still cause a machine crash in conditions the simulator did not represent.
Evals also cannot substitute for process validation on a real machine. The appropriate use of a G-code eval is to measure model capability and failure rates during development, not to certify that a model's output is safe to run without review. Any deployment of LLM-generated G-code in a production environment requires human expert review and dry-run verification, regardless of eval scores.
Finally, difficulty calibration is model-specific and date-specific. A task that is hard for current frontier models may become easy after the next training run. Evals require ongoing re-calibration. The methodology for maintaining headroom is covered in the Chiron Data Labs post on re-baselining saturated evals.
Frequently Asked Questions
What is the minimum number of tasks needed for a G-code safety eval?
There is no universal minimum, but a useful heuristic is at least 10 tasks per error class in the taxonomy. With seven error classes in the table above, that is a minimum of 70 tasks. Statistical power depends on the expected pass rate per class; for rare failure modes where the expected model pass rate is above 80%, more tasks are needed to detect meaningful differences between model versions.
Can synthetic G-code tasks replace expert-authored ones?
Synthetic tasks can cover structural patterns, such as missing M03, but they consistently fail to reproduce the contextual complexity that makes crash-prone errors hard to avoid: realistic fixture geometry, multi-tool programs with offset tables, and dialect-specific edge cases. Expert-authored tasks capture the scenarios that practitioners have actually encountered on machines. Synthetic tasks are useful for augmenting coverage of well-defined error classes, not for replacing the expert-authored core.
How should pass@k be interpreted for safety-critical tasks?
Pass@k estimates the probability that at least one of k independent model samples is correct. For safety-critical G-code, the inverse metric is more informative: the probability that at least one of k samples contains a crash-prone error. If a model produces one unsafe program in 16 samples, a post-training team needs to know that, not just the aggregate pass rate. Report both pass@k and the per-error-class failure rate across all k samples.
Should LLM-as-judge be used for G-code safety evals?
LLM-as-judge is not appropriate as the primary verifier for safety-critical G-code errors. A language model judging another language model's G-code will share the same modal-state blind spots and dialect gaps. Use deterministic verifiers (rule-based, state-machine, simulation) as the primary signal. LLM-as-judge may be useful for scoring secondary dimensions such as program readability or comment quality, where the failure mode is not physical.
How do you prevent eval contamination in G-code tasks?
Expert-authored tasks with specific fixture geometries, named offset tables, and non-standard part configurations are structurally resistant to contamination: they cannot be reconstructed from web-scraped G-code examples because the context is original. Contamination risk rises when tasks use generic geometries (drilling a square pattern of holes) that appear in public CAM tutorials. Task authors should be instructed to use non-canonical geometries and to document the source of each task. For a broader treatment of contamination controls, see the Chiron Data Labs post on private held-out eval governance.
What This Means in Practice
Safety-critical G-code errors are not an edge case in LLM evaluation. They are the central challenge for any team building or evaluating models intended for manufacturing applications. The methodology is clear: build a crash-error taxonomy, author tasks with expert practitioners, deploy tiered verifiers that match the error class, calibrate difficulty empirically, and report per-class failure rates rather than aggregate scores. Aggregate pass rates hide the failure modes that matter most.
The eval design described here is hard to build correctly. It requires CNC practitioners who understand both the machining domain and the task authoring process, verifiers that model controller behavior accurately, and ongoing re-calibration as frontier models improve. Shortcuts at any stage produce evals that overestimate model safety.
Chiron Data Labs authors expert-authored tasks and evals for domains where model failure has physical or operational consequences, including CNC and CAM programming. If you are building evals or post-training data pipelines in this domain, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.