feat: add clinical SLM memory preflight - #3172
Open
maziyarpanahi wants to merge 1 commit into
Open
maziyarpanahi wants to merge 1 commit into
maziyarpanahi wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds a deterministic, local-only memory admission check for local clinical SLM
loading. The preflight estimates weight, KV-cache, context, batch, and runtime
overhead bytes from bounded artifact metadata and an explicit runtime profile.
Loads that cannot preserve the configured headroom are rejected before model
construction with an aggregate, value-free resource report.
Type of Change
Changes Made
ClinicalSLMRuntimeProfile, artifact metadata normalization, anddeterministic memory estimation for weights, cache, context, batch, and
runtime overhead.
ClinicalSLMMemoryPreflightReportwith stablememory_budget_exceededandheadroom_insufficientreason codes, aggregatebyte arithmetic, and a normalized artifact fingerprint.
call, imports no optional backend, and does not open model weight bytes.
component manifests, local metadata paths, stat-only binary paths, alias
normalization, shortfalls, and value-free errors.
publication contract.
Testing
Exact local validation:
.venv/bin/python -m pytest tests/unit/models/test_clinical_slm_memory.py -q— 9 passed.venv/bin/python -m pytest tests/unit/models/test_bootstrap_check.py tests/unit/models/test_bundled.py -q— 29 passedmake format— passed; 2,036 files left unchangedmake lint— passedmake format-check— passed; 2,036 files already formatteduv run --frozen --extra dev mypy openmed/models/clinical_slm_memory.py tests/unit/models/test_clinical_slm_memory.py— passed.venv/bin/python -m py_compile openmed/models/clinical_slm_memory.py tests/unit/models/test_clinical_slm_memory.py— passedgit diff --cached --check— passed before commitmake docs-build— passed; staged Pages artifact and publication validation completedThe documentation build emitted the repository’s existing Material-for-MkDocs,
un-navigated-page, and revision-timestamp notices; it did not fail. No
model-backed inference or real clinical inputs were used.
Checks intentionally not run: the full repository test suite, model-backed or
integration/benchmark gates, Swift/OpenMedKit checks (no Swift files changed),
remote CI checks, and
gh pr checks --watch.Documentation
The changelog and release metadata are intentionally unchanged; this PR does
not bump or publish a release.
Code Quality
make format,make lint, andmake format-checkmake format-swiftandmake lint-swiftDependencies
The implementation uses only the Python standard library; no package or lock
file changes are required.
Checklist
Related Issues
Closes #2759
Screenshots/Examples
No UI changes. The documentation includes a synthetic
weights_bytesexampleand the exact weight/cache/context/batch arithmetic. Reports contain aggregate
resource values and a fingerprint only; they do not contain patient data,
credentials, model identifiers, paths, prompts, or model contents.