Skip to content

gguf-py: fix gguf-py/examples/writer.py #8952

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

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

tarilabs
Copy link
Contributor

@tarilabs tarilabs commented Aug 9, 2024

Double-call to add_architecture() in example results in ValueError.

Example is instantiating GGUFWriter in example:
https://github.com/ggerganov/llama.cpp/blob/3071c0a5f218f107dabd13b73f6090af683ef5ec/gguf-py/examples/writer.py#L16-L18

But constructor already has the add_architecture() call here:
https://github.com/ggerganov/llama.cpp/blob/3071c0a5f218f107dabd13b73f6090af683ef5ec/gguf-py/gguf/gguf_writer.py#L108

Before (today)

(gguf-py3.11) gguf-py % python examples/writer.py
Traceback (most recent call last):
  File "/Users/mmortari/git/llama.cpp/gguf-py/examples/writer.py", line 40, in <module>
    writer_example()
  File "/Users/mmortari/git/llama.cpp/gguf-py/examples/writer.py", line 18, in writer_example
    gguf_writer.add_architecture()
  File "/Users/mmortari/git/llama.cpp/gguf-py/gguf/gguf_writer.py", line 484, in add_architecture
    self.add_string(Keys.General.ARCHITECTURE, self.arch)
  File "/Users/mmortari/git/llama.cpp/gguf-py/gguf/gguf_writer.py", line 312, in add_string
    self.add_key_value(key, val, GGUFValueType.STRING)
  File "/Users/mmortari/git/llama.cpp/gguf-py/gguf/gguf_writer.py", line 272, in add_key_value
    raise ValueError(f'Duplicated key name {key!r}')
ValueError: Duplicated key name 'general.architecture'

After

(gguf-py3.11) gguf-py % python examples/writer.py                                  
(gguf-py3.11) gguf-py % ls -la *.gguf
-rw-r--r--@ 1 mmortari  staff  1088 Aug  9 16:36 example.gguf

@github-actions github-actions bot added the python python script changes label Aug 9, 2024
@tarilabs tarilabs changed the title gguf-py: fix gguf-py/examples/reader.py gguf-py: fix gguf-py/examples/writer.py Aug 9, 2024
@ggerganov ggerganov merged commit 911b437 into ggml-org:master Aug 10, 2024
8 checks passed
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
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