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/Scheduler/scheduler.py b/Scheduler/scheduler.py index 98ebb1d5..8aa849b1 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,8 +162,10 @@ def __init__(self, tog_simulator : TOGSimulator, num_partion=1) -> None: # Dry run for compile and create generator os.environ["TOGSIM_EAGER_MODE"] = "1" - @staticmethod - def setup_device(): + @classmethod + 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" @@ -201,6 +204,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]: 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 diff --git a/tutorial/session1/DNNServing.ipynb b/tutorial/session1/DNNServing.ipynb index b38bfe6a..741f463f 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", @@ -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", 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",