Skip to content

[Simulator] Read TOGSim's results from the file it writes with --result, not from its log - #446

Closed
student-Jungmin wants to merge 1 commit into
pytorchsim-triton-backendfrom
togsim-result-file
Closed

student-Jungmin wants to merge 1 commit into
pytorchsim-triton-backendfrom
togsim-result-file

Conversation

@student-Jungmin

Copy link
Copy Markdown
Collaborator

What

The frontend now reads TOGSim's results from the JSON file TOGSim writes with --result (PSAL-POSTECH/TOGSim#60), not from its log.

  • TOGSimProcess.run_standalone and the FIFO session both pass --result <stamp>.json, beside the .log. run_standalone returns that path.
  • get_result_from_file and its five regexes go. TOGSimProcess.read_result(path) returns the JSON object.
  • driver/select.py takes total_cycles from it. codecache logs simulated: N cycles.
  • A run that wrote no file is a FileNotFoundError. Before, an unparsable log came back as inf cycles with only a warning. A timed candidate still turns the error into a logged inf.
  • FINISH_STR and the unused TOGSIM_RESULT_PATH_KEY go.

Depends on

  1. --result <json>: the run's results as data, the values its end-of-run lines print TOGSim#60 (--result). A TOGSim without the option refuses it.
  2. A PTB pin that carries that TOGSim, then this repository's compiler pin moved to it.

Until then CI fails at the first TOGSim run, so this stays a draft.

Tests

tests/system/test_togsim_result.py now runs a stub Simulator that copies a real result file. It pins three things: the standalone path passes --result and reads the file back, the session leaves its file, and a run without a file is an error. The fixture tests/system/data/togsim_tpuv6e.json replaces the cut log; it comes from a tpuv6e test_matmul.py run.

Checked locally

TOGSim e0c820f (PTB main's pin) with the --result commit cherry-picked, on a PTB 1b35878 toolchain. This repository's pin (PTB 1b1e0607, TOGSim b9c9519) had no local build, so that pair is left to CI.

  • tests/ops/gemm/test_matmul.py with TORCHSIM_TIMING_MODE=1: 11/11 passed.
  • In all 42 result files (11 kernel runs, 31 autotune candidates), total_cycles equals the log's Total execution cycles.
  • test_togsim_result, test_togsim_exit: PASS.

The fixture's version is "e0c820f+result" because e0c820f has no version string; that local build set one. Nothing reads the field.

No cycle numbers change: only the path the frontend reads them from.

…lt, not from its log

get_result_from_file read the end-of-run lines with five regular expressions, and a log it could not
parse came back as infinite cycles without a reason. TOGSim now writes the same values as JSON
(--result <path>, each value recorded where its line is printed), so both launch paths hand it a
path beside the log and TOGSimProcess.read_result returns that object. driver/select.py takes
total_cycles from it; a run that wrote no file is a FileNotFoundError, which a timed candidate
already turns into a logged inf.

The regexes, FINISH_STR and the unused TOGSIM_RESULT_PATH_KEY go. test_togsim_result now runs a
stub Simulator that writes the result of a tpuv6e test_matmul.py run (the fixture replaces the cut
log) and pins that both paths pass --result and read the file back.

This needs a TOGSim with --result: it lands only after the compiler pins one (a TOGSim without the
option refuses it). Checked locally on TOGSim e0c820f (PTB main's pin) with --result
cherry-picked: test_matmul.py in timing mode passes, and total_cycles of all 42 result files (11
kernel runs, 31 autotune candidates) equals the log's Total execution cycles.
@student-Jungmin

Copy link
Copy Markdown
Collaborator Author

Carried into the frontend refactor as part 6/7, #461, with the compiler pin moved to PTB main 70221f4 (TOGSim 5791272, which has --result) and the session log fix. Closing this in favour of #461; the branch is left as it is.

@YWHyuk
YWHyuk deleted the togsim-result-file branch October 27, 2026 07:47
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