From 18d7babf7cf7c4ed15fd68f418bf5bf8d31d233a Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Mon, 15 Dec 2025 21:54:43 +0900 Subject: [PATCH 1/9] [Tutorial] Fix wrong config name --- PyTorchSimFrontend/extension_config.py | 2 +- tutorial/session1/LogAnalysis.ipynb | 2 +- tutorial/session2/Hands_on.ipynb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PyTorchSimFrontend/extension_config.py b/PyTorchSimFrontend/extension_config.py index ab8aea69..2b1b3102 100644 --- a/PyTorchSimFrontend/extension_config.py +++ b/PyTorchSimFrontend/extension_config.py @@ -103,7 +103,7 @@ def __getattr__(name): if name == "CONFIG_TORCHSIM_DUMP_PATH": return os.environ.get('TORCHSIM_DUMP_PATH', default = CONFIG_TORCHSIM_DIR) if name == "CONFIG_TORCHSIM_LOG_PATH": - return os.environ.get('TORCHSIM_DUMP_LOG_PATH', default = os.path.join(CONFIG_TORCHSIM_DIR, "togsim_results")) + return os.environ.get('TORCHSIM_LOG_PATH', default = os.path.join(CONFIG_TORCHSIM_DIR, "togsim_results")) if name == "CONFIG_TOGSIM_EAGER_MODE": return int(os.environ.get("TOGSIM_EAGER_MODE", default=False)) diff --git a/tutorial/session1/LogAnalysis.ipynb b/tutorial/session1/LogAnalysis.ipynb index d3207af1..a82737db 100644 --- a/tutorial/session1/LogAnalysis.ipynb +++ b/tutorial/session1/LogAnalysis.ipynb @@ -19,7 +19,7 @@ "base_dir = os.environ.get('TORCHSIM_DIR', default='/workspace/PyTorchSim')\n", "sys.path.append(base_dir)\n", "os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_timing_only.yml\"\n", - "os.environ['TORCHSIM_DUMP_LOG_PATH']=os.path.join(os.getcwd(), \"togsim_results\")" + "os.environ['TORCHSIM_LOG_PATH']=os.path.join(os.getcwd(), \"togsim_results\")" ] }, { diff --git a/tutorial/session2/Hands_on.ipynb b/tutorial/session2/Hands_on.ipynb index 33ec1a28..2d5a5cdc 100644 --- a/tutorial/session2/Hands_on.ipynb +++ b/tutorial/session2/Hands_on.ipynb @@ -32,6 +32,7 @@ "import torch._dynamo\n", "import torch.utils.cpp_extension\n", "base_dir = os.environ.get('TORCHSIM_DIR', default='/workspace/PyTorchSim')\n", + "os.environ['TORCHSIM_DUMP_PATH']=os.path.join(os.getcwd(), \"togsim_results\")\n", "sys.path.append(base_dir)\n", "\n", "from Scheduler.scheduler import PyTorchSimRunner\n", From 1e4d72a0fea00c80ef681b9da6bec783f4b2bd93 Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Wed, 17 Dec 2025 22:01:36 +0900 Subject: [PATCH 2/9] [Fix] configuration reference in DNNServing.ipynb --- tutorial/session1/DNNServing.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/session1/DNNServing.ipynb b/tutorial/session1/DNNServing.ipynb index b38bfe6a..56ad5ab6 100644 --- a/tutorial/session1/DNNServing.ipynb +++ b/tutorial/session1/DNNServing.ipynb @@ -38,7 +38,7 @@ "from Scheduler.scheduler import Scheduler, SchedulerDNNModel, Request\n", "from PyTorchSimFrontend import extension_config\n", "\n", - "scheduler = Scheduler(num_request_queue=1, engine_select=Scheduler.FIFO_ENGINE, togsim_config=extension_config.TOGSIM_CONFIG)\n", + "scheduler = Scheduler(num_request_queue=1, engine_select=Scheduler.FIFO_ENGINE, togsim_config=extension_config.CONFIG_TOGSIM_CONFIG)\n", "device = scheduler.execution_engine.module.custom_device()\n", "\n", "model = resnet18().eval()\n", From 232c4a69053f0082e254e536cfcd04dddbc9c2c0 Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Wed, 17 Dec 2025 22:02:27 +0900 Subject: [PATCH 3/9] Change log level from warn to debug for unused tags --- TOGSim/include/DMA.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TOGSim/include/DMA.h b/TOGSim/include/DMA.h index 2f41c6f3..3056c626 100644 --- a/TOGSim/include/DMA.h +++ b/TOGSim/include/DMA.h @@ -62,7 +62,7 @@ class DMA { const std::vector& tag_key = tag_entry.first; uint32_t value = tag_entry.second; if (value == 1) { - spdlog::warn("[Tag Table][{}] Unused tag found: (key={}, val={})", + spdlog::debug("[Tag Table][{}] Unused tag found: (key={}, val={})", subgraph_id, fmt::format("[{}]", fmt::join(tag_key, ", ")), value); } } @@ -134,4 +134,4 @@ class DMA { std::queue _pending_accesses; bool _generated_once = false; }; -#endif \ No newline at end of file +#endif From 8b0f5354bcfce195d7a48498d0dde824be278a94 Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Wed, 17 Dec 2025 22:08:26 +0900 Subject: [PATCH 4/9] Add placeholder echo command in Dockerfile Added a placeholder echo command for future removal. --- tutorial/jupyterhub/Dockerfile.ksc2025 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorial/jupyterhub/Dockerfile.ksc2025 b/tutorial/jupyterhub/Dockerfile.ksc2025 index 9eaec15a..4993538a 100644 --- a/tutorial/jupyterhub/Dockerfile.ksc2025 +++ b/tutorial/jupyterhub/Dockerfile.ksc2025 @@ -80,6 +80,8 @@ RUN git clone https://github.com/riscv-software-src/riscv-pk.git && \ RUN apt install ninja-build && pip install onnx matplotlib && pip install --user conan==1.56.0 # Prepare PyTorchSim project +RUN echo "Remove me!" + RUN git clone https://github.com/PSAL-POSTECH/PyTorchSim.git --branch tutorial RUN cd PyTorchSim/TOGSim && \ git submodule update --recursive --init && \ From 602131571983a5b752bcea4bd929043aca556023 Mon Sep 17 00:00:00 2001 From: Yunseon Date: Wed, 17 Dec 2025 22:53:21 +0900 Subject: [PATCH 5/9] [Frontend] prevent reload device --- Scheduler/scheduler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Scheduler/scheduler.py b/Scheduler/scheduler.py index 98ebb1d5..34f0eda4 100644 --- a/Scheduler/scheduler.py +++ b/Scheduler/scheduler.py @@ -163,6 +163,8 @@ def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: @staticmethod def setup_device(): + if cls._npu_module is not None: + return cls._npu_module source_file_path = os.path.dirname(os.path.abspath(__file__)) source_file = os.path.join( source_file_path, f"{extension_config.CONFIG_TORCHSIM_DIR}/PyTorchSimFrontend/extension_device.cpp" @@ -201,6 +203,7 @@ def setup_device(): get_wrapper_codegen_for_device("npu") == ExtensionWrapperCodegen ) + cls._npu_module = module return module def submit(self, batched_req, partition_idx) -> List[RequestReturn]: From 7c5dcccd539b9174da3ff8e1751117fa72910fd6 Mon Sep 17 00:00:00 2001 From: Yunseon Date: Wed, 17 Dec 2025 22:59:39 +0900 Subject: [PATCH 6/9] [fix] setup_device to class method --- Scheduler/scheduler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scheduler/scheduler.py b/Scheduler/scheduler.py index 34f0eda4..94092723 100644 --- a/Scheduler/scheduler.py +++ b/Scheduler/scheduler.py @@ -144,6 +144,7 @@ class PyTorchSimRunner: PARTITION_BUSY = 0 PARTITION_IDLE = 1 SELECT_NOTHING = 2 + _npu_module = None def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: self.module = self.setup_device() self.num_partion = num_partion @@ -161,7 +162,7 @@ def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: # Dry run for compile and create generator os.environ["TOGSIM_EAGER_MODE"] = "1" - @staticmethod + @classmethod def setup_device(): if cls._npu_module is not None: return cls._npu_module From 88d9eb8f74f03566034e2de95323f6662b3cd183 Mon Sep 17 00:00:00 2001 From: Yunseon Date: Wed, 17 Dec 2025 23:13:59 +0900 Subject: [PATCH 7/9] [Fix] typo in TOGSIM_CONFIG --- tutorial/session1/DNNServing.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial/session1/DNNServing.ipynb b/tutorial/session1/DNNServing.ipynb index 56ad5ab6..741f463f 100644 --- a/tutorial/session1/DNNServing.ipynb +++ b/tutorial/session1/DNNServing.ipynb @@ -83,7 +83,7 @@ "target_model1 = resnet18().eval()\n", "\n", "# Init scheduler\n", - "scheduler = Scheduler(num_request_queue=1, max_batch=32, engine_select=Scheduler.FIFO_ENGINE, togsim_config=extension_config.TOGSIM_CONFIG)\n", + "scheduler = Scheduler(num_request_queue=1, max_batch=32, engine_select=Scheduler.FIFO_ENGINE, togsim_config=extension_config.CONFIG_TOGSIM_CONFIG)\n", "# Register compiled model\n", "opt_model1 = torch.compile(target_model1.to(device=scheduler.execution_engine.module.custom_device(), memory_format=torch.channels_last), dynamic=False)\n", "SchedulerDNNModel.register_model(\"resnet18\", opt_model1)\n", From d1ffac21708a30d40ff378e315c00c44d840fdc5 Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Wed, 17 Dec 2025 23:15:10 +0900 Subject: [PATCH 8/9] Remove echo command from Dockerfile Removed unnecessary echo command from Dockerfile. --- tutorial/jupyterhub/Dockerfile.ksc2025 | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorial/jupyterhub/Dockerfile.ksc2025 b/tutorial/jupyterhub/Dockerfile.ksc2025 index 4993538a..9eaec15a 100644 --- a/tutorial/jupyterhub/Dockerfile.ksc2025 +++ b/tutorial/jupyterhub/Dockerfile.ksc2025 @@ -80,8 +80,6 @@ RUN git clone https://github.com/riscv-software-src/riscv-pk.git && \ RUN apt install ninja-build && pip install onnx matplotlib && pip install --user conan==1.56.0 # Prepare PyTorchSim project -RUN echo "Remove me!" - RUN git clone https://github.com/PSAL-POSTECH/PyTorchSim.git --branch tutorial RUN cd PyTorchSim/TOGSim && \ git submodule update --recursive --init && \ From 7c45f8015e1a83b2abc177c25e3b2d66ff2ac0a7 Mon Sep 17 00:00:00 2001 From: Wonhyuk Yang Date: Thu, 18 Dec 2025 00:21:44 +0900 Subject: [PATCH 9/9] Refactor NPU module variable naming convention --- Scheduler/scheduler.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Scheduler/scheduler.py b/Scheduler/scheduler.py index 94092723..8aa849b1 100644 --- a/Scheduler/scheduler.py +++ b/Scheduler/scheduler.py @@ -144,7 +144,7 @@ class PyTorchSimRunner: PARTITION_BUSY = 0 PARTITION_IDLE = 1 SELECT_NOTHING = 2 - _npu_module = None + NPU_MODULE = None def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: self.module = self.setup_device() self.num_partion = num_partion @@ -163,9 +163,9 @@ def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: os.environ["TOGSIM_EAGER_MODE"] = "1" @classmethod - def setup_device(): - if cls._npu_module is not None: - return cls._npu_module + def setup_device(cls): + if cls.NPU_MODULE is not None: + return cls.NPU_MODULE source_file_path = os.path.dirname(os.path.abspath(__file__)) source_file = os.path.join( source_file_path, f"{extension_config.CONFIG_TORCHSIM_DIR}/PyTorchSimFrontend/extension_device.cpp" @@ -204,7 +204,7 @@ def setup_device(): get_wrapper_codegen_for_device("npu") == ExtensionWrapperCodegen ) - cls._npu_module = module + cls.NPU_MODULE = module return module def submit(self, batched_req, partition_idx) -> List[RequestReturn]: