jmontp commited on
Commit
182f2b0
·
1 Parent(s): c1f357b

Works in streamlit offline with numba

Browse files
Files changed (1) hide show
  1. multivariate_gaussian_overlap.py +23 -14
multivariate_gaussian_overlap.py CHANGED
@@ -28,6 +28,9 @@ from config import LOW_LEVEL_TASKS
28
  from multiprocessing import Pool, cpu_count
29
  import importlib
30
 
 
 
 
31
  # Environment setup
32
  os.environ['PYDEVD_DISABLE_FILE_VALIDATION'] = '1'
33
 
@@ -67,6 +70,8 @@ _SENSOR_STATS_CACHE = {}
67
 
68
  def _import_optional_module(module_name: str):
69
  """Import a helper module regardless of package context."""
 
 
70
  candidates = []
71
  if __package__:
72
  candidates.append(f"{__package__}.{module_name}")
@@ -509,18 +514,20 @@ def _compute_overlap_backend(means1_batch, vars1_batch, means2_batch, vars2_batc
509
 
510
  elif method == 'auto':
511
  # Auto fallback - try GPU → Numba → NumPy
512
- gpu_module = _import_optional_module('gpu_overlap')
513
- if gpu_module and getattr(gpu_module, 'GPU_AVAILABLE', False):
514
- compute_overlap_batch_gpu = getattr(gpu_module, 'compute_overlap_batch_gpu', None)
515
- if callable(compute_overlap_batch_gpu):
516
- return compute_overlap_batch_gpu(
517
- means1_batch,
518
- vars1_batch,
519
- means2_batch,
520
- vars2_batch,
521
- tol,
522
- biomechanical_difference,
523
- )
 
 
524
 
525
  numba_module = _import_optional_module('numba_overlap')
526
  if numba_module and getattr(numba_module, 'NUMBA_AVAILABLE', False):
@@ -919,11 +926,13 @@ def _process_task_pair_batch(args):
919
  except ValueError as e:
920
  # Handle missing sensor errors gracefully
921
  if "Missing sensor data" in str(e):
 
922
  return (t1, t2, None)
923
- # For other ValueErrors, also return None but could log if needed
924
  return (t1, t2, None)
925
- except Exception:
926
  # Catch any other exceptions to prevent worker crash
 
927
  return (t1, t2, None)
928
 
929
 
 
28
  from multiprocessing import Pool, cpu_count
29
  import importlib
30
 
31
+ # TEMP: force auto backend to skip GPU for debugging parity with CPU-only deployments.
32
+ _FORCE_DISABLE_GPU_AUTO = True
33
+
34
  # Environment setup
35
  os.environ['PYDEVD_DISABLE_FILE_VALIDATION'] = '1'
36
 
 
70
 
71
  def _import_optional_module(module_name: str):
72
  """Import a helper module regardless of package context."""
73
+ if module_name == 'gpu_overlap' and _FORCE_DISABLE_GPU_AUTO:
74
+ return None
75
  candidates = []
76
  if __package__:
77
  candidates.append(f"{__package__}.{module_name}")
 
514
 
515
  elif method == 'auto':
516
  # Auto fallback - try GPU → Numba → NumPy
517
+ gpu_module = None
518
+ if not _FORCE_DISABLE_GPU_AUTO:
519
+ gpu_module = _import_optional_module('gpu_overlap')
520
+ if gpu_module and getattr(gpu_module, 'GPU_AVAILABLE', False):
521
+ compute_overlap_batch_gpu = getattr(gpu_module, 'compute_overlap_batch_gpu', None)
522
+ if callable(compute_overlap_batch_gpu):
523
+ return compute_overlap_batch_gpu(
524
+ means1_batch,
525
+ vars1_batch,
526
+ means2_batch,
527
+ vars2_batch,
528
+ tol,
529
+ biomechanical_difference,
530
+ )
531
 
532
  numba_module = _import_optional_module('numba_overlap')
533
  if numba_module and getattr(numba_module, 'NUMBA_AVAILABLE', False):
 
926
  except ValueError as e:
927
  # Handle missing sensor errors gracefully
928
  if "Missing sensor data" in str(e):
929
+ warnings.warn(str(e), RuntimeWarning)
930
  return (t1, t2, None)
931
+ warnings.warn(f"ValueError while processing {t1} vs {t2}: {e}", RuntimeWarning)
932
  return (t1, t2, None)
933
+ except Exception as e:
934
  # Catch any other exceptions to prevent worker crash
935
+ warnings.warn(f"Unexpected error while processing {t1} vs {t2}: {e}", RuntimeWarning)
936
  return (t1, t2, None)
937
 
938