Skip to content

feat: batchgen_kernels versioning, ccache, JIT dev mode, and multi-arch support - #112

Merged
Andrewxu313 merged 2 commits into
mainfrom
tairan/kernel-versioning
Mar 25, 2026
Merged

feat: batchgen_kernels versioning, ccache, JIT dev mode, and multi-arch support#112
Andrewxu313 merged 2 commits into
mainfrom
tairan/kernel-versioning

Conversation

@Andrewxu313

Copy link
Copy Markdown
Contributor

Description

Add proper version management, incremental build support, and multi-architecture infrastructure to batchgen_kernels. Previously, the version was hardcoded as "0.1.0" in three places with no tagging, no compatibility checks, and full recompilation required for any change.

Motivation

  1. No version tracking: Users had no way to know which kernel version was installed. Version mismatches between batchgen and batchgen_kernels caused silent failures.
  2. Slow iteration: Adding or modifying a single .cu file required recompiling all 37 CUDA files (~10-20 min). No caching.
  3. No multi-arch story: SM100 (Blackwell) kernels need entirely different source code (tcgen05 vs WGMMA), but the build system had no arch-awareness beyond compile flags.

Changes

1. Version infrastructure (single source of truth)

  • New _version.py: __version__ = "0.2.0", version_info = (0, 2, 0), arch-aware __version_full__
  • setup.py and pyproject.toml read version dynamically — one place to bump
  • Git tag convention: batchgen-kernels-v{X.Y.Z}+sm90a

2. Runtime compatibility check

  • New batchgen/kernel_compat.py: checks batchgen_kernels.version_info >= MIN_KERNELS_VERSION at import batchgen
  • Clear error message with rebuild instructions if outdated

3. ccache/sccache integration

  • setup.py auto-detects ccache or sccache and configures CC/CXX wrappers
  • Unchanged files are cache hits (~instant). Only modified .cu files recompile.

4. JIT dev mode

  • BATCHGEN_KERNELS_DEV=1 enables JIT fallback in load_extension()
  • New _jit_registry.py mirrors all 22 CUDAExtension configs for JIT compilation
  • Developers can add a new .cu file and test immediately without rebuilding the wheel

5. Multi-architecture build gating

  • BUILD_ARCH env var: "sm90a" (default), "sm100", "all"
  • SM90a and SM80+ extensions split into separate lists, gated by BUILD_ARCH
  • Wheel naming: batchgen_kernels-0.2.0+sm90a-*.whl (PEP 440 local version)

6. External user support

  • CUDA_HOME auto-detection from nvcc path
  • Helpful error if CUDA toolkit not found
File Change
batchgen_kernels/_version.py New — single source of truth for version
batchgen_kernels/_jit_registry.py New — JIT compilation config for all extensions
batchgen_kernels/__init__.py Version import, load_extension() with JIT fallback
batchgen_kernels/setup.py Dynamic version, ccache, CUDA_HOME, BUILD_ARCH gating
batchgen_kernels/pyproject.toml Dynamic version via setuptools
batchgen/kernel_compat.py New — runtime version compatibility check
batchgen/__init__.py Add compat check at import

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Code cleanup
  • Documentation update

Checklist

  • I have read the CONTRIBUTION guide.
  • I have updated the tests (if applicable).
  • I have updated the documentation (if applicable).

TairanXU added 2 commits March 24, 2026 21:16
…_dim)

For models with rotary_dim < head_dim (e.g., MiniMax rotary_dim=64, head_dim=128),
the kernel now copies dims [2*half_dim, head_dim) from input to output.
Zero overhead for models where 2*half_dim == head_dim (loop never executes).
…ch support

Add proper version management (0.2.0), incremental build support via
ccache/sccache auto-detection, JIT dev mode (BATCHGEN_KERNELS_DEV=1),
runtime compatibility check in batchgen, and BUILD_ARCH gating for
multi-architecture wheel builds (sm90a/sm100/all).

Single source of truth: batchgen_kernels/_version.py
@Andrewxu313
Andrewxu313 merged commit 124ffa0 into main Mar 25, 2026
1 check failed
@Andrewxu313
Andrewxu313 deleted the tairan/kernel-versioning branch March 25, 2026 15:04
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