Repository navigation
Description
Describe the bug
At 0b94d79c67, the cases below violate the stated supported contract. The validation scope for each case is explicit; source/dispatch proofs are not device numerical qualification.
A pruning exception permanently poisons the patched Triton autotuner single-flight key
Severity: P2
Contract and impact
After publishing a per-key future, every owner exit must resolve the future and remove or deliberately retain it in a terminal state.
If prune_configs raises after the owner installs a per-key future, the first caller receives the error but concurrent callers and every same-key retry wait on an unset Event. A normally catchable callback/pruning error becomes a permanent per-key hang. No claim is made that a default shipped model workload or normal valid shape necessarily raises in pruning.
To reproduce / evidence
The repository-installed public TritonPatch is active on a runtime Autotuner with multiple configs; its owner reaches self.prune_configs(kwargs), and that operation raises. This is an error-finalization contract defect. The separate repository CustomizedTritonAutoTuner is not the patched class and is not used to establish reachability.
This bounded stdlib-only probe executes the exact shipped CacheFuture class and _get_config_for_key function from the checkout. It preinitializes the cache, so ensure_threadsafe_cache is inert; only prune_configs raises. This establishes future cleanup/control flow, not a real Triton or GPU kernel run. Run from the pinned repository root:
import ast
import threading
from pathlib import Path
from types import SimpleNamespace
path = Path('gptqmodel/utils/nogil_patcher.py')
tree = ast.parse(path.read_text())
cls = next(n for n in ast.walk(tree) if isinstance(n, ast.ClassDef) and n.name == 'CacheFuture')
fn = next(n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef) and n.name == '_get_config_for_key')
scope = {'threading': threading, 'ensure_threadsafe_cache': lambda obj: None}
exec(compile(ast.Module(body=[cls, fn], type_ignores=[]), str(path), 'exec'), scope)
def prune(_kwargs):
raise ValueError('pruner rejected input')
obj = SimpleNamespace(_cache_lock=threading.RLock(), _cache={}, _cache_futures={}, prune_configs=prune)
lookup = scope['_get_config_for_key']
try:
lookup(obj, 'key', (), {})
except ValueError:
pass
future = obj._cache_futures['key']
print('retained, signaled, error:', True, future.event.is_set(), future.error)
def retry():
try:
lookup(obj, 'key', (), {})
except ValueError:
pass
t = threading.Thread(target=retry, daemon=True)
t.start()
t.join(0.1)
print('same-key retry blocked:', t.is_alive())
# Bound the test and release the waiter explicitly.
future.error = ValueError('probe cleanup')
future.event.set()
t.join(1)
assert not t.is_alive()Observed: retained=True, signaled=False, error=None; same-key retry blocked=True. Expected: the failed runner resolves/removes its future so a same-key caller receives the failure or can retry, rather than waiting forever.
Observed and expected behavior
Observed: first call raises pruner rejected input; retained future event_set False, error None; retry_blocked True. Expected: the first error resolves the future, all waiters receive the error, the key is eligible for a deliberate retry, and no thread waits forever.
Public source and history
GPTQModel/gptqmodel/utils/nogil_patcher.py
Lines 335 to 355 in 0b94d79
| def _get_config_for_key(self, key, args, kwargs): | |
| ensure_threadsafe_cache(self) | |
| with self._cache_lock: | |
| cached = self._cache.get(key) | |
| if cached is not None: | |
| return cached, True, None | |
| future = self._cache_futures.get(key) | |
| if future is None: | |
| future = CacheFuture() | |
| self._cache_futures[key] = future | |
| runner = True | |
| else: | |
| runner = False | |
| if not runner: | |
| future.event.wait() | |
| if future.error is not None: | |
| raise future.error | |
| return future.config, future.used_cached_result, future.bench_time | |
| pruned_configs = self.prune_configs(kwargs) |
GPTQModel/gptqmodel/utils/nogil_patcher.py
Lines 369 to 396 in 0b94d79
| try: | |
| if self.cache_results: | |
| used_cached_result, bench_time, configs_timings, best_config = patched_check_disk_cache( | |
| self, key, pruned_configs, benchmark | |
| ) | |
| else: | |
| configs_timings, bench_time, best_config = benchmark() | |
| used_cached_result = False | |
| if configs_timings is not None: | |
| self.configs_timings = configs_timings | |
| self.bench_time = bench_time | |
| if best_config is not None: | |
| with self._cache_lock: | |
| self._cache[key] = best_config | |
| future.config = best_config | |
| future.used_cached_result = used_cached_result | |
| future.bench_time = bench_time | |
| return best_config, used_cached_result, bench_time | |
| except BaseException as exc: | |
| future.error = exc | |
| raise | |
| finally: | |
| future.event.set() | |
| with self._cache_lock: | |
| self._cache_futures.pop(key, None) |
GPTQModel/gptqmodel/utils/nogil_patcher.py
Lines 59 to 87 in 0b94d79
| class TritonPatch: | |
| _apply_lock = threading.RLock() | |
| _applied = False | |
| @classmethod | |
| def apply(cls) -> None: | |
| with cls._apply_lock: | |
| if cls._applied: | |
| return | |
| errors = [] | |
| for patch in (patch_triton_autotuner, patch_triton_jit_compile): | |
| try: | |
| patch() | |
| except Exception as exc: # keep the other patch installed | |
| errors.append(exc) | |
| if errors: | |
| raise errors[0] | |
| cls._applied = True | |
| # Triton's compiler uses nanobind objects that are not free-thread safe. Two | |
| # threads that miss the same kernel cache entry compile the same kernel at the | |
| # same time and libtriton aborts the process ("attempted to delete an unknown | |
| # instance", exit 134) under PYTHON_GIL=0. The lock also collapses concurrent | |
| # misses for one key into a single compile: the loser rechecks the kernel cache | |
| # after acquiring it. It is process-global because the unsafe state is inside | |
| # libtriton, not per JITFunction. | |
| _TRITON_COMPILE_LOCK = threading.RLock() |
151ccbe / #2056 (2025-10-18) contains the same pre-try pruning and single-flight future. 1a30538 changes state/signature handling and dd67ee7 adds JIT single flight, but neither moves this failure-prone operation into the owner-finalization scope.
Existing reports
Search across open/closed public issues and PRs for prune_configs found #3972 and #3986. They repair thread-local scratch state and worker failures, not this exact orphaned-future path. #4094 / #4102 is related JIT/global-guard work, not evidence this case was fixed.
Software / device info and validation limits
Airtight repository Python control-flow proof plus a fake-Triton execution of the shipped patch. Real Triton is unavailable, so no actual kernel, actual third-party callback, GPU OOM, or supported-version end-to-end integration was executed. The demonstrated result is future poisoning when the existing prune call raises, not a claim that normal valid shapes always raise. Independently re-run in this verifier using the explicit harness embedded in coverage; package initialization/logging are bypassed.
Model / datasets
The evidence uses tiny synthetic tensors or local fixtures derived from the public tests; no private model or dataset is required. Device execution that remains untested is stated above.
Activity
Qubitium commentedon Nov 17, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.
fix(triton): resolve autotuner future on pruning exceptions (#4477) (#…