Skip to content

Q4_1 inference appears broken for 13B parameters #152

Closed

Description

@blackhole89

I have been experimenting with q4_1 quantisation (since some preliminary results suggest it shold perform better), and noticed that something about the pipeline for the 13B parameter model is broken (whether it is the quantization itself, or the saving or loading). This results in all inferred tokens coming out as #. Meanwhile, 7B works well.

I know we had a patch a while ago that first made the 13B+ models work for q4_0 - did whatever fixes it made not cover q4_1?

Activity

  1. added
    bug
    on Mar 15, 2023
  2. tisfeng commented on Mar 15, 2023

    @tisfeng

    Yes, I use the 13B model and it doesn't work properly for either chatting or tasks. It simply ends without any response, which is very confusing to me.

    image

  3. ggerganov commented on Mar 15, 2023

    @ggerganov
    Member

    First - great work!

    Most likely the cause is that when I changed the Q4_0 scaling storage, I skipped the Q4_1 routines:

    007a8f6

    This change was necessary to make larger model works, because when we merge rows from different shards, the scaling factors have to be next to the integer quants. Originally, what happened, is the scaling factors of a row, ended up at the start of the memory buffer, before all the int quants, and this caused the merging in main.cpp to fail.

    In short: you need to rearrange the scaling and offset factors for a chunk to be located right before the int quants in the memory buffer in order to have correct merging of the shards.

    P.S. Btw it is strange that you don't see any asserts firing up. Are you building with -NDEBUG while developing? You should see infs or nans at the very start of the inference if you remove -NDEBUG

  4. tisfeng commented on Mar 15, 2023

    @tisfeng

    I didn't use -NDEBUG, I am a newcomer to this, just converted the 13B model using the latest code from the main branch,no errors were reported during the conversion.

    make -j && ./main -m ./models/13B/ggml-model-q4_0.bin -p "What is the best programming language in the world? Why?" -t 8 -n 512
    

    When using the 7B model, it works fine.

    image

  5. added
    model
    on Mar 15, 2023
  6. added a commit that references this issue on Mar 15, 2023
    58175e3
  7. blackhole89 commented on Mar 15, 2023

    @blackhole89
    ContributorAuthor

    In 13B Q4_1 mode:

    image

    I think it seems to work now, so I might make a PR against the main repository.

  8. added a commit that references this issue on Mar 16, 2023
    a2e9d49
  9. tisfeng commented on Mar 16, 2023

    @tisfeng

    Great, thank you!

  10. added a commit that references this issue on Mar 17, 2023
    904d2a8
  11. added a commit that references this issue on Mar 17, 2023
    7ee59d2
  12. added a commit that references this issue on Mar 17, 2023
    00f34c1
  13. added a commit that references this issue on Apr 26, 2026
    03c8e88
  14. added a commit that references this issue on May 6, 2026
    3ef5293
  15. 12 remaining items

  16. added a commit that references this issue on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmodel

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions