Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PyTorchSimFrontend/extension_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 6 additions & 2 deletions Scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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]:
Expand Down
4 changes: 2 additions & 2 deletions TOGSim/include/DMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DMA {
const std::vector<int>& 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);
}
}
Expand Down Expand Up @@ -134,4 +134,4 @@ class DMA {
std::queue<mem_fetch*> _pending_accesses;
bool _generated_once = false;
};
#endif
#endif
4 changes: 2 additions & 2 deletions tutorial/session1/DNNServing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tutorial/session1/LogAnalysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions tutorial/session2/Hands_on.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down