Skip to content

Commit c63ed28

Browse files
fix: Memory leak (#282)
* test: Add reproducing test * fix: Make sampling neighbors form uniform Int stable * fix: Memory leak with UniformIntegerHyperparameter When querying a large range for a UniformIntegerHyperparameter with a small std.deviation and log scale, this could cause an infinite loop as the reachable neighbors would be quickly exhausted, yet rejection sampling will continue sampling until some arbitrary termination criterion. Why this was causing a memory leak, I'm not entirely sure. The solution now is that is we have seen a sampled value before, we simply take the one "next to it". * fix: Memory issues with Normal and Beta dists Replaced usages of arange with a chunked version to prevent memory blowup. However this is still incredibly slow and needs a more refined solution as a huge amount of values are required to be computed for what can possibly be analytically derived. * chore: Update flake8 * fix: flake8 version compatible with Python 3.7 * fix: Name generators properly * fix: Test numbers * doc: typo fixes * perf: Generate all possible neighbors at once * test: Add test for center_range and arange_chunked * perf: Call transform on np vector from rvs * perf: Use numpy `.astype(int)` instead of `int` * doc: Document how to get flamegraphs for optimizing * fix: Allow for negatives in arange_chunked again * fix: Change build back to raw Extensions * build: Properly set compiler_directives * ci: Update makefile with helpful commands * ci: Fix docs to install build * perf: cython optimizations * perf: Fix possible memory leak with UniformIntegerHyperparam * fix: Duplicates as `list` instead of set * fix: Convert to `long long` vector * perf: Revert clip to truncnorm This truncnorm has some slight overhead due to however scipy generates its truncnorm distribution, however this overhead is considered worth it for the sake of readability and understanding * test: Test values not match implementation * Intermediate commit * INtermediate commit 2 * Update neighborhood generation for UniformIntegerHyperparameter * Update tests * Make the benchmark sampling script more robust * Revert small change in util function * Improve readability Co-authored-by: Matthias Feurer <[email protected]>
1 parent 7f1ac3b commit c63ed28

20 files changed

+397
-153
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636

3737
- name: Install dependencies
3838
run: |
39+
pip install build
3940
pip install ".[dev]"
4041
4142
- name: Make docs

.github/workflows/pytest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ jobs:
159159
- name: Create sdist
160160
id: sdist
161161
run: |
162-
python -m pip install --upgrade pip
163-
python setup.py sdist
164-
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
162+
python -m pip install --upgrade pip build
163+
python -m build --sdist
164+
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"
165165
166166
- name: Install ${{ env.package-name }}
167167
run: |

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ jobs:
184184

185185
- name: Build source distribution
186186
run: |
187-
python -m pip install --upgrade pip
188-
python setup.py sdist
189-
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> $GITHUB_ENV
187+
python -m pip install --upgrade pip build
188+
python build --sdist
189+
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"
190190
191191
- name: Twine check ${{ env.package-name }}
192192
run: |

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ repos:
77
name: mypy ConfigSpace
88
files: ConfigSpace
99

10-
- repo: https://gitlab.com/pycqa/flake8
11-
rev: 4.0.1
10+
- repo: https://github.com/pycqa/flake8
11+
rev: 5.0.4
1212
hooks:
1313
- id: flake8
1414
name: flake8 ConfigSpace

ConfigSpace/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from ConfigSpace.__version__ import __version__
3030
from ConfigSpace.__authors__ import __authors__
3131

32-
import ConfigSpace.api.distributions as distributions
33-
import ConfigSpace.api.types as types
3432
from ConfigSpace.api import (Beta, Categorical, Distribution, Float, Integer,
3533
Normal, Uniform)
3634
from ConfigSpace.conditions import (AndConjunction, EqualsCondition,
@@ -53,6 +51,8 @@
5351
UniformFloatHyperparameter,
5452
UniformIntegerHyperparameter,
5553
UnParametrizedHyperparameter)
54+
import ConfigSpace.api.distributions as distributions
55+
import ConfigSpace.api.types as types
5656

5757
__all__ = [
5858
"__authors__",

ConfigSpace/c_util.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
from collections import deque
42

53
import numpy as np

ConfigSpace/conditions.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
import numpy as np
42
cimport numpy as np
53

ConfigSpace/conditions.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2727
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
# cython: language_level=3
30-
3129
import io
3230
from functools import reduce
3331
from abc import ABCMeta, abstractmethod

ConfigSpace/configuration_space.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2727
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828

29-
# cython: language_level=3
30-
3129
import collections.abc
3230
from collections import defaultdict, deque, OrderedDict
3331
import copy

ConfigSpace/forbidden.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cython: language_level=3
2-
31
import numpy as np
42
cimport numpy as np
53

0 commit comments

Comments
 (0)