Skip to content

Commit 3b22613

Browse files
committed
lazy import scipy
Signed-off-by: PeaBrane <[email protected]>
1 parent e5837a4 commit 3b22613

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

components/src/dynamo/planner/utils/perf_interpolation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from typing import Optional
2121

2222
import numpy as np
23-
import scipy
2423

2524
from dynamo.runtime.logging import configure_dynamo_logging
2625

@@ -80,6 +79,9 @@ def __init__(
8079
self.min_isl = min(self.prefill_isl)
8180
self.max_isl = max(self.prefill_isl)
8281

82+
# Lazy import scipy only when interpolation is actually needed
83+
import scipy.interpolate
84+
8385
# perform 1d interpolation
8486
self.ttft_interpolator = scipy.interpolate.interp1d(
8587
self.prefill_isl, self.prefill_ttft, kind="cubic"
@@ -151,6 +153,9 @@ def __init__(
151153
self.yi = np.linspace(0, max(self.y_context_length), resolution)
152154
self.X, self.Y = np.meshgrid(self.xi, self.yi)
153155

156+
# Lazy import scipy only when interpolation is actually needed
157+
import scipy.interpolate
158+
154159
# perform 2d interpolation with fallback for NaN values
155160
self.itl_interpolator = scipy.interpolate.griddata(
156161
(self.x_kv_usage, self.y_context_length),

0 commit comments

Comments
 (0)