Skip to content

Conversation

@fitzsim
Copy link
Contributor

@fitzsim fitzsim commented Jan 11, 2023

No description provided.

@fitzsim fitzsim mentioned this pull request Jan 11, 2023
Copy link

@awilfox awilfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nits I found while reviewing the changes.

Makefile Outdated
Comment on lines 120 to 123
ifneq (,$(findstring POWER9,$(POWER9_M)))
CFLAGS += -mpower9-vector -DGGML_BIG_ENDIAN
CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN
endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this port will be big-endian even if run on non-Power9 systems (consider P8, P10, or any other generation), so I think this is more correct:

Suggested change
ifneq (,$(findstring POWER9,$(POWER9_M)))
CFLAGS += -mpower9-vector -DGGML_BIG_ENDIAN
CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN
endif
ifneq (,$(findstring POWER9,$(POWER9_M)))
CFLAGS += -mpower9-vector
endif
CFLAGS += -DGGML_BIG_ENDIAN
CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN

ggml.c Outdated
case GGML_TYPE_F16: {
unsigned short * toswap = (unsigned short *)(node->src1->data);
for (int k = 0; k < (ggml_nbytes(node->src1) / sizeof(unsigned short)); k++) {
toswap[k] = bswap_16(toswap[k]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for using std::byteswap in whisper.cpp but not here?

whisper.cpp Outdated
static void read_safe(std::ifstream& fin, T& dest) {
fin.read((char*)& dest, sizeof(T));
#if defined(GGML_BIG_ENDIAN)
if constexpr (std::endian::native == std::endian::big) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise the reason for the guard is because <bit> is guarded by it, but this seems wrong; if that's defined, it will always be BE.

What you probably want is something like #if __cplusplus >= 202110L (the revision of C++2x that added std::byteswap).

@fitzsim fitzsim changed the title PPC64 BE support incomplete draft PPC64 BE support Jan 21, 2023
@fitzsim
Copy link
Contributor Author

fitzsim commented Jan 21, 2023

This is ready to merge now. @awilfox, all your comments on the draft are addressed, thanks.

Maybe convert-pt-to-ggml.py should hard-code struct-packing to use little-endian, so that when it is run on big-endian targets the resulting model will still be compatible with this code. Calls like struct.pack("i", 0x67676d6c) would be changed to struct.pack("<i", 0x67676d6c) (untested). That said, on PPC64 import torch doesn't even work, so the models can't currently be generated on that platform anyway.

@fitzsim fitzsim changed the title PPC64 BE support PPC64 big-endian support Jan 21, 2023
@ggerganov ggerganov merged commit ae16c21 into ggml-org:master Jan 23, 2023
anandijain pushed a commit to anandijain/whisper.cpp that referenced this pull request Apr 28, 2023
* ggml : set cache line size to 128 on POWER9

* whisper : add PPC64 big endian support
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
* ggml : set cache line size to 128 on POWER9

* whisper : add PPC64 big endian support
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
* ggml : set cache line size to 128 on POWER9

* whisper : add PPC64 big endian support
landtanin pushed a commit to landtanin/whisper.cpp that referenced this pull request Dec 16, 2023
* ggml : set cache line size to 128 on POWER9

* whisper : add PPC64 big endian support
iThalay pushed a commit to iThalay/whisper.cpp that referenced this pull request Sep 23, 2024
* ggml : set cache line size to 128 on POWER9

* whisper : add PPC64 big endian support
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.

3 participants