Skip to content

Conversation

@simonguozirui
Copy link
Collaborator

@simonguozirui simonguozirui commented Dec 27, 2025

Restructure package to use src/kernelbench/ layout

Restructures the package to follow Python packaging best practices and fix namespace collision issues.

Directory Structure

Before:

KernelBench/
├── src/                    ← Package code (imported as "src")
│   ├── eval.py
│   ├── utils.py
│   ├── dataset.py
│   └── prompts/
├── scripts/
└── pyproject.toml          (name = "src")

After:

KernelBench/
├── src/                    ← Container directory (not imported)
│   └── kernelbench/        ← Actual package (imported as "kernelbench")
│       ├── eval.py
│       ├── utils.py
│       ├── dataset.py
│       └── prompts/
├── scripts/
└── pyproject.toml          (name = "kernelbench")

Changes

  • Package name: srckernelbench in pyproject.toml
  • Directory structure: Moved all code from src/ to src/kernelbench/
  • Imports: Updated all imports from from src.* to from kernelbench.*
  • Paths: Fixed REPO_TOP_PATH calculations to account for new structure

Why

  • Fixes dependency name collision when installing via uv add git+... (no more generic "src" in dependencies) - A problem @S1ro1 encountered recently while doing integeration
  • Prevents namespace conflicts with other projects' src/ directories
  • Follows standard Python packaging conventions (src layout)
  • Makes KernelBench easier to use as a library/submodule

We use the src layout rather than flat layout as KernelBench is folder of actual problem files. So we will wrap the kernelbench core logic inside src to avoid confusion.

Migration Notes

  • Install in editable mode: uv pip install -e .
  • All imports now use kernelbench.* instead of src.*
  • No functional changes, only structural reorganization

@simonguozirui simonguozirui requested a review from PaliC December 27, 2025 04:24
Copy link
Collaborator

@PaliC PaliC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@simonguozirui
Copy link
Collaborator Author

simonguozirui commented Dec 27, 2025

Updated the modal image setup a bit

Modal Image Setup
Modal's uv_sync() only installs dependencies, not the local kernelbench package. We use add_local_dir + PYTHONPATH as a workaround:

.uv_sync(...)                                    # deps only
.env({"PYTHONPATH": "/root/src"})                # makes kernelbench importable  
.add_local_dir(SRC_DIR, remote_path="/root/src") # must be LAST`add_local_dir` must be last per Modal's requirements—files sync at container startup for fast iteration.

@simonguozirui
Copy link
Collaborator Author

simonguozirui commented Dec 27, 2025

Now people can easily use KernelBench as a library

# Core modules
from kernelbench import eval, timing, utils
from kernelbench.dataset import construct_kernelbench_dataset

# Or import specific functions directly
from kernelbench.eval import eval_kernel_against_ref
from kernelbench.timing import get_timing_function, time_execution_with_cuda_event
from kernelbench.utils import read_file, set_gpu_arch

This would help other integrations. Thanks @S1ro1 for suggestions again!

@simonguozirui simonguozirui merged commit 29c73cc into main Dec 27, 2025
@S1ro1
Copy link

S1ro1 commented Dec 28, 2025

Appreciate the quick fix <3

ethanboneh pushed a commit that referenced this pull request Jan 6, 2026
* migrate src path

* modal related update due to pkg import

* remove pinged pkg version & verify local eval work with new pkg managaement
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.

4 participants