quark.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright 2025 The HuggingFace Inc. team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from ..core_model_loading import ConversionOps
  15. from ..utils import is_torch_available
  16. if is_torch_available():
  17. import torch
  18. class QuarkDeserialize(ConversionOps):
  19. def __init__(self, hf_quantizer):
  20. self.hf_quantizer = hf_quantizer
  21. def convert(
  22. self,
  23. input_dict: torch.Tensor,
  24. full_layer_name: str | None = None,
  25. **kwargs,
  26. ) -> dict[str, torch.Tensor]:
  27. value = list(input_dict.values())[0]
  28. value = value[0] if isinstance(value, list) else value
  29. return {full_layer_name: value}