Skip to content

Commit dd28da3

Browse files
YWHyukclaude
andcommitted
[Tests] Reorganize tests/ into ops/<family>, models, system
tests/ was a flat mix of op-level files, single-file model tests, and multi-file model directories with inconsistent capitalization. This PR introduces a hierarchy: tests/ _utils.py ops/ elementwise/ reduce/ gemm/ conv/ attention/ view/ sort/ sparsity/ misc/ fusion/ models/ DeepSeek/ Diffusion/ Llama/ MLP/ MoE/ MobileNet/ Mixtral8x7B/ Yolov5/ test_mlp.py test_resnet.py test_single_perceptron.py test_transformer.py test_vit.py system/ test_eager.py test_hetro.py test_scheduler.py test_stonne.py test_vectorops.py Mixtral_8x7B renamed to Mixtral8x7B for consistency with the other PascalCase model dirs. Existing single-file model dirs are kept as dirs (they may grow companion files like the Mixtral model.py). All file moves use git mv to preserve history. External path references rewritten across .github/workflows/pytorchsim_test.yml, README.md, CLAUDE.md, .github/ISSUE_TEMPLATE/bug_report.md, and the scripts/{sparsity,stonne}_experiment/ shell scripts. Cross-test imports updated: - tests/system/test_hetro.py - tests/system/test_scheduler.py - tests/system/test_vectorops.py - tests/ops/sparsity/test_sparsity.py __init__.py added to each new subdir so `from tests.ops.X.test_Y import ...` resolves. Six files (test_resnet, test_vit, test_stonne, test_sparse_core, test_gqa, test_diffusion) had their `sys.path.append` inside an `if __name__ == "__main__":` block, which made the PR-A migration script insert the import at the wrong indent level. Moved the import + path append to the module top. Sample-verified locally on tests/ops/elementwise/test_add.py, tests/ops/gemm/test_matmul.py, tests/ops/view/test_transpose2D.py, tests/ops/sort/test_sort.py, tests/ops/fusion/test_matmul_vector.py (all pass) plus import-only checks on the cross-import files. Stacks on top of PR #234 (tests/_utils.py extraction). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 73ab1b4 commit dd28da3

78 files changed

Lines changed: 132 additions & 109 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion

.github/workflows/pytorchsim_test.yml

Lines changed: 40 additions & 40 deletions
Large diffs are not rendered by default.

CLAUDE.md

Lines changed: 9 additions & 9 deletions

README.md

Lines changed: 8 additions & 8 deletions

scripts/sparsity_experiment/run.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,48 @@ export TORCHSIM_FORCE_TIME_N=8
66

77
OUTPUT_DIR="12GB"
88
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c1_12G_simple_noc.yml"
9-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
10-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
11-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
12-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
13-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
9+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
10+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
11+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
12+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
13+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
1414

1515
OUTPUT_DIR="24GB"
1616
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c1_24G_simple_noc.yml"
17-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
18-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
19-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
20-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
21-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
17+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
18+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
19+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
20+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
21+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
2222

2323
OUTPUT_DIR="48GB"
2424
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c1_48G_simple_noc.yml"
25-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
26-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
27-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
28-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
29-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
25+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
26+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
27+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
28+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
29+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
3030

3131
OUTPUT_DIR="12GB_2core"
3232
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c2_12G_simple_noc.yml"
33-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
34-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
35-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
36-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
37-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
33+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
34+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
35+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
36+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
37+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
3838

3939
OUTPUT_DIR="24GB_2core"
4040
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c2_24G_simple_noc.yml"
41-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
42-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
43-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
44-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
45-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
41+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
42+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
43+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
44+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
45+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
4646

4747
OUTPUT_DIR="48GB_2core"
4848
export TOGSIM_CONFIG="/workspace/PyTorchSim/configs/systolic_ws_8x8_c2_48G_simple_noc.yml"
49-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
50-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
51-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
52-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
53-
python3 /workspace/PyTorchSim/tests/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8
49+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.0 > ${OUTPUT_DIR}/0.0
50+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.2 > ${OUTPUT_DIR}/0.2
51+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.4 > ${OUTPUT_DIR}/0.4
52+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.6 > ${OUTPUT_DIR}/0.6
53+
python3 /workspace/PyTorchSim/tests/ops/sparsity/test_sparsity.py --sparsity 0.8 > ${OUTPUT_DIR}/0.8

scripts/stonne_experiment/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
export TORCHSIM_FORCE_TIME_M=1024
33
export TORCHSIM_FORCE_TIME_K=1024
44
export TORCHSIM_FORCE_TIME_N=1024
5-
python3 ../../tests/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config stonne_big_c1_simple_noc.yml --mode 0 > hetero/big_sparse.log
6-
python3 ../../tests/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config systolic_ws_128x128_c1_simple_noc_tpuv3_half.yml --mode 1 > hetero/big.log
7-
python3 ../../tests/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config heterogeneous_c2_simple_noc.yml --mode 2 > hetero/hetero.log
5+
python3 ../../tests/system/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config stonne_big_c1_simple_noc.yml --mode 0 > hetero/big_sparse.log
6+
python3 ../../tests/system/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config systolic_ws_128x128_c1_simple_noc_tpuv3_half.yml --mode 1 > hetero/big.log
7+
python3 ../../tests/system/test_hetro.py --M 1024 --N 1024 --K 1024 --sparsity 0.9 --config heterogeneous_c2_simple_noc.yml --mode 2 > hetero/hetero.log
88

99
echo "All processes completed!"

scripts/stonne_experiment/run_trace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
SCRIPT="/workspace/PyTorchSim/tests/test_stonne.py"
3+
SCRIPT="/workspace/PyTorchSim/tests/system/test_stonne.py"
44

55
SIZES=(32 64 128)
66
SPARSITIES=(0.0 0.2 0.4 0.6 0.8)
File renamed without changes.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from diffusers.models.upsampling import Upsample2D
1010
from diffusers.models.resnet import ResnetBlock2D
1111
from diffusers.models.embeddings import Timesteps
12+
sys.path.append(os.environ.get("TORCHSIM_DIR", default="/workspace/PyTorchSim"))
13+
from tests._utils import test_result
1214

1315
@torch.no_grad()
1416
def test_unet_conditional(
@@ -620,7 +622,6 @@ def test_timesteps(
620622
args = parser.parse_args()
621623

622624
sys.path.append(os.environ.get("TORCHSIM_DIR", "/workspace/PyTorchSim"))
623-
from tests._utils import test_result
624625
device = torch.device("npu:0")
625626

626627
#test_upsample2d(device)

0 commit comments

Comments
 (0)