跳到导航

dynamo.mocker

Mock engine used to run Dynamo workflows without a real GPU backend.

dynamo.mocker publishes 2 classes and 23 functions. Source: components/src/dynamo/mocker/__init__.py

Result of processing —planner-profile-data argument. Cleans up tmpdir on deletion.

from dynamo.mocker.args import ProfileDataResult
ProfileDataResult(npz_path: Path | None, tmpdir: tempfile.TemporaryDirectory | None, ais_perf_model: Path | None = None)

npz_path is the lookup-table file, ais_perf_model the AIS perf model file written for a profiler results directory; at most one is set.

components/src/dynamo/mocker/args.py#L35

Public methods

init

__init__(npz_path: Path | None, tmpdir: tempfile.TemporaryDirectory | None, ais_perf_model: Path | None = None)

No summary available.

source

No summary available.

from dynamo.mocker import ReasoningConfig
ReasoningConfig(start_thinking_token_id: int, end_thinking_token_id: int, thinking_ratio: float) -> None

lib/bindings/python/src/dynamo/_core.pyi#L2166

Public methods

init

__init__(start_thinking_token_id: int, end_thinking_token_id: int, thinking_ratio: float) -> None

No summary available.

source

No summary available.

from dynamo.mocker.config import apply_worker_engine_args_overrides
apply_worker_engine_args_overrides(engine_args: Mapping[str, Any], *, kv_bytes_per_token: int | None = None, bootstrap_port: int | None = None, zmq_kv_events_port: int | None = None, zmq_replay_port: int | None = None, ais_mtp_seed: int | None = None) -> dict

components/src/dynamo/mocker/config.py#L286

No summary available.

from dynamo.mocker.config import build_mocker_engine_args
build_mocker_engine_args(args: argparse.Namespace) -> dict

components/src/dynamo/mocker/config.py#L104

The argument parser of a mocker that runs with env.

from dynamo.mocker.args import build_mocker_parser
build_mocker_parser(env: Mapping[str, str], parser: argparse.ArgumentParser | None = None) -> argparse.ArgumentParser

Env defaults come from env only, never os.environ. Registers what parse_args registers, without --help and --version. Parsing --ais-perf-config reads its file; to read no local file, give a parser that keeps values as typed. Nothing parse_args does after parsing is done here: call set_ais_perf_model_attributes on the parsed namespace before old_ais_perf_inputs reads it.

components/src/dynamo/mocker/args.py#L817

No summary available.

from dynamo.mocker.config import build_runtime_config
build_runtime_config(engine_args: Mapping[str, Any]) -> tuple[int, ModelRuntimeConfig]

components/src/dynamo/mocker/config.py#L312

Compute the stagger delay based on worker count to give the frontend time to process registrations. Returns the delay in seconds between worker launches.

from dynamo.mocker.main import compute_stagger_delay
compute_stagger_delay(num_workers: int, stagger_delay: float) -> float

components/src/dynamo/mocker/main.py#L123

No summary available.

from dynamo.mocker.config import engine_limit
engine_limit(config: Mapping[str, Any], name: str) -> int | None

components/src/dynamo/mocker/config.py#L47

Shutdown dynamo distributed runtime instances. The endpoints will be immediately invalidated so no new requests will be accepted.

from dynamo.mocker.main import graceful_shutdown
graceful_shutdown(runtimes: list)

components/src/dynamo/mocker/main.py#L36

Launch mocker worker(s) with isolated DistributedRuntime instances.

from dynamo.mocker.main import launch_workers
launch_workers(args: argparse.Namespace, base_engine_args)

Each worker gets its own DistributedRuntime, which means:

  • Separate etcd/NATS connections
  • Separate Component instances (no shared overhead)
  • Independent service registration and stats scraping
  • But still sharing the same tokio runtime (efficient)

components/src/dynamo/mocker/main.py#L145

No summary available.

from dynamo.mocker.config import load_mocker_engine_args
load_mocker_engine_args(args: argparse.Namespace) -> dict

components/src/dynamo/mocker/config.py#L239

No summary available.

from dynamo.mocker.main import main
main()

components/src/dynamo/mocker/main.py#L314

No summary available.

from dynamo.mocker.config import normalize_mocker_config
normalize_mocker_config(config: Mapping[str, Any] | str | None = None) -> dict

components/src/dynamo/mocker/config.py#L24

Return the names of the old AIS perf model inputs args holds.

from dynamo.mocker.config import old_ais_perf_inputs
old_ais_perf_inputs(args: argparse.Namespace) -> list[str]

These are --ais-perf-model without a value, --ais-perf-config and the flat identity flags, named with the --ais- spelling. An attribute that args does not have counts as not given.

components/src/dynamo/mocker/config.py#L74

Parse command-line arguments for the Dynamo mocker engine.

from dynamo.mocker.args import parse_args
parse_args(argv: list[str] | None = None) -> argparse.Namespace

Returns

  • argparse.Namespace — argparse.Namespace: Parsed command-line arguments.

components/src/dynamo/mocker/args.py#L836

Parse comma-separated bootstrap ports string into list of integers.

from dynamo.mocker.args import parse_bootstrap_ports
parse_bootstrap_ports(ports_str: str | None) -> list[int]

components/src/dynamo/mocker/args.py#L207

No summary available.

from dynamo.mocker.config import performance_config
performance_config(config: Mapping[str, Any]) -> dict | None

components/src/dynamo/mocker/config.py#L40

Resolve model_path to a local directory, fetching config/tokenizer if needed.

from dynamo.mocker.main import prefetch_model
prefetch_model(model_path: str) -> str

fetch_model returns the cached snapshot directory without contacting the hub when config.json and the tokenizer files are already present, and downloads only those files otherwise. Resolving once here means neither the workers nor the KV-bytes estimate below resolve a hub ID over the network. Returns the original path on failure so callers degrade to their previous behavior.

components/src/dynamo/mocker/main.py#L47

Resolve —planner-profile-data to a timing source.

from dynamo.mocker.args import resolve_planner_profile_data
resolve_planner_profile_data(planner_profile_data: Path | None, *, model: str | None = None, backend: str = 'vllm', nextn: int = 0) -> ProfileDataResult

Accepts either:

  1. A mocker-format NPZ file with lookup tables (returned as-is)
  2. A profiler-style results directory. An AIS perf model is tuned with its measured points and written to a temporary directory.

Parameters

planner_profile_data
Path | None

Path from —planner-profile-data argument.

model
str | None

Model name recorded in the AIS perf model of a directory; the name of the directory when None.

backend
str

Engine backend recorded in that AIS perf model.

nextn
int

Speculative decoding depth recorded in that AIS perf model.

Returns

  • ProfileDataResult — ProfileDataResult with npz_path or ais_perf_model, and the tmpdir for cleanup.

Raises

  • FileNotFoundError — If path doesn’t contain valid profile data in any supported format.
  • ValueError — If the points of a directory do not allow a fit.

components/src/dynamo/mocker/args.py#L61

No summary available.

from dynamo.mocker import run_mocker_trace_replay
run_mocker_trace_replay(trace_files, extra_engine_args = None, router_config = None, num_workers = 1, replay_concurrency = None, router_mode = 'round_robin', arrival_speedup_ratio = 1.0, trace_block_size = None, trace_format = 'mooncake', trace_shared_prefix_ratio = 0.0, trace_num_prefix_groups = 0, model_name = None, sla_ttft_ms = None, sla_itl_ms = None, sla_e2e_ms = None, capture_per_request = False, agentic_lanes = None, execution_model = None)

components/src/dynamo/mocker/__init__.py#L36

Replace the recorded uses of --ais-perf-model by three attributes.

from dynamo.mocker.args import set_ais_perf_model_attributes
set_ais_perf_model_attributes(parser: argparse.ArgumentParser, args: argparse.Namespace, env: str | None) -> None

env is DYN_AIS_PERF_MODEL of the mocker args was parsed for; None or empty is unset. Sets ais_perf_model_without_value, ais_perf_model_value (the value typed last, else env) and ais_perf_model_source (the name of what gave the value). A combination with no single meaning is an error of parser.

components/src/dynamo/mocker/args.py#L225

Resolve --planner-profile-data and make it the timing input of args.

from dynamo.mocker.args import use_planner_profile_data
use_planner_profile_data(args: argparse.Namespace) -> ProfileDataResult

A lookup-table file stays in args.planner_profile_data. A profiler results directory becomes the AIS perf model value of args, tuned for --model-path, --engine-type and --ais-nextn; together with an old AIS input it is a ValueError. With --extra-engine-args the profile data is not used for timing, as before.

The result owns the temporary directory of that AIS perf model: keep it until the workers have stopped.

components/src/dynamo/mocker/args.py#L134

Gate the serial capability on the effective scheduler configuration.

from dynamo.mocker.config import validate_systemone_serial_config
validate_systemone_serial_config(args: argparse.Namespace, config: Mapping[str, Any]) -> None

components/src/dynamo/mocker/config.py#L264

Resolve disaggregation mode from —disaggregation-mode or legacy boolean flags. Raises ValueError if validation fails.

from dynamo.mocker.args import validate_worker_type_args
validate_worker_type_args(args: argparse.Namespace) -> None

components/src/dynamo/mocker/args.py#L161

Main worker function that launches mocker instances.

from dynamo.mocker.main import worker
worker()

Each mocker gets its own DistributedRuntime instance for true isolation, while still sharing the same event loop and tokio runtime.

components/src/dynamo/mocker/main.py#L79