Skip to content

AIPYTORCH-1779 Add PyTorch test result metrics to status.json - #127

Open
ethanwee1 wants to merge 5 commits into
ROCm:developfrom
ethanwee1:ethanwee1-pytorch-test-failure-schema-v2
Open

ethanwee1 wants to merge 5 commits into
ROCm:developfrom
ethanwee1:ethanwee1-pytorch-test-failure-schema-v2

Conversation

@ethanwee1

@ethanwee1 ethanwee1 commented Oct 16, 2026 •

Copy link
Copy Markdown

Problem

PyTorch test variants in status.json only report a job status. Consumers can't
see how many tests ran, passed, failed, or were skipped, and can't tell a clean
run from an incomplete report set.

Tracked in AIPYTORCH-1779 (builds on AIPYTORCH-1525).

Changes

  • Schema 2.3: optional per-variant PyTorch test metrics. 2.2 shipped on develop with feat: per-cell build counters on PyTorch/JAX status.json summary #125's summary build counters, so these take the next minor:
    • test_results_complete
    • test_failure_count (test_full and test)
    • test_run_count, test_passed_count, and test_skipped_count (test, standard suite)
  • Trust TheRock's flag: counts are copied from the test workflow's captured outputs only when TheRock reports results_complete: true. TheRock sets that flag only for a complete, valid report set, so Quartz does not re-check shard counts or sums.
  • Attach to the right cell only: metrics go on the (py, ref) cell named by the test workflow's own inputs. When no unique cell matches, they are dropped rather than misattributed. This matters in the shared build run, where one snapshot can derive several cells.
  • merge_variant: the cell merge used by both leaf-merge functions. When a same-attempt snapshot without metrics wins a cell (for example the build run's completion re-deriving cells from job names), the metrics carry over. A newer run attempt never inherits them.
  • Reads: older documents without the fields, including live 2.2 documents, still load and are restamped to 2.3.
  • Docs: the reference JSONC and the schema changelog (a 2.3 entry dated 2026-11-12, referencing AIPYTORCH-1779 Add PyTorch test result metrics to status.json #127, above feat: per-cell build counters on PyTorch/JAX status.json summary #125's 2.2) are updated.

TheRock producer: ROCm/TheRock#10006 (standard and full suite counts).

Validation

  • pytest scripts docs after merging develop: 669 passed, 49 subtests passed. The metric tests cover:
    • full-suite count publication, asserted on the published JSON, and the incomplete-run flag
    • standard-suite attachment to its own cell
    • counts surviving the build refresh in both arrival orders
    • reruns not inheriting counts
    • the incomplete-run flag
    • dropping counts when no unique cell matches
    • the published status.json shape
    • Variant round-trip as cell state, and negative-count rejection
    • restamping a live 2.2 document to 2.3
  • pre-commit run on the changed files (black, mypy, mdformat, whitespace, tabs): passed.
  • The standard-suite counts were checked against real TheRock dev runs: 41787 run / 0 failed / 2649 skipped on Linux gfx94X-dcgpu, and 15032 run / 0 failed / 26385 skipped on Windows gfx120X-all.
  • No live ingest yet: TheRock dev runs don't notify Quartz. Counts flow from nightly and prerelease runs once feat(pytorch): count test outcomes and check report completeness TheRock#10006 merges.

Extend the schema 2.2 variant metrics to the standard suite
(test_pytorch_wheels.yml): test_run_count, test_passed_count,
test_failure_count, and test_skipped_count, published only for complete,
self-consistent reports and attached to the cell named by the test
workflow's inputs. merge_variant keeps metrics when a same-attempt
snapshot without them wins the cell.
@ethanwee1 ethanwee1 changed the title AIPYTORCH-1525 Add PyTorch test failure metrics AIPYTORCH-1525 Add PyTorch test result metrics to status.json Nov 3, 2026
Copy PyTorch test counts whenever TheRock reports results_complete: true
instead of re-checking expected/observed shard counts and count sums;
TheRock already sets the flag only for complete, valid report sets. Trim
the metric tests to the core attachment, ordering, rerun, incomplete, and
publication cases.
… assertion

Date the 2.2 changelog entry for the current change and reference ROCm#127.
Assert the full-suite leaf shape on the published JSON instead of
hasattr on a RunLeaf, which could never fail.
develop's ROCm#125 already shipped status.json schema_version 2.2 (summary
build counters), so this PR's per-variant PyTorch test metrics move to
2.3: SCHEMA_VERSION, the model literal, the reference JSONC, and the
consumer test assertions. Resolve the changelog conflict with a 2.3 entry
above ROCm#125's 2.2 entry, and cover restamping live 2.2 documents.
@ethanwee1 ethanwee1 changed the title AIPYTORCH-1525 Add PyTorch test result metrics to status.json AIPYTORCH-1779 Add PyTorch test result metrics to status.json Nov 16, 2026
@ethanwee1
ethanwee1 marked this pull request as ready for review November 17, 2026 20:23
@ethanwee1
ethanwee1 requested a review from a team November 17, 2026 20:23

@HereThereBeDragons HereThereBeDragons left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks for all the work.

Could you also update the description? ROCm/TheRock#10006 alone does not make the counts flow. It also needs a step in test_wheels that writes the counts (the existing completed notify forwards step outputs) and the full-suite wiring in test_summary.

While reviewing, I found #139. It is not caused by this PR and does not need to be fixed here; it is just for information.

Please also update the schema to 2.4 (#138 bumped it to 2.3)

"completed_at": "2026-04-08T18:00:00Z",
"variants": [
{ "py": "3.12", "torch": "release/2.10", "run_id": 12346900, "run_attempt": 1, "status": "in_progress", "started_at": "2026-04-08T13:00:00Z", "completed_at": null }
{ "py": "3.12", "torch": "release/2.10", "run_id": 12346900, "run_attempt": 1, "test_failure_count": 20, "test_results_complete": true, "status": "failure", "started_at": "2026-04-08T13:00:00Z", "completed_at": "2026-04-08T18:00:00Z" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should always list all test_.. if at least one of them is set.


### Added

- Optional per-variant PyTorch test metrics: `test_results_complete`, plus

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we make it a bit more clear what (test_full and test) means? there will be people not familiar with that for pytorch we have 2 test workflows: test_full and test - and how come there is no test_skipped_count for test_full?

i would argue that independent of test_full or test, the counters being exposed in quartz are the same - to not have any surprise. even if that means that test_skipped_count = 0 always for test_full

further question:
results_complete: true - this should be maybe a bit more clarified that this is a return value of within the therock pytorch test workflows?


# Per-variant test metrics, in on-disk order. A cell carries them only when the
# reporting test run published a complete, self-consistent report set.
TEST_RESULT_FIELDS: Final = (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets use the same naming schema without count as we are already using in the summary:

"test":  { "success": 1, "failure": 1, "in_progress": 1, "cancelled": 0, "skipped": 0 }

so i would suggest a restructering:
have a dict for the test_results and drop all the test_.._count part.

{ "py": "3.10",
"torch": "release/2.10",
"run_id": 12345900,
"run_attempt": 1,
"test_results": {
    "total": 10278, (if we do sum(of all test including skipped), or "executed" to exclude the skipped ones?)
    "passed": 10278, (or "succeeded"?)
    "failed": 0,
    "skipped": 9117,
    "results_complete": true
 },
 "status": "success",
 "started_at": "2026-04-08T11:30:00Z",
 "completed_at": "2026-04-08T12:15:00Z" },

agent suggestion how this then can look like:

Sketch for therock_status_document.py (replaces the five fields, TEST_RESULT_FIELDS, and the test_results() method, which would clash with the field name):

class TestResults(BaseModel):
    executed: int | None = Field(default=None, ge=0)  # ran; excludes skipped
    passed: int | None = Field(default=None, ge=0)
    failed: int | None = Field(default=None, ge=0)  # failures + errors
    skipped: int | None = Field(default=None, ge=0)
    results_complete: bool

_VARIANT_STATE_KEYS = frozenset(
    {"run_id", "run_attempt", "test_results", "status", "started_at", "completed_at"}
)

class Variant(BaseModel):
    ...
    test_results: TestResults | None = None

    def _flatten(self):
        ...
        if self.test_results is not None:
            out["test_results"] = self.test_results.model_dump(exclude_none=True)

def merge_variant(existing, new):
    winner, other = (new, existing) if existing.should_replace(new) else (existing, new)
    same_attempt = (winner.run_id, winner.run_attempt) == (other.run_id, other.run_attempt)
    if winner.test_results is None and other.test_results is not None and same_attempt:
        return winner.model_copy(update={"test_results": other.test_results})
    return winner

Notes:

  • "test_results" must be in _VARIANT_STATE_KEYS. Otherwise _unflatten treats it as a matrix axis and stringifies it, which changes the cell key on reload.
  • In therock_update_status_json.py, _test_results would return TestResults | None, and _attach_test_results would use update={"test_results": results}.

Comment on lines +751 to +756
_TEST_COUNT_OUTPUTS: dict[str, str] = {
"run_test_count": "test_run_count",
"passed_test_count": "test_passed_count",
"failed_test_count": "test_failure_count",
"skipped_test_count": "test_skipped_count",
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

with the nested model, this duplicate declaration is not needed, and the one from therock_status_document can be used.

)


def _nonnegative_output_int(value: object) -> int | None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please use _parse_int from therock_types.py


# More than one reporting job would make attribution to this variant
# ambiguous; fail closed instead of combining their counts.
if len(output_sets) != 1:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is then not needed anymore

if not results or not variants:
return variants
cell = _input_cell(workflow_run, axis_key)
matches = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need for the matches list and the len(matches) != 1 check: _variants_from_jobs groups jobs by (py, ref), so each combination appears at most once in variants. An exact match on the input cell therefore hits zero or one variant, and the fail-closed behavior stays without extra code.

Possible implementation (uses _captured_pytorch_test_results and the nested test_results field from my other comments):

def _attach_test_results(
    workflow_run: WorkflowRunRecord, variants: list[Variant], axis_key: str
) -> list[Variant]:
    """Attach this run's test counts to the cell named by its inputs."""
    results = _captured_pytorch_test_results(workflow_run)
    if results is None:
        return variants
    cell = _input_cell(workflow_run, axis_key)
    return [
        v.model_copy(update={"test_results": results}) if v.matrix == cell else v
        for v in variants
    ]

The exact match is slightly stricter than the current subset match: a partial or empty input cell no longer matches anything. Both TheRock test workflows always send python_version and pytorch_git_ref, so that should not drop real results.

for output, field in _TEST_COUNT_OUTPUTS.items():
count = _nonnegative_output_int(outputs.get(output))
if count is not None:
results[field] = count

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

with the new design we should always list all counters, and if there is at least one counter put "missing" ones to 0.

# reporting test run published a complete, self-consistent report set.
TEST_RESULT_FIELDS: Final = (
"test_run_count",
"test_passed_count",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets also let full test always report all values itself

from pydantic import BaseModel, Field, model_serializer, model_validator

SCHEMA_VERSION: Final = "2.2"
SCHEMA_VERSION: Final = "2.3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please update the schema to 2.4

This branch has not been deployed

No deployments
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.

2 participants