Repository navigation
Conversation
arthw
left a comment
There was a problem hiding this comment.
@bri-prism
There is no import change in SYCL backend.
I can't review this PR as maintainer.
Thank you!
|
Since this is just TQ1_0 with 128 instead of 256 values per scale, wouldnt this be named TQ1_X instead? |
|
It is a different layout, not TQ1_0 with a smaller block: 2-bit codes with a per-128 scale, so it round-trips exactly-ternary weights losslessly where TQ1_0's 5-trits-per-byte packing does not (see the lossless.py numbers above). The P prefix follows PQ2_0. Happy to rename if the maintainers prefer another convention. |
|
Can you explain in the op how it works then? |
|
Correction to my earlier reply, you were right: the packing is the same as TQ1_0 (5 trits per byte plus a 4-per-byte tail). The only difference is a 128-value block with its own fp16 scale. These models are quantized with one scale per 128 weights, and TQ1_0's single scale per 256 has to merge two of them, which is where the lossless.py error comes from. I've added this to the description. A TQ1_X-style name is fine by me if that fits the naming better. |
|
@Green-Sky Since the packing matches TQ1_0, I'm happy to rename this to TQ1_X before review if you or the maintainers prefer that. Otherwise I'll keep PTQ1_0 to match PQ2_0. |
I am not the authority on that, but historically it has been like that. I would wait for someone with more say :) |
From Brian (bri-prism), PR ggml-org#29672. Preserve type ID 143 for existing GGUF files. Source: ggml-org#29672 Original-commit: 5e22dd0 Assisted-by: Claude Code Assisted-by: Codex (porting and rebasing) Ported and rebased by Codex.
From Brian (bri-prism), PR ggml-org#29672. Preserve type ID 143 for existing GGUF files. Source: ggml-org#29672 Original-commit: 5e22dd0 Assisted-by: Claude Code Assisted-by: Codex (porting and rebasing) Ported and rebased by Codex.
|
Thanks to everyone working on this! I was looking back at #8151 and noticed that compilade had already considered smaller ternary block sizes, including 64, during the original TQ1_0 development. With Bonsai 2 now requiring a 128-element block to preserve its learned per-group scales, I wonder if this might be a good opportunity to revisit that discussion. Would it make sense to consider a common design for a small set of block sizes (such as 64, 128, and 256), or would keeping PTQ1_0 as a separate type be more practical for llama.cpp? I understand that both approaches have trade-offs, especially regarding compatibility and long-term maintenance. @ggerganov @CISC — If you have a chance, I'd be interested to hear your thoughts on the preferred direction. Even a brief comment would be appreciated. I'm just following the development with interest, and I appreciate all the work going into Bonsai 2 support. Thanks! |
From Brian (bri-prism), PR ggml-org#29672. Preserve type ID 143 for existing GGUF files. Source: ggml-org#29672 Original-commit: 5e22dd0 Assisted-by: Claude Code Assisted-by: Codex (porting and rebasing) Assisted-by: Claude (Opus 5.5), rebase onto ggml-org master with conflict resolution Ported and rebased by Codex.
|
i think this is not right ! this does not maintain its first merge ! : the tq_01 works fine in lmstudio and other products which already acess these original ternary quantizes : and this relese would force those previous models to fail : this is a failure on the part of prisimML whom should just add new quantizes instead of overwriting previous versions : personally i have not made the newer version work locally with the newer PQ_01 or the PQ_02 quantizes ! obviousy quantizing methods should not be model specific but cover most models ! we are currenty waiting for the right release and standardized version of this quantizing method ! this shoudl also apply to new quantizing methods : ( also providing full documentations ! ) |
yes its important to maintain backwards compatiblity : as well as make sense : same as turboquantizes need to also have some identifiers such as TB_Q1 Q2 etc but we need to be able to understand these things at a glance : ( by adding the P ( for prisimML ) ) no !! TQ was exactly right and sets the right standard going forwards for others : |
|
I would really hate to see this PR remain stalled over naming conventions, especially given the potential impact of Ternary Bonsai 2. Among models that can run within an approximately 8 GB memory budget, Bonsai 2 represents a remarkably interesting level of capability. If it becomes broadly accessible through mainstream llama.cpp and its ecosystem, it could significantly change what is practical on ordinary consumer gaming PCs. I think getting this support merged upstream is particularly valuable. Regarding naming, I believe @spydaz's suggestion offers a reasonable direction, while preserving backward compatibility:
Of course, the exact spelling could follow whatever convention the llama.cpp maintainers prefer. The important point is that group size is not merely a storage detail. Bonsai 2 was trained with groups of 128 weights, and converting those weights to a 256-element scale group introduces additional quantization error. Recovering that lost accuracy could require substantial QAT adjustments. Future ternary models may benefit from different group sizes, so a naming scheme that can accommodate 64, 128, and 256 seems worth considering. The PR author has already indicated willingness to rename I am certainly not suggesting that support for all three group sizes needs to be implemented now. Supporting G128 while preserving the existing G256 format would already be an important step. Could one of the maintainers or contributors familiar with GGUF quantization formats help coordinate a naming decision and a clear path toward merging this PR? It would be unfortunate for such a promising development to remain pending simply because no common naming convention has been settled. Thanks again to everyone contributing to this work. I genuinely hope we can get this into upstream llama.cpp and make it available to a much wider community. |
|
Hi, can you pls rebase? Wanna try your But on master there have been lots of performance optimizations (including #29772 by you 😊) and your branch is kinda outdated, I'd appreciate if you could rebase 😊 |
Preserve the published 128-element, 28-byte codec contract on upstream 5a4afd8. Add CPU byte, CLI and GGUF compatibility coverage. Model-level quality and performance acceptance remains pending. Assisted-by: Claude Code and Codex
f1bf0ae to
a967c2a
Compare
Document the existing group-128 packing and CLI option without changing published names or IDs. Verify actual CLI shape fallbacks to Q4_0/F16 and COPY payload preservation. Assisted-by: Codex
|
Nice to see this PR rebased and caught up with recent upstream changes! The expanded test coverage is also great to see. Thanks for keeping this moving and for all the work on compatibility! |
PTQ1_0 preserves exactly ternary weights with one scale per 128 elements. It uses the same base-3 digit encoding as TQ1_0. Its block is 24 base-3 payload bytes, two tail bytes and one fp16 scale (28 bytes, 1.75 bits/weight). Existing TQ1_0 remains unchanged. The published PTQ1_0 name and tensor ID 143 are retained pending maintainer agreement; this update does not silently change existing files.
Reconstructed onto upstream
5a4afd80779ba51166b59986e61a0bfbb9e1a4c6, preserving current F8_E4M3 support and the native x86 Q2 implementation. Scope: original 20 production/test files plus two existing Python test files and quantizer documentation. CUDA support stays in #29676.Validation on the rebased tree (Linux x86-64, CPU only):
llama-quantize --pure PTQ1_0andCOPYon a bounded synthetic matrix. Additional actual CLI cases verify Q4_0 fallback for width 96 and F16 fallback for width 127, including COPY payload preservation. This is not a generatable model test.ty; model-name mappings and whitespace checks pass. Official EditorConfig checker was unavailable.The quantizer documentation now explains the block layout, CLI creation, shape fallback, fp16-scale losslessness conditions and preservation of existing TQ1_0 files. Generic high-precision-to-ternary conversion is not claimed lossless.
Remaining upstream acceptance evidence: a small public model example, PPL and KL against native FP16/BF16 and similar-size quantizations, and matched pure-CPU performance. The previously linked 27B example depends on folded Hadamard support (#29600). Historical numbers against the Prism fork are not a fresh native-baseline quality or performance result for this rebase. No GPU/device validation was run.
AI assistance: the original implementation used Claude Code; this rebase, compatibility tests and update were assisted by Codex.
[skip ci]prevents this update from initiating ordinary CI while device testing is not authorized.