Skip to content

studiobench: do not fail UI parity on repetitions that swap two renderings - #11772

Merged
danielhanchen merged 4 commits into
mainfrom
fix/parity-swapped-digests
Sep 24, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/parity-swapped-digests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

studiobench UI parity ("Parity verdict, scored against the null") failed on #11756 (run 35949769378). #11756 only touched the Images, Video and Audio model pickers, not the chat thread. Four "stable actions differing" were reported:

delete_message  parity-result r100K rep0: thread scaffolding outside any message (11265->13287c)
delete_message  parity-result r100K rep1: thread scaffolding outside any message (13287->11265c)
thread_reopen   parity-result r100K rep0: thread scaffolding outside any message (11296->13308c)
thread_reopen   parity-result r100K rep1: thread scaffolding outside any message (13308->11296c)

The run's payloads show an exact swap for both actions. Every capture field of rep0 base equals rep1 head, and rep0 head equals rep1 base, with only the screenshot name differing:

action digests scaffold digests chars
delete_message 9ea715e4 / 9ba6cced 1ae73903 / 47d0503a 11265 / 13287
thread_reopen 2c3f79b2 / d63bc863 5308ec3e / b5e3f91f 11296 / 13308

The style-probe digests swap too, and every message row is identical across the four cells.

The extra ~2000 characters come from image_upload, which runs two actions earlier inside an 800 ms slot. In the cells where that slot was reached, its attachment chip was still in the composer, and the composer sits inside the digested thread root. The screenshots show the chip on exactly the larger side, and across all 8 cells of the result and null-control payloads the larger scaffold appears exactly when image_upload ran.

Which cells reached the slot was a race. The arms run in ABBA order, and the result run went: base missed, head ran, head missed, base ran. Each build rendered both states, so the difference belongs to neither build. corroborated() still counted it as one difference seen in two repetitions, because it treats a digest difference as having no direction. It already applies the opposite reasoning to one-arm failures that blame opposite arms.

Fix

The changes are in tests/studio/studiobench/sweep/ui_parity.py:

  • rendering_of(capture) builds an exact identity for one arm's capture from every rendering field: digests, messages, overlays, styles, mount counts and run state. It returns None when a capture has no digest.
  • compare_all keeps each pair's two renderings.
  • swapped_between_arms(results, min_reps) excuses a differing pair only when another repetition of the same action and rung holds the same two renderings, entire, on the opposite arms. It is an exact match, not a size-sign heuristic, so a treatment that changes anything else breaks the match and the pair is scored as before. A repetition can never be its own partner, and the check is off at min_reps <= 1.
  • report() prints those pairs as "swapped between arms" in an UNCORROBORATED block rather than failing on them, and still counts them as compared.
  • The null-audit scope (actions_needing_an_excuse) and parity_shots.differing_actions apply the same check, so the audit and the evidence screenshots agree with the verdict.

The cost is stated in the docstring. A real change that makes each build render the other's state in some repetition cannot be told from this race at two repetitions, so it is reported as UNCORROBORATED instead of failing.

The underlying carry-over is not changed here: the attachment surviving past image_upload into later actions' captures. It is a separate question for the harness.

Tests

selftest/test_studiobench_swapped_parity.py has 17 tests. They use trimmed copies of the two CI payloads (testdata/pr11756_{result,null}.payload.jsonl.gz), which give the same verdict text as the full payloads.

  • The Studio: add Search Hub to the Images, Video and Audio model pickers #11756 shape: exits 0, needs no null-control excuse, and gets no evidence screenshot.
  • Still fails: a consistent difference in both repetitions; the recorded swap with an extra 17-character change on head; and a swap that differs only in the style probe.
  • Scoping: a swap on one action does not excuse a consistent difference on another, and different rungs or the same repetition label never pair.
  • Old behaviour kept: payloads without digests, and --min-reps 1, behave exactly as before.

Sabotage:

pytest tests/studio/studiobench -n 8: main 1606 passed, this branch 1623 passed.

…rings

The parity verdict on #11756 (run 35949769378) failed on four stable pairs,
delete_message and thread_reopen at r100K, in both repetitions. The two
repetitions held the same two renderings with the arms swapped: rep0's
(base, head) captures are rep1's (head, base) captures, field for field.
The extra 2012 and 2022 characters of scaffold are the attachment chip
image_upload leaves in the composer when it reaches its 800ms slot, and
which cells reached it was a race (base missed, head ran, head missed,
base ran). The null control shows one build rendering both states.

corroborated() already refuses to let two one-arm failures that blame
opposite arms corroborate each other, but treated a digest difference as
having no direction. swapped_between_arms() now finds a differing pair
whose two renderings another repetition of the same action and rung holds
on the opposite arms, compared exactly on every capture field, and report()
prints those as UNCORROBORATED instead of counting them. The null audit
scope and the evidence step apply the same predicate so all three agree.
A consistent difference, or a real change on top of the race, does not
line up as a swap and still fails. Captures without a digest and
--min-reps 1 are scored as before.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T05:12:13.658239Z f135d38 Manual request
🔒 Security Review ⚠️ Failed 2026-09-24T04:52:32.260317Z ded45d9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ded45d9db5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1681 to +1682
if any(c != cell and (b, t) == (treat, base) for _j, c, b, t in group):
out.add(i)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pair swapped observations one-to-one

When a run contains more than two repetitions, one reversed pair causes every matching forward pair to be classified as swapped because each satisfies this any(...). For example, with --min-reps 2, three repetitions producing (R1, R2) and one producing (R2, R1) are all removed before corroboration, so the command passes even though the same build difference appeared three times and only one observation reversed. Match swaps one-to-one, or otherwise leave enough same-direction observations for corroborated() to enforce the requested threshold.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, existence matching let one reversal excuse every same-direction repetition. Fixed in 6df3295: swaps are matched one-to-one, each reversal excusing exactly one observation in the other direction, and the rest go to corroborated() as before. Your example (three (R1, R2), one (R2, R1)) now leaves two firm repetitions; that test fails on the previous commit. Two forwards against two reversals are still all swaps. studiobench suite: 1625 passed.

A differing pair was excused whenever any other repetition held its reverse,
so three repetitions of (R1, R2) against one (R2, R1) were all excused and a
difference seen three times passed. Each reversal now excuses exactly one
observation in the other direction; the rest go to corroborated() as before,
so the example above leaves two firm repetitions.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6df329502d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1688 to +1690
for j, c, b, t in sorted(group, key = lambda e: (e[1], e[0])):
if j not in used and j != i and c != cell and (b, t) == (treat, base):
used.update((i, j))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Deduplicate reversal observations before matching

When the input contains the same reversed repetition in multiple shards, this loop can consume each duplicate as a separate partner. For example, three distinct (R1, R2) repetitions plus (R2, R1) for rep3 duplicated in two shards marks four rows as swapped, leaving only one forward repetition, so corroborated(..., 2) passes instead of retaining two firm differences. The fresh evidence after the one-to-one fix is that matching is one-to-one by row index rather than by the distinct cell labels that corroborated() treats as observations; deduplicate or otherwise consume each (cell, direction) only once.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, matching went by row while corroborated() counts distinct repetitions. Fixed in 36dce57: swaps are matched on distinct (repetition, direction) observations, and all rows of a matched observation are excused together. Your example (three forward repetitions, one reversal carried by two shards) now excuses the reversal and one forward repetition and leaves two firm; a forward repetition in two shards is excused whole. Both tests fail on the previous commit. studiobench suite: 1627 passed.

One-to-one by row let a reversed repetition carried by two shards partner
two forward repetitions, while corroborated() counts it once. Swaps are now
matched on distinct (repetition, direction) observations, and every row of a
matched observation is excused together, so the duplicate leaves two firm
forward repetitions in Codex's example.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36dce5799b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1686 to +1688
observations: dict[tuple[str, str, str], list[int]] = collections.defaultdict(list)
for i, cell, base, treat in group:
observations[(cell, base, treat)].append(i)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Match each repetition at most once

When one cell appears in multiple shards with opposite outcomes, keying observations by (cell, base, treat) allows that single repetition to participate in two swap matches. For example, rep0 recorded as both A→B and B→A, plus rep1 A→B and rep2 B→A, marks all four rows swapped and the gate passes, even though corroborated() treats rep0 as only one observation and one direction should remain firm across two distinct cells. The fresh evidence beyond the prior duplicate-shard fix is this contradictory-direction duplicate: deduplicate or reject ambiguity by cell before matching so a repetition can be consumed only once.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, a repetition could still join two matches through opposite-direction duplicates. Fixed in f135d38: the repetition is now the unit. It takes part in at most one swap, and a repetition that holds more than one outcome pair (shards that disagree, as in your example) is never excused. Your example now excuses only rep1 and rep2 and leaves rep0 as a difference; that test fails on the previous commit. studiobench suite: 1629 passed.

Keying observations on (repetition, direction) let a repetition recorded by
two shards in opposite directions join two swaps, excusing a difference seen
in two other repetitions. A repetition is now the unit: it takes part in at
most one swap, and one that holds more than one outcome pair (shards that
disagree) is never excused.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: f135d3819f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 9815e76 into main Sep 24, 2026
26 of 27 checks passed
@danielhanchen
danielhanchen deleted the fix/parity-swapped-digests branch September 24, 2026 05:13
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…rings (unslothai#11772)

* studiobench: do not fail UI parity on repetitions that swap two renderings

The parity verdict on unslothai#11756 (run 35949769378) failed on four stable pairs,
delete_message and thread_reopen at r100K, in both repetitions. The two
repetitions held the same two renderings with the arms swapped: rep0's
(base, head) captures are rep1's (head, base) captures, field for field.
The extra 2012 and 2022 characters of scaffold are the attachment chip
image_upload leaves in the composer when it reaches its 800ms slot, and
which cells reached it was a race (base missed, head ran, head missed,
base ran). The null control shows one build rendering both states.

corroborated() already refuses to let two one-arm failures that blame
opposite arms corroborate each other, but treated a digest difference as
having no direction. swapped_between_arms() now finds a differing pair
whose two renderings another repetition of the same action and rung holds
on the opposite arms, compared exactly on every capture field, and report()
prints those as UNCORROBORATED instead of counting them. The null audit
scope and the evidence step apply the same predicate so all three agree.
A consistent difference, or a real change on top of the race, does not
line up as a swap and still fails. Captures without a digest and
--min-reps 1 are scored as before.

* studiobench parity: match swapped repetitions one-to-one

A differing pair was excused whenever any other repetition held its reverse,
so three repetitions of (R1, R2) against one (R2, R1) were all excused and a
difference seen three times passed. Each reversal now excuses exactly one
observation in the other direction; the rest go to corroborated() as before,
so the example above leaves two firm repetitions.

* studiobench parity: match swaps by observation, not row

One-to-one by row let a reversed repetition carried by two shards partner
two forward repetitions, while corroborated() counts it once. Swaps are now
matched on distinct (repetition, direction) observations, and every row of a
matched observation is excused together, so the duplicate leaves two firm
forward repetitions in Codex's example.

* studiobench parity: each repetition joins at most one swap

Keying observations on (repetition, direction) let a repetition recorded by
two shards in opposite directions join two swaps, excusing a difference seen
in two other repetitions. A repetition is now the unit: it takes part in at
most one swap, and one that holds more than one outcome pair (shards that
disagree) is never excused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant