@@ -28,6 +28,16 @@ defmodule StackLab.Examples.TRINITYParityHarness do
2828 :deferred_stage_parity
2929 ]
3030
31+ @ phase15_rows [
32+ :source_inventory ,
33+ :task_surface ,
34+ :prompt_eval_fixtures ,
35+ :no_bypass_fixtures ,
36+ :cuda_parity ,
37+ :stage_parity ,
38+ :python_scripts
39+ ]
40+
3141 @ all_task_count 17
3242 @ coordinator_source_count 60
3343
@@ -38,7 +48,7 @@ defmodule StackLab.Examples.TRINITYParityHarness do
3848
3949 rows =
4050 opts
41- |> Keyword . get ( :rows , @ default_rows )
51+ |> selected_rows ( )
4252 |> Enum . map ( & run_row ( & 1 , coordinator_root , framework_root , opts ) )
4353
4454 status =
@@ -60,6 +70,15 @@ defmodule StackLab.Examples.TRINITYParityHarness do
6070 receipt
6171 end
6272
73+ @ spec run! ( keyword ( ) ) :: Receipt . t ( )
74+ def run! ( opts ) do
75+ { :ok , receipt } = run ( opts )
76+ receipt
77+ end
78+
79+ @ spec phase15_rows ( ) :: [ atom ( ) ]
80+ def phase15_rows , do: @ phase15_rows
81+
6382 defp run_row ( :source_inventory , coordinator_root , _framework_root , _opts ) do
6483 files =
6584 coordinator_root
@@ -158,6 +177,86 @@ defmodule StackLab.Examples.TRINITYParityHarness do
158177 }
159178 end
160179
180+ defp run_row ( :cuda_parity , _coordinator_root , _framework_root , opts ) do
181+ phase15_dir = phase15_dir ( opts )
182+ old_snapshot = Path . join ( phase15_dir , "coordinator_cuda_qwen_router_prompt_eval_logits.json" )
183+ new_snapshot = Path . join ( phase15_dir , "framework_cuda_qwen_router_prompt_eval_logits.json" )
184+ old_log = Path . join ( phase15_dir , "coordinator_cuda_qwen_router_prompt_eval.log" )
185+ new_log = Path . join ( phase15_dir , "framework_cuda_qwen_router_prompt_eval.log" )
186+
187+ details = cuda_parity_details ( old_snapshot , new_snapshot , old_log , new_log )
188+ status = if details . pass? , do: :pass , else: :open_defect
189+
190+ % Row {
191+ id: :cuda_parity ,
192+ description:
193+ "old/new CUDA prompt-eval snapshots pass 37/37 and match decision-stable invariants" ,
194+ status: status ,
195+ details: Map . delete ( details , :pass? )
196+ }
197+ end
198+
199+ defp run_row ( :stage_parity , _coordinator_root , _framework_root , opts ) do
200+ summary_path = Path . join ( phase15_dir ( opts ) , "stage_parity_summary.json" )
201+
202+ details =
203+ if File . regular? ( summary_path ) do
204+ summary = summary_path |> File . read! ( ) |> Jason . decode! ( )
205+
206+ % {
207+ pass?: summary [ "ok" ] == true and summary [ "exit_status" ] == 0 ,
208+ summary_path: summary_path ,
209+ python_report: summary [ "python_report" ] ,
210+ elixir_report: summary [ "elixir_report" ] ,
211+ strict_stage_tolerances?: "--strict-stage-tolerances" in summary [ "comparator_args" ]
212+ }
213+ else
214+ % { pass?: false , summary_path: summary_path , reason: :missing_summary }
215+ end
216+
217+ % Row {
218+ id: :stage_parity ,
219+ description: "strict Python/Elixir stage tolerance comparator completed successfully" ,
220+ status: if ( details . pass? , do: :pass , else: :open_defect ) ,
221+ details: Map . delete ( details , :pass? )
222+ }
223+ end
224+
225+ defp run_row ( :python_scripts , coordinator_root , _framework_root , _opts ) do
226+ expected = % {
227+ py: [
228+ "compare_sakana_parity_reports.py" ,
229+ "convert_router_vector_to_safetensors.py" ,
230+ "debug_sakana_large_tensor_chunks.py" ,
231+ "debug_sakana_parity_sample.py" ,
232+ "debug_sakana_router_trace.py" ,
233+ "export_sakana_trinity_safetensors.py"
234+ ] ,
235+ sh: [ "run_expensive_all_selected_decompose.sh" , "run_original_submission_svd_weights.sh" ] ,
236+ md: [ "SVD_PARITY_DEBUG.md" ]
237+ }
238+
239+ script_dir = Path . join ( coordinator_root , "priv/sakana_trinity/scripts" )
240+
241+ missing =
242+ expected
243+ |> Map . values ( )
244+ |> List . flatten ( )
245+ |> Enum . reject ( & File . regular? ( Path . join ( script_dir , & 1 ) ) )
246+
247+ % Row {
248+ id: :python_scripts ,
249+ description: "Sakana Python parity scripts remain preserved as the external reference gate" ,
250+ status: if ( missing == [ ] , do: :pass , else: :open_defect ) ,
251+ details: % {
252+ script_dir: script_dir ,
253+ expected: expected ,
254+ missing: missing ,
255+ preservation: :coordinator_external_reference_until_shim_cutover
256+ }
257+ }
258+ end
259+
161260 defp run_row ( :deferred_cuda_parity , _coordinator_root , _framework_root , _opts ) do
162261 % Row {
163262 id: :deferred_cuda_parity ,
@@ -185,6 +284,68 @@ defmodule StackLab.Examples.TRINITYParityHarness do
185284 }
186285 end
187286
287+ defp selected_rows ( opts ) do
288+ if Keyword . get ( opts , :phase15 , false ) ,
289+ do: @ phase15_rows ,
290+ else: Keyword . get ( opts , :rows , @ default_rows )
291+ end
292+
293+ defp cuda_parity_details ( old_snapshot , new_snapshot , old_log , new_log ) do
294+ with { :old_snapshot , true } <- { :old_snapshot , File . regular? ( old_snapshot ) } ,
295+ { :new_snapshot , true } <- { :new_snapshot , File . regular? ( new_snapshot ) } ,
296+ { :old_log , true } <- { :old_log , File . regular? ( old_log ) } ,
297+ { :new_log , true } <- { :new_log , File . regular? ( new_log ) } do
298+ old_cases = snapshot_cases! ( old_snapshot )
299+ new_cases = snapshot_cases! ( new_snapshot )
300+ count = length ( old_cases )
301+ stable_keys = ~w( id agent_id role_id token_count transcript_hash)
302+ stable_matches = Map . new ( stable_keys , & { & 1 , matching_count ( old_cases , new_cases , & 1 ) } )
303+ route_hash_matches = matching_count ( old_cases , new_cases , "route_hash" )
304+ old_log_pass? = qwen_log_pass? ( old_log )
305+ new_log_pass? = qwen_log_pass? ( new_log )
306+
307+ % {
308+ pass?:
309+ count == 37 and length ( new_cases ) == 37 and old_log_pass? and new_log_pass? and
310+ Enum . all? ( stable_matches , fn { _key , matches } -> matches == 37 end ) ,
311+ old_snapshot: old_snapshot ,
312+ new_snapshot: new_snapshot ,
313+ old_log: old_log ,
314+ new_log: new_log ,
315+ old_case_count: count ,
316+ new_case_count: length ( new_cases ) ,
317+ stable_matches: stable_matches ,
318+ route_hash_matches: route_hash_matches ,
319+ route_hash_policy: :diagnostic_across_processes
320+ }
321+ else
322+ { missing , false } ->
323+ % { pass?: false , reason: :missing_file , missing: missing }
324+ end
325+ end
326+
327+ defp snapshot_cases! ( path ) do
328+ path
329+ |> File . read! ( )
330+ |> Jason . decode! ( )
331+ |> Map . fetch! ( "cases" )
332+ end
333+
334+ defp matching_count ( old_cases , new_cases , key ) do
335+ old_cases
336+ |> Enum . zip ( new_cases )
337+ |> Enum . count ( fn { old_case , new_case } -> Map . get ( old_case , key ) == Map . get ( new_case , key ) end )
338+ end
339+
340+ defp qwen_log_pass? ( path ) do
341+ log = File . read! ( path )
342+
343+ String . contains? ( log , "passed: 37" ) and String . contains? ( log , "failed: 0" ) and
344+ String . contains? ( log , "PASS qwen_router_prompt_eval" )
345+ end
346+
347+ defp phase15_dir ( opts ) , do: Keyword . get ( opts , :phase15_dir , "tmp/phase15" )
348+
188349 defp mix_help_tasks! ( runner , root ) do
189350 output = runner . ( root , [ "help" , "--search" , "trinity" ] )
190351
0 commit comments