Repository navigation
Conversation
QStorage::Cpu is a Box<dyn QuantizedType>, so from_data copies every tensor into anonymous memory. from_mapped borrows an Arc<Mmap> window instead: the weights stay file-backed and fault in on use. QuantizedType::from_float and from_float_imatrix now return Result, because mapped storage is read-only.
This branch has not been deployed
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.
Toward #3708.
QStorage::Cpuis aBox<dyn QuantizedType>, sofrom_datacopies every tensor into anonymous memory at load. For a multi-GB GGUF that doubles the resident cost of the weights.QStorage::from_mappedborrows anArc<Mmap>window.TensorInfo::read_mapped,Content::tensor_mapped, andContent::from_mmapplumb that through the GGUF reader, andVarBuilder::from_ggufuses it. The mapping lives as long as any tensor that holds it. Mapped storage is read-only (from_floatreturns an error). Non-CPU devices still copy, because the upload needs the bytes.from_gguf_bufferis unchanged.Breaking change:
QuantizedType::from_floatandfrom_float_imatrixnow returnResult<()>.Measured on an aarch64 Ampere-1a, Linux,
schedutil, caches not dropped, loadingflint-Q4_K_M.gguf(22.5 GiB, 779 tensors). Mapping every tensor and not reading them leftAnonymousat 25 MB. Reading one 240 MB tensor faulted file pages and did not growAnonymous.from_data(Cow::Borrowed)of 2.07 GiB grewAnonymousby 2.07 GiB. The mapped tensor matched the copy byte for byte, including throughQMatMul.Tests:
mapped_tensor_matches_the_copied_one,mapped_window_is_checked,mapped_tensor_matmuls_like_the_copied_one. Nosmapsassertion in CI.