Repository navigation
Enable determinism check in CI #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
938f96b
Added option to run determinism checks, and their results are include…
joniohtonen 37fffbd
Better env check
joniohtonen fed5afd
Rolled back run.py linting
joniohtonen 9864af3
No need for two different variables doing the same thing, changed env…
joniohtonen 50041af
Accidentally removed a condition that's still needed
joniohtonen 418388a
Single module for handling the determinism report
joniohtonen 30460a4
Moved the summary output to the report checking action and left the d…
joniohtonen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # Copyright Advanced Micro Devices, Inc. | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """Schema and I/O for the xFuser determinism check report. | ||
|
|
||
| Written by ``run.py`` after each experiment that ran with the determinism | ||
| check enabled, and read by ``.github/actions/check-determinism-report`` to | ||
| decide whether a benchmark run's architecture should be treated as failed. | ||
| Both sides import this module so the report's shape has a single definition. | ||
| This module deliberately holds only raw data and its I/O: how a report gets | ||
| rendered (e.g. icons, summary tables) and what counts as a failure are | ||
| policy decisions left to the action that consumes the report. | ||
| """ | ||
|
|
||
| import json | ||
| import logging | ||
| from pathlib import Path | ||
| from typing import Any, Dict, List, Optional | ||
|
|
||
| REPORT_FILENAME = "determinism_report.json" | ||
|
|
||
| STATUS_PASSED = "passed" | ||
| STATUS_FAILED = "failed" | ||
| STATUS_ERROR = "error" | ||
| STATUS_UNAVAILABLE = "unavailable" | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| logger.setLevel(logging.INFO) | ||
| if not logger.handlers: | ||
| _handler = logging.StreamHandler() | ||
| _handler.setFormatter( | ||
| logging.Formatter( | ||
| fmt="%(asctime)s - %(levelname)s: %(message)s", | ||
| datefmt="%Y-%m-%d %H:%M:%S", | ||
| ) | ||
| ) | ||
| logger.addHandler(_handler) | ||
| logger.propagate = False | ||
|
|
||
|
|
||
| def make_entry( | ||
| name: str, | ||
| status: str = STATUS_UNAVAILABLE, | ||
| failed_checks: int = 0, | ||
| dump_bytes: int = 0, | ||
| output_directory: str = "", | ||
| ) -> Dict[str, Any]: | ||
| """Build one experiment's entry in the report's ``experiments`` list. | ||
|
|
||
| Args: | ||
| name: Name of the experiment the entry describes. | ||
| status: One of the ``STATUS_*`` constants. | ||
| failed_checks: Number of determinism checks that failed. | ||
| dump_bytes: Bytes occupied by dumps produced by failed checks. | ||
| output_directory: Path to the experiment's output directory. | ||
|
|
||
| Returns: | ||
| A dictionary with the entry's fields, ready to be placed in the | ||
| report's ``experiments`` list. | ||
| """ | ||
| return { | ||
| "name": name, | ||
| "status": status, | ||
| "failed_checks": failed_checks, | ||
| "dump_bytes": dump_bytes, | ||
| "output_directory": output_directory, | ||
| } | ||
|
|
||
|
|
||
| def write_report(results_directory: Path, entries: List[Dict[str, Any]]) -> Optional[Path]: | ||
| """Build and write the determinism report, logging the outcome. | ||
|
|
||
| Aggregates `entries` into a report and writes it to | ||
| ``<results_directory>/determinism_report.json``, creating the directory | ||
| if necessary. Failures are logged rather than raised, so this can be | ||
| called as a fire-and-forget step at the end of a benchmark run. | ||
|
|
||
| Args: | ||
| results_directory: Directory the report is written into. | ||
| entries: Per-experiment entries, as built by `make_entry`. | ||
|
|
||
| Returns: | ||
| The path the report was written to, or None if writing failed. | ||
| """ | ||
| results_directory = Path(results_directory) | ||
| path = results_directory / REPORT_FILENAME | ||
| report = { | ||
| "experiments": entries, | ||
| "failed_experiments": sum(1 for e in entries if e["status"] == STATUS_FAILED), | ||
| "failed_checks": sum(e["failed_checks"] for e in entries), | ||
| } | ||
| try: | ||
| results_directory.mkdir(parents=True, exist_ok=True) | ||
| path.write_text(json.dumps(report, indent=2) + "\n") | ||
| except OSError as exc: | ||
| logger.error("Failed to write determinism report to %s: %s", path, exc) | ||
| return None | ||
|
|
||
| logger.info( | ||
| "Determinism report written to %s (%d of %d experiments failed).", | ||
| path, | ||
| report["failed_experiments"], | ||
| len(entries), | ||
| ) | ||
| return path | ||
|
|
||
|
|
||
| def load_report(results_directory: Path) -> Optional[Dict[str, Any]]: | ||
| """Load the determinism report from a results directory. | ||
|
|
||
| Args: | ||
| results_directory: Directory expected to hold | ||
| ``determinism_report.json``. | ||
|
|
||
| Returns: | ||
| The parsed report, or None if the file doesn't exist. | ||
| """ | ||
| path = Path(results_directory) / REPORT_FILENAME | ||
| if not path.is_file(): | ||
| return None | ||
| return json.loads(path.read_text()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright Advanced Micro Devices, Inc. | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| name: Check Determinism Report | ||
| description: > | ||
| Summarise the determinism report of one architecture and fail when any | ||
| benchmark was non-deterministic, so GitHub's own run-failure notification | ||
| reaches whoever dispatched the run. | ||
|
|
||
| inputs: | ||
| results_dir: | ||
| description: 'Benchmark results directory holding determinism_report.json' | ||
| required: true | ||
| arch: | ||
| description: 'GPU tag from the matrix (e.g. gfx942, mi300, gfx950)' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Check determinism report | ||
| shell: bash | ||
| env: | ||
| RESULTS_DIR: ${{ inputs.results_dir }} | ||
| ARCH: ${{ inputs.arch }} | ||
| run: python3 "$GITHUB_ACTION_PATH/scripts/check-determinism.py" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.