Skip to content

Commit c7d6faf

Browse files
committed
[Tutorial] Basic usage
1 parent 5e26917 commit c7d6faf

14 files changed

Lines changed: 236 additions & 22 deletions

configs/systolic_ws_128x128_c1_simple_noc_tpuv3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"pytorchsim_functional_mode" : 1,
2525
"pytorchsim_timing_mode" : 1,
2626

27-
"codegen_mapping_strategy" : "autotune",
27+
"codegen_mapping_strategy" : "heuristic",
2828
"codegen_external_mapping_file" : "",
2929
"codegen_autotune_max_retry": 10,
3030
"codegen_autotune_template_topk": 4,

configs/systolic_ws_128x128_c2_simple_noc_tpuv2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"pytorchsim_functional_mode" : 1,
2424
"pytorchsim_timing_mode" : 1,
2525

26-
"codegen_mapping_strategy" : "autotune",
26+
"codegen_mapping_strategy" : "heuristic",
2727
"codegen_external_mapping_file" : "",
2828
"codegen_autotune_max_retry": 10,
2929
"codegen_autotune_template_topk": 4,

configs/systolic_ws_128x128_c2_simple_noc_tpuv3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"pytorchsim_functional_mode" : 1,
2525
"pytorchsim_timing_mode" : 1,
2626

27-
"codegen_mapping_strategy" : "autotune",
27+
"codegen_mapping_strategy" : "heuristic",
2828
"codegen_external_mapping_file" : "",
2929
"codegen_autotune_max_retry": 10,
3030
"codegen_autotune_template_topk": 4,

tutorial/session1/CompilerOptimization.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"import sys\n",
1919
"base_dir = os.environ.get('TORCHSIM_DIR', default='/workspace/PyTorchSim')\n",
2020
"sys.path.append(base_dir)\n",
21-
"os.environ['pytorchsim_functional_mode']=\"0\"\n",
22-
"os.environ['TORCHSIM_TIMING_MODE']=\"1\""
21+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_timing_only.json\""
2322
]
2423
},
2524
{
@@ -72,7 +71,7 @@
7271
"outputs": [],
7372
"source": [
7473
"os.environ['TORCHSIM_DUMP_PATH']=os.path.join(base_dir, \"non_fused\")\n",
75-
"os.environ['TORCHSIM_COMPILER_OPTIMIZATION']=\"none\"\n",
74+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_no_compiler_optimization.json\"\n",
7675
"\n",
7776
"input = torch.randn(1024, 1024).to(device=device)\n",
7877
"weight = torch.randn(1024, 1024).to(device=device)\n",

tutorial/session1/ExecutionMode.ipynb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
"from Scheduler.scheduler import PyTorchSimRunner\n",
3737
"device = PyTorchSimRunner.setup_device().custom_device()\n",
3838
"\n",
39-
"os.environ['pytorchsim_functional_mode']=\"1\"\n",
40-
"os.environ['pytorchsim_timing_mode']=\"1\"\n",
41-
"\n",
4239
"input = torch.randn(1024, 1024).to(device=device)\n",
4340
"weight = torch.randn(1024, 1024).to(device=device)\n",
4441
"\n",
@@ -59,8 +56,7 @@
5956
"metadata": {},
6057
"outputs": [],
6158
"source": [
62-
"os.environ['pytorchsim_functional_mode']=\"1\"\n",
63-
"os.environ['pytorchsim_timing_mode']=\"0\"\n",
59+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_functional_only.json\"\n",
6460
"\n",
6561
"input = torch.randn(1024, 1024).to(device=device)\n",
6662
"weight = torch.randn(1024, 1024).to(device=device)\n",
@@ -82,8 +78,7 @@
8278
"metadata": {},
8379
"outputs": [],
8480
"source": [
85-
"os.environ['pytorchsim_functional_mode']=\"0\"\n",
86-
"os.environ['pytorchsim_timing_mode']=\"1\"\n",
81+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_timing_only.json\"\n",
8782
"\n",
8883
"input = torch.randn(1024, 1024).to(device=device)\n",
8984
"weight = torch.randn(1024, 1024).to(device=device)\n",
@@ -106,7 +101,7 @@
106101
"metadata": {},
107102
"outputs": [],
108103
"source": [
109-
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/configs/systolic_ws_128x128_c1_simple_noc_tpuv3.json\"\n",
104+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_timing_only.json\"\n",
110105
"\n",
111106
"input = torch.randn(2048, 2048).to(device=device)\n",
112107
"weight = torch.randn(2048, 2048).to(device=device)\n",
@@ -137,7 +132,7 @@
137132
"metadata": {},
138133
"outputs": [],
139134
"source": [
140-
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/configs/systolic_ws_128x128_c2_simple_noc_tpuv3.json\"\n",
135+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_2_cores.json\"\n",
141136
"\n",
142137
"input = torch.randn(2048, 2048).to(device=device)\n",
143138
"weight = torch.randn(2048, 2048).to(device=device)\n",

tutorial/session1/LogAnalysis.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"import sys\n",
1919
"base_dir = os.environ.get('TORCHSIM_DIR', default='/workspace/PyTorchSim')\n",
2020
"sys.path.append(base_dir)\n",
21-
"os.environ['pytorchsim_functional_mode']=\"0\"\n",
22-
"os.environ['pytorchsim_timing_modededededede']=\"1\""
21+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_timing_only.json\""
2322
]
2423
},
2524
{

tutorial/session1/Mapping.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@
6868
"source": [
6969
"torch._dynamo.reset()\n",
7070
"\n",
71-
"os.environ['TORCHSIM_MAPPING_POLICY']=\"manual\"\n",
72-
"os.environ['TORCHSIM_TILE_M']=\"512\"\n",
73-
"os.environ['TORCHSIM_TILE_N']=\"512\"\n",
74-
"os.environ['TORCHSIM_TILE_K']=\"512\"\n",
71+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_external_mapping.json\"\n",
7572
"\n",
7673
"input = torch.randn(1024, 1024).to(device=device)\n",
7774
"weight = torch.randn(1024, 1024).to(device=device)\n",
@@ -104,7 +101,7 @@
104101
"source": [
105102
"torch._dynamo.reset()\n",
106103
"\n",
107-
"os.environ['TORCHSIM_MAPPING_POLICY']=\"heuristic\"\n",
104+
"os.environ['TOGSIM_CONFIG']=f\"{base_dir}/tutorial/session1/togsim_configs/togsim_config_autotune.json\"\n",
108105
"\n",
109106
"input = torch.randn(1024, 1024).to(device=device)\n",
110107
"weight = torch.randn(1024, 1024).to(device=device)\n",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"num_cores" : 1,
3+
"core_freq_mhz" : 940,
4+
"core_stats_print_period_cycles" : 10000,
5+
"num_systolic_array_per_core" : 2,
6+
7+
"vpu_num_lanes" : 128,
8+
"vpu_spad_size_kb_per_lane" : 128,
9+
"vpu_vector_length_bits" : 256,
10+
11+
"dram_type" : "ramulator2",
12+
"dram_freq_mhz" : 940,
13+
"dram_channels": 16,
14+
"dram_req_size_byte": 32,
15+
"dram_num_burst_length" : 2,
16+
"dram_stats_print_period_cycles": 10000,
17+
"ramulator_config_path" : "../configs/ramulator2_configs/HBM2_TPUv3.yaml",
18+
19+
"icnt_type" : "simple",
20+
"icnt_latency_cycles" : 10,
21+
"icnt_freq_mhz" : 940,
22+
"icnt_injection_ports_per_core" : 16,
23+
24+
"pytorchsim_functional_mode" : 1,
25+
"pytorchsim_timing_mode" : 1,
26+
27+
"codegen_mapping_strategy" : "heuristic",
28+
"codegen_external_mapping_file" : "",
29+
"codegen_autotune_max_retry": 10,
30+
"codegen_autotune_template_topk": 4,
31+
"codegen_compiler_optimization" : "all"
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"num_cores" : 2,
3+
"core_freq_mhz" : 940,
4+
"core_stats_print_period_cycles" : 10000,
5+
"num_systolic_array_per_core" : 2,
6+
7+
"vpu_num_lanes" : 128,
8+
"vpu_spad_size_kb_per_lane" : 128,
9+
"vpu_vector_length_bits" : 256,
10+
11+
"dram_type" : "ramulator2",
12+
"dram_freq_mhz" : 940,
13+
"dram_channels": 16,
14+
"dram_req_size_byte": 32,
15+
"dram_num_burst_length" : 2,
16+
"dram_stats_print_period_cycles": 10000,
17+
"ramulator_config_path" : "../configs/ramulator2_configs/HBM2_TPUv3.yaml",
18+
19+
"icnt_type" : "simple",
20+
"icnt_latency_cycles" : 10,
21+
"icnt_freq_mhz" : 940,
22+
"icnt_injection_ports_per_core" : 16,
23+
24+
"pytorchsim_functional_mode" : 0,
25+
"pytorchsim_timing_mode" : 1,
26+
27+
"codegen_mapping_strategy" : "heuristic",
28+
"codegen_external_mapping_file" : "",
29+
"codegen_autotune_max_retry": 10,
30+
"codegen_autotune_template_topk": 4,
31+
"codegen_compiler_optimization" : "all"
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"num_cores" : 1,
3+
"core_freq_mhz" : 940,
4+
"core_stats_print_period_cycles" : 10000,
5+
"num_systolic_array_per_core" : 2,
6+
7+
"vpu_num_lanes" : 128,
8+
"vpu_spad_size_kb_per_lane" : 128,
9+
"vpu_vector_length_bits" : 256,
10+
11+
"dram_type" : "ramulator2",
12+
"dram_freq_mhz" : 940,
13+
"dram_channels": 16,
14+
"dram_req_size_byte": 32,
15+
"dram_num_burst_length" : 2,
16+
"dram_stats_print_period_cycles": 10000,
17+
"ramulator_config_path" : "../configs/ramulator2_configs/HBM2_TPUv3.yaml",
18+
19+
"icnt_type" : "simple",
20+
"icnt_latency_cycles" : 10,
21+
"icnt_freq_mhz" : 940,
22+
"icnt_injection_ports_per_core" : 16,
23+
24+
"pytorchsim_functional_mode" : 1,
25+
"pytorchsim_timing_mode" : 1,
26+
27+
"codegen_mapping_strategy" : "autotune",
28+
"codegen_external_mapping_file" : "",
29+
"codegen_autotune_max_retry": 10,
30+
"codegen_autotune_template_topk": 4,
31+
"codegen_compiler_optimization" : "all"
32+
}

0 commit comments

Comments
 (0)