]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
convert : fix big-endian conversion (#17431)
authorAleksei Nikiforov <redacted>
Tue, 25 Nov 2025 13:18:16 +0000 (14:18 +0100)
committerGitHub <redacted>
Tue, 25 Nov 2025 13:18:16 +0000 (14:18 +0100)
commit05872ac88532585fb198f1113be43ac654955cba
treeac431584cb9e264e9052b304f8a0fa8f0202f309
parent55ab25caf5caec6840d502325c8480b8afccc0b4
convert : fix big-endian conversion (#17431)

* Fix convert_hf_to_gguf.py script on s390x

Assume converted model data is originally little-endian.
Byteswap data on s390x after reading it to put values in correct presentation
for any transformation needed, like calculating weight tensors.

Then byteswap data to little-endian before passing it to GGUFWriter while
GGUFWriter will byteswap data back to big endian if big endian output is requested.

byteswap(inplace=True) calls don't work with lazy tensor and array wrappers.
Use byteswap with copying data to workaround this behaviour.

* Make GGUFWriter accept tensors in native endianness instead of little-endian

With this change if no byteswapping is actually needed, 2 excessive byteswaps can be omitted on s390x

* Fix byteswapping in convert_hf_to_gguf.py for remote models
convert_hf_to_gguf.py
gguf-py/gguf/gguf_writer.py