Repository navigation
Call the compiler package's Spike launcher instead of a copy - #434
Merged
Merged
Conversation
…her, not its own copy functional.py:253-511 was a second copy of the compiler's Spike launcher (SPIKE/PK aside: ITEMSIZE, artifact, argv_order, argv_scalars, grid3, writable, splittable, nbytes, _run, launch, _jobs, _split, _worker_path, _prepare, _merge_outputs, _merge_traces), kept in step by hand. The compiler now ships it as pytorchsim_triton_compiler.runtime.spike (PyTorchSim-Triton-Backend runtime/launcher-in-package), so this file keeps only what is PyTorchSim's: tensors <-> runtime/*.raw, the replay cache, and its own config names for Spike, pk and the job count (TORCHSIM_SPIKE / TORCHSIM_PK / TORCHSIM_SPIKE_JOBS, each falling back to the TORCHSIM_COMPILE_* spelling as before). launch() resolves the ELF and run_options() and hands both to spike.launch(); a missing ELF or target is a SpikeError as before. compiler_bridge.compiler_module(name) is compiler_contract() generalised to any module of the package, with the same "imports from the checkout TORCHSIM_COMPILE_DIR names" check. Needs the compiler pin to carry runtime/spike.py (next commit). Checked in topk-ptb:pts-base-92028c8, torch.manual_seed(0), before = PyTorchSim 069878a with PTB main 602777c (5fb15ee, rebased onto, moves only the pin file), after = this commit with PTB runtime/launcher-in-package 127eaa3: tests/ops/elementwise/test_add.py, tests/ops/reduce/test_reduce.py, tests/ops/reduce/test_softmax.py, test_add.py with TORCHSIM_SPIKE_JOBS=4, and with TORCHSIM_SPIKE_JOBS=4 tests/ops/gemm/test_bmm.py (16, 12 and 4 programs over 4 processes), tests/ops/misc/test_indirect_access.py and test_inplace_partial_write.py (inout: one process). Same verdicts, and all 125 runtime/*.raw and indirect_access dumps byte-identical.
YWHyuk
force-pushed
the
item10/launcher-from-ptb
branch
from
October 23, 2026 10:18
a5ad788 to
14fb0ae
Compare
YWHyuk
marked this pull request as ready for review
October 23, 2026 10:18
YWHyuk
added a commit
that referenced
this pull request
Oct 23, 2026
…ernel object format 7 The compiler's kernel object 7 (PTB #298) names a hidden output, runtime_attributes.raw, in which the ELF records what a TOG reads from data: a DMA offset, a loop bound, a gather's index tile. Handing it to main(), splitting it over workers and turning it into runtime/runtime_attribute/ (programs.bin and attr_<key>_<id>.bin) is the compiler's launcher (runtime/spike.py: start_hidden, merge_hidden, record_attributes), which functional.launch calls since #434. What stays here is PyTorchSim's: the replay cache saves and restores that directory with the outputs, and a saved run without it is a miss. Refs PSAL-POSTECH/PyTorchSim-Triton-Backend#298
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #428
Why
pytorchsim/simulator/functional.pycarried a ~250-line copy of the compiler's Spike launcher (split, clash fallback, inout single-process, trace merge). PSAL-POSTECH/PyTorchSim-Triton-Backend#330 moves that launcher into the compiler package; this PR calls it instead of keeping the copy.What changed (before -> after)
e9e6ae3—functional.pycallsspike.launch()from the compiler package and deletes the copied helpers (net −250 lines). Kept: tensor <->.rawI/O, the replay cache, PTS's ownTORCHSIM_SPIKE/TORCHSIM_PK/TORCHSIM_SPIKE_JOBSwith the existingTORCHSIM_COMPILE_*fallbacks. Newcompiler_bridge.compiler_module(name)generalisescompiler_contract()with the same check that the import comes from theTORCHSIM_COMPILE_DIRcheckout.codecache.py:23remains the only importer and calls onlyfunctional.run.Verification (seed 0; implementer + independent reviewer, separate containers)
test_add,test_reduce,test_softmax,test_layernorm,test_user_triton_kernel(24 kernels with scalars ->scalar_values); withTORCHSIM_SPIKE_JOBS=4:gemm/test_bmm(16/12/4 programs over 4 processes),misc/test_indirect_access,misc/test_inplace_partial_write(inout, one process)..rawand index-dump files byte-identical (125 implementer, 111 reviewer). The after run goes through the new launcher (log prefix[spike], inout line names the argument).tog_replay/tests/runtime/devicereferences in PTS.Dependencies
Resolved. PSAL-POSTECH/PyTorchSim-Triton-Backend#330 is merged as 479243b on PTB main, and this branch's base already pins it (#436, 8967db2). The provisional pin commit (127eaa3) is dropped; the PR is the
functional.pycommit alone, rebased onto the current base.Open issues
[spike], inout message names the argument); thedma_accesserror no longer names an env var; Spike dump directories are created afterrun_options; a scalar with no value raisesko.ObjectErrorinstead ofSpikeError(bothRuntimeError, nothing catches by class).functional.py:26-30_NP_CARRIERstill duplicatesko.NP_DTYPE(bool->bool here vs bool->int8 there), follow-up.🤖 Generated with Claude Code
https://claude.ai/code/session_01UnJWSTNtd6944XAzy4bhk5