Add qfloat8 offloading#930
Open
PlagueKind wants to merge 2 commits into
Open
Conversation
PlagueKind
force-pushed
the
ostris/feature/qfloat8offload
branch
from
July 10, 2026 22:07
c1eeb88 to
ccba60b
Compare
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.
Add qfloat8 (quanto) support with layer offloading and LoRA/LoKr merge
Quanto's
qfloat8quantization was forced tofloat8(torchao) in several places because the memory offload and merge-in code paths only recognized torchao's tensor subclass. This adds proper detection for quanto tensors and removes the resulting workarounds.Changes
toolkit/memory_management/manager_modules.py—_is_ao_quantized_tensornow also recognizesoptimum.quanto.*tensor subclasses, not justtorchao.*. Fixes offload/pin/bounce for qfloat8 weights, which were previously silently treated as plain float tensors.toolkit/config_modules.py— removed the forcedqfloat8→float8override forlayer_offloading, now unnecessary.toolkit/util/quantize.py—is_quantized_tensornow recognizes quanto tensors;requantize_module_weightnow re-quantizes quanto modules via.freeze()when no torchao config is available (quanto modules retain their ownweight_qtype/optimizer config from creation).toolkit/network_mixins.py,toolkit/models/lokr.py,toolkit/lora_special.py— removed early-returns that silently skippedmerge_in/merge_outentirely for quanto-quantized weights ('weight._data' in state_dict). The dequantize → merge → re-quantize logic underneath already worked generically once detection was fixed.extensions_built_in/diffusion_models/krea2/krea2.py— removed the forced qtype override for assistant LoRA loading, now unnecessary since merge_in correctly re-quantizes.Testing
_is_ao_quantized_tensor/_move_params_to_cpu_and_pinagainst a real quantoQLinear: outer wrapper and inner_data/_scalestorage both correctly land on CPU, not just the outer tensor.PIPELINE_DEPTH × weight size), not per-layer accumulation.toolkit/memory_management/test_memory_manager.py(temporarily swapped toqfloat8) across all 8 offload/checkpoint configs on a 1.2B-param model with a real LoRA network — no exceptions, correct output/gradient match against non-offloaded reference (output diff ~2e-3, input grad diff ~1e-6, consistent with fp8 quant noise).merge_in/merge_outround-trip correctness for bothFullModuleandLoRAModuleagainst real quantoQBytesTensorweights — weight changes as expected, stays quantized throughout, round-trip diff ~4e-3 (quant noise only).