Uh oh!
There was an error while loading. Please reload this page.
Harden ML inference load and decode paths - #73
Conversation
Greptile SummaryThis PR hardens the ML inference load and decode path. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "Accept indexed and probeable torch devic..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
SDK Coverage •
| ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 702e8d4. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…ning # Conflicts: # CHANGELOG.md
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.

Summary
*-INJlabel maps at load (ModelError), validate forced torch devices (ConfigError), and makeModelProvider/SpanInferenceModelload thread-safeunplug.optional.mlhelpers; add ML module logging for device selection and tokenizer fallbacksTest plan
cd sdk && make check(1027 passed)cd sdk && make test-cov(80% gate green;span_model.py~82%,injection_ml.py~72%)test_bioes,test_device,test_providers,test_span_model,test_injection_ml_scanner(markedrequires_ml)Note
Medium Risk
Changes sit on the injection-detection ML path (load, decode, device), but behavior for valid checkpoints should match prior logic while invalid config and mislabeled weights fail earlier with explicit errors.
Overview
Hardens the ML injection span pipeline so bad checkpoints and device config fail clearly instead of crashing at decode time, and concurrent loads do not double-initialize models.
SpanInferenceModelnow rejects checkpoints whose label map lacks any*-INJtags at load withModelError, anddecode_bioes_spansreturns no spans when those columns are missing (defense in depth).resolve_torch_devicevalidates forced devices (ConfigErrorwith available backends), keepscpuwithout importing torch, and auto-selection still prefers cuda → mps → cpu viaunplug.optional.ml.Thread-safe loading uses double-checked locking on
ModelProviderandSpanInferenceModel(predict stays lock-free after load). Torch/transformers imports go throughget_torch/get_transformers; providers and span model log load, device, and tokenizer fallback warnings.CI/offline testing: session-scoped synthetic BIOES checkpoints plus unit tests for BIOES decode, device resolution, concurrent provider load, span model load/predict/overflow, and
InjectionSpanScannerintegration (requires_ml).Reviewed by Cursor Bugbot for commit b6e33f5. Bugbot is set up for automated code reviews on this repo. Configure here.