Repository navigation
Keep HF cuFile/hipFile weights on device when memory permits - #2
Merged
Merged
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
cyyever
marked this pull request as ready for review
October 22, 2026 04:55
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.
Overview
Keep oversized original HF checkpoint tensors on the device during cuFile/hipFile compatibility-mode loading when memory permits. The existing model loader still handles names, slicing, fusion and layout conversions; no deployment-specific checkpoint conversion is required.
Claims
Validation
test_direct_io.pyandtest_hipfile.py, including sufficient memory, low memory, allocation races, byte correctness and tail chunks.PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --no-project .venv/bin/python -m pytest --confcutdir=tests/model_executor/model_loader -o addopts= tests/model_executor/model_loader/test_direct_io.py tests/model_executor/model_loader/test_hipfile.py -q.Details
Large compatibility-mode weights previously always passed through a CPU tensor, even with spare VRAM. This incremental path reuses existing backend readers and chunked writes without adding a model-specific mapping or dependency.
This is device staging, not zero-copy parameter adoption: the model loader may still copy or transform the loaded GPU tensor. It does not implement safetensors-native DLPack integration or arbitrary final-destination mapping. No end-to-end acceleration is claimed yet.
Review must consider consumer memory spikes, fragmentation and the possibility that asynchronous model loading retains source tensors longer than the generator iteration. Allocation fallback does not catch OOM inside model transformations.
Duplicate searches found no open BakeLab PR and no matching upstream model-loader PR; upstream results concerned KV offload and unrelated kernels. This builds on #1.
Remaining work
Pull Request Checklist
/pr-checklistskill.