This document explains how to work effectively in this repository.
helion/: Core Python package (DSL, compiler, runtime, autotuner).test/: PyTest test suite (test_*.py) with golden files*.expected.examples/: Runnable examples; each script must define amain()(pre-commit check).docs/: Sphinx docs; outputs tosite/.benchmarks/,dist/,scripts/: Ancillary utilities and build artifacts.
- Lint/format/type-check:
./lint.sh(auto-formats and fixes some issues)- Optional hooks:
pre-commit run -a
- Run tests:
pytest <filename>- Run subset:
pytest <filename> -k name_substring
- Run subset:
- Build docs:
make -C docs html(writes HTML undersite/)
- Language: Python 3.10+ with type hints; enable
from __future__ import annotations. - Formatting: Ruff formatter, line length 88, double quotes.
- Imports: Sorted by Ruff/isort; single import per line; avoid local scope imports when possible.
- Helion import pattern:
import helion; import helion.language as hl(do notimport helion as hl). - Modules/files: snake_case; tests
test_*.py; examples*.pywithmain(). - Run
./lint.sh fixbefore pushing; CI uses Ruff and Pyrefly. - Don't call
del .../_ = ...on unused function args. There is not unused arg linter.
- Framework: PyTest. Place tests in
test/and nametest_<feature>.py. - Use helpers in
helion._testing(e.g.,check_example). - Runtime: Many tests require CUDA, PyTorch nightly, and Triton dev builds; keep each test fast (<~30s).
- Local tips: For iteration, use
-k, or setHELION_USE_DEFAULT_CONFIG=1to skip autotuning.- Warning: Do not run the full test suite with
HELION_USE_DEFAULT_CONFIG=1— it can change execution paths and break tests. Only use this env var for targeted local iteration on specific tests.
- Warning: Do not run the full test suite with
- Helpful env vars:
HELION_LOGS=all|+all,HELION_PRINT_OUTPUT_CODE=1,HELION_USE_DEFAULT_CONFIG=1.
- Prefer
pytest -x -vv -swhile iterating: stops on first failure, prints full logs and stderr (needed to see generated code from failures that write to stderr). - Target a single test via node id:
pytest test/test_examples.py::TestExamples::test_attention_block_pointer -x -vv -s. - For long outputs, pipe to a file:
... -s 2>&1 | tee /tmp/pytest.out. - Enable dtype/codegen checks when chasing codegen bugs: set
HELION_DEBUG_DTYPE_ASSERTS=1and/orHELION_PRINT_OUTPUT_CODE=1. - Show skip reasons with
pytest -ra; narrow with-k <pattern>for fast cycles. - When running many tests, prefer
pytest-xdistwith-n4
- Do NOT run
pip install, networked installs, or system package managers. - Do NOT run
git commitorgit push; users handle commits/branches. - Do NOT
print()inside kernels; use logging or host-side code. - Tile indexing preserves dimensions;
i = hl.tile(...); x[i]keeps ranks. - Do NOT add unnecessary error checks via
hasattr,getattr,except, etc. - When asked to read a Github issue or pull request, use
gh api.