Skip to content
Draft
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
15 changes: 15 additions & 0 deletions sendnn_inference/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ def clear_env_cache():
"SENDNN_INFERENCE_TP_MM_SHARING": lambda: bool(
int(os.getenv("SENDNN_INFERENCE_TP_MM_SHARING", "1"))
),
# Sim-mode: replace the real Spyre forward with a no-op model and substitute
# virtual durations into request_metrics.jsonl. Lets us exercise scheduler /
# runner / batching logic on a laptop without AIU hardware. Use with
# DYNAMO_BACKEND=eager.
Comment thread
yannicks1 marked this conversation as resolved.
"SENDNN_INFERENCE_SIM_MODE": lambda: bool(int(os.getenv("SENDNN_INFERENCE_SIM_MODE", "0"))),
# Virtual duration (ms) charged for each prefill forward step in sim mode.
# Operator-supplied; default 0 means no virtual time accumulates.
"SENDNN_INFERENCE_SIM_PREFILL_MS": lambda: float(
os.getenv("SENDNN_INFERENCE_SIM_PREFILL_MS", "0")
),
# Virtual duration (ms) charged for each decode forward step in sim mode.
# Operator-supplied; default 0 means no virtual time accumulates.
"SENDNN_INFERENCE_SIM_DECODE_MS": lambda: float(
os.getenv("SENDNN_INFERENCE_SIM_DECODE_MS", "0")
),
}
# --8<-- [end:env-vars-definition]

Expand Down
23 changes: 20 additions & 3 deletions sendnn_inference/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,18 @@ def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
if not is_decoder and not is_pooling:
raise ValueError("Only the 'generate' and 'pooling' runners are supported")

if envs_spyre.SENDNN_INFERENCE_SIM_MODE:
if parallel_config.tensor_parallel_size != 1:
raise ValueError(
"SENDNN_INFERENCE_SIM_MODE only supports tensor_parallel_size=1, "
f"got {parallel_config.tensor_parallel_size}."
)
if envs_spyre.SENDNN_INFERENCE_DYNAMO_BACKEND != "eager":
raise ValueError(
"SENDNN_INFERENCE_SIM_MODE requires SENDNN_INFERENCE_DYNAMO_BACKEND=eager, "
f"got '{envs_spyre.SENDNN_INFERENCE_DYNAMO_BACKEND}'."
)

if parallel_config.worker_cls == "auto":
parallel_config.worker_cls = "sendnn_inference.v1.worker.spyre_worker.SpyreWorker"

Expand All @@ -260,9 +272,14 @@ def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
os.environ["FLEX_DEVICE"] = "COMPILE"

if is_decoder:
scheduler_config.scheduler_cls = (
"sendnn_inference.v1.core.scheduler.ChunkedPrefillSpyreScheduler"
)
if envs_spyre.SENDNN_INFERENCE_SIM_MODE:
scheduler_config.scheduler_cls = (
"sendnn_inference.v1.sim.SimulatedChunkedPrefillSpyreScheduler"
)
else:
scheduler_config.scheduler_cls = (
"sendnn_inference.v1.core.scheduler.ChunkedPrefillSpyreScheduler"
)

if (
vllm_config.model_config.quantization
Expand Down
6 changes: 6 additions & 0 deletions sendnn_inference/v1/metrics/stats_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def record(
self.iso_format
)[:-3]

if envs_spyre.SENDNN_INFERENCE_SIM_MODE:
# In sim mode, virtual timings are emitted directly from the engine
# process to sim_metrics.jsonl. The wall-clock fields here are ~0
# and would be misleading; skip writing.
return

records_to_write: list[str] = []
for r in iteration_stats.finished_requests:
# Calculate some estimates to add to the engine stats
Expand Down
Loading