Skip to content

Fix GGMLLayer reconstruction for GGUF quantized weights#6

Draft
maxious wants to merge 3 commits intoFearL0rd:mainfrom
maxious:fix/ggml-layer-reconstruction
Draft

Fix GGMLLayer reconstruction for GGUF quantized weights#6
maxious wants to merge 3 commits intoFearL0rd:mainfrom
maxious:fix/ggml-layer-reconstruction

Conversation

@maxious
Copy link
Copy Markdown

@maxious maxious commented Apr 6, 2026

GGMLLayer (from gguf.ops or gguf.pig) stores quantized weights as plain tensor attributes rather than nn.Parameter. When clone_module_simple() tries to reconstruct it via the generic handler, it wraps the quantized weight in nn.Parameter(), which fails with 'Only Tensors of floating point and complex dtype can require gradients'.

This special case handles GGMLLayer by:

  • Creating new instance via new + nn.Module.init
  • Deep-copying non-weight/bias attributes
  • Moving weight/bias tensors to target device via .to() instead of wrapping

This stops the warning flood: 'Warning: Failed to reconstruct... Only Tensors of floating point and complex dtype can require gradients'

FirstName LastName added 2 commits April 7, 2026 01:47
GGMLLayer (from gguf.ops or gguf.pig) stores quantized weights as plain
tensor attributes rather than nn.Parameter. When clone_module_simple() tries
to reconstruct it via the generic handler, it wraps the quantized weight in
nn.Parameter(), which fails with 'Only Tensors of floating point and complex
dtype can require gradients'.

This special case handles GGMLLayer by:
- Creating new instance via __new__ + nn.Module.__init__
- Deep-copying non-weight/bias attributes
- Moving weight/bias tensors to target device via .to() instead of wrapping

This stops the warning flood: 'Warning: Failed to reconstruct... Only
Tensors of floating point and complex dtype can require gradients'
Handles GGMLOps.Linear from ComfyUI-GGUF in addition to gguf.ops and gguf.pig
@maxious maxious marked this pull request as draft April 6, 2026 16:01
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.

1 participant