Source code for chia.firesim.state_def

"""Result dataclasses for FireSim build and run operations.
"""

from __future__ import annotations

from dataclasses import dataclass, field

import yaml

from chia.firesim.config import load_build_recipes


[docs] @dataclass class BitstreamBuildResult: """Result of a :func:`firesim_build_bitstream` FPGA bitstream build. Attributes: recipe_name: Name of the build recipe this result is for. agfi: AWS Global FPGA Image ID produced by the build (e.g. ``"agfi-..."``); ``None`` on failure or for non-AGFI platforms (see ``bitstream_path``). afi: AWS FPGA Image ID (the un-globalized ``"afi-..."`` handle); ``None`` when not produced. success: True iff the build completed and a usable image was produced. build_log: Captured build log (also carries the failure reason on early recipe-resolution errors). hwdb_entry: The hardware-database YAML stanza for this bitstream, ready to paste/feed into a FireSim run config. driver_s3_path: S3 URI of the uploaded simulation driver tarball; ``None`` if not uploaded. build_id: Unique identifier assigned to this build. build_ref: ``"{recipe_name}/{build_id}"`` — the handle to pass as a run config's ``build_ref`` to auto-resolve the AGFI + driver for a run. bitstream_path: S3 URI of a raw ``.bit`` artifact, for platforms that don't produce an AGFI (e.g. ``corigine_xb10``); ``None`` for AGFI-producing platforms (``f2``/``f1``). """ recipe_name: str agfi: str | None afi: str | None success: bool build_log: str hwdb_entry: str driver_s3_path: str | None = None build_id: str = "" build_ref: str = "" # "{recipe_name}/{build_id}" — use this for runs # S3 URI of a raw .bit artifact for platforms that don't produce an AGFI # (e.g. corigine_xb10). None for AGFI-producing platforms (f2/f1). bitstream_path: str | None = None
[docs] @dataclass class FireSimRunResult: """Result of a :func:`firesim_run_workload` FPGA simulation run. Attributes: workload_name: Name of the workload that was run. success: True iff the simulation completed successfully. uartlogs: Per-slot UART console output, mapping ``slot_name`` -> captured uartlog text. rootfs_outputs: Per-slot files copied back from each simulation's rootfs, mapping ``slot_name`` -> ``{relative_filepath -> file_content}``. sim_outputs: Per-slot host-side simulation artifacts (memory_stats, autocounters, etc.), mapping ``slot_name`` -> ``{relative_filepath -> file_content}``. duration_seconds: Wall-clock duration of the run, in seconds. """ workload_name: str success: bool uartlogs: dict[str, str] = field(default_factory=dict) rootfs_outputs: dict[str, dict[str, str]] = field(default_factory=dict) # rootfs_outputs maps slot_name -> {relative_filepath -> file_content} sim_outputs: dict[str, dict[str, str]] = field(default_factory=dict) # sim_outputs maps slot_name -> {relative_filepath -> file_content} # for all host-side simulation artifacts (memory_stats, autocounters, etc.) duration_seconds: float = 0.0
@dataclass class SuiteRunResult: suite_name: str workload_results: dict[str, FireSimRunResult] = field(default_factory=dict) all_success: bool = False total_duration_seconds: float = 0.0 scores: dict[str, dict[str, float]] = field(default_factory=dict) # scores maps workload_name -> {RealTime, UserTime, KernelTime, score}
[docs] @dataclass class SimJobResult: """Result of running one single-job workload on one FPGA. ``success`` is true only if infrasetup and runworkload both exited 0, which means FireSim ran the job, not that the benchmark passed (see ``uartlog``); ``log`` holds the manager output tail, which carries the reason on failure. ``outputs`` maps each file of the run's results directory to its bytes. ``node_id`` and ``ip`` name the machine that ran it: its Ray node and its public IP. """ benchmark_name: str success: bool uartlog: str = "" outputs: dict[str, bytes] = field(default_factory=dict) duration_seconds: float = 0.0 log: str = "" node_id: str = "" ip: str = ""
[docs] @dataclass class BuildRecipe: """What to build: the FireSim quintuplet plus the Vivado knobs. Mirrors one stanza of ``config_build_recipes.yaml``. """ name: str design: str = "FireSim" target_config: str = "FireSimRocketConfig" platform_config: str = "BaseF2Config" platform: str = "f2" target_project: str = "firesim" fpga_frequency: int = 75 build_strategy: str = "TIMING" java_heap_size: str = "16G" def quintuplet(self) -> str: return "-".join([self.platform, self.target_project, self.design, self.target_config, self.platform_config])
[docs] @classmethod def from_yaml(cls, path: str, name: str) -> BuildRecipe: """Recipe ``name`` of a FireSim ``config_build_recipes.yaml``.""" recipe = load_build_recipes(path)[name] return cls(name, design=recipe.design, target_config=recipe.target_config, platform_config=recipe.platform_config, platform=recipe.platform, target_project=recipe.target_project, fpga_frequency=recipe.fpga_frequency, build_strategy=recipe.build_strategy)
[docs] @dataclass class RunConfig: """FireSim runtime settings: sections of ``config_runtime.yaml``, ``{section: {key: value}}``. The run farm, the workload and the hardware config are chia's, and it writes them over these.""" sections: dict = field(default_factory=dict)
[docs] @classmethod def from_yaml(cls, path: str) -> RunConfig: """The sections of a FireSim ``config_runtime.yaml``.""" with open(path) as f: return cls(yaml.safe_load(f))
[docs] @dataclass class EcadBuildResult: """Result of an :meth:`~chia.firesim.bitstream_build_node.BitstreamBuildNode.build_bitstream`. ``bitstream`` is the artifact to hand to a run, and is ``None`` unless the build succeeded; ``log`` carries the reason when it did not. ``logs`` is a ``.tar.gz`` of the build's logs and reports, whether or not it succeeded. """ recipe_name: str success: bool bitstream: "FSBitstream | None" = None log: str = "" logs: bytes = b""