Skip to content

fix(vram): size every torch dtype so DeepSeek V4.1 budget placement loads - #6543

Merged
Qubitium merged 1 commit into
mainfrom
fix/vram-dtype-byte-size
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/vram-dtype-byte-size

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Fixes #6541

Root cause

#6473 replaced Accelerate's infer_auto_device_map in the DeepSeek V4.1 Placement.budget path with gptqmodel.utils.vram.compute_module_sizes. Its dtype_byte_size only handled bool / one-byte floats / fp16 / bf16 / fp32 / int32 and raised ValueError: dtype is not a valid dtype for any other torch dtype. V4.1 stores its packed FP4/FP8 payloads and scales as int8/uint8, so GPTQModel.load(v41, placement=Placement.budget({...})) always failed before placement. gptqmodel.utils.get_vram failed the same way on int8/uint8/int64/float64 tensors.

Fix

dtype_byte_size falls back to torch.empty((), dtype=dtype).element_size() for any other torch.dtype. The existing explicit branches (including sub-byte string formats) and the ValueError for non-dtypes are unchanged. No control-flow change outside this function, so no diagram.

Tests

Test main c649fcb this branch
tests/module_tree/test_deepseek_v41_flash.py::test_v41_cpu_budget_placement_loads_packed_checkpoint[128] (new; CPU budget load is byte-identical to device="cpu" load) FAIL dtype is not a valid dtype: torch.int8 pass
...::test_v41_budget_that_cannot_hold_a_unit_raises_the_fit_error[128] (new; 1 KiB budget gives the documented "does not fit" error) FAIL (dtype ValueError instead) pass
...::test_v41_cuda_load_runs_packed_projections[128] (existing, RTX 4090 sm_89, Marlin path, budget {"cuda:0": "1GiB"}) FAIL dtype is not a valid dtype: torch.int8 pass
tests/test_vram_non_persistent_buffers.py::test_compute_module_sizes_counts_every_torch_dtype (new; hand-computed byte counts for int8/uint8/int64/float64/bf16 plus get_vram) FAIL pass
Full files: pytest tests/module_tree/test_deepseek_v41_flash.py tests/test_vram_non_persistent_buffers.py 4 failed, 28 passed 32 passed
Lint gate uvx [email protected] check gptqmodel ... tests setup.py pass

Not verified: multi-GPU budget packing (single GPU assigned), native-MX path on sm_100+ (Blackwell not exercised).

🤖 Generated with Claude Code

…oads (#6541)

#6473 moved the V4.1 Placement.budget path from Accelerate's
infer_auto_device_map to utils.vram.compute_module_sizes, whose
dtype_byte_size raised for int8/uint8 (and int64/float64). V4.1 keeps
its packed payloads and scales in those dtypes, so every budget load
raised ValueError before placement.

Fall back to the dtype's element size for any other torch dtype.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 02:42
@Qubitium
Qubitium merged commit 5b93706 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/vram-dtype-byte-size branch December 1, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeek V4.1: GPTQModel.load(placement=Placement.budget(...)) raises ValueError: dtype is not a valid dtype: torch.int8

1 participant