Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ max-line-length = 120
# Ignore E402: module-level import not at top of file
# Ignore W503: line break before binary operator (incompatible with W504)
ignore = E402,W503
exclude = .venv
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*.sln.docstates
*.env

# Environment files
.venv/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down
15 changes: 15 additions & 0 deletions simulator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Simulator package — provisioning sweeps, multi-request analysis, and plotting
on top of the model_provisioner allocation policies.

The allocation policy implementations live in ``streamwise/model_provisioner/``.
"""
import os
import sys

# Make model_provisioner importable for simulator modules.
_STREAMWISE_DIR = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "streamwise")
)
if _STREAMWISE_DIR not in sys.path:
sys.path.insert(0, _STREAMWISE_DIR)
2 changes: 1 addition & 1 deletion simulator/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from sim_types import Objective
from sim_types import Policy

from policies import STREAMWISE_POLICY
from model_provisioner.policies import STREAMWISE_POLICY

from models import get_model_allocation

Expand Down
12 changes: 6 additions & 6 deletions simulator/auto_model_allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sim_types import GPUType
from sim_types import Result

from policies import STREAMWISE_POLICY
from model_provisioner.policies import STREAMWISE_POLICY

from model_allocator import ModelAllocator

Expand Down Expand Up @@ -47,39 +47,39 @@ def __init__(
def _build_allocator(self) -> ModelAllocator:
"""Create concrete allocator based on configured solver."""
if self.policy.solver == Solver.GREEDY:
from greedy import GreedyAllocator
from model_provisioner.greedy import GreedyAllocator
return GreedyAllocator(
workflow=self.workflow,
latency_data=self.latency_data,
power_data=self.power_data,
policy=self.policy,
)
if self.policy.solver == Solver.NAIVE:
from naive_baseline import NaiveAllocator
from model_provisioner.naive_baseline import NaiveAllocator
return NaiveAllocator(
workflow=self.workflow,
latency_data=self.latency_data,
power_data=self.power_data,
policy=self.policy,
)
if self.policy.solver in {Solver.GUROBI, Solver.HIGHS}:
from milp import MILPAllocator
from model_provisioner.milp import MILPAllocator
return MILPAllocator(
workflow=self.workflow,
latency_data=self.latency_data,
power_data=self.power_data,
policy=self.policy,
)
if self.policy.solver == Solver.HEXGEN:
from hexgen import HexGenAllocator
from model_provisioner.hexgen import HexGenAllocator
return HexGenAllocator(
workflow=self.workflow,
latency_data=self.latency_data,
power_data=self.power_data,
policy=self.policy,
)
if self.policy.solver == Solver.HELIX:
from helix import HelixAllocator
from model_provisioner.helix import HelixAllocator
return HelixAllocator(
workflow=self.workflow,
latency_data=self.latency_data,
Expand Down
12 changes: 7 additions & 5 deletions simulator/data_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@
from constants import POWER_GPU_IDLE
from constants import POWER_GPU_TDP

_DEFAULT_DATA_DIR = Path(__file__).resolve().parent / "data"


def load_latency_data(
data_dir: str = "data/",
data_dir: str | Path = _DEFAULT_DATA_DIR,
) -> LatencyData:
"""
Load latency and throughput mapping data from CSV files.

Args:
data_dir (str): The directory where the CSV files are stored.
data_dir: The directory where the CSV files are stored.
Returns:
LatencyData: An object containing all loaded latency data.
"""
Expand Down Expand Up @@ -107,13 +109,13 @@ def load_latency_data(


def load_power_data(
data_dir: str = "data/"
data_dir: str | Path = _DEFAULT_DATA_DIR
) -> PowerData:
"""
Load power consumption data from CSV files.

Args:
data_dir (str): The directory where the CSV files are stored.
data_dir: The directory where the CSV files are stored.
Returns:
PowerData: An object containing all loaded power consumption data.
"""
Expand Down Expand Up @@ -216,7 +218,7 @@ def load_power_data(


def load_adaptive_quality_data(
data_dir: str,
data_dir: str | Path,
level: QualityLevel,
) -> LatencyData:
"""Load latency data for adaptive quality."""
Expand Down
2 changes: 1 addition & 1 deletion simulator/model_allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from models import UpscalerModelAllocation
from models import OthersModelAllocation

from policies import NAIVE_POLICY
from model_provisioner.policies import NAIVE_POLICY


class ModelAllocator(ABC):
Expand Down
2 changes: 1 addition & 1 deletion simulator/multirequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from workflows import PODCAST_WORKFLOW

from policies import STREAMWISE_POLICY
from model_provisioner.policies import STREAMWISE_POLICY
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot import model_provisioner when running inside the cost_estimator_multirequests.ipynb


from auto_model_allocator import AutoModelAllocator

Expand Down
2 changes: 1 addition & 1 deletion simulator/provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from auto_model_allocator import AutoModelAllocator

from policies import STREAMWISE_POLICY
from model_provisioner.policies import STREAMWISE_POLICY

from constants import SECONDS_IN_HOUR

Expand Down
Loading
Loading