Repository navigation
feat(writer): re-enable split_by="layer" with the SGLang caveat - #6683
Merged
Merged
Conversation
952c6fc disabled split_by="layer" while SGLang could not load the per-layer directory layout. The writer path still works (the dedicated tests pass once the gate is removed), so re-enable the option and warn about the limitation instead of rejecting it. - SUPPORTED_SPLIT_BY = {None, "layer"} with an accurate comment. - One log.warning per split_by="layer" save naming the SGLang limitation and the two bypasses. - One log.info when a load opens a shard index that points into per-layer sub-directories (split_by="layer" or per-layer reshard). - Un-skip the three split_by tests; add save-warning and load-detection tests; document the layout in the quantization guide. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qubitium
force-pushed
the
feat/reenable-split-by-layer
branch
from
December 1, 2026 18:42
fc8816e to
15a1402
Compare
Qubitium
marked this pull request as ready for review
December 1, 2026 18:59
This was referenced Dec 1, 2026
Qubitium
added a commit
that referenced
this pull request
Dec 1, 2026
…6689) #6656 added CalibrationConfig.spill_path and #6683 re-enabled split_by="layer" after #6640 refreshed the notes. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Summary
Re-enable
split_by="layer"(disabled in 952c6fc / #2625 while SGLang could not load the layout) and make the SGLang limitation explicit at save and load time. The writer path itself had not bit-rotted: the three tests skipped since 952c6fc pass unchanged once the gate is removed, and CPU round-trips for tiny Llama GPTQ, Qwen3-MoE GPTQ, Qwen2 AWQ, GPT-2, a quantizedlm_head, and a re-save of a loaded checkpoint are bit-identical tosplit_by=None.Rebased onto current
main(8eeab5e35, after #6666/#6667 reworked the writer meta table and removed the save-state overlay and #6676 changed the loader); the writer split path, the A/B, the round-trips and the red/green run below were all re-executed on that base.No production code path changed for the default
split_by=None; the writer A/B below is byte-identical.What Changed
gptqmodel/models/writer.py:SUPPORTED_SPLIT_BY = {None, "layer"}and an accurate comment replacing the 2026-03 disable note._parse_split_bykeeps its existing error text.gptqmodel/models/writer.py: onelog.warningpersplit_by="layer"save: the layout, the SGLang limitation, and the two bypasses (load with GPT-QModel, or re-save withsplit_by=None).gptqmodel/models/loader.py: onelog.infowhen a load opens a shard index whoseweight_mappoints into sub-directories (split_by="layer"or a per-layerreshard), with the same bypasses.tests/test_split_by_layer_save.py: un-skipped the three tests from 952c6fc; added a save-warning test and a layout-detection/load-log test.docs/quantization-guide.md: a short save-options note plus the layout/flow diagram.tests/models/model_test.pykeepsSPLIT_BY = None. That matrix needs GPUs and model downloads to validate, so this PR does not flip its default; the layout is covered by the dedicated CPU tests and the round-trips below.No writer bit-rot was found:
_stream_state_dict_to_layer_dirsdelegates to the samestreaming_state_dict_to_shards, so the 8 months of writer refactors (TensorSource, shard reuse, atomic writes, offload guards) apply to the per-layer path too. Verified explicitly: per-layer sharding undermax_shard_size, stale-shard cleanup on re-save into the same directory, flat→split and split→flat conversion in one directory, index self-consistency, and load/generate from the nested layout.SGLang caveat
The message states only what is known from #2625: SGLang currently cannot load this per-layer directory layout. I could not reach GitHub from this host to re-read the #2625 discussion, so the message does not claim a specific SGLang loader mechanism or invent an SGLang PR number. It names the two verified bypasses.
Tests
CPU,
/root/venv/bin/python -P, clone first onPYTHONPATH,CUDA_VISIBLE_DEVICES=(this host has no usable NVIDIA driver):Red/green (the un-skipped test file run against current
origin/main8eeab5e35vs this branch):Skips: none in the runs above.
tests/models/model_test.pyand the CUDA/integration model tests were not run (no GPU, model downloads unavailable), so the model-matrix default staysNone; the split layout is unverified for multimodal/vision layer stacks.Measured Impact
Not applicable: re-enabling a save option does not change the default output. The default-path writer A/B below is byte-identical.
Default-path A/B (
split_by=None), base8eeab5e35vs branchReused the 8-config writer A/B from the writer-meta-table work (
meta_ab.py: GPTQ default/GPTAQ/FOEM/JointQ, AWQ, GGUF, Paro, EXL3). It records every saved file's sha256 plusquantize_config.json/config.jsonmeta keys and hashes.split_by="layer"round-trips (CPU)All comparisons are bytewise (dtype/shape checked, then
view(uint8/int)equality), notallclose.The table was re-run on the rebased branch (post-#6666/#6667); every case passed again with the
same tensor counts:
offload_to_disk=TrueGPTQModel.loadstate_dict bit-identical (77); logits bit-identical;generate()worksgenerate()worksgenerate()worksgenerate()workstransformer.hlayer prefix)transformer.h.0/1; tensors bit-identical; loads and forwardslm_head=Truelm_head.safetensorsat root; flat vs split bit-identical (66)split_by="layer"max_shard_size="8KB"layer-00001-of-00005..05; index points at all 5; tensors bit-identical to flatmax_shard_size=Nonelayer-0000N-of-0000Mfiles removed,layer.safetensorsrestored; loads, bit-identicalmodel-*.safetensors; loads at each step; tensors bit-identicalScripts and outputs:
pr/reenable-split-by-layer.scratch/{roundtrip,resave,lmhead_resave,roundtrip_gpt2,convert}.pyandrt-*/rs/convoutput trees.Model Support / Module Plan
Not applicable: no new model, alias, definition, module plan or fusion change.
tests/module_treeis untouched.AWQ onboarding safety
Not applicable: no model definition, AWQ grouping, search, replay or fold code changed. The AWQ path was exercised only as a saver (
tests/round-trip above).Logic Flow Documentation
The save-layout decision is restored, so the flow is shown here and repeated in the quantization guide.
flowchart TD A["model.save(split_by=...)"] --> B["_parse_split_by"] B -- "None" --> C["streaming_state_dict_to_shards"] B -- "layer" --> W["log.warning: SGLang cannot load this layout"] B -- "other" --> X["ValueError: unsupported split_by"] W --> D["_stream_state_dict_to_layer_dirs"] D --> E["model.layers.N/layer.safetensors"] D --> F["model.safetensors.index.json"] C --> G["model.safetensors"] F --> H["GPTQModel.load: nested shard index"] H --> I["log.info: per-layer layout, SGLang bypass"] classDef failure fill:#ffe8e8,stroke:#b30000,color:#111; class X failure;SUPPORTED_SPLIT_BY(models/writer.py:214){None};"layer"raisedValueError{None, "layer"}; comment names the SGLang limitationsave_quantized(split_by="layer")(models/writer.py:3077)GPTQModel.loadof that layout (models/loader.py:3966)weight_map, logs one infoReview Requirements
Kernel Accuracy Requirements
Not applicable: no kernel, dispatch, pack or fusion code changed.
Notes
reshard()output, because it is the same layout and has the same SGLang limitation.tests/models/model_test.pydeliberately keepsSPLIT_BY = None(see Summary); flipping it is a follow-up that needs the GPU model matrix.deepseek_v41_flash.save()still rejectssplit_byexplicitly; its single indexed component checkpoint has no per-layer layout.🤖 Generated with Claude Code