Open engine: a model-adjacent kernel set silently outranks FLM_OPEN_KERNELS_DIR, so a rebuilt kernel set never runs
Engine::find_kernels() prefers <model_dir>/open_kernels unconditionally over
the environment variables, whenever that directory exists and is complete. So
once a model is installed with a kernel set beside it, FLM_OPEN_KERNELS_DIR
and FLM_XCLBIN_PATH are silently ignored, and any locally rebuilt kernel set
never runs.
Why it is worth fixing rather than documenting
It fails open. There is no error, no warning, and no line in the log saying which kernel directory was chosen — the engine loads a valid set and produces valid output, just not from the kernels you built.
Found while measuring a change to the kernels: an A/B came back at 71.19 s against 70.39 s, i.e. a clean "no measurable effect". Both runs had in fact loaded the same stale set and were byte-for-byte the same configuration. The real difference, once the right kernels were actually loaded, was 1.7×. A null result that is really "the experiment did not run" is the expensive kind, because it terminates an investigation instead of prompting one.
Reproduce
- Install a model so that
<model_dir>/open_kernelsexists and is complete. - Build a modified kernel set somewhere else.
- Point
FLM_OPEN_KERNELS_DIR(orFLM_XCLBIN_PATH) at it and run. - The model-adjacent set is used. Nothing says so.
Suggested fix
Two parts, either useful alone:
- Order: an explicitly-set environment variable should outrank the model-adjacent directory. Explicit beats implicit; that is the reason the variable exists.
- Say which: log the resolved kernel directory once at load, unconditionally. This project has a general habit of reporting the value read rather than the value intended, and this is a place with none of it — a single line would have turned the failure above into a five-second diagnosis.
The second is worth doing even if the first is judged too disruptive to change: the silence is what made this expensive, not the precedence order itself.
Found while working on #32.
Was this fixed with #40?
Yes — #40 added the log line, which was the part that mattered. Closing.