Skip to content

Commit 7e7dbfe

Browse files
committed
Remove default settings
This seems redundant with the environment variables stack-info: PR: #964, branch: jansel/stack/203
1 parent 5332857 commit 7e7dbfe

File tree

5 files changed

+4
-79
lines changed

5 files changed

+4
-79
lines changed

docs/api/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ runtime
5353
:nosignatures:
5454
5555
kernel
56-
set_default_settings
5756
Config
5857
Settings
5958
```

docs/api/settings.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Settings can be configured via:
3434

3535
1. **Environment variables**
3636
2. **Keyword arguments to `@helion.kernel`**
37-
3. **Global defaults via `helion.set_default_settings()`**
37+
38+
If both are provided, decorator arguments take precedence.
3839

3940
## Configuration Examples
4041

@@ -62,24 +63,6 @@ def my_kernel(x: torch.Tensor) -> torch.Tensor:
6263
return result
6364
```
6465

65-
### Global Configuration
66-
67-
```python
68-
import logging
69-
import helion
70-
71-
# Set global defaults
72-
with helion.set_default_settings(
73-
ignore_warnings=[helion.exc.TensorOperationInWrapper],
74-
autotune_log_level=logging.WARNING
75-
):
76-
# All kernels in this block use these settings
77-
@helion.kernel
78-
def kernel1(x): ...
79-
80-
@helion.kernel
81-
def kernel2(x): ...
82-
```
8366

8467
## Settings Reference
8568

@@ -227,9 +210,7 @@ Built-in values for ``HELION_AUTOTUNER`` include ``"PatternSearch"``, ``"Differe
227210
## Functions
228211

229212
```{eval-rst}
230-
.. autofunction:: set_default_settings
231213
232-
.. automethod:: Settings.default
233214
```
234215

235216
## Environment Variable Reference

helion/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from .runtime import kernel as jit # alias
1515
from .runtime.settings import RefMode
1616
from .runtime.settings import Settings
17-
from .runtime.settings import set_default_settings
1817

1918
__all__ = [
2019
"Config",
@@ -28,7 +27,6 @@
2827
"language",
2928
"next_power_of_2",
3029
"runtime",
31-
"set_default_settings",
3230
]
3331

3432
_logging.init_logs()

helion/runtime/kernel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(
7979
Args:
8080
fn: The function to be compiled as a Helion kernel.
8181
configs: A list of configurations to use for the kernel.
82-
settings: The settings to be used by the Kernel. If None, default settings are used.
82+
settings: The settings to be used by the Kernel. If None, a new `Settings()` instance is created.
8383
key: Optional callable that returns an extra hashable component for specialization.
8484
"""
8585
super().__init__()
@@ -88,7 +88,7 @@ def __init__(
8888
self.name: str = fn.__name__
8989
self.fn: types.FunctionType = fn
9090
self.signature: inspect.Signature = inspect.signature(fn)
91-
self.settings: Settings = settings or Settings.default()
91+
self.settings: Settings = settings or Settings()
9292
self._key_fn: Callable[..., Hashable] | None = key
9393
self.configs: list[Config] = [
9494
Config(**c) if isinstance(c, dict) else c # pyright: ignore[reportArgumentType]

helion/runtime/settings.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import dataclasses
44
import logging
55
import os
6-
import threading
76
import time
87
from typing import TYPE_CHECKING
98
from typing import Literal
@@ -20,47 +19,15 @@
2019
from .ref_mode import RefMode
2120

2221
if TYPE_CHECKING:
23-
from contextlib import AbstractContextManager
24-
2522
from ..autotuner.base_search import BaseAutotuner
2623
from .kernel import BoundKernel
2724

28-
class _TLS(Protocol):
29-
default_settings: Settings | None
30-
3125
class AutotunerFunction(Protocol):
3226
def __call__(
3327
self, bound_kernel: BoundKernel, args: Sequence[object], **kwargs: object
3428
) -> BaseAutotuner: ...
3529

3630

37-
_tls: _TLS = cast("_TLS", threading.local())
38-
39-
40-
def set_default_settings(settings: Settings) -> AbstractContextManager[None, None]:
41-
"""
42-
Set the default settings for the current thread and return a context manager
43-
that restores the previous settings upon exit.
44-
45-
Args:
46-
settings: The Settings object to set as the default.
47-
48-
Returns:
49-
AbstractContextManager[None, None]: A context manager that restores the previous settings upon exit.
50-
"""
51-
prior = getattr(_tls, "default_settings", None)
52-
_tls.default_settings = settings
53-
54-
class _RestoreContext:
55-
def __enter__(self) -> None:
56-
pass
57-
58-
def __exit__(self, *args: object) -> None:
59-
_tls.default_settings = prior
60-
61-
return _RestoreContext()
62-
63-
6431
def default_autotuner_fn(
6532
bound_kernel: BoundKernel, args: Sequence[object], **kwargs: object
6633
) -> BaseAutotuner:
@@ -254,15 +221,8 @@ class Settings(_Settings):
254221
def __init__(self, **settings: object) -> None:
255222
"""
256223
Initialize the Settings object with the provided dictionary of settings.
257-
If no settings are provided, the default settings are used (see `set_default_settings`).
258-
259-
Args:
260-
settings: Keyword arguments representing various settings.
261224
"""
262225

263-
if defaults := getattr(_tls, "default_settings", None):
264-
settings = {**defaults.to_dict(), **settings}
265-
266226
super().__init__(**settings) # pyright: ignore[reportArgumentType]
267227

268228
self._check_ref_eager_mode_before_print_output_code()
@@ -323,16 +283,3 @@ def _check_ref_eager_mode_before_print_output_code(self) -> None:
323283
"""
324284
if self.ref_mode == RefMode.EAGER and self.print_output_code:
325285
raise exc.RefEagerModeCodePrintError
326-
327-
@staticmethod
328-
def default() -> Settings:
329-
"""
330-
Get the default Settings object. If no default settings are set, create a new one.
331-
332-
Returns:
333-
Settings: The default Settings object.
334-
"""
335-
result = getattr(_tls, "default_settings", None)
336-
if result is None:
337-
_tls.default_settings = result = Settings()
338-
return result

0 commit comments

Comments
 (0)