Skip to content

gguf-py: handle numpy 2.0 byte-ordering changes #11905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

gguf-py: handle numpy 2.0 byte-ordering changes #11905

wants to merge 1 commit into from

Conversation

parsapoorsh
Copy link

this commit fixes this error:

Traceback (most recent call last):
  File "/home/poweruser/python-goddamn-venv/bin/gguf-dump", line 8, in <module>
    sys.exit(gguf_dump_entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 450, in main
    dump_metadata(reader, args)
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 35, in dump_metadata
    host_endian, file_endian = get_file_host_endian(reader)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 24, in get_file_host_endian
    host_endian = 'LITTLE' if np.uint32(1) == np.uint32(1).newbyteorder("<") else 'BIG'
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: newbyteorder was removed from scalar types in NumPy 2.0. Use sc.view(sc.dtype.newbyteorder(order)) instead.

this commit fixes this error:
```python
Traceback (most recent call last):
  File "/home/poweruser/python-goddamn-venv/bin/gguf-dump", line 8, in <module>
    sys.exit(gguf_dump_entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 450, in main
    dump_metadata(reader, args)
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 35, in dump_metadata
    host_endian, file_endian = get_file_host_endian(reader)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/poweruser/python-goddamn-venv/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 24, in get_file_host_endian
    host_endian = 'LITTLE' if np.uint32(1) == np.uint32(1).newbyteorder("<") else 'BIG'
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: newbyteorder was removed from scalar types in NumPy 2.0. Use sc.view(sc.dtype.newbyteorder(order)) instead.
```
@github-actions github-actions bot added the python python script changes label Feb 16, 2025
@ggerganov ggerganov requested a review from Copilot February 16, 2025 06:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@ngxson
Copy link
Collaborator

ngxson commented Feb 16, 2025

AFAIK the same code is also present in gguf_new_metadata and other python scripts. So probably better to do a full pass to change it in other places.

And btw these scripts are not actually part of gguf-py, they are more like "examples"

@CISC
Copy link
Collaborator

CISC commented Feb 16, 2025

Hey, sorry, this PR reminded me I had a lot of unsubmitted code locally, made #11909 that supercedes this...

@parsapoorsh
Copy link
Author

And btw these scripts are not actually part of gguf-py, they are more like "examples"

i have a bunch of guff models downloaded with ollama which their file doesn't have the name of the model, instead they are like:
sha256-170370233dd5c5415250a2ecd5c71586352850729062ccef1496385647293868
sha256-22a849aafe3ded20e9b6551b02684d8fa911537c35895dd2a1bf9eb70da8f69e

and i was looking for a tool that i could give a .guff file as input and get info about the model, something like the UNIX file or ffprobe command, and i stumbled upon this.

Closing the issue in favor of #11909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python python script changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants