flashinfer_bench.data.Solution

pydantic model flashinfer_bench.data.Solution

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 benchmarking the implementation.

Show JSON schema
{
   "title": "Solution",
   "description": "A concrete implementation for a given Definition.\n\nRepresents a complete solution that provides a high-performance implementation\nfor a computational workload defined by a Definition. Contains all source code,\nbuild specifications, and metadata required for building, interfacing, and\nbenchmarking the implementation.",
   "type": "object",
   "properties": {
      "name": {
         "description": "A unique, human-readable name for this specific solution (e.g., 'rmsnorm_triton_v1_h100').",
         "minLength": 1,
         "title": "Name",
         "type": "string"
      },
      "definition": {
         "description": "The name of the Definition this implementation solves.",
         "minLength": 1,
         "title": "Definition",
         "type": "string"
      },
      "author": {
         "description": "The name of the author or agent system that created this solution.",
         "minLength": 1,
         "title": "Author",
         "type": "string"
      },
      "spec": {
         "$ref": "#/$defs/BuildSpec",
         "description": "Technical specifications for building and executing this solution."
      },
      "sources": {
         "description": "Array of source code files representing the complete implementation.",
         "items": {
            "$ref": "#/$defs/SourceFile"
         },
         "minItems": 1,
         "title": "Sources",
         "type": "array"
      },
      "description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Optional human-readable description of the solution's technique or approach.",
         "title": "Description"
      }
   },
   "$defs": {
      "BuildSpec": {
         "description": "Build specification for a solution implementation.\n\nContains all technical specifications required to build and execute a solution, including\nlanguage, hardware targets, dependencies, entry point, and build commands.",
         "properties": {
            "language": {
               "$ref": "#/$defs/SupportedLanguages",
               "description": "The primary programming language (e.g., 'triton', 'cuda', 'python')."
            },
            "target_hardware": {
               "description": "List of hardware this solution is compatible with. E.g. 'cpu', 'cuda'. Note this is not used\nin verification and building now.",
               "items": {
                  "type": "string"
               },
               "minItems": 1,
               "title": "Target Hardware",
               "type": "array"
            },
            "entry_point": {
               "description": "The exact path to the function to be called. Format: '{file_path}::{function_name}'\n(e.g., 'main.py::run').",
               "minLength": 1,
               "title": "Entry Point",
               "type": "string"
            },
            "dependencies": {
               "description": "Optional list of required libraries or packages. E.g. for CUDA, we support 'cublas',\n'cudnn', 'cutlass'",
               "items": {
                  "minLength": 1,
                  "type": "string"
               },
               "title": "Dependencies",
               "type": "array"
            },
            "destination_passing_style": {
               "default": true,
               "description": "Whether to use destination passing style for the solution. If True, the solution should\naccept the output tensors as the last arguments. If False, the solution should return the\noutput tensors.",
               "title": "Destination Passing Style",
               "type": "boolean"
            },
            "binding": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/SupportedBindings"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The binding type to use for C++/CUDA solutions. If None, defaults to 'tvm-ffi' for\nC++/CUDA languages. Ignored for Python and Triton languages."
            }
         },
         "required": [
            "language",
            "target_hardware",
            "entry_point"
         ],
         "title": "BuildSpec",
         "type": "object"
      },
      "SourceFile": {
         "description": "A single source code file in a solution implementation.\n\nRepresents a source code file with its relative path and complete content.\nThe file content is validated for syntax correctness based on the file extension.",
         "properties": {
            "path": {
               "description": "The relative path of the file, including its name and extension (e.g., 'src/kernel.cu',\n'main.py'). When compiling the solution, a temporary solution source directory will be\ncreated, and the file will be placed according to this path. The path should not contain\nparent directory traversal (\"..\").",
               "minLength": 1,
               "title": "Path",
               "type": "string"
            },
            "content": {
               "description": "The complete text content of the source file.",
               "minLength": 1,
               "title": "Content",
               "type": "string"
            }
         },
         "required": [
            "path",
            "content"
         ],
         "title": "SourceFile",
         "type": "object"
      },
      "SupportedBindings": {
         "description": "Supported bindings for C++/CUDA solution implementations.\n\nEnumeration of binding types that can be used to interface compiled\nC++/CUDA code with Python.",
         "enum": [
            "tvm-ffi",
            "torch"
         ],
         "title": "SupportedBindings",
         "type": "string"
      },
      "SupportedLanguages": {
         "description": "Supported programming languages for solution implementations.\n\nEnumeration of programming languages that can be used to implement\nsolutions for computational workloads.",
         "enum": [
            "python",
            "triton",
            "cpp",
            "cuda",
            "tilelang"
         ],
         "title": "SupportedLanguages",
         "type": "string"
      }
   },
   "required": [
      "name",
      "definition",
      "author",
      "spec",
      "sources"
   ]
}

Fields:
  • name (str)

  • definition (str)

  • author (str)

  • spec (flashinfer_bench.data.solution.BuildSpec)

  • sources (List[flashinfer_bench.data.solution.SourceFile])

  • description (str | None)

field name: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

A unique, human-readable name for this specific solution (e.g., ‘rmsnorm_triton_v1_h100’).

Constraints:
  • min_length = 1

field definition: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

The name of the Definition this implementation solves.

Constraints:
  • min_length = 1

field author: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

The name of the author or agent system that created this solution.

Constraints:
  • min_length = 1

field spec: BuildSpec [Required]

Technical specifications for building and executing this solution.

field sources: List[SourceFile] [Required]

Array of source code files representing the complete implementation.

Constraints:
  • min_length = 1

field description: str | None = None

Optional human-readable description of the solution’s technique or approach.

get_entry_path() Path

Extract the file path from the entry point specification.

The entry point format is ‘{file_path}::{function_name}’, and this method returns the file path component as a Path object.

Returns:

The relative path to the entry source file (e.g., ‘main.py’, ‘src/kernel.cu’).

Return type:

Path

get_entry_symbol() str

Extract the function/symbol name from the entry point specification.

The entry point format is ‘{file_path}::{function_name}’, and this method returns the function name component. This is the symbol that builders will look up in the compiled module or imported Python module.

Returns:

The function or symbol name to be loaded (e.g., ‘run’, ‘forward’, ‘kernel’).

Return type:

str

get_entry_source() SourceFile | None

Get the entry source file specified in the build spec.

Returns:

The SourceFile object containing the entry point, or None if not found.

Return type:

Optional[SourceFile]

model_post_init(_Solution__context: Any) None

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

Parameters:

_Solution__context (Any)

Return type:

None

hash() str

Return the memoized deterministic hash of the solution content.

This hash is computed from all fields that affect the solution’s behavior: name, definition, language, entry point, dependencies, and all source file paths and contents. This ensures that any meaningful change to the solution results in a different hash.

The hash is used for caching build artifacts, allowing solutions with the same hash to reuse the same cached build result.

Returns:

A SHA1 hash (40 hex characters) uniquely identifying this solution’s content.

Return type:

str

class flashinfer_bench.data.SupportedLanguages

Supported programming languages for solution implementations.

Enumeration of programming languages that can be used to implement solutions for computational workloads.

PYTHON = 'python'

Python programming language.

TRITON = 'triton'

Triton GPU programming language.

CPP = 'cpp'

Pure C++ source code.

CUDA = 'cuda'

CUDA C++ programming language.

TILELANG = 'tilelang'

TileLang GPU programming language.

__new__(value)
pydantic model flashinfer_bench.data.SourceFile

A single source code file in a solution implementation.

Represents a source code file with its relative path and complete content. The file content is validated for syntax correctness based on the file extension.

Show JSON schema
{
   "title": "SourceFile",
   "description": "A single source code file in a solution implementation.\n\nRepresents a source code file with its relative path and complete content.\nThe file content is validated for syntax correctness based on the file extension.",
   "type": "object",
   "properties": {
      "path": {
         "description": "The relative path of the file, including its name and extension (e.g., 'src/kernel.cu',\n'main.py'). When compiling the solution, a temporary solution source directory will be\ncreated, and the file will be placed according to this path. The path should not contain\nparent directory traversal (\"..\").",
         "minLength": 1,
         "title": "Path",
         "type": "string"
      },
      "content": {
         "description": "The complete text content of the source file.",
         "minLength": 1,
         "title": "Content",
         "type": "string"
      }
   },
   "required": [
      "path",
      "content"
   ]
}

Fields:
  • path (str)

  • content (str)

field path: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

The relative path of the file, including its name and extension (e.g., ‘src/kernel.cu’, ‘main.py’). When compiling the solution, a temporary solution source directory will be created, and the file will be placed according to this path. The path should not contain parent directory traversal (“..”).

The relative path of the file, including its name and extension (e.g., ‘src/kernel.cu’, ‘main.py’). When compiling the solution, a temporary solution source directory will be created, and the file will be placed according to this path. The path should not contain parent directory traversal (“..”).

Constraints:
  • min_length = 1

field content: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

The complete text content of the source file.

Constraints:
  • min_length = 1

pydantic model flashinfer_bench.data.BuildSpec

Build specification for a solution implementation.

Contains all technical specifications required to build and execute a solution, including language, hardware targets, dependencies, entry point, and build commands.

Show JSON schema
{
   "title": "BuildSpec",
   "description": "Build specification for a solution implementation.\n\nContains all technical specifications required to build and execute a solution, including\nlanguage, hardware targets, dependencies, entry point, and build commands.",
   "type": "object",
   "properties": {
      "language": {
         "$ref": "#/$defs/SupportedLanguages",
         "description": "The primary programming language (e.g., 'triton', 'cuda', 'python')."
      },
      "target_hardware": {
         "description": "List of hardware this solution is compatible with. E.g. 'cpu', 'cuda'. Note this is not used\nin verification and building now.",
         "items": {
            "type": "string"
         },
         "minItems": 1,
         "title": "Target Hardware",
         "type": "array"
      },
      "entry_point": {
         "description": "The exact path to the function to be called. Format: '{file_path}::{function_name}'\n(e.g., 'main.py::run').",
         "minLength": 1,
         "title": "Entry Point",
         "type": "string"
      },
      "dependencies": {
         "description": "Optional list of required libraries or packages. E.g. for CUDA, we support 'cublas',\n'cudnn', 'cutlass'",
         "items": {
            "minLength": 1,
            "type": "string"
         },
         "title": "Dependencies",
         "type": "array"
      },
      "destination_passing_style": {
         "default": true,
         "description": "Whether to use destination passing style for the solution. If True, the solution should\naccept the output tensors as the last arguments. If False, the solution should return the\noutput tensors.",
         "title": "Destination Passing Style",
         "type": "boolean"
      },
      "binding": {
         "anyOf": [
            {
               "$ref": "#/$defs/SupportedBindings"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The binding type to use for C++/CUDA solutions. If None, defaults to 'tvm-ffi' for\nC++/CUDA languages. Ignored for Python and Triton languages."
      }
   },
   "$defs": {
      "SupportedBindings": {
         "description": "Supported bindings for C++/CUDA solution implementations.\n\nEnumeration of binding types that can be used to interface compiled\nC++/CUDA code with Python.",
         "enum": [
            "tvm-ffi",
            "torch"
         ],
         "title": "SupportedBindings",
         "type": "string"
      },
      "SupportedLanguages": {
         "description": "Supported programming languages for solution implementations.\n\nEnumeration of programming languages that can be used to implement\nsolutions for computational workloads.",
         "enum": [
            "python",
            "triton",
            "cpp",
            "cuda",
            "tilelang"
         ],
         "title": "SupportedLanguages",
         "type": "string"
      }
   },
   "required": [
      "language",
      "target_hardware",
      "entry_point"
   ]
}

Fields:
  • language (flashinfer_bench.data.solution.SupportedLanguages)

  • target_hardware (List[str])

  • entry_point (str)

  • dependencies (List[str])

  • destination_passing_style (bool)

  • binding (flashinfer_bench.data.solution.SupportedBindings | None)

field language: SupportedLanguages [Required]

The primary programming language (e.g., ‘triton’, ‘cuda’, ‘python’).

field target_hardware: List[str] [Required]

List of hardware this solution is compatible with. E.g. ‘cpu’, ‘cuda’. Note this is not used in verification and building now.

List of hardware this solution is compatible with. E.g. ‘cpu’, ‘cuda’. Note this is not used in verification and building now.

Constraints:
  • min_length = 1

field entry_point: Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])] [Required]

The exact path to the function to be called. Format: ‘{file_path}::{function_name}’ (e.g., ‘main.py::run’).

The exact path to the function to be called. Format: ‘{file_path}::{function_name}’ (e.g., ‘main.py::run’).

Constraints:
  • min_length = 1

field dependencies: List[Annotated[str, FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])]] [Optional]

Optional list of required libraries or packages. E.g. for CUDA, we support ‘cublas’, ‘cudnn’, ‘cutlass’

Optional list of required libraries or packages. E.g. for CUDA, we support ‘cublas’, ‘cudnn’, ‘cutlass’

field destination_passing_style: bool = True

Whether to use destination passing style for the solution. If True, the solution should accept the output tensors as the last arguments. If False, the solution should return the output tensors.

Whether to use destination passing style for the solution. If True, the solution should accept the output tensors as the last arguments. If False, the solution should return the output tensors.

field binding: SupportedBindings | None = None

The binding type to use for C++/CUDA solutions. If None, defaults to ‘tvm-ffi’ for C++/CUDA languages. Ignored for Python and Triton languages.

The binding type to use for C++/CUDA solutions. If None, defaults to ‘tvm-ffi’ for C++/CUDA languages. Ignored for Python and Triton languages.