Skip to content

[Refactor 7/9] One place for each fact: tool paths in config, the runtime attribute directory, build identity, launch hooks, template records - #462

Merged
student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-7c-cleanup
Oct 24, 2026
Merged

student-Jungmin merged 1 commit into
pytorchsim-triton-backendfrom
refactor/r441-7c-cleanup

Conversation

@student-Jungmin

@student-Jungmin student-Jungmin commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Draft: waiting for verification (CI and the validation reports) before review.

Part 7 of 9 of the frontend refactor. It is one commit of this part's final state. Stacked on #461 (refactor/r441-7b-togsim-result); review only this PR's commit.

What

  • Tool paths in config. Spike's and pk's paths and the Spike job count are config.CONFIG_SPIKE_PATH, CONFIG_PK_PATH and CONFIG_SPIKE_JOBS, beside gem5's. VCIX_ENV_ROOT's default is stated once (CONFIG_VCIX_ENV_ROOT). The variables, their order and their defaults are unchanged.

  • One runtime attribute directory. compiler_bridge.runtime_attribute_dir(workdir) is read by both the functional replay and timing. A kernel that declares none hands TOGSim no --attribute_path.

  • codecache.py is three files:

    • launch_hooks.py: the observers, torchsim_extern, and notify_launch, which the launcher calls;
    • build_identity.py: the stamp of what a workdir was built with, and cached_elf;
    • codecache.py: torchsim_compile and the launcher.

    The generated wrapper imports torchsim_extern from launch_hooks.

  • template_timing.py keeps the timing (time_choices, time_module). template_record.py holds where a choice came from, the timed templates, the record and the digests.

  • contract.py: its four parts are listed in its docstring and sectioned, and its docstrings are three lines at most.

Behavior change

  • The identity's "the compiler" key is "compiler", so every cached workdir is rebuilt once.
  • clear_stale raises a removal that fails for any reason except the file being gone already.
  • The breakdown's exit hook logs a write that fails.
  • TOGSimProcess no longer reads the machine YAML it never used (load_yaml, config_yaml). A missing file is still refused; TOGSim refuses a malformed one.

Pinned by:

  • test_cache_identity: the key, a failed removal raised, an already-gone one not;
  • test_breakdown_viewer: the warning;
  • test_togsim_exit: a missing machine file refused;
  • test_attribute_sources: no directory for a kernel that declares none.

Checked locally

PTB 70221f4 with TOGSim 5791272:

  • compileall;
  • test_add, test_eager, test_patch_scope, test_cache_identity, test_tuned_blocks_on_hit, test_togsim_result, test_togsim_exit, test_breakdown_viewer, test_attribute_sources, test_bundle_reuse, test_module_form, test_device_interface, test_custom_fused_kernel, test_topk, test_grouped_mm, test_user_triton_kernel, test_histc;
  • test_matmul (11/11) and test_select in timing mode;
  • test_add with TORCHSIM_BREAKDOWN=1.

All pass. Files whose only change here is an import line (scripts/ci/bundle.py, scripts/selection_merge.py, tests/ops/gemm/test_grouped_mm.py) keep their comments.

…attribute directory, the build identity, launch hooks and template records

Spike's and pk's paths and the Spike job count are config's (CONFIG_SPIKE_PATH, CONFIG_PK_PATH,
CONFIG_SPIKE_JOBS), beside gem5's, and VCIX_ENV_ROOT's default is stated once (CONFIG_VCIX_ENV_ROOT);
the variables, their order and their defaults are unchanged. The runtime attribute directory is
compiler_bridge.runtime_attribute_dir, read by the functional replay and by timing; a kernel that
declares none hands TOGSim no --attribute_path.

codecache.py is three files: launch_hooks.py (the observers, torchsim_extern, notify_launch, which
the launcher calls), build_identity.py (the stamp of what a workdir was built with, and cached_elf),
and codecache.py (torchsim_compile and the launcher). The generated wrapper imports torchsim_extern
from launch_hooks. template_timing.py keeps the timing (time_choices, time_module); template_record.py
holds where a choice came from, the timed templates, the record and the digests. contract.py's four
parts are listed in its docstring and sectioned, its docstrings three lines at most.

Behavior: the identity's "the compiler" key is "compiler", so every cached workdir is rebuilt once.
clear_stale raises a removal that fails for any reason but the file being gone already, and the
breakdown's exit hook logs a write that fails. TOGSimProcess no longer reads the machine YAML it never
used (load_yaml, config_yaml): a missing file is still refused, a malformed one by TOGSim.

Tests pin each of these: test_cache_identity (the compiler key; a removal that fails is raised, one already
gone is not), test_breakdown_viewer (a breakdown that cannot be written is logged), test_togsim_exit (a
session on a missing machine file is refused), test_attribute_sources (no runtime attribute directory
for a kernel that declares none).

Checked on PTB 70221f4 with TOGSim 5791272: compileall; test_add, test_eager, test_patch_scope,
test_cache_identity, test_tuned_blocks_on_hit, test_togsim_result, test_togsim_exit,
test_breakdown_viewer, test_attribute_sources, test_bundle_reuse, test_module_form,
test_device_interface, test_custom_fused_kernel, test_topk, test_grouped_mm, test_user_triton_kernel,
test_histc; test_matmul (11/11) and test_select in timing mode; test_add with TORCHSIM_BREAKDOWN=1.
@student-Jungmin student-Jungmin changed the title [Refactor 7/8] One place for each fact: tool paths in config, the runtime attribute directory, build identity, launch hooks, template records [Refactor 7/9] One place for each fact: tool paths in config, the runtime attribute directory, build identity, launch hooks, template records Oct 24, 2026
@student-Jungmin
student-Jungmin marked this pull request as ready for review October 24, 2026 14:01
@student-Jungmin
student-Jungmin changed the base branch from refactor/r441-7b-togsim-result to pytorchsim-triton-backend October 24, 2026 14:01
@student-Jungmin
student-Jungmin merged commit 084c125 into pytorchsim-triton-backend Oct 24, 2026
@YWHyuk
YWHyuk deleted the refactor/r441-7c-cleanup branch October 27, 2026 07:46
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