Skip to content

torch.npu.TOGSimulator, and usage docs that match the code - #413

Merged
YWHyuk merged 2 commits into
pytorchsim-triton-backendfrom
togsimulator-rename
Oct 22, 2026
Merged

YWHyuk merged 2 commits into
pytorchsim-triton-backendfrom
togsimulator-rename

Conversation

@YWHyuk

@YWHyuk YWHyuk commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

  1. Rename. The context manager is torch.npu.TOGSimulator again, as in v1. torch.npu.simulator is removed and has no alias. The backend class, pytorchsim.simulator.togsim.TOGSimulator, becomes TOGSimProcess, so the device-side and backend names are now different. Every caller is updated: select.py, timing.py, verify.py, the tests and the experiments. The "no TOGSim is open" error used to tell users to call torch.npu.init(), which opens no session; it now tells them to launch inside the with block.
  2. Docs. I audited every usage instruction in README, .claude/CLAUDE.md, docs/worktrees.md and experiments/tpu_validation/README.md against the code, and fixed the instructions that fail or silently do nothing:
    • TOGSIM_CONFIG: setting it raises NoTarget ... is retired at import torch. The docs now say to set TORCHSIM_TARGET.
    • Run settings in the YAML: pytorchsim_timing_mode, pytorchsim_functional_mode, pytorchsim_functional_verify_per_kernel and codegen_autotune_template_topk are only read from env vars (config.py RUN_SETTINGS). The docs now give those env vars.
    • README matmul example: timing is off by default, so the example produced no TOGSim log. It now sets TORCHSIM_TIMING_MODE=1, and the log path is corrected; there is no togsim_result/ subdirectory.
    • README reference YAML: the compiler refused it because it lacked isa and address_map. It is replaced with the shipped tpuv6e machine, and the optional keys kept are only those TOGSim reads.
    • Removed references to things that don't exist or aren't read:
      • tests/system/test_scheduler.py
      • SRAM_BUFFER_PLAN_PATH and tpuv4/
      • TORCHSIM_USE_TIMING_POOLING
      • TORCHSIM_COMPILE_VCIX_MODEL
      • vpu_vector_length_bits
      • STONNE keys (TOGSim aborts on core_type: stonne)
      • scheduler
      • codegen_compiler_optimization
    • Wrong names: booksim is now booksim2 with booksim_config_path, tests/_utils.py is now tests/_pytorchsim_utils.py, and the tpu_validation --config default is tpuv6e.

Verification

Docker local/torchsim_base:ptb-9618c0e:

  • Before vs after the rename: test_togsim_exit, test_togsim_result, test_gqa_decode (timing 1) and an a@b inside the with block (timing 0 and 1) all pass, with identical results before and after. torch.npu.simulator now raises AttributeError.
  • Docs as written:
    • The README reference YAML, used as the machine with timing 1, passes test_add and TOGSim writes its log.
    • TORCHSIM_TIMING_MODE=1 python tests/ops/gemm/test_matmul.py passes, with the log at the documented path.
    • TORCHSIM_FUNCTIONAL_VERIFY_PER_KERNEL=1 runs [FuncVerify].
    • TORCHSIM_FUNCTIONAL_MODE=0 skips Spike and leaves outputs uncomputed. The docs now say so.

Not in this PR (tracked as FIXME issues #414–#417)

  • The Quick start docker image torchsim-ci:v1.1.0 (and v1.0.1 in CLAUDE.md) is the v1 tree. No release image exists for this branch yet.
  • The artifact scripts (run_cycle.sh, run_speed_ils_*.sh) export TOGSIM_CONFIG and name systolic_ws_* configs, which are no longer shipped. The README scopes them to the v1.0.0 image.
  • experiments/*.py fail at lowering unless TORCHSIM_TIMING_MODE is set in the environment: the scripts' setdefault runs after import torch.
  • scripts/util_viewer.py --breakdown <dir> globs for breakdown.json, but the run writes breakdown_<stamp>.json.

The device-side context manager is torch.npu.TOGSimulator again, as in v1;
torch.npu.simulator is gone, with no alias. The backend class it builds,
pytorchsim.simulator.togsim.TOGSimulator, is renamed TOGSimProcess so the two
no longer share a name. Callers in select.py, timing.py, verify.py, the tests
and experiments follow. The "no TOGSim is open" error now says to launch inside
the with block; it said to call torch.npu.init(), which opens no session.
- torch.npu.TOGSimulator in the README and CLAUDE.md examples.
- The machine is TORCHSIM_TARGET; TOGSIM_CONFIG is refused at import, and
  README, CLAUDE.md and docs/worktrees.md still told users to set it.
- Run settings (timing, functional, per-kernel verify, GEMM tile top-k) are
  environment variables; the YAML keys the docs named are not read.
- Timing is off by default: the matmul example sets TORCHSIM_TIMING_MODE=1,
  and its log is $TORCHSIM_LOG_PATH/<stamp>_<hash>.log, not togsim_result/.
- The reference YAML is the shipped tpuv6e machine; the old block lacked isa
  and address_map and was refused. Keys nothing reads are dropped
  (vpu_vector_length_bits, STONNE, scheduler, codegen_compiler_optimization).
- Removed: tests/system/test_scheduler.py, SRAM_BUFFER_PLAN_PATH,
  TORCHSIM_USE_TIMING_POOLING, TORCHSIM_COMPILE_VCIX_MODEL (none exist or are
  read). booksim is booksim2 with booksim_config_path; the test helper is
  tests/_pytorchsim_utils.py; tpu_validation's --config defaults to tpuv6e.
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