queries#
Structured, injection-safe search helpers over the kernels table.
Shared by the KernelFoundry MCP server (local execution) and the gui app’s REST API
(remote execution), so both modes run the exact same query and return identical results.
Module Attributes
Max characters of output_code included in kernel_to_preview_dict before truncating. |
|
kernels below this speedup are not meaningfully better than native and are not useful as examples, so it is always applied rather than exposed as a filter. |
Functions
|
Fetch a single kernel row by primary key, or None if it doesn't exist. |
|
Full get_kernel result entry: every field an agent would plausibly want. |
|
Compact search_kernels result entry: metadata plus a truncated code preview. |
|
Search the |
- kernelfoundry.eval_pipeline.database.queries.SEARCH_PREVIEW_LEN = 300#
Max characters of output_code included in kernel_to_preview_dict before truncating.
- kernelfoundry.eval_pipeline.database.queries.MIN_IMPROVE_OVER_NATIVE = 0.5#
kernels below this speedup are not meaningfully better than native and are not useful as examples, so it is always applied rather than exposed as a filter.
- Type:
Baseline floor
- kernelfoundry.eval_pipeline.database.queries.search_kernels(filters: dict, limit: int = 20, offset: int = 0) tuple[list[Kernel], int][source]#
Search the
kernelstable with a fixed set of safe, parameterized filters.Always restricted to
status == "correct"andimprove_over_native > MIN_IMPROVE_OVER_NATIVE– incorrect or non-improving kernels aren’t useful examples.Results are diversified across
task_namerather than just sorted by speedup: Each task’s single best kernel is returned first (that first batch itself ordered by speedup, best task first), then each task’s second-best, and so on.- Parameters:
filters – Optional keys — case-insensitive exact match: output_language, task_name, gpu_arch; substring match: task_name_contains, output_code_contains, gpu_arch_contains; all-term code match: output_code_terms; numeric range: max_runtime, min_speedup/max_speedup (further narrows above the baseline floor;
speedupis the ratio stored inKernel.improve_over_native).limit – Max rows to return, clamped to [1, MAX_LIMIT].
offset – Row offset for pagination.
- Returns:
Tuple of (matching Kernel rows for this page, total matching row count).
- kernelfoundry.eval_pipeline.database.queries.get_kernel(kernel_id: int) Kernel | None[source]#
Fetch a single kernel row by primary key, or None if it doesn’t exist.