fix: correct flash_attn and main_gpu flag checks in llamacpp extension
Previously the condition for `flash_attn` was always truthy, causing unnecessary or incorrect `--flash-attn` arguments to be added. The `main_gpu` check also used a loose inequality which could match values that were not intended. The updated logic uses strict comparison and correctly handles the empty string case, ensuring the command line arguments are generated only when appropriate.
This commit is contained in:
parent
1f4977c1d1
commit
ea231676bf
@ -1646,10 +1646,15 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
if (cfg.device.length > 0) args.push('--device', cfg.device)
|
if (cfg.device.length > 0) args.push('--device', cfg.device)
|
||||||
if (cfg.split_mode.length > 0 && cfg.split_mode != 'layer')
|
if (cfg.split_mode.length > 0 && cfg.split_mode != 'layer')
|
||||||
args.push('--split-mode', cfg.split_mode)
|
args.push('--split-mode', cfg.split_mode)
|
||||||
if (cfg.main_gpu !== undefined && cfg.main_gpu != 0)
|
if (cfg.main_gpu !== undefined && cfg.main_gpu !== 0)
|
||||||
args.push('--main-gpu', String(cfg.main_gpu))
|
args.push('--main-gpu', String(cfg.main_gpu))
|
||||||
// Note: Older llama.cpp versions are no longer supported
|
// Note: Older llama.cpp versions are no longer supported
|
||||||
if (cfg.flash_attn !== undefined || !cfg.flash_attn || cfg.flash_attn !== '') args.push('--flash-attn', String(cfg.flash_attn)) //default: auto = ON when supported
|
if (
|
||||||
|
cfg.flash_attn !== undefined ||
|
||||||
|
!cfg.flash_attn ||
|
||||||
|
cfg.flash_attn !== ''
|
||||||
|
)
|
||||||
|
args.push('--flash-attn', String(cfg.flash_attn)) //default: auto = ON when supported
|
||||||
|
|
||||||
// Boolean flags
|
// Boolean flags
|
||||||
if (cfg.ctx_shift) args.push('--context-shift')
|
if (cfg.ctx_shift) args.push('--context-shift')
|
||||||
@ -1666,7 +1671,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
if (cfg.cache_type_k && cfg.cache_type_k != 'f16')
|
if (cfg.cache_type_k && cfg.cache_type_k != 'f16')
|
||||||
args.push('--cache-type-k', cfg.cache_type_k)
|
args.push('--cache-type-k', cfg.cache_type_k)
|
||||||
if (
|
if (
|
||||||
cfg.flash_attn &&
|
cfg.flash_attn !== 'on' &&
|
||||||
cfg.cache_type_v != 'f16' &&
|
cfg.cache_type_v != 'f16' &&
|
||||||
cfg.cache_type_v != 'f32'
|
cfg.cache_type_v != 'f32'
|
||||||
) {
|
) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user