kernelforge 0.1.14__tar.gz → 0.1.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kernelforge-0.1.16/.clang-format +84 -0
- kernelforge-0.1.16/.clang-tidy +60 -0
- kernelforge-0.1.16/.github/workflows/code-quality.yml +41 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/.github/workflows/release.yaml +2 -1
- {kernelforge-0.1.14 → kernelforge-0.1.16}/.gitignore +2 -2
- kernelforge-0.1.16/.pre-commit-config.yaml +46 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/CMakeLists.txt +47 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/Makefile +19 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/PKG-INFO +8 -2
- {kernelforge-0.1.14 → kernelforge-0.1.16}/environments/environment-dev-macos.yaml +2 -2
- kernelforge-0.1.16/pyproject.toml +130 -0
- kernelforge-0.1.16/python/kernelforge/__init__.py +8 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/python/kernelforge/cli.py +20 -24
- kernelforge-0.1.16/src/aligned_alloc64.hpp +34 -0
- kernelforge-0.1.16/src/bindings.cpp +99 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/src/bindings_cholesky.cpp +74 -75
- kernelforge-0.1.16/src/bindings_fchl19.cpp +861 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/src/bindings_kernels.cpp +115 -134
- kernelforge-0.1.16/src/cholesky.cpp +182 -0
- kernelforge-0.1.16/src/cholesky.hpp +17 -0
- kernelforge-0.1.16/src/constants.hpp +22 -0
- kernelforge-0.1.16/src/fchl19_representation.cpp +2149 -0
- kernelforge-0.1.16/src/fchl19_representation.hpp +114 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/src/invdist.cpp +14 -20
- {kernelforge-0.1.14 → kernelforge-0.1.16}/src/invdist.hpp +5 -12
- {kernelforge-0.1.14 → kernelforge-0.1.16}/src/invdist_bindings.cpp +24 -32
- kernelforge-0.1.16/src/kernels.cpp +495 -0
- kernelforge-0.1.16/src/kernels.hpp +27 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_cholesky.py +5 -12
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_fchl19.py +128 -67
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_fchl19_gradient.py +1 -2
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_hessian.py +16 -14
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_invdist.py +1 -2
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_jacobian.py +1 -2
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_kernels.py +17 -8
- {kernelforge-0.1.14 → kernelforge-0.1.16}/tests/test_rfp.py +6 -6
- kernelforge-0.1.16/wheelhouse/kernelforge-0.1.16-cp311-cp311-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.16/wheelhouse/kernelforge-0.1.16-cp312-cp312-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.16/wheelhouse/kernelforge-0.1.16-cp313-cp313-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.14/pyproject.toml +0 -38
- kernelforge-0.1.14/python/kernelforge/__init__.py +0 -0
- kernelforge-0.1.14/src/aligned_alloc64.hpp +0 -31
- kernelforge-0.1.14/src/bindings.cpp +0 -114
- kernelforge-0.1.14/src/bindings_fchl19.cpp +0 -912
- kernelforge-0.1.14/src/cholesky.cpp +0 -232
- kernelforge-0.1.14/src/cholesky.hpp +0 -22
- kernelforge-0.1.14/src/fchl19_representation.cpp +0 -1984
- kernelforge-0.1.14/src/fchl19_representation.hpp +0 -173
- kernelforge-0.1.14/src/kernels.cpp +0 -1287
- kernelforge-0.1.14/src/kernels.hpp +0 -55
- kernelforge-0.1.14/wheelhouse/kernelforge-0.1.14-cp310-cp310-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.14/wheelhouse/kernelforge-0.1.14-cp311-cp311-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.14/wheelhouse/kernelforge-0.1.14-cp312-cp312-macosx_15_0_arm64.whl +0 -0
- kernelforge-0.1.14/wheelhouse/kernelforge-0.1.14-cp313-cp313-macosx_15_0_arm64.whl +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/.github/workflows/ci.yml +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/LICENSE +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/README.md +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/environments/environment-dev.yaml +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/desc_hess-gauss.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/desc_hess.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/ethanol.sdf +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/fchl_example.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/fchl_hess.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/qm7_example.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/regression_ethanol-Copy1.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/regression_forces.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/examples/sgdml.ipynb +0 -0
- {kernelforge-0.1.14 → kernelforge-0.1.16}/pytest.ini +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
# KernelForge C++ Code Style Configuration
|
|
3
|
+
# Based on Google style with customizations
|
|
4
|
+
|
|
5
|
+
BasedOnStyle: Google
|
|
6
|
+
|
|
7
|
+
# Core formatting preferences
|
|
8
|
+
IndentWidth: 4
|
|
9
|
+
ColumnLimit: 100
|
|
10
|
+
DerivePointerAlignment: false
|
|
11
|
+
PointerAlignment: Right # int *ptr style
|
|
12
|
+
UseTab: Never
|
|
13
|
+
|
|
14
|
+
# Indentation
|
|
15
|
+
AccessModifierOffset: -4
|
|
16
|
+
IndentCaseLabels: true
|
|
17
|
+
NamespaceIndentation: None
|
|
18
|
+
IndentPPDirectives: BeforeHash
|
|
19
|
+
|
|
20
|
+
# Alignment
|
|
21
|
+
AlignAfterOpenBracket: Align
|
|
22
|
+
AlignConsecutiveAssignments: None
|
|
23
|
+
AlignConsecutiveDeclarations: None
|
|
24
|
+
AlignOperands: Align
|
|
25
|
+
AlignTrailingComments: true
|
|
26
|
+
|
|
27
|
+
# Line breaks
|
|
28
|
+
AllowShortFunctionsOnASingleLine: Inline
|
|
29
|
+
AllowShortIfStatementsOnASingleLine: Never
|
|
30
|
+
AllowShortLoopsOnASingleLine: false
|
|
31
|
+
AllowShortBlocksOnASingleLine: Never
|
|
32
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
33
|
+
AlwaysBreakAfterReturnType: None
|
|
34
|
+
AlwaysBreakBeforeMultilineStrings: false
|
|
35
|
+
|
|
36
|
+
# Braces (K&R style)
|
|
37
|
+
BreakBeforeBraces: Attach
|
|
38
|
+
BraceWrapping:
|
|
39
|
+
AfterClass: false
|
|
40
|
+
AfterControlStatement: Never
|
|
41
|
+
AfterEnum: false
|
|
42
|
+
AfterFunction: false
|
|
43
|
+
AfterNamespace: false
|
|
44
|
+
AfterStruct: false
|
|
45
|
+
AfterUnion: false
|
|
46
|
+
BeforeCatch: false
|
|
47
|
+
BeforeElse: false
|
|
48
|
+
|
|
49
|
+
# Spaces
|
|
50
|
+
SpaceAfterCStyleCast: false
|
|
51
|
+
SpaceBeforeAssignmentOperators: true
|
|
52
|
+
SpaceBeforeParens: ControlStatements
|
|
53
|
+
SpacesInParentheses: false
|
|
54
|
+
SpacesInAngles: Never
|
|
55
|
+
SpacesInSquareBrackets: false
|
|
56
|
+
|
|
57
|
+
# Includes
|
|
58
|
+
SortIncludes: true
|
|
59
|
+
IncludeBlocks: Regroup
|
|
60
|
+
IncludeCategories:
|
|
61
|
+
# Own headers first
|
|
62
|
+
- Regex: '^".*\.h(pp)?"$'
|
|
63
|
+
Priority: 1
|
|
64
|
+
# C system headers
|
|
65
|
+
- Regex: '^<[a-z_]+\.h>$'
|
|
66
|
+
Priority: 2
|
|
67
|
+
# C++ standard library
|
|
68
|
+
- Regex: '^<[a-z_]+>$'
|
|
69
|
+
Priority: 3
|
|
70
|
+
# Third-party libraries (BLAS, OpenMP, pybind11)
|
|
71
|
+
- Regex: '^<(cblas|omp|pybind11|Accelerate).*>$'
|
|
72
|
+
Priority: 4
|
|
73
|
+
# Everything else
|
|
74
|
+
- Regex: '.*'
|
|
75
|
+
Priority: 5
|
|
76
|
+
|
|
77
|
+
# Language
|
|
78
|
+
Language: Cpp
|
|
79
|
+
Standard: c++17
|
|
80
|
+
|
|
81
|
+
# Other
|
|
82
|
+
MaxEmptyLinesToKeep: 1
|
|
83
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
84
|
+
ReflowComments: true
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
# KernelForge C++ Static Analysis Configuration
|
|
3
|
+
# Moderate checks for code quality without being overly restrictive
|
|
4
|
+
|
|
5
|
+
Checks: >
|
|
6
|
+
bugprone-*,
|
|
7
|
+
clang-analyzer-*,
|
|
8
|
+
cppcoreguidelines-*,
|
|
9
|
+
modernize-*,
|
|
10
|
+
performance-*,
|
|
11
|
+
readability-*,
|
|
12
|
+
-bugprone-easily-swappable-parameters,
|
|
13
|
+
-bugprone-implicit-widening-of-multiplication-result,
|
|
14
|
+
-modernize-use-trailing-return-type,
|
|
15
|
+
-modernize-avoid-c-arrays,
|
|
16
|
+
-readability-identifier-length,
|
|
17
|
+
-readability-function-cognitive-complexity,
|
|
18
|
+
-readability-magic-numbers,
|
|
19
|
+
-cppcoreguidelines-avoid-magic-numbers,
|
|
20
|
+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
|
21
|
+
-cppcoreguidelines-pro-type-reinterpret-cast,
|
|
22
|
+
-cppcoreguidelines-pro-type-const-cast,
|
|
23
|
+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
|
24
|
+
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
|
25
|
+
-cppcoreguidelines-owning-memory,
|
|
26
|
+
-cppcoreguidelines-no-malloc,
|
|
27
|
+
-performance-no-int-to-ptr
|
|
28
|
+
|
|
29
|
+
CheckOptions:
|
|
30
|
+
# Naming conventions - snake_case for most things
|
|
31
|
+
- key: readability-identifier-naming.NamespaceCase
|
|
32
|
+
value: lower_case
|
|
33
|
+
- key: readability-identifier-naming.ClassCase
|
|
34
|
+
value: CamelCase
|
|
35
|
+
- key: readability-identifier-naming.StructCase
|
|
36
|
+
value: CamelCase
|
|
37
|
+
- key: readability-identifier-naming.FunctionCase
|
|
38
|
+
value: snake_case
|
|
39
|
+
- key: readability-identifier-naming.VariableCase
|
|
40
|
+
value: snake_case
|
|
41
|
+
- key: readability-identifier-naming.ParameterCase
|
|
42
|
+
value: snake_case
|
|
43
|
+
- key: readability-identifier-naming.ConstantCase
|
|
44
|
+
value: UPPER_CASE
|
|
45
|
+
- key: readability-identifier-naming.EnumConstantCase
|
|
46
|
+
value: UPPER_CASE
|
|
47
|
+
- key: readability-identifier-naming.GlobalConstantCase
|
|
48
|
+
value: UPPER_CASE
|
|
49
|
+
|
|
50
|
+
# Make some checks less aggressive
|
|
51
|
+
- key: readability-function-size.LineThreshold
|
|
52
|
+
value: '200'
|
|
53
|
+
- key: readability-function-size.StatementThreshold
|
|
54
|
+
value: '150'
|
|
55
|
+
- key: cppcoreguidelines-avoid-do-while.MaxStatements
|
|
56
|
+
value: '10'
|
|
57
|
+
|
|
58
|
+
WarningsAsErrors: ''
|
|
59
|
+
HeaderFilterRegex: 'src/.*\.(h|hpp)$'
|
|
60
|
+
FormatStyle: file # Use .clang-format
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: Code Quality
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
code-quality:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install black isort ruff mypy
|
|
28
|
+
pip install numpy pytest
|
|
29
|
+
|
|
30
|
+
- name: Check formatting with Black
|
|
31
|
+
run: black --check python/ tests/
|
|
32
|
+
|
|
33
|
+
- name: Check import sorting with isort
|
|
34
|
+
run: isort --check-only python/ tests/
|
|
35
|
+
|
|
36
|
+
- name: Lint with Ruff
|
|
37
|
+
run: ruff check python/ tests/
|
|
38
|
+
|
|
39
|
+
- name: Type check with mypy
|
|
40
|
+
run: mypy python/ tests/
|
|
41
|
+
continue-on-error: true # Don't fail CI on mypy errors initially
|
|
@@ -16,6 +16,8 @@ jobs:
|
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0 # Fetch all history for setuptools-scm to detect version from tags
|
|
19
21
|
|
|
20
22
|
- uses: actions/setup-python@v5
|
|
21
23
|
with:
|
|
@@ -105,4 +107,3 @@ jobs:
|
|
|
105
107
|
- uses: pypa/gh-action-pypi-publish@v1.11.0
|
|
106
108
|
with:
|
|
107
109
|
packages-dir: dist/flat
|
|
108
|
-
|
|
@@ -185,9 +185,9 @@ cython_debug/
|
|
|
185
185
|
.abstra/
|
|
186
186
|
|
|
187
187
|
# Visual Studio Code
|
|
188
|
-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
188
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
189
189
|
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
190
|
-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
190
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
191
191
|
# you could uncomment the following to ignore the entire vscode folder
|
|
192
192
|
# .vscode/
|
|
193
193
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Pre-commit hooks for code quality
|
|
2
|
+
# See https://pre-commit.com for more information
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v4.5.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: trailing-whitespace
|
|
9
|
+
- id: end-of-file-fixer
|
|
10
|
+
- id: check-yaml
|
|
11
|
+
- id: check-added-large-files
|
|
12
|
+
- id: check-merge-conflict
|
|
13
|
+
- id: mixed-line-ending
|
|
14
|
+
|
|
15
|
+
- repo: https://github.com/psf/black
|
|
16
|
+
rev: 24.2.0
|
|
17
|
+
hooks:
|
|
18
|
+
- id: black
|
|
19
|
+
|
|
20
|
+
- repo: https://github.com/pycqa/isort
|
|
21
|
+
rev: 5.13.2
|
|
22
|
+
hooks:
|
|
23
|
+
- id: isort
|
|
24
|
+
args: ["--profile", "black"]
|
|
25
|
+
|
|
26
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
27
|
+
rev: v0.3.0
|
|
28
|
+
hooks:
|
|
29
|
+
- id: ruff
|
|
30
|
+
args: [--fix, --exit-non-zero-on-fix]
|
|
31
|
+
|
|
32
|
+
- repo: https://github.com/pre-commit/mirrors-clang-format
|
|
33
|
+
rev: v19.1.6
|
|
34
|
+
hooks:
|
|
35
|
+
- id: clang-format
|
|
36
|
+
types_or: [c++, c]
|
|
37
|
+
files: ^src/.*\.(cpp|hpp|h|cc|cxx)$
|
|
38
|
+
|
|
39
|
+
# Mypy disabled in pre-commit (run manually with: pre-commit run mypy --all-files --hook-stage manual)
|
|
40
|
+
# - repo: https://github.com/pre-commit/mirrors-mypy
|
|
41
|
+
# rev: v1.9.0
|
|
42
|
+
# hooks:
|
|
43
|
+
# - id: mypy
|
|
44
|
+
# additional_dependencies: [numpy>=2.0, types-psutil]
|
|
45
|
+
# args: [--ignore-missing-imports]
|
|
46
|
+
# files: ^(python|tests|benchmark)/.*\.py$
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.18)
|
|
2
2
|
project(kernelforge LANGUAGES C CXX)
|
|
3
3
|
|
|
4
|
+
# C++ standard
|
|
5
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
6
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
7
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
8
|
+
|
|
4
9
|
# Platform tweaks
|
|
5
10
|
if(APPLE)
|
|
6
11
|
|
|
@@ -136,3 +141,45 @@ install(TARGETS _kernels _invdist _fchl19 _cholesky
|
|
|
136
141
|
RUNTIME DESTINATION kernelforge # Windows (.pyd)
|
|
137
142
|
)
|
|
138
143
|
install(FILES python/kernelforge/__init__.py DESTINATION kernelforge)
|
|
144
|
+
|
|
145
|
+
# ---- Development targets -----------------------------------------------------
|
|
146
|
+
# Collect all C++ source files
|
|
147
|
+
file(GLOB_RECURSE KF_CXX_SOURCES
|
|
148
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
|
|
149
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp
|
|
150
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# clang-format target
|
|
154
|
+
find_program(CLANG_FORMAT_EXE NAMES clang-format)
|
|
155
|
+
if(CLANG_FORMAT_EXE)
|
|
156
|
+
add_custom_target(format
|
|
157
|
+
COMMAND ${CLANG_FORMAT_EXE} -i ${KF_CXX_SOURCES}
|
|
158
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
159
|
+
COMMENT "Running clang-format on all C++ source files"
|
|
160
|
+
VERBATIM
|
|
161
|
+
)
|
|
162
|
+
else()
|
|
163
|
+
add_custom_target(format
|
|
164
|
+
COMMAND ${CMAKE_COMMAND} -E echo "clang-format not found. Please install it to use this target."
|
|
165
|
+
COMMENT "clang-format not available"
|
|
166
|
+
)
|
|
167
|
+
endif()
|
|
168
|
+
|
|
169
|
+
# clang-tidy target
|
|
170
|
+
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
|
|
171
|
+
if(CLANG_TIDY_EXE)
|
|
172
|
+
add_custom_target(tidy
|
|
173
|
+
COMMAND ${CLANG_TIDY_EXE} ${KF_CXX_SOURCES} --
|
|
174
|
+
-std=c++17
|
|
175
|
+
-I${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
176
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
177
|
+
COMMENT "Running clang-tidy on all C++ source files"
|
|
178
|
+
VERBATIM
|
|
179
|
+
)
|
|
180
|
+
else()
|
|
181
|
+
add_custom_target(tidy
|
|
182
|
+
COMMAND ${CMAKE_COMMAND} -E echo "clang-tidy not found. Please install it to use this target."
|
|
183
|
+
COMMENT "clang-tidy not available"
|
|
184
|
+
)
|
|
185
|
+
endif()
|
|
@@ -10,3 +10,22 @@ test:
|
|
|
10
10
|
environment:
|
|
11
11
|
uv venv --python 3.14
|
|
12
12
|
uv pip install scikit-build-core pybind11
|
|
13
|
+
|
|
14
|
+
# Code quality targets
|
|
15
|
+
.PHONY: format lint typecheck check
|
|
16
|
+
|
|
17
|
+
format:
|
|
18
|
+
black python/ tests/
|
|
19
|
+
isort python/ tests/
|
|
20
|
+
|
|
21
|
+
lint:
|
|
22
|
+
ruff check python/ tests/
|
|
23
|
+
|
|
24
|
+
lint-fix:
|
|
25
|
+
ruff check --fix python/ tests/
|
|
26
|
+
|
|
27
|
+
typecheck:
|
|
28
|
+
mypy python/ tests/
|
|
29
|
+
|
|
30
|
+
check: format lint typecheck
|
|
31
|
+
@echo "All code quality checks passed!"
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: kernelforge
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Optimized Kernels for ML
|
|
5
5
|
Author: Anders Christensen
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/andersx/kernelforge
|
|
8
8
|
Project-URL: Issues, https://github.com/andersx/kernelforge/issues
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
10
|
Requires-Dist: numpy>=2.00
|
|
11
11
|
Provides-Extra: test
|
|
12
12
|
Requires-Dist: pytest>=8; extra == "test"
|
|
13
13
|
Requires-Dist: pytest-xdist; extra == "test"
|
|
14
14
|
Requires-Dist: pytest-cov; extra == "test"
|
|
15
15
|
Requires-Dist: pytest-timeout; extra == "test"
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: black>=24.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: isort>=5.13.0; extra == "dev"
|
|
19
|
+
Requires-Dist: ruff>=0.3.0; extra == "dev"
|
|
20
|
+
Requires-Dist: mypy>=1.9.0; extra == "dev"
|
|
21
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
16
22
|
Description-Content-Type: text/markdown
|
|
17
23
|
|
|
18
24
|
# KernelForge - Optimized Kernels for ML
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["scikit-build-core>=0.9", "setuptools-scm>=8.0", "pybind11", "setuptools", "wheel"]
|
|
3
|
+
build-backend = "scikit_build_core.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kernelforge"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Optimized Kernels for ML"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [{name = "Anders Christensen"}]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"numpy>=2.00",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[project.optional-dependencies]
|
|
18
|
+
test = ["pytest>=8", "pytest-xdist", "pytest-cov", "pytest-timeout"]
|
|
19
|
+
dev = [
|
|
20
|
+
"black>=24.0.0",
|
|
21
|
+
"isort>=5.13.0",
|
|
22
|
+
"ruff>=0.3.0",
|
|
23
|
+
"mypy>=1.9.0",
|
|
24
|
+
"pre-commit>=3.6.0",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
qmlbench = "kernelforge.cli:main"
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/andersx/kernelforge"
|
|
32
|
+
Issues = "https://github.com/andersx/kernelforge/issues"
|
|
33
|
+
|
|
34
|
+
[tool.scikit-build]
|
|
35
|
+
wheel.expand-macos-universal-tags = true
|
|
36
|
+
cmake.build-type = "Release"
|
|
37
|
+
build.verbose = true
|
|
38
|
+
wheel.packages = ["python/kernelforge"]
|
|
39
|
+
|
|
40
|
+
[tool.scikit-build.metadata.version]
|
|
41
|
+
provider = "scikit_build_core.metadata.setuptools_scm"
|
|
42
|
+
|
|
43
|
+
[tool.scikit-build.cmake.define]
|
|
44
|
+
CMAKE_VERBOSE_MAKEFILE = "ON"
|
|
45
|
+
CMAKE_BUILD_TYPE = "Release"
|
|
46
|
+
|
|
47
|
+
[tool.uv.extra-build-dependencies]
|
|
48
|
+
kernelforge = ["scikit_build_core"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools_scm]
|
|
51
|
+
# Use git tags with 'v' prefix (e.g., v0.1.14)
|
|
52
|
+
version_scheme = "python-simplified-semver"
|
|
53
|
+
local_scheme = "no-local-version"
|
|
54
|
+
tag_regex = "^v?(?P<version>[0-9.]+)$"
|
|
55
|
+
fallback_version = "0.0.0.dev0"
|
|
56
|
+
|
|
57
|
+
[tool.black]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = ["py311", "py312"] # Black doesn't support py313/py314 yet
|
|
60
|
+
exclude = '''
|
|
61
|
+
/(
|
|
62
|
+
\.git
|
|
63
|
+
| \.venv
|
|
64
|
+
| _build
|
|
65
|
+
| build
|
|
66
|
+
| dist
|
|
67
|
+
)/
|
|
68
|
+
'''
|
|
69
|
+
|
|
70
|
+
[tool.isort]
|
|
71
|
+
profile = "black"
|
|
72
|
+
line_length = 100
|
|
73
|
+
multi_line_output = 3
|
|
74
|
+
include_trailing_comma = true
|
|
75
|
+
force_grid_wrap = 0
|
|
76
|
+
use_parentheses = true
|
|
77
|
+
ensure_newline_before_comments = true
|
|
78
|
+
skip_gitignore = true
|
|
79
|
+
|
|
80
|
+
[tool.ruff]
|
|
81
|
+
line-length = 100
|
|
82
|
+
target-version = "py311"
|
|
83
|
+
exclude = [
|
|
84
|
+
".git",
|
|
85
|
+
".venv",
|
|
86
|
+
"__pycache__",
|
|
87
|
+
"build",
|
|
88
|
+
"dist",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
[tool.ruff.lint]
|
|
92
|
+
select = [
|
|
93
|
+
"E", # pycodestyle errors
|
|
94
|
+
"W", # pycodestyle warnings
|
|
95
|
+
"F", # pyflakes
|
|
96
|
+
"N", # pep8-naming
|
|
97
|
+
"UP", # pyupgrade
|
|
98
|
+
"B", # flake8-bugbear
|
|
99
|
+
"C4", # flake8-comprehensions
|
|
100
|
+
"PTH", # flake8-use-pathlib
|
|
101
|
+
]
|
|
102
|
+
ignore = [
|
|
103
|
+
"E501", # line too long (handled by black)
|
|
104
|
+
"B008", # do not perform function calls in argument defaults
|
|
105
|
+
"PTH123", # use pathlib for open (not always needed)
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
[tool.ruff.lint.per-file-ignores]
|
|
109
|
+
"tests/*" = ["F401", "F811", "N803", "N806", "F841", "B017", "B023", "C408"] # Test-specific ignores
|
|
110
|
+
"python/kernelforge/cli.py" = ["N806", "F841", "B905"] # CLI benchmarking code - allow scientific variable names
|
|
111
|
+
|
|
112
|
+
[tool.mypy]
|
|
113
|
+
python_version = "3.11"
|
|
114
|
+
warn_return_any = true
|
|
115
|
+
warn_unused_configs = true
|
|
116
|
+
disallow_untyped_defs = true
|
|
117
|
+
check_untyped_defs = true
|
|
118
|
+
warn_redundant_casts = true
|
|
119
|
+
warn_unused_ignores = true
|
|
120
|
+
warn_no_return = true
|
|
121
|
+
strict_optional = true
|
|
122
|
+
no_implicit_optional = true
|
|
123
|
+
|
|
124
|
+
[[tool.mypy.overrides]]
|
|
125
|
+
module = ["numpy.*", "pytest.*", "typer.*", "psutil.*", "cpuinfo.*"]
|
|
126
|
+
ignore_missing_imports = true
|
|
127
|
+
|
|
128
|
+
[[tool.mypy.overrides]]
|
|
129
|
+
module = "kernelforge.*"
|
|
130
|
+
ignore_errors = true
|
|
@@ -6,9 +6,9 @@ import urllib.request
|
|
|
6
6
|
import zipfile
|
|
7
7
|
from importlib.metadata import version
|
|
8
8
|
from pathlib import Path
|
|
9
|
-
from typing import Dict, Tuple
|
|
10
9
|
|
|
11
10
|
import numpy as np
|
|
11
|
+
|
|
12
12
|
from kernelforge._fchl19 import (
|
|
13
13
|
fgdml_kernel,
|
|
14
14
|
fgdml_kernel_symm,
|
|
@@ -31,7 +31,7 @@ def load_ethanol_raw_data() -> np.ndarray:
|
|
|
31
31
|
|
|
32
32
|
if not npz_path.exists():
|
|
33
33
|
url = "https://sgdml.org/secure_proxy.php?file=data/npz/ethanol_ccsd_t.zip"
|
|
34
|
-
print(
|
|
34
|
+
print(" [Downloading ethanol dataset...]")
|
|
35
35
|
|
|
36
36
|
try:
|
|
37
37
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
@@ -39,9 +39,7 @@ def load_ethanol_raw_data() -> np.ndarray:
|
|
|
39
39
|
req = urllib.request.Request(url)
|
|
40
40
|
with urllib.request.urlopen(req) as response:
|
|
41
41
|
if response.status != 200:
|
|
42
|
-
raise RuntimeError(
|
|
43
|
-
f"HTTP {response.status}: Failed to download from {url}"
|
|
44
|
-
)
|
|
42
|
+
raise RuntimeError(f"HTTP {response.status}: Failed to download from {url}")
|
|
45
43
|
with open(zip_path, "wb") as f:
|
|
46
44
|
f.write(response.read())
|
|
47
45
|
|
|
@@ -62,15 +60,13 @@ def load_qm7b_raw_data() -> np.ndarray:
|
|
|
62
60
|
|
|
63
61
|
if not npz_path.exists():
|
|
64
62
|
url = "https://github.com/andersx/kernelforge/releases/download/dataset-qm7b-v1.0/qm7b_complete.npz"
|
|
65
|
-
print(
|
|
63
|
+
print(" [Downloading QM7b dataset...]")
|
|
66
64
|
|
|
67
65
|
try:
|
|
68
66
|
req = urllib.request.Request(url)
|
|
69
67
|
with urllib.request.urlopen(req) as response:
|
|
70
68
|
if response.status != 200:
|
|
71
|
-
raise RuntimeError(
|
|
72
|
-
f"HTTP {response.status}: Failed to download from {url}"
|
|
73
|
-
)
|
|
69
|
+
raise RuntimeError(f"HTTP {response.status}: Failed to download from {url}")
|
|
74
70
|
with open(npz_path, "wb") as f:
|
|
75
71
|
f.write(response.read())
|
|
76
72
|
except Exception as e:
|
|
@@ -80,7 +76,7 @@ def load_qm7b_raw_data() -> np.ndarray:
|
|
|
80
76
|
return np.load(npz_path, allow_pickle=True)
|
|
81
77
|
|
|
82
78
|
|
|
83
|
-
def prepare_ethanol_fchl19(n_structures: int = 100) ->
|
|
79
|
+
def prepare_ethanol_fchl19(n_structures: int = 100) -> dict:
|
|
84
80
|
"""Prepare FCHL19 representations and gradients for ethanol."""
|
|
85
81
|
data = load_ethanol_raw_data()
|
|
86
82
|
R = data["R"][:n_structures]
|
|
@@ -102,7 +98,7 @@ def prepare_ethanol_fchl19(n_structures: int = 100) -> Dict:
|
|
|
102
98
|
return {"X": X, "dX": dX, "N": N, "Q": Q, "z": z}
|
|
103
99
|
|
|
104
100
|
|
|
105
|
-
def prepare_qm7b_fchl19(n_structures: int = 100) ->
|
|
101
|
+
def prepare_qm7b_fchl19(n_structures: int = 100) -> dict:
|
|
106
102
|
"""Prepare FCHL19 representations for QM7b."""
|
|
107
103
|
data = load_qm7b_raw_data()
|
|
108
104
|
R = data["R"][:n_structures]
|
|
@@ -134,7 +130,7 @@ def prepare_qm7b_fchl19(n_structures: int = 100) -> Dict:
|
|
|
134
130
|
return {"X": X, "N": N, "Q": Q}
|
|
135
131
|
|
|
136
132
|
|
|
137
|
-
def benchmark_ethanol_fchl19_representations() ->
|
|
133
|
+
def benchmark_ethanol_fchl19_representations() -> tuple[float, str]:
|
|
138
134
|
"""Benchmark FCHL19 representation generation on ethanol (N=1000)."""
|
|
139
135
|
data = load_ethanol_raw_data()
|
|
140
136
|
n = 10000
|
|
@@ -150,7 +146,7 @@ def benchmark_ethanol_fchl19_representations() -> Tuple[float, str]:
|
|
|
150
146
|
return elapsed, f"Ethanol FCHL19 representations (N={n})"
|
|
151
147
|
|
|
152
148
|
|
|
153
|
-
def benchmark_ethanol_fchl19_gradients() ->
|
|
149
|
+
def benchmark_ethanol_fchl19_gradients() -> tuple[float, str]:
|
|
154
150
|
"""Benchmark FCHL19 gradient computation on ethanol (N=1000)."""
|
|
155
151
|
data = load_ethanol_raw_data()
|
|
156
152
|
n = 10000
|
|
@@ -166,7 +162,7 @@ def benchmark_ethanol_fchl19_gradients() -> Tuple[float, str]:
|
|
|
166
162
|
return elapsed, f"Ethanol FCHL19 gradients (N={n})"
|
|
167
163
|
|
|
168
164
|
|
|
169
|
-
def benchmark_qm7b_fchl19_representations() ->
|
|
165
|
+
def benchmark_qm7b_fchl19_representations() -> tuple[float, str]:
|
|
170
166
|
"""Benchmark FCHL19 representation generation on QM7b (N=7211)."""
|
|
171
167
|
data = load_qm7b_raw_data()
|
|
172
168
|
R = data["R"]
|
|
@@ -181,7 +177,7 @@ def benchmark_qm7b_fchl19_representations() -> Tuple[float, str]:
|
|
|
181
177
|
return elapsed, f"QM7b FCHL19 representations (N={len(R)})"
|
|
182
178
|
|
|
183
179
|
|
|
184
|
-
def benchmark_qm7b_fchl19_gradients() ->
|
|
180
|
+
def benchmark_qm7b_fchl19_gradients() -> tuple[float, str]:
|
|
185
181
|
"""Benchmark FCHL19 gradient computation on QM7b (N=7211)."""
|
|
186
182
|
data = load_qm7b_raw_data()
|
|
187
183
|
R = data["R"]
|
|
@@ -196,7 +192,7 @@ def benchmark_qm7b_fchl19_gradients() -> Tuple[float, str]:
|
|
|
196
192
|
return elapsed, "QM7b FCHL19 gradients (N=7211)"
|
|
197
193
|
|
|
198
194
|
|
|
199
|
-
def benchmark_kernel_symm_ethanol() ->
|
|
195
|
+
def benchmark_kernel_symm_ethanol() -> tuple[float, str]:
|
|
200
196
|
"""Benchmark symmetric local kernel on ethanol (N=100)."""
|
|
201
197
|
data = prepare_ethanol_fchl19(100)
|
|
202
198
|
X = data["X"][:100]
|
|
@@ -211,7 +207,7 @@ def benchmark_kernel_symm_ethanol() -> Tuple[float, str]:
|
|
|
211
207
|
return elapsed, "Local kernel symmetric (Ethanol, N=100)"
|
|
212
208
|
|
|
213
209
|
|
|
214
|
-
def benchmark_kernel_asymm_ethanol() ->
|
|
210
|
+
def benchmark_kernel_asymm_ethanol() -> tuple[float, str]:
|
|
215
211
|
"""Benchmark asymmetric local kernel on ethanol (N=20, train-test split)."""
|
|
216
212
|
data = prepare_ethanol_fchl19(20)
|
|
217
213
|
X = data["X"][:20]
|
|
@@ -231,7 +227,7 @@ def benchmark_kernel_asymm_ethanol() -> Tuple[float, str]:
|
|
|
231
227
|
return elapsed, "Local kernel asymmetric (Ethanol, N=20)"
|
|
232
228
|
|
|
233
229
|
|
|
234
|
-
def benchmark_kernel_symm_qm7b() ->
|
|
230
|
+
def benchmark_kernel_symm_qm7b() -> tuple[float, str]:
|
|
235
231
|
"""Benchmark symmetric local kernel on QM7b (N=100)."""
|
|
236
232
|
data = prepare_qm7b_fchl19(100)
|
|
237
233
|
X = data["X"][:100]
|
|
@@ -246,7 +242,7 @@ def benchmark_kernel_symm_qm7b() -> Tuple[float, str]:
|
|
|
246
242
|
return elapsed, "Local kernel symmetric (QM7b, N=100)"
|
|
247
243
|
|
|
248
244
|
|
|
249
|
-
def benchmark_kernel_asymm_qm7b() ->
|
|
245
|
+
def benchmark_kernel_asymm_qm7b() -> tuple[float, str]:
|
|
250
246
|
"""Benchmark asymmetric local kernel on QM7b (N=100, train-test split)."""
|
|
251
247
|
data = prepare_qm7b_fchl19(100)
|
|
252
248
|
X = data["X"][:100]
|
|
@@ -266,7 +262,7 @@ def benchmark_kernel_asymm_qm7b() -> Tuple[float, str]:
|
|
|
266
262
|
return elapsed, "Local kernel asymmetric (QM7b, N=100)"
|
|
267
263
|
|
|
268
264
|
|
|
269
|
-
def benchmark_kernel_gdml_ethanol() ->
|
|
265
|
+
def benchmark_kernel_gdml_ethanol() -> tuple[float, str]:
|
|
270
266
|
"""Benchmark symmetric GDML kernel on ethanol (N=100)."""
|
|
271
267
|
n = 200
|
|
272
268
|
data = prepare_ethanol_fchl19(n)
|
|
@@ -280,10 +276,10 @@ def benchmark_kernel_gdml_ethanol() -> Tuple[float, str]:
|
|
|
280
276
|
K = fgdml_kernel(X, X, dX, dX, Q, Q, N, N, sigma)
|
|
281
277
|
elapsed = (time.perf_counter() - start) * 1000
|
|
282
278
|
|
|
283
|
-
return elapsed,
|
|
279
|
+
return elapsed, "GDML kernel symmetric (Ethanol, N=n)"
|
|
284
280
|
|
|
285
281
|
|
|
286
|
-
def benchmark_kernel_gdml_symm_ethanol() ->
|
|
282
|
+
def benchmark_kernel_gdml_symm_ethanol() -> tuple[float, str]:
|
|
287
283
|
"""Benchmark symmetric GDML kernel on ethanol (N=100)."""
|
|
288
284
|
n = 200
|
|
289
285
|
data = prepare_ethanol_fchl19(n)
|
|
@@ -297,7 +293,7 @@ def benchmark_kernel_gdml_symm_ethanol() -> Tuple[float, str]:
|
|
|
297
293
|
K = fgdml_kernel_symm(X, dX, Q, N, sigma)
|
|
298
294
|
elapsed = (time.perf_counter() - start) * 1000
|
|
299
295
|
|
|
300
|
-
return elapsed,
|
|
296
|
+
return elapsed, "GDML kernel symmetric (Ethanol, N=n)"
|
|
301
297
|
|
|
302
298
|
|
|
303
299
|
BENCHMARKS = {
|
|
@@ -365,7 +361,7 @@ def print_footer(total_ms: float, count: int) -> None:
|
|
|
365
361
|
print()
|
|
366
362
|
print(f" Total time: {total_s:.4f} s")
|
|
367
363
|
print(f" Benchmarks: {count}")
|
|
368
|
-
print(
|
|
364
|
+
print(" Status: OK ✓")
|
|
369
365
|
print()
|
|
370
366
|
|
|
371
367
|
|