Skip to content

[Tests] Reorganize tests/ into ops/<family>, models, system#235

Closed
YWHyuk wants to merge 1 commit into
refactor/tests-shared-helperfrom
refactor/tests-hierarchy
Closed

[Tests] Reorganize tests/ into ops/<family>, models, system#235
YWHyuk wants to merge 1 commit into
refactor/tests-shared-helperfrom
refactor/tests-hierarchy

Conversation

@YWHyuk
Copy link
Copy Markdown
Collaborator

@YWHyuk YWHyuk commented May 22, 2026

Summary

Reorganizes tests/ from a flat mix of op-level files, single-file model tests, and inconsistently-cased model directories into a 3-level 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_8x7BMixtral8x7B for consistency. Existing single-file model dirs (Llama, DeepSeek, ...) are kept as dirs since they may grow companion files like the Mixtral model.py.

All file moves use git mv to preserve history.

What was rewired

  • External path references: .github/workflows/pytorchsim_test.yml, README.md, CLAUDE.md, .github/ISSUE_TEMPLATE/bug_report.md, scripts/{sparsity,stonne}_experiment/*.sh.
  • Cross-test imports (4 files): tests/system/test_hetro.py, tests/system/test_scheduler.py, tests/system/test_vectorops.py, tests/ops/sparsity/test_sparsity.py now use fully qualified tests.<group>.<file> imports.
  • __init__.py added to every new subdir so from tests.ops.X.test_Y import ... resolves.
  • Side fix for 6 files (test_resnet, test_vit, test_stonne, test_sparse_core, test_gqa, test_diffusion): the PR-A migration inserted from tests._utils import test_result at column 0 even though their original sys.path.append was indented inside an if __name__ == "__main__": block. Moved the import/path-append to the module top.

Verification

Sample-ran 5 moved tests (one per group): 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. Import-only sanity for the 3 cross-import files (test_sparsity, test_vectorops, test_hetro).

Dependency

Stacks on PR #234 (the tests/_utils.py extraction). When #234 merges, this PR can be retargeted to develop.

🤖 Generated with Claude Code

@YWHyuk YWHyuk force-pushed the refactor/tests-shared-helper branch from 73ab1b4 to c08e1dc Compare May 26, 2026 05:21
@YWHyuk YWHyuk force-pushed the refactor/tests-hierarchy branch from dd28da3 to bf722c8 Compare May 26, 2026 05:51
@YWHyuk YWHyuk force-pushed the refactor/tests-shared-helper branch from c08e1dc to 5ca0455 Compare May 26, 2026 06:12
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/
    _pytorchsim_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 to drop the `tests.` prefix (because PR #234
puts `<repo>/tests` on sys.path[0] to avoid the ultralytics top-level
`tests` package collision):
- 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 e.g. `from ops.elementwise.test_add
import test_vectoradd` 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
sys.path/import block to module top.

Sample-verified locally on tests/ops/elementwise/test_add.py and
tests/ops/fusion/test_matmul_vector.py (both pass) plus import-only
checks on the cross-import files.

Stacks on top of PR #234 (tests/_pytorchsim_utils.py extraction).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YWHyuk YWHyuk force-pushed the refactor/tests-hierarchy branch from bf722c8 to 0549297 Compare May 26, 2026 06:16
@YWHyuk YWHyuk closed this May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant