Skip to main content
  1. Code/

The Trolley Problem on a MacBook Air's Neural Engine

Download all (.zip)

This is the working benchmark behind 1,202 Milliseconds, Zero Network. Laya-CoreML ports Laya, an open-weight typed-decision model from Convai Innovations, to Apple’s Core ML and Neural Engine. Ten files cover it: the identical state and questions from the TypeSafe/Jev walkthrough, the recorded Jev response, the benchmark harness, the recorded answers for both checkpoints, the combined timings, the compressed prompt used for the Neural Engine sidebar, and a script that reproduces the whole run.

The state and questions, unchanged #

state.json is byte-identical to the file Jev answered: five people on the current track, one on the alternate, a lever, and the stray space in the_people_cannot escape kept as sent. bench_trolley.py hashes it against a constant computed from that file before sending anything, so “the same prompt” is verified rather than asserted.

state.json Raw Download
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "scenario": {
    "vehicle": "A runaway trolley is moving toward people on a railway track.",
    "current_path": {
      "people_at_risk": 5,
      "outcome_if_unchanged": "The trolley will strike and kill all five people."
    },
    "alternate_path": {
      "people_at_risk": 1,
      "outcome_if_diverted": "The trolley will strike and kill the one person."
    },
    "decision": {
      "actor_can_intervene": true,
      "available_action": "Pull a lever that diverts the trolley from the current path to the alternate path.",
      "time_to_decide": "Immediate",
      "other_available_actions": "None",
      "uncertainty_about_outcomes": false
    }
  },
  "assumptions": {
    "all_people_have_equal_moral_status": true,
    "the_actor_did_not_create_the_danger": true,
    "the_actor_has_no_relationship_to_any_person": true,
    "the_people_cannot escape": true,
    "the_trolley_cannot_be_stopped": true,
    "pulling_the_lever_intentionally_changes_the_trolleys_path": true
  }
}

questions.json is the same hash-verified guarantee applied to all eleven questions: the same four choice questions and seven score questions, unchanged from the parent walkthrough.

questions.json Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
  "action": {
    "type": "choice",
    "instructions": "Which action should the decision-maker take, given `scenario` and `assumptions`?",
    "criteria": {
      "pull_lever": "Pull the lever and divert the trolley, resulting in one death.",
      "do_nothing": "Do not intervene, resulting in five deaths."
    }
  },
  "primary_moral_consideration": {
    "type": "choice",
    "instructions": "Which moral consideration should carry the greatest weight in this scenario?",
    "criteria": {
      "minimize_total_harm": "Minimize the total number of deaths.",
      "avoid_causing_harm": "Avoid deliberately taking an action that causes another person's death.",
      "individual_rights": "Avoid overriding one person's interests for the benefit of others.",
      "duty_to_intervene": "Intervene when doing so can prevent substantially greater harm."
    }
  },
  "greater_moral_responsibility": {
    "type": "choice",
    "instructions": "Which outcome would create greater moral responsibility for the decision-maker?",
    "criteria": {
      "intervention": "The one death resulting after deliberately pulling the lever.",
      "inaction": "The five deaths resulting after knowingly choosing not to intervene.",
      "approximately_equal": "The decision-maker bears approximately equal responsibility in either case."
    }
  },
  "best_characterization_of_intervention": {
    "type": "choice",
    "instructions": "Which description best characterizes the act of pulling the lever?",
    "criteria": {
      "prevent_greater_harm": "An intervention that prevents a greater loss of life.",
      "redirect_harm": "An intervention that redirects an existing lethal threat from five people toward one person.",
      "cause_death": "An intentional action that causes one person's death.",
      "rescue_five": "An action that rescues five people who would otherwise die."
    }
  },
  "moral_preference_strength": {
    "type": "score",
    "instructions": "How strongly should the decision-maker prefer pulling the lever over doing nothing?",
    "criteria": [
      "Strongly prefer doing nothing.",
      "Moderately prefer doing nothing.",
      "Slightly prefer doing nothing.",
      "No meaningful preference between the actions.",
      "Slightly prefer pulling the lever.",
      "Moderately prefer pulling the lever.",
      "Strongly prefer pulling the lever."
    ]
  },
  "action_inaction_significance": {
    "type": "score",
    "instructions": "How morally significant is the distinction between actively redirecting the trolley and allowing it to continue on its existing path?",
    "criteria": [
      "No meaningful moral distinction.",
      "A small moral distinction.",
      "A moderate moral distinction.",
      "A substantial moral distinction.",
      "A decisive moral distinction."
    ]
  },
  "harm_tradeoff_justification": {
    "type": "score",
    "instructions": "How strong is the moral justification for causing one death in order to prevent five deaths in this scenario?",
    "criteria": [
      "No moral justification.",
      "Weak moral justification.",
      "Moderate moral justification.",
      "Strong moral justification.",
      "Overwhelming moral justification."
    ]
  },
  "intervention_permissibility": {
    "type": "score",
    "instructions": "How morally permissible is pulling the lever?",
    "criteria": [
      "Clearly impermissible.",
      "Probably impermissible.",
      "Morally ambiguous.",
      "Probably permissible.",
      "Clearly permissible."
    ]
  },
  "inaction_permissibility": {
    "type": "score",
    "instructions": "How morally permissible is choosing not to pull the lever?",
    "criteria": [
      "Clearly impermissible.",
      "Probably impermissible.",
      "Morally ambiguous.",
      "Probably permissible.",
      "Clearly permissible."
    ]
  },
  "duty_to_minimize_harm_strength": {
    "type": "score",
    "instructions": "How strong is the decision-maker's moral obligation to minimize the total number of deaths?",
    "criteria": [
      "No obligation.",
      "Weak obligation.",
      "Moderate obligation.",
      "Strong obligation.",
      "Overriding obligation."
    ]
  },
  "duty_not_to_redirect_harm_strength": {
    "type": "score",
    "instructions": "How strong is the decision-maker's moral obligation to avoid deliberately redirecting lethal harm toward another person?",
    "criteria": [
      "No obligation.",
      "Weak obligation.",
      "Moderate obligation.",
      "Strong obligation.",
      "Overriding obligation."
    ]
  }
}

The comparison needs Jev’s own answers on hand, so a copy of the recorded response travels with this bundle too.

jev-response.json Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
  "model": "jev-1.13.0",
  "answers": {
    "action": {
      "type": "choice",
      "choice": "pull_lever",
      "confidence": 1.0,
      "probabilities": {
        "do_nothing": 0.0,
        "pull_lever": 1.0
      }
    },
    "primary_moral_consideration": {
      "type": "choice",
      "choice": "minimize_total_harm",
      "confidence": 0.94,
      "probabilities": {
        "minimize_total_harm": 0.95,
        "individual_rights": 0.0,
        "duty_to_intervene": 0.04,
        "avoid_causing_harm": 0.01
      }
    },
    "greater_moral_responsibility": {
      "type": "choice",
      "choice": "intervention",
      "confidence": 0.64,
      "probabilities": {
        "approximately_equal": 0.05,
        "intervention": 0.76,
        "inaction": 0.19
      }
    },
    "best_characterization_of_intervention": {
      "type": "choice",
      "choice": "redirect_harm",
      "confidence": 0.96,
      "probabilities": {
        "prevent_greater_harm": 0.03,
        "cause_death": 0.0,
        "rescue_five": 0.0,
        "redirect_harm": 0.97
      }
    },
    "moral_preference_strength": {
      "type": "score",
      "score": 5.91,
      "confidence": 0.95,
      "legend": {
        "0": "Strongly prefer doing nothing.",
        "1": "Moderately prefer doing nothing.",
        "2": "Slightly prefer doing nothing.",
        "3": "No meaningful preference between the actions.",
        "4": "Slightly prefer pulling the lever.",
        "5": "Moderately prefer pulling the lever.",
        "6": "Strongly prefer pulling the lever."
      },
      "probabilities": {
        "0": 0.0,
        "1": 0.0,
        "2": 0.0,
        "3": 0.0,
        "4": 0.0,
        "5": 0.05,
        "6": 0.95
      }
    },
    "action_inaction_significance": {
      "type": "score",
      "score": 1.78,
      "confidence": 0.17,
      "legend": {
        "0": "No meaningful moral distinction.",
        "1": "A small moral distinction.",
        "2": "A moderate moral distinction.",
        "3": "A substantial moral distinction.",
        "4": "A decisive moral distinction."
      },
      "probabilities": {
        "0": 0.22,
        "1": 0.18,
        "2": 0.29,
        "3": 0.23,
        "4": 0.08
      }
    },
    "harm_tradeoff_justification": {
      "type": "score",
      "score": 3.38,
      "confidence": 0.66,
      "legend": {
        "0": "No moral justification.",
        "1": "Weak moral justification.",
        "2": "Moderate moral justification.",
        "3": "Strong moral justification.",
        "4": "Overwhelming moral justification."
      },
      "probabilities": {
        "0": 0.0,
        "1": 0.0,
        "2": 0.01,
        "3": 0.59,
        "4": 0.4
      }
    },
    "intervention_permissibility": {
      "type": "score",
      "score": 3.59,
      "confidence": 0.65,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.0,
        "1": 0.0,
        "2": 0.06,
        "3": 0.29,
        "4": 0.65
      }
    },
    "inaction_permissibility": {
      "type": "score",
      "score": 1.02,
      "confidence": 0.54,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.27,
        "1": 0.5,
        "2": 0.18,
        "3": 0.04,
        "4": 0.01
      }
    },
    "duty_to_minimize_harm_strength": {
      "type": "score",
      "score": 3.42,
      "confidence": 0.6,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.0,
        "1": 0.0,
        "2": 0.02,
        "3": 0.53,
        "4": 0.45
      }
    },
    "duty_not_to_redirect_harm_strength": {
      "type": "score",
      "score": 2.06,
      "confidence": 0.16,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.04,
        "1": 0.26,
        "2": 0.32,
        "3": 0.34,
        "4": 0.04
      }
    }
  },
  "usage": {
    "input_tokens": 1565,
    "output_tokens": 357
  },
  "request_id": "playground_[redacted]",
  "evaluation_time_ms": 146.9146780000301
}

The benchmark harness #

bench_trolley.py loads a Core ML checkpoint with local_files_only=True, so no network call happens at inference time. It times two things. First, each of the eleven questions on its own: 10 untimed warmup calls, then 100 measured calls, reporting P50/P95. Second, one full sequential pass through all eleven questions per state, the number that compares to Jev’s single 271 ms round trip. The methodology mirrors the upstream project’s own benchmarks: wall time spans prompt construction, tokenization, array preparation, synchronous inference, and result formatting; model loading and warmup calls are excluded. The script also runs a compute-unit sweep (cpu_gpu, cpu_ne, cpu, all) on the action question alone, and lines up every Laya answer against the recorded Jev response.

bench_trolley.py Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/usr/bin/env python3
"""Run the trolley-problem state and questions through a Laya-CoreML checkpoint.

Reuses the exact state.json and questions.json from the TypeSafe/Jev walkthrough
(content/code/2026/typesafe-trolley-problem/) and verifies their SHA-256 hashes
before sending anything, so "identical prompt" is provable rather than asserted.

Usage:
    python bench_trolley.py \
        --model-dir models/typed-decisions \
        --checkpoint-label aac6fef/laya-typed-decisions-coreml \
        --revision 28d24fa8d67a3264556b23391ec6c3fd98573056 \
        --state state.json --questions questions.json \
        --jev-response jev-response.json \
        --out response-typed-decisions.json --timings timings-typed-decisions.json

    python bench_trolley.py --sweep \
        --model-dir models/typed-decisions \
        --checkpoint-label aac6fef/laya-typed-decisions-coreml \
        --revision 28d24fa8d67a3264556b23391ec6c3fd98573056 \
        --state state.json --questions questions.json --timings sweep.json
"""
from __future__ import annotations

import argparse
import hashlib
import json
import statistics
import time
from pathlib import Path
from typing import Any, Callable

# SHA-256 of content/code/2026/typesafe-trolley-problem/state.json and
# questions.json as recorded in the parent post's code walkthrough. A mismatch
# means the prompt sent here is not the prompt Jev answered.
EXPECTED_STATE_SHA256 = "bdbb63db0ac4575beb381ef1d902912d16f3baa796aeb47ce57145c5a82cc6f0"
EXPECTED_QUESTIONS_SHA256 = "0cd986e420d813e3c3b95cf55200a131a1a0e1f28a0fb48a6662c3b2fd88fa08"

WARMUP_CALLS = 10
MEASURED_CALLS = 100
SWEEP_CALLS = 50
COMPUTE_UNIT_CHOICES = ["cpu_gpu", "cpu_ne", "cpu", "all"]


def sha256_of_file(path: Path) -> str:
    return hashlib.sha256(path.read_bytes()).hexdigest()


def verify_prompt_hashes(state_path: Path, questions_path: Path) -> None:
    """Raise if the local prompt files do not match the recorded Jev run."""
    state_hash = sha256_of_file(state_path)
    questions_hash = sha256_of_file(questions_path)
    if state_hash != EXPECTED_STATE_SHA256:
        raise SystemExit(
            f"state.json hash mismatch: got {state_hash}, "
            f"expected {EXPECTED_STATE_SHA256}. Refusing to run on a different prompt."
        )
    if questions_hash != EXPECTED_QUESTIONS_SHA256:
        raise SystemExit(
            f"questions.json hash mismatch: got {questions_hash}, "
            f"expected {EXPECTED_QUESTIONS_SHA256}. Refusing to run on a different prompt."
        )


def percentiles(samples_ms: list[float]) -> dict[str, float]:
    """P50/P95 using nearest-index interpolation (matches upstream BENCHMARKS.md)."""
    if not samples_ms:
        raise ValueError("percentiles() requires at least one sample")
    ordered = sorted(samples_ms)
    n = len(ordered)

    def pct(p: float) -> float:
        idx = max(0, min(n - 1, int(round(p * (n - 1)))))
        return ordered[idx]

    return {
        "p50_ms": pct(0.50),
        "p95_ms": pct(0.95),
        "mean_ms": statistics.mean(ordered),
        "min_ms": ordered[0],
        "max_ms": ordered[-1],
        "n": n,
    }


def time_call_ms(fn: Callable[[], Any]) -> tuple[float, Any]:
    start = time.perf_counter()
    result = fn()
    elapsed_ms = (time.perf_counter() - start) * 1000.0
    return elapsed_ms, result


def benchmark_question(
    predict: Callable[[dict], Any],
    state: dict,
    question_key: str,
    question: dict,
    warmup: int = WARMUP_CALLS,
    measured: int = MEASURED_CALLS,
) -> dict:
    """Warm up, then time `measured` sequential single-question calls."""
    last_result = None
    for _ in range(warmup):
        last_result = predict(state, {question_key: question})

    samples_ms: list[float] = []
    for _ in range(measured):
        elapsed_ms, last_result = time_call_ms(
            lambda: predict(state, {question_key: question})
        )
        samples_ms.append(elapsed_ms)

    stats = percentiles(samples_ms)
    stats["question"] = question_key
    stats["last_answer"] = last_result["answers"][question_key] if last_result else None
    return stats


def benchmark_all_questions(
    predict: Callable[[dict], Any],
    state: dict,
    questions: dict[str, dict],
) -> dict:
    per_question = {}
    for key, question in questions.items():
        per_question[key] = benchmark_question(predict, state, key, question)
    return per_question


def benchmark_sequential_pass(
    predict: Callable[[dict], Any],
    state: dict,
    questions: dict[str, dict],
    repeats: int = 20,
) -> dict:
    """Time one full pass through all questions, in insertion order, per call.

    This is the number that compares directly to Jev's single 271 ms round trip:
    eleven sequential predict() calls against one state, timed end to end.
    """
    # One untimed warmup pass so the model and caches are hot.
    for key, question in questions.items():
        predict(state, {key: question})

    pass_times_ms: list[float] = []
    answers_by_pass: list[dict] = []
    for _ in range(repeats):
        start = time.perf_counter()
        answers = {}
        for key, question in questions.items():
            result = predict(state, {key: question})
            answers[key] = result["answers"][key]
        pass_times_ms.append((time.perf_counter() - start) * 1000.0)
        answers_by_pass.append(answers)

    stats = percentiles(pass_times_ms)
    stats["repeats"] = repeats
    stats["last_answers"] = answers_by_pass[-1]
    return stats


def compute_unit_sweep(
    load_agent: Callable[[str], Any],
    checkpoint: str,
    state: dict,
    question_key: str,
    question: dict,
    calls: int = SWEEP_CALLS,
) -> dict:
    """Time one question across every compute_units setting."""
    results = {}
    for unit in COMPUTE_UNIT_CHOICES:
        agent = load_agent(checkpoint, compute_units=unit)
        for _ in range(WARMUP_CALLS):
            agent.predict(state, {question_key: question})
        samples_ms: list[float] = []
        for _ in range(calls):
            elapsed_ms, _ = time_call_ms(
                lambda: agent.predict(state, {question_key: question})
            )
            samples_ms.append(elapsed_ms)
        results[unit] = percentiles(samples_ms)
    return results


def compare_to_jev(laya_answers: dict, jev_response_path: Path) -> dict:
    """Line up Laya's answers against the recorded Jev response, question by
    question. Returns per-question agreement for choice questions and score
    deltas for score questions, plus which questions both models were least
    confident about.
    """
    jev = json.loads(jev_response_path.read_text())
    jev_answers = jev["answers"]

    comparison = {}
    for key, laya_answer in laya_answers.items():
        jev_answer = jev_answers.get(key)
        if jev_answer is None:
            continue
        entry: dict[str, Any] = {
            "type": jev_answer["type"],
            "jev_confidence": jev_answer.get("confidence"),
            "laya_confidence": laya_answer.get("confidence"),
        }
        if jev_answer["type"] == "choice":
            entry["jev_choice"] = jev_answer["choice"]
            entry["laya_choice"] = laya_answer.get("choice")
            entry["agree"] = jev_answer["choice"] == laya_answer.get("choice")
        else:
            entry["jev_score"] = jev_answer["score"]
            entry["laya_score"] = laya_answer.get("score")
            if laya_answer.get("score") is not None:
                entry["score_delta"] = abs(jev_answer["score"] - laya_answer["score"])
        comparison[key] = entry

    # Questions where a model reported low confidence (<0.3), matching the
    # parent post's threshold for "confidence collapses". Tracked per model
    # rather than as one combined list: Jev's confidence spans roughly 0.16
    # to 1.0, so a 0.3 cutoff picks out a genuine minority. Laya's confidence
    # runs an order of magnitude lower across nearly every question (the two
    # models compute confidence differently), so its list may cover most or
    # all questions rather than a distinguishing subset.
    jev_low_confidence = [
        key
        for key, entry in comparison.items()
        if entry.get("jev_confidence") is not None and entry["jev_confidence"] < 0.3
    ]
    laya_low_confidence = [
        key
        for key, entry in comparison.items()
        if entry.get("laya_confidence") is not None and entry["laya_confidence"] < 0.3
    ]

    return {
        "per_question": comparison,
        "jev_low_confidence": jev_low_confidence,
        "laya_low_confidence": laya_low_confidence,
    }


def _load_json(path: Path) -> dict:
    return json.loads(path.read_text())


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "--model-dir",
        required=True,
        help="Local directory holding the mirrored Core ML bundle "
        "(loaded with local_files_only=True, no network at runtime)",
    )
    parser.add_argument("--checkpoint-label", required=True, help="Name to record in output")
    parser.add_argument("--revision", required=True)
    parser.add_argument("--compute-units", default="cpu_gpu")
    parser.add_argument("--state", type=Path, required=True)
    parser.add_argument("--questions", type=Path, required=True)
    parser.add_argument(
        "--out", type=Path, help="Where to write the answer set (ignored in --sweep mode)"
    )
    parser.add_argument("--timings", type=Path, required=True)
    parser.add_argument("--jev-response", type=Path, default=None)
    parser.add_argument("--skip-hash-check", action="store_true")
    parser.add_argument(
        "--sweep", action="store_true", help="Run the compute-unit sweep on 'action' only"
    )
    args = parser.parse_args()

    if not args.sweep and args.out is None:
        parser.error("--out is required unless --sweep is set")

    if not args.skip_hash_check:
        verify_prompt_hashes(args.state, args.questions)

    import laya_coreml as laya  # deferred: only needed for a real run

    state = _load_json(args.state)
    questions = _load_json(args.questions)

    load_start = time.perf_counter()
    agent = laya.load(
        args.model_dir, local_files_only=True, compute_units=args.compute_units
    )
    load_ms = (time.perf_counter() - load_start) * 1000.0

    first_call_start = time.perf_counter()
    first_result = agent.predict(state, {"action": questions["action"]})
    first_call_ms = (time.perf_counter() - first_call_start) * 1000.0

    timings: dict[str, Any] = {
        "checkpoint": args.checkpoint_label,
        "revision": args.revision,
        "compute_units": args.compute_units,
        "load_ms": load_ms,
        "first_call_ms": first_call_ms,
        "first_call_answer": first_result["answers"]["action"],
    }

    if args.sweep:

        def load_agent(_checkpoint: str, compute_units: str):
            return laya.load(
                args.model_dir, local_files_only=True, compute_units=compute_units
            )

        timings["compute_unit_sweep"] = compute_unit_sweep(
            load_agent, args.checkpoint_label, state, "action", questions["action"]
        )
        args.timings.write_text(json.dumps(timings, indent=2))
        print(f"Wrote sweep timings to {args.timings}")
        return

    per_question = benchmark_all_questions(agent.predict, state, questions)
    sequential = benchmark_sequential_pass(agent.predict, state, questions)

    timings["per_question"] = per_question
    timings["sequential_pass"] = sequential

    answers = {key: stats["last_answer"] for key, stats in per_question.items()}
    response = {
        "checkpoint": args.checkpoint_label,
        "revision": args.revision,
        "answers": answers,
    }

    if args.jev_response is not None:
        timings["vs_jev"] = compare_to_jev(answers, args.jev_response)

    args.out.write_text(json.dumps(response, indent=2))
    args.timings.write_text(json.dumps(timings, indent=2))
    print(f"Wrote {args.out} and {args.timings}")


if __name__ == "__main__":
    main()

The recorded responses #

This is the answer set from aac6fef/laya-typed-decisions-coreml at revision 28d24fa8d67a3264556b23391ec6c3fd98573056, the checkpoint upstream describes as its “typed-decisions” specialization and the closest analog to Jev’s purpose. Each answer carries a choice or score, a probability distribution, and Laya’s own confidence figure, the same three fields Jev returns. The two models compute confidence by different methods, so the numbers are not on a guaranteed-comparable scale.

response-typed-decisions.json Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
{
  "checkpoint": "aac6fef/laya-typed-decisions-coreml",
  "revision": "28d24fa8d67a3264556b23391ec6c3fd98573056",
  "answers": {
    "action": {
      "type": "choice",
      "confidence": 0.2955,
      "action": {
        "act_probability": 1.0
      },
      "choice": "pull_lever",
      "probabilities": {
        "pull_lever": 0.8085,
        "do_nothing": 0.1915
      }
    },
    "primary_moral_consideration": {
      "type": "choice",
      "confidence": 0.0148,
      "action": {
        "act_probability": 1.0
      },
      "choice": "duty_to_intervene",
      "probabilities": {
        "minimize_total_harm": 0.1764,
        "avoid_causing_harm": 0.2397,
        "individual_rights": 0.271,
        "duty_to_intervene": 0.3128
      }
    },
    "greater_moral_responsibility": {
      "type": "choice",
      "confidence": 0.1818,
      "action": {
        "act_probability": 1.0
      },
      "choice": "intervention",
      "probabilities": {
        "intervention": 0.6391,
        "inaction": 0.15,
        "approximately_equal": 0.2108
      }
    },
    "best_characterization_of_intervention": {
      "type": "choice",
      "confidence": 0.1128,
      "action": {
        "act_probability": 1.0
      },
      "choice": "redirect_harm",
      "probabilities": {
        "prevent_greater_harm": 0.1544,
        "redirect_harm": 0.3973,
        "cause_death": 0.3651,
        "rescue_five": 0.0832
      }
    },
    "moral_preference_strength": {
      "type": "score",
      "confidence": 0.0314,
      "action": {
        "act_probability": 1.0
      },
      "score": 3.5473,
      "legend": {
        "0": "Strongly prefer doing nothing.",
        "1": "Moderately prefer doing nothing.",
        "2": "Slightly prefer doing nothing.",
        "3": "No meaningful preference between the actions.",
        "4": "Slightly prefer pulling the lever.",
        "5": "Moderately prefer pulling the lever.",
        "6": "Strongly prefer pulling the lever."
      },
      "probabilities": {
        "0": 0.0556,
        "1": 0.1237,
        "2": 0.1212,
        "3": 0.1643,
        "4": 0.1484,
        "5": 0.226,
        "6": 0.1608
      }
    },
    "action_inaction_significance": {
      "type": "score",
      "confidence": 0.1215,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.8157,
      "legend": {
        "0": "No meaningful moral distinction.",
        "1": "A small moral distinction.",
        "2": "A moderate moral distinction.",
        "3": "A substantial moral distinction.",
        "4": "A decisive moral distinction."
      },
      "probabilities": {
        "0": 0.0331,
        "1": 0.1275,
        "2": 0.179,
        "3": 0.3116,
        "4": 0.3489
      }
    },
    "harm_tradeoff_justification": {
      "type": "score",
      "confidence": 0.0417,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.4617,
      "legend": {
        "0": "No moral justification.",
        "1": "Weak moral justification.",
        "2": "Moderate moral justification.",
        "3": "Strong moral justification.",
        "4": "Overwhelming moral justification."
      },
      "probabilities": {
        "0": 0.0877,
        "1": 0.163,
        "2": 0.2071,
        "3": 0.2844,
        "4": 0.2579
      }
    },
    "intervention_permissibility": {
      "type": "score",
      "confidence": 0.0215,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.2128,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.1406,
        "1": 0.2456,
        "2": 0.148,
        "3": 0.1918,
        "4": 0.274
      }
    },
    "inaction_permissibility": {
      "type": "score",
      "confidence": 0.0553,
      "action": {
        "act_probability": 1.0
      },
      "score": 1.4616,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.3367,
        "1": 0.2665,
        "2": 0.1369,
        "3": 0.1182,
        "4": 0.1417
      }
    },
    "duty_to_minimize_harm_strength": {
      "type": "score",
      "confidence": 0.0376,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.4095,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.0946,
        "1": 0.1545,
        "2": 0.234,
        "3": 0.2809,
        "4": 0.2361
      }
    },
    "duty_not_to_redirect_harm_strength": {
      "type": "score",
      "confidence": 0.0821,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.6626,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.0551,
        "1": 0.1398,
        "2": 0.1938,
        "3": 0.3101,
        "4": 0.3013
      }
    }
  }
}

The second checkpoint, aac6fef/laya-multilingual-coreml, answers the identical eleven questions in the same format. It is smaller (322M parameters against 421M) and, on this run, faster and less confident about the dominant moral consideration.

response-multilingual.json Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
{
  "checkpoint": "aac6fef/laya-multilingual-coreml",
  "revision": "8139e9089273319512c730218903784074133187",
  "answers": {
    "action": {
      "type": "choice",
      "confidence": 0.0359,
      "action": {
        "act_probability": 1.0
      },
      "choice": "pull_lever",
      "probabilities": {
        "pull_lever": 0.6111,
        "do_nothing": 0.3889
      }
    },
    "primary_moral_consideration": {
      "type": "choice",
      "confidence": 0.2202,
      "action": {
        "act_probability": 1.0
      },
      "choice": "minimize_total_harm",
      "probabilities": {
        "minimize_total_harm": 0.4464,
        "avoid_causing_harm": 0.3683,
        "individual_rights": 0.0107,
        "duty_to_intervene": 0.1747
      }
    },
    "greater_moral_responsibility": {
      "type": "choice",
      "confidence": 0.1424,
      "action": {
        "act_probability": 1.0
      },
      "choice": "intervention",
      "probabilities": {
        "intervention": 0.5695,
        "inaction": 0.1243,
        "approximately_equal": 0.3062
      }
    },
    "best_characterization_of_intervention": {
      "type": "choice",
      "confidence": 0.0913,
      "action": {
        "act_probability": 1.0
      },
      "choice": "cause_death",
      "probabilities": {
        "prevent_greater_harm": 0.1655,
        "redirect_harm": 0.2032,
        "cause_death": 0.4799,
        "rescue_five": 0.1514
      }
    },
    "moral_preference_strength": {
      "type": "score",
      "confidence": 0.0773,
      "action": {
        "act_probability": 1.0
      },
      "score": 3.1384,
      "legend": {
        "0": "Strongly prefer doing nothing.",
        "1": "Moderately prefer doing nothing.",
        "2": "Slightly prefer doing nothing.",
        "3": "No meaningful preference between the actions.",
        "4": "Slightly prefer pulling the lever.",
        "5": "Moderately prefer pulling the lever.",
        "6": "Strongly prefer pulling the lever."
      },
      "probabilities": {
        "0": 0.0495,
        "1": 0.1419,
        "2": 0.1052,
        "3": 0.3227,
        "4": 0.1593,
        "5": 0.147,
        "6": 0.0743
      }
    },
    "action_inaction_significance": {
      "type": "score",
      "confidence": 0.0456,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.4722,
      "legend": {
        "0": "No meaningful moral distinction.",
        "1": "A small moral distinction.",
        "2": "A moderate moral distinction.",
        "3": "A substantial moral distinction.",
        "4": "A decisive moral distinction."
      },
      "probabilities": {
        "0": 0.0943,
        "1": 0.1648,
        "2": 0.237,
        "3": 0.1821,
        "4": 0.3218
      }
    },
    "harm_tradeoff_justification": {
      "type": "score",
      "confidence": 0.0537,
      "action": {
        "act_probability": 1.0
      },
      "score": 1.8444,
      "legend": {
        "0": "No moral justification.",
        "1": "Weak moral justification.",
        "2": "Moderate moral justification.",
        "3": "Strong moral justification.",
        "4": "Overwhelming moral justification."
      },
      "probabilities": {
        "0": 0.1244,
        "1": 0.3442,
        "2": 0.2013,
        "3": 0.223,
        "4": 0.1072
      }
    },
    "intervention_permissibility": {
      "type": "score",
      "confidence": 0.1104,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.3731,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.0319,
        "1": 0.1964,
        "2": 0.2813,
        "3": 0.3474,
        "4": 0.143
      }
    },
    "inaction_permissibility": {
      "type": "score",
      "confidence": 0.1044,
      "action": {
        "act_probability": 1.0
      },
      "score": 2.2521,
      "legend": {
        "0": "Clearly impermissible.",
        "1": "Probably impermissible.",
        "2": "Morally ambiguous.",
        "3": "Probably permissible.",
        "4": "Clearly permissible."
      },
      "probabilities": {
        "0": 0.0336,
        "1": 0.2261,
        "2": 0.3299,
        "3": 0.2756,
        "4": 0.1349
      }
    },
    "duty_to_minimize_harm_strength": {
      "type": "score",
      "confidence": 0.1933,
      "action": {
        "act_probability": 1.0
      },
      "score": 1.6886,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.0675,
        "1": 0.3754,
        "2": 0.395,
        "3": 0.1255,
        "4": 0.0367
      }
    },
    "duty_not_to_redirect_harm_strength": {
      "type": "score",
      "confidence": 0.1529,
      "action": {
        "act_probability": 1.0
      },
      "score": 1.7284,
      "legend": {
        "0": "No obligation.",
        "1": "Weak obligation.",
        "2": "Moderate obligation.",
        "3": "Strong obligation.",
        "4": "Overriding obligation."
      },
      "probabilities": {
        "0": 0.082,
        "1": 0.3471,
        "2": 0.3756,
        "3": 0.1513,
        "4": 0.044
      }
    }
  }
}

The timings #

timings.json is assembled from four separate runs of bench_trolley.py, not the literal output of a single invocation: per-question P50/P95 and answers for both checkpoints, the sequential eleven-question pass for each, the compute-unit sweep, and the Neural Engine sidebar. The Jev reference numbers the post compares against are copied in from the parent walkthrough’s response.json rather than recomputed.

timings.json Raw Download
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
{
  "machine": {
    "model": "MacBook Air (M4)",
    "cpu": "Apple M4, 4 performance + 6 efficiency cores",
    "gpu": "10-core",
    "memory_gb": 24,
    "macos": "27.0 (build 26A428)"
  },
  "software": {
    "python": "3.13.7",
    "laya_coreml": "0.1.0",
    "coremltools": "9.0",
    "numpy": "2.1.3",
    "tokenizers": "0.23.2",
    "huggingface_hub": "1.32.0"
  },
  "checkpoints": {
    "aac6fef/laya-typed-decisions-coreml": {
      "revision": "28d24fa8d67a3264556b23391ec6c3fd98573056",
      "params": "421M",
      "compute_units": "cpu_gpu",
      "load_ms": 3276.419458008604,
      "first_call_ms": 525.8849160163663,
      "sequential_11_question_pass_ms": {
        "p50": 1201.7482920200564,
        "p95": 1230.4090000106953,
        "mean": 1204.8529187988606,
        "repeats": 20
      },
      "per_question_p50_ms": {
        "action": 101.65058399434201,
        "primary_moral_consideration": 101.68916700058617,
        "greater_moral_responsibility": 102.24212499451824,
        "best_characterization_of_intervention": 104.93895798572339,
        "moral_preference_strength": 103.60195898101665,
        "action_inaction_significance": 104.37779099447653,
        "harm_tradeoff_justification": 108.25224997824989,
        "intervention_permissibility": 105.42354200151749,
        "inaction_permissibility": 106.1581669782754,
        "duty_to_minimize_harm_strength": 106.88395801116712,
        "duty_not_to_redirect_harm_strength": 108.4515830152668
      },
      "answers": {
        "action": {
          "type": "choice",
          "confidence": 0.2955,
          "action": {
            "act_probability": 1.0
          },
          "choice": "pull_lever",
          "probabilities": {
            "pull_lever": 0.8085,
            "do_nothing": 0.1915
          }
        },
        "primary_moral_consideration": {
          "type": "choice",
          "confidence": 0.0148,
          "action": {
            "act_probability": 1.0
          },
          "choice": "duty_to_intervene",
          "probabilities": {
            "minimize_total_harm": 0.1764,
            "avoid_causing_harm": 0.2397,
            "individual_rights": 0.271,
            "duty_to_intervene": 0.3128
          }
        },
        "greater_moral_responsibility": {
          "type": "choice",
          "confidence": 0.1818,
          "action": {
            "act_probability": 1.0
          },
          "choice": "intervention",
          "probabilities": {
            "intervention": 0.6391,
            "inaction": 0.15,
            "approximately_equal": 0.2108
          }
        },
        "best_characterization_of_intervention": {
          "type": "choice",
          "confidence": 0.1128,
          "action": {
            "act_probability": 1.0
          },
          "choice": "redirect_harm",
          "probabilities": {
            "prevent_greater_harm": 0.1544,
            "redirect_harm": 0.3973,
            "cause_death": 0.3651,
            "rescue_five": 0.0832
          }
        },
        "moral_preference_strength": {
          "type": "score",
          "confidence": 0.0314,
          "action": {
            "act_probability": 1.0
          },
          "score": 3.5473,
          "legend": {
            "0": "Strongly prefer doing nothing.",
            "1": "Moderately prefer doing nothing.",
            "2": "Slightly prefer doing nothing.",
            "3": "No meaningful preference between the actions.",
            "4": "Slightly prefer pulling the lever.",
            "5": "Moderately prefer pulling the lever.",
            "6": "Strongly prefer pulling the lever."
          },
          "probabilities": {
            "0": 0.0556,
            "1": 0.1237,
            "2": 0.1212,
            "3": 0.1643,
            "4": 0.1484,
            "5": 0.226,
            "6": 0.1608
          }
        },
        "action_inaction_significance": {
          "type": "score",
          "confidence": 0.1215,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.8157,
          "legend": {
            "0": "No meaningful moral distinction.",
            "1": "A small moral distinction.",
            "2": "A moderate moral distinction.",
            "3": "A substantial moral distinction.",
            "4": "A decisive moral distinction."
          },
          "probabilities": {
            "0": 0.0331,
            "1": 0.1275,
            "2": 0.179,
            "3": 0.3116,
            "4": 0.3489
          }
        },
        "harm_tradeoff_justification": {
          "type": "score",
          "confidence": 0.0417,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.4617,
          "legend": {
            "0": "No moral justification.",
            "1": "Weak moral justification.",
            "2": "Moderate moral justification.",
            "3": "Strong moral justification.",
            "4": "Overwhelming moral justification."
          },
          "probabilities": {
            "0": 0.0877,
            "1": 0.163,
            "2": 0.2071,
            "3": 0.2844,
            "4": 0.2579
          }
        },
        "intervention_permissibility": {
          "type": "score",
          "confidence": 0.0215,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.2128,
          "legend": {
            "0": "Clearly impermissible.",
            "1": "Probably impermissible.",
            "2": "Morally ambiguous.",
            "3": "Probably permissible.",
            "4": "Clearly permissible."
          },
          "probabilities": {
            "0": 0.1406,
            "1": 0.2456,
            "2": 0.148,
            "3": 0.1918,
            "4": 0.274
          }
        },
        "inaction_permissibility": {
          "type": "score",
          "confidence": 0.0553,
          "action": {
            "act_probability": 1.0
          },
          "score": 1.4616,
          "legend": {
            "0": "Clearly impermissible.",
            "1": "Probably impermissible.",
            "2": "Morally ambiguous.",
            "3": "Probably permissible.",
            "4": "Clearly permissible."
          },
          "probabilities": {
            "0": 0.3367,
            "1": 0.2665,
            "2": 0.1369,
            "3": 0.1182,
            "4": 0.1417
          }
        },
        "duty_to_minimize_harm_strength": {
          "type": "score",
          "confidence": 0.0376,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.4095,
          "legend": {
            "0": "No obligation.",
            "1": "Weak obligation.",
            "2": "Moderate obligation.",
            "3": "Strong obligation.",
            "4": "Overriding obligation."
          },
          "probabilities": {
            "0": 0.0946,
            "1": 0.1545,
            "2": 0.234,
            "3": 0.2809,
            "4": 0.2361
          }
        },
        "duty_not_to_redirect_harm_strength": {
          "type": "score",
          "confidence": 0.0821,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.6626,
          "legend": {
            "0": "No obligation.",
            "1": "Weak obligation.",
            "2": "Moderate obligation.",
            "3": "Strong obligation.",
            "4": "Overriding obligation."
          },
          "probabilities": {
            "0": 0.0551,
            "1": 0.1398,
            "2": 0.1938,
            "3": 0.3101,
            "4": 0.3013
          }
        }
      },
      "vs_jev": {
        "per_question": {
          "action": {
            "type": "choice",
            "jev_confidence": 1.0,
            "laya_confidence": 0.2955,
            "jev_choice": "pull_lever",
            "laya_choice": "pull_lever",
            "agree": true
          },
          "primary_moral_consideration": {
            "type": "choice",
            "jev_confidence": 0.94,
            "laya_confidence": 0.0148,
            "jev_choice": "minimize_total_harm",
            "laya_choice": "duty_to_intervene",
            "agree": false
          },
          "greater_moral_responsibility": {
            "type": "choice",
            "jev_confidence": 0.64,
            "laya_confidence": 0.1818,
            "jev_choice": "intervention",
            "laya_choice": "intervention",
            "agree": true
          },
          "best_characterization_of_intervention": {
            "type": "choice",
            "jev_confidence": 0.96,
            "laya_confidence": 0.1128,
            "jev_choice": "redirect_harm",
            "laya_choice": "redirect_harm",
            "agree": true
          },
          "moral_preference_strength": {
            "type": "score",
            "jev_confidence": 0.95,
            "laya_confidence": 0.0314,
            "jev_score": 5.91,
            "laya_score": 3.5473,
            "score_delta": 2.3627000000000002
          },
          "action_inaction_significance": {
            "type": "score",
            "jev_confidence": 0.17,
            "laya_confidence": 0.1215,
            "jev_score": 1.78,
            "laya_score": 2.8157,
            "score_delta": 1.0357
          },
          "harm_tradeoff_justification": {
            "type": "score",
            "jev_confidence": 0.66,
            "laya_confidence": 0.0417,
            "jev_score": 3.38,
            "laya_score": 2.4617,
            "score_delta": 0.9182999999999999
          },
          "intervention_permissibility": {
            "type": "score",
            "jev_confidence": 0.65,
            "laya_confidence": 0.0215,
            "jev_score": 3.59,
            "laya_score": 2.2128,
            "score_delta": 1.3771999999999998
          },
          "inaction_permissibility": {
            "type": "score",
            "jev_confidence": 0.54,
            "laya_confidence": 0.0553,
            "jev_score": 1.02,
            "laya_score": 1.4616,
            "score_delta": 0.4416
          },
          "duty_to_minimize_harm_strength": {
            "type": "score",
            "jev_confidence": 0.6,
            "laya_confidence": 0.0376,
            "jev_score": 3.42,
            "laya_score": 2.4095,
            "score_delta": 1.0105
          },
          "duty_not_to_redirect_harm_strength": {
            "type": "score",
            "jev_confidence": 0.16,
            "laya_confidence": 0.0821,
            "jev_score": 2.06,
            "laya_score": 2.6626,
            "score_delta": 0.6025999999999998
          }
        },
        "jev_low_confidence": [
          "action_inaction_significance",
          "duty_not_to_redirect_harm_strength"
        ],
        "laya_low_confidence": [
          "action",
          "primary_moral_consideration",
          "greater_moral_responsibility",
          "best_characterization_of_intervention",
          "moral_preference_strength",
          "action_inaction_significance",
          "harm_tradeoff_justification",
          "intervention_permissibility",
          "inaction_permissibility",
          "duty_to_minimize_harm_strength",
          "duty_not_to_redirect_harm_strength"
        ]
      }
    },
    "aac6fef/laya-multilingual-coreml": {
      "revision": "8139e9089273319512c730218903784074133187",
      "params": "322M",
      "compute_units": "cpu_gpu",
      "load_ms": 3141.4533750212286,
      "first_call_ms": 1065.6672909972258,
      "sequential_11_question_pass_ms": {
        "p50": 470.1291249948554,
        "p95": 473.42687501804903,
        "mean": 470.5920000036713,
        "repeats": 20
      },
      "per_question_p50_ms": {
        "action": 41.69704098603688,
        "primary_moral_consideration": 41.89337498974055,
        "greater_moral_responsibility": 41.93679100717418,
        "best_characterization_of_intervention": 42.148875014390796,
        "moral_preference_strength": 42.18595800921321,
        "action_inaction_significance": 42.22841700538993,
        "harm_tradeoff_justification": 42.4314999836497,
        "intervention_permissibility": 42.3672080214601,
        "inaction_permissibility": 42.53037500893697,
        "duty_to_minimize_harm_strength": 42.532791005214676,
        "duty_not_to_redirect_harm_strength": 42.68258300726302
      },
      "answers": {
        "action": {
          "type": "choice",
          "confidence": 0.0359,
          "action": {
            "act_probability": 1.0
          },
          "choice": "pull_lever",
          "probabilities": {
            "pull_lever": 0.6111,
            "do_nothing": 0.3889
          }
        },
        "primary_moral_consideration": {
          "type": "choice",
          "confidence": 0.2202,
          "action": {
            "act_probability": 1.0
          },
          "choice": "minimize_total_harm",
          "probabilities": {
            "minimize_total_harm": 0.4464,
            "avoid_causing_harm": 0.3683,
            "individual_rights": 0.0107,
            "duty_to_intervene": 0.1747
          }
        },
        "greater_moral_responsibility": {
          "type": "choice",
          "confidence": 0.1424,
          "action": {
            "act_probability": 1.0
          },
          "choice": "intervention",
          "probabilities": {
            "intervention": 0.5695,
            "inaction": 0.1243,
            "approximately_equal": 0.3062
          }
        },
        "best_characterization_of_intervention": {
          "type": "choice",
          "confidence": 0.0913,
          "action": {
            "act_probability": 1.0
          },
          "choice": "cause_death",
          "probabilities": {
            "prevent_greater_harm": 0.1655,
            "redirect_harm": 0.2032,
            "cause_death": 0.4799,
            "rescue_five": 0.1514
          }
        },
        "moral_preference_strength": {
          "type": "score",
          "confidence": 0.0773,
          "action": {
            "act_probability": 1.0
          },
          "score": 3.1384,
          "legend": {
            "0": "Strongly prefer doing nothing.",
            "1": "Moderately prefer doing nothing.",
            "2": "Slightly prefer doing nothing.",
            "3": "No meaningful preference between the actions.",
            "4": "Slightly prefer pulling the lever.",
            "5": "Moderately prefer pulling the lever.",
            "6": "Strongly prefer pulling the lever."
          },
          "probabilities": {
            "0": 0.0495,
            "1": 0.1419,
            "2": 0.1052,
            "3": 0.3227,
            "4": 0.1593,
            "5": 0.147,
            "6": 0.0743
          }
        },
        "action_inaction_significance": {
          "type": "score",
          "confidence": 0.0456,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.4722,
          "legend": {
            "0": "No meaningful moral distinction.",
            "1": "A small moral distinction.",
            "2": "A moderate moral distinction.",
            "3": "A substantial moral distinction.",
            "4": "A decisive moral distinction."
          },
          "probabilities": {
            "0": 0.0943,
            "1": 0.1648,
            "2": 0.237,
            "3": 0.1821,
            "4": 0.3218
          }
        },
        "harm_tradeoff_justification": {
          "type": "score",
          "confidence": 0.0537,
          "action": {
            "act_probability": 1.0
          },
          "score": 1.8444,
          "legend": {
            "0": "No moral justification.",
            "1": "Weak moral justification.",
            "2": "Moderate moral justification.",
            "3": "Strong moral justification.",
            "4": "Overwhelming moral justification."
          },
          "probabilities": {
            "0": 0.1244,
            "1": 0.3442,
            "2": 0.2013,
            "3": 0.223,
            "4": 0.1072
          }
        },
        "intervention_permissibility": {
          "type": "score",
          "confidence": 0.1104,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.3731,
          "legend": {
            "0": "Clearly impermissible.",
            "1": "Probably impermissible.",
            "2": "Morally ambiguous.",
            "3": "Probably permissible.",
            "4": "Clearly permissible."
          },
          "probabilities": {
            "0": 0.0319,
            "1": 0.1964,
            "2": 0.2813,
            "3": 0.3474,
            "4": 0.143
          }
        },
        "inaction_permissibility": {
          "type": "score",
          "confidence": 0.1044,
          "action": {
            "act_probability": 1.0
          },
          "score": 2.2521,
          "legend": {
            "0": "Clearly impermissible.",
            "1": "Probably impermissible.",
            "2": "Morally ambiguous.",
            "3": "Probably permissible.",
            "4": "Clearly permissible."
          },
          "probabilities": {
            "0": 0.0336,
            "1": 0.2261,
            "2": 0.3299,
            "3": 0.2756,
            "4": 0.1349
          }
        },
        "duty_to_minimize_harm_strength": {
          "type": "score",
          "confidence": 0.1933,
          "action": {
            "act_probability": 1.0
          },
          "score": 1.6886,
          "legend": {
            "0": "No obligation.",
            "1": "Weak obligation.",
            "2": "Moderate obligation.",
            "3": "Strong obligation.",
            "4": "Overriding obligation."
          },
          "probabilities": {
            "0": 0.0675,
            "1": 0.3754,
            "2": 0.395,
            "3": 0.1255,
            "4": 0.0367
          }
        },
        "duty_not_to_redirect_harm_strength": {
          "type": "score",
          "confidence": 0.1529,
          "action": {
            "act_probability": 1.0
          },
          "score": 1.7284,
          "legend": {
            "0": "No obligation.",
            "1": "Weak obligation.",
            "2": "Moderate obligation.",
            "3": "Strong obligation.",
            "4": "Overriding obligation."
          },
          "probabilities": {
            "0": 0.082,
            "1": 0.3471,
            "2": 0.3756,
            "3": 0.1513,
            "4": 0.044
          }
        }
      },
      "vs_jev": {
        "per_question": {
          "action": {
            "type": "choice",
            "jev_confidence": 1.0,
            "laya_confidence": 0.0359,
            "jev_choice": "pull_lever",
            "laya_choice": "pull_lever",
            "agree": true
          },
          "primary_moral_consideration": {
            "type": "choice",
            "jev_confidence": 0.94,
            "laya_confidence": 0.2202,
            "jev_choice": "minimize_total_harm",
            "laya_choice": "minimize_total_harm",
            "agree": true
          },
          "greater_moral_responsibility": {
            "type": "choice",
            "jev_confidence": 0.64,
            "laya_confidence": 0.1424,
            "jev_choice": "intervention",
            "laya_choice": "intervention",
            "agree": true
          },
          "best_characterization_of_intervention": {
            "type": "choice",
            "jev_confidence": 0.96,
            "laya_confidence": 0.0913,
            "jev_choice": "redirect_harm",
            "laya_choice": "cause_death",
            "agree": false
          },
          "moral_preference_strength": {
            "type": "score",
            "jev_confidence": 0.95,
            "laya_confidence": 0.0773,
            "jev_score": 5.91,
            "laya_score": 3.1384,
            "score_delta": 2.7716000000000003
          },
          "action_inaction_significance": {
            "type": "score",
            "jev_confidence": 0.17,
            "laya_confidence": 0.0456,
            "jev_score": 1.78,
            "laya_score": 2.4722,
            "score_delta": 0.6921999999999999
          },
          "harm_tradeoff_justification": {
            "type": "score",
            "jev_confidence": 0.66,
            "laya_confidence": 0.0537,
            "jev_score": 3.38,
            "laya_score": 1.8444,
            "score_delta": 1.5355999999999999
          },
          "intervention_permissibility": {
            "type": "score",
            "jev_confidence": 0.65,
            "laya_confidence": 0.1104,
            "jev_score": 3.59,
            "laya_score": 2.3731,
            "score_delta": 1.2168999999999999
          },
          "inaction_permissibility": {
            "type": "score",
            "jev_confidence": 0.54,
            "laya_confidence": 0.1044,
            "jev_score": 1.02,
            "laya_score": 2.2521,
            "score_delta": 1.2321
          },
          "duty_to_minimize_harm_strength": {
            "type": "score",
            "jev_confidence": 0.6,
            "laya_confidence": 0.1933,
            "jev_score": 3.42,
            "laya_score": 1.6886,
            "score_delta": 1.7313999999999998
          },
          "duty_not_to_redirect_harm_strength": {
            "type": "score",
            "jev_confidence": 0.16,
            "laya_confidence": 0.1529,
            "jev_score": 2.06,
            "laya_score": 1.7284,
            "score_delta": 0.3316000000000001
          }
        },
        "jev_low_confidence": [
          "action_inaction_significance",
          "duty_not_to_redirect_harm_strength"
        ],
        "laya_low_confidence": [
          "action",
          "primary_moral_consideration",
          "greater_moral_responsibility",
          "best_characterization_of_intervention",
          "moral_preference_strength",
          "action_inaction_significance",
          "harm_tradeoff_justification",
          "intervention_permissibility",
          "inaction_permissibility",
          "duty_to_minimize_harm_strength",
          "duty_not_to_redirect_harm_strength"
        ]
      }
    }
  },
  "compute_unit_sweep_typed_decisions_action_question": {
    "cpu_gpu": {
      "p50_ms": 101.22425001463853,
      "p95_ms": 101.56270800507627,
      "mean_ms": 101.14633010060061,
      "min_ms": 100.52579201874323,
      "max_ms": 101.59120798925869,
      "n": 50
    },
    "cpu_ne": {
      "p50_ms": 754.350290982984,
      "p95_ms": 766.6959589987528,
      "mean_ms": 755.9304499597056,
      "min_ms": 749.1610000142828,
      "max_ms": 776.8597079848405,
      "n": 50
    },
    "cpu": {
      "p50_ms": 754.800458002137,
      "p95_ms": 764.0228750242386,
      "mean_ms": 755.3792240773328,
      "min_ms": 749.1829579812475,
      "max_ms": 764.8939579958096,
      "n": 50
    },
    "all": {
      "p50_ms": 758.3346249884926,
      "p95_ms": 766.503749997355,
      "mean_ms": 760.1547166181263,
      "min_ms": 755.7183750031982,
      "max_ms": 787.6160000159871,
      "n": 50
    }
  },
  "ane_sidebar": {
    "checkpoint": "aac6fef/laya-multilingual-coreml-ane",
    "revision": "39d6a9b3d0f67f06da74fbade6121ea134cbdb21",
    "compute_units": "cpu_ne",
    "prompt": "compressed to fit the 96-token total budget (state-96.json + questions-96.json), NOT the same prompt as the primary comparison",
    "load_ms": 17401.437997817993,
    "single_question_p50_ms": 5.358499998692423,
    "single_question_p95_ms": 5.583416990702972,
    "single_question_mean_ms": 5.4044458593125455,
    "n": 100,
    "answer": {
      "choice": "pull_lever",
      "confidence": 0.2557,
      "probabilities": {
        "pull_lever": 0.7885,
        "do_nothing": 0.2115
      }
    }
  },
  "jev_reference": {
    "source": "content/code/2026/typesafe-trolley-problem/response.json",
    "model": "jev-1.13.0",
    "browser_round_trip_ms": 271,
    "server_evaluation_time_ms": 146.9146780000301,
    "input_tokens": 1565,
    "output_tokens": 357
  }
}

The compressed prompt for the Neural Engine #

The Neural Engine bundle caps total input, question, options, and state combined, at 96 tokens. The real trolley state alone tokenizes to 258 tokens against that model’s tokenizer, so it cannot run on the ANE path at all. state-96.json compresses the same scenario to its bare arithmetic: five on one track, one on the other, a lever. This is a different, smaller prompt than the rest of the walkthrough, kept in its own file so it is never confused with the byte-identical comparison above.

state-96.json Raw Download
1
2
3
4
5
{
  "people_on_current_track": 5,
  "people_on_alternate_track": 1,
  "lever_diverts_trolley_to_alternate_track": true
}

questions-96.json holds the matching single question, compressed the same way.

questions-96.json Raw Download
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "action": {
    "type": "choice",
    "instructions": "Should the bystander pull the lever?",
    "criteria": {
      "pull_lever": "Divert the trolley, killing one.",
      "do_nothing": "Do not act, killing five."
    }
  }
}

Running it yourself #

The script picks the newest available Python 3.11-3.13 interpreter on PATH (Laya-CoreML does not yet support 3.14), installs laya-coreml, downloads all three checkpoints from Hugging Face at their pinned revisions, and reproduces every result above: the two full-prompt checkpoints, the compute-unit sweep, and the compressed-prompt Neural Engine run.

run.sh Raw Download
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
# Set up and run the Laya-CoreML trolley-problem benchmark on Apple Silicon.
#
# Requires macOS 15+ on Apple Silicon and a Python 3.11-3.13 interpreter
# (Laya-CoreML does not yet support 3.14). Downloads three Core ML checkpoints
# (~1.5 GB total) from Hugging Face on first run, then reproduces every number
# in the post: the two full-prompt checkpoints, the compute-unit sweep, and
# the compressed-prompt Neural Engine run. All output (venv, models, results)
# is written under this directory in `.venv/`, `models/`, and `out/`, which
# stay out of the published bundle.
set -euo pipefail

cd "$(dirname "$0")"

PYTHON=""
for candidate in python3.13 python3.12 python3.11; do
  if command -v "$candidate" >/dev/null 2>&1; then
    PYTHON="$candidate"
    break
  fi
done
if [ -z "$PYTHON" ]; then
  echo "No Python 3.11-3.13 interpreter found on PATH (Laya-CoreML does not support 3.14+)." >&2
  exit 1
fi

mkdir -p out
"$PYTHON" -m venv .venv
.venv/bin/python -m pip install --quiet --upgrade pip
.venv/bin/python -m pip install --quiet 'laya-coreml==0.1.0' 'huggingface_hub==1.32.0'

.venv/bin/hf download aac6fef/laya-typed-decisions-coreml \
  --revision 28d24fa8d67a3264556b23391ec6c3fd98573056 \
  --local-dir models/typed-decisions

.venv/bin/hf download aac6fef/laya-multilingual-coreml \
  --revision 8139e9089273319512c730218903784074133187 \
  --local-dir models/multilingual

.venv/bin/hf download aac6fef/laya-multilingual-coreml-ane \
  --revision 39d6a9b3d0f67f06da74fbade6121ea134cbdb21 \
  --local-dir models/ane

# The two full-prompt checkpoints, each against the identical, hash-verified
# eleven-question state.
.venv/bin/python bench_trolley.py \
  --model-dir models/typed-decisions \
  --checkpoint-label aac6fef/laya-typed-decisions-coreml \
  --revision 28d24fa8d67a3264556b23391ec6c3fd98573056 \
  --state state.json --questions questions.json \
  --jev-response jev-response.json \
  --out out/response-typed-decisions.json \
  --timings out/timings-typed-decisions.json

.venv/bin/python bench_trolley.py \
  --model-dir models/multilingual \
  --checkpoint-label aac6fef/laya-multilingual-coreml \
  --revision 8139e9089273319512c730218903784074133187 \
  --state state.json --questions questions.json \
  --jev-response jev-response.json \
  --out out/response-multilingual.json \
  --timings out/timings-multilingual.json

# The compute-unit sweep on the `action` question alone (cpu_gpu vs cpu_ne vs
# cpu vs all), on the typed-decisions checkpoint.
.venv/bin/python bench_trolley.py --sweep \
  --model-dir models/typed-decisions \
  --checkpoint-label aac6fef/laya-typed-decisions-coreml \
  --revision 28d24fa8d67a3264556b23391ec6c3fd98573056 \
  --state state.json --questions questions.json \
  --timings out/sweep-typed-decisions.json

# The Neural Engine sidebar: a different, compressed prompt (state-96.json /
# questions-96.json) that fits the ANE bundle's 96-token budget. --skip-hash-check
# is required here because this is deliberately not the eleven-question prompt.
.venv/bin/python bench_trolley.py \
  --model-dir models/ane \
  --checkpoint-label aac6fef/laya-multilingual-coreml-ane \
  --revision 39d6a9b3d0f67f06da74fbade6121ea134cbdb21 \
  --compute-units cpu_ne \
  --state state-96.json --questions questions-96.json \
  --skip-hash-check \
  --out out/response-ane.json \
  --timings out/timings-ane.json

echo "Done. See the out/ directory for every result file."

Run it from the bundle directory. The three checkpoints total roughly 1.5 GB; after that first download, every subsequent run is offline. The virtual environment, downloaded weights, and result files land in .venv/, models/, and out/, none of which ship with the bundle.


Leave a comment

Preview

Comments are reviewed before publishing.