MCPcopy Create free account
hub / github.com/NVIDIA/SOL-ExecBench / Solution

Class Solution

src/sol_execbench/core/data/solution.py:234–371  ·  view source on GitHub ↗

A concrete implementation for a given Definition. Represents a complete solution that provides a high-performance implementation for a computational workload defined by a Definition. Contains all source code, build specifications, and metadata required for building, interfacing, and

Source from the content-addressed store, hash-verified

232
233
234class Solution(BaseModelWithDocstrings):
235 """A concrete implementation for a given Definition.
236
237 Represents a complete solution that provides a high-performance implementation
238 for a computational workload defined by a Definition. Contains all source code,
239 build specifications, and metadata required for building, interfacing, and
240 benchmarking the implementation.
241 """
242
243 model_config = ConfigDict(use_attribute_docstrings=True, frozen=True)
244 """Treat Solution as immutable to safely memoize derived fields."""
245
246 _hash_cache: str = PrivateAttr()
247 """Memoized hash of the solution content."""
248
249 name: NonEmptyString
250 """A unique, human-readable name for this specific solution (e.g., 'rmsnorm_triton_v1_h100')."""
251 definition: NonEmptyString
252 """The name of the Definition this implementation solves."""
253 author: NonEmptyString
254 """The name of the author or agent system that created this solution."""
255 spec: BuildSpec
256 """Technical specifications for building and executing this solution."""
257 sources: list[SourceFile] = Field(min_length=1)
258 """Array of source code files representing the complete implementation."""
259 description: Optional[str] = Field(default=None)
260 """Optional human-readable description of the solution's technique or approach."""
261
262 @model_validator(mode="after")
263 def _validate_source_path_entry_point(self) -> "Solution":
264 """Validate source file paths for uniqueness and entry file existence.
265
266 Raises
267 ------
268 ValueError
269 If duplicate source file paths are found or the entry file is not found in the sources.
270 """
271 seen_paths = set()
272 for source in self.sources:
273 # Check for duplicates
274 if source.path in seen_paths:
275 raise ValueError(f"Duplicate source path '{source.path}'")
276 seen_paths.add(source.path)
277
278 entry_file = self.spec.entry_point.split("::")[0]
279
280 if entry_file not in seen_paths:
281 raise ValueError(f"Entry source file '{entry_file}' not found in sources")
282
283 return self
284
285 def get_entry_path(self) -> Path:
286 """Extract the file path from the entry point specification.
287
288 The entry point format is '{file_path}::{function_name}', and this method
289 returns the file path component as a Path object.
290
291 Returns

Callers 10

build_ext.pyFile · 0.90
eval_driver.pyFile · 0.90
_load_sampleFunction · 0.90
_load_evil_sampleFunction · 0.90
python_solutionFunction · 0.90
cuda_solutionFunction · 0.90
_load_exampleFunction · 0.90
_load_solutionFunction · 0.85

Calls

no outgoing calls

Tested by 7

_load_sampleFunction · 0.72
_load_evil_sampleFunction · 0.72
python_solutionFunction · 0.72
cuda_solutionFunction · 0.72
_load_exampleFunction · 0.72