common: force C locale for numeric formatting#20022
Closed
Scottcjn wants to merge 1 commit intoggml-org:masterfrom
Closed
common: force C locale for numeric formatting#20022Scottcjn wants to merge 1 commit intoggml-org:masterfrom
Scottcjn wants to merge 1 commit intoggml-org:masterfrom
Conversation
Ensure consistent decimal point formatting across all tools by setting LC_NUMERIC to "C" in common_init(). Also override LC_NUMERIC back to "C" in console::init() after it sets LC_ALL to the user's locale, preventing locales like de_DE from changing decimal separators to commas. Without this fix, tools using console::init() (like llama-cli) print "10000,0" while others (like llama-perplexity) print "10000.0" on systems with non-English LC_NUMERIC locale. Fixes #10613 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
Incorrect fix (making a library change global locale) and essentially duplicate of #17331 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ensure consistent decimal point formatting across all llama.cpp tools by forcing
LC_NUMERICto"C"locale.Problem
On systems with non-English
LC_NUMERIClocale (e.g.de_DE.UTF-8), different llama.cpp tools produce inconsistent decimal formatting:llama-cli10000,0(comma)console::init()callssetlocale(LC_ALL, "")llama-perplexity10000.0(period)This affects all floating-point output including sampler parameters, performance stats, and model metadata — not just GGUF KV data.
Fix
Two-pronged approach:
common_init()incommon.cpp: SetLC_NUMERICto"C"early — catches all tools on startupconsole::init()inconsole.cpp: OverrideLC_NUMERICback to"C"aftersetlocale(LC_ALL, "")— prevents the user locale call from re-overriding the numeric localeThis keeps the user's locale for character handling (UTF-8, wide chars) while forcing consistent period-as-decimal-separator for all numeric output.
Testing
To verify on a system with German locale:
Fixes #10613
🤖 Generated with Claude Code