| 11654 | |
| 11655 | @staticmethod |
| 11656 | def build_context_params( |
| 11657 | *, |
| 11658 | n_ctx: Optional[int], |
| 11659 | n_batch: Optional[int], |
| 11660 | n_ubatch: Optional[int], |
| 11661 | n_seq_max: Optional[int], |
| 11662 | n_threads: Optional[int], |
| 11663 | n_threads_batch: Optional[int], |
| 11664 | rope_scaling_type: Optional[int], |
| 11665 | pooling_type: Optional[int], |
| 11666 | attention_type: Optional[int], |
| 11667 | embedding: bool, |
| 11668 | rope_freq_base: Optional[float], |
| 11669 | rope_freq_scale: Optional[float], |
| 11670 | yarn_ext_factor: Optional[float], |
| 11671 | yarn_attn_factor: Optional[float], |
| 11672 | yarn_beta_fast: Optional[float], |
| 11673 | yarn_beta_slow: Optional[float], |
| 11674 | yarn_orig_ctx: Optional[int], |
| 11675 | offload_kqv: Optional[bool], |
| 11676 | flash_attn: Optional[bool], |
| 11677 | op_offload: Optional[bool], |
| 11678 | swa_full: Optional[bool], |
| 11679 | no_perf: Optional[bool], |
| 11680 | type_k: Optional[int], |
| 11681 | type_v: Optional[int], |
| 11682 | kv_unified: bool, |
| 11683 | n_rs_seq: Optional[int] = None, |
| 11684 | ctx_type: Optional[int] = None, |
| 11685 | n_outputs_max: Optional[int] = None, |
| 11686 | ctx_other: Optional[Any] = None, |
| 11687 | ) -> Any: |
| 11688 | context_params = llama_cpp.llama_context_default_params() |
| 11689 | if n_ctx is not None: |
| 11690 | context_params.n_ctx = n_ctx |
| 11691 | if n_batch is not None: |
| 11692 | context_params.n_batch = min(int(context_params.n_ctx), n_batch) |
| 11693 | if n_ubatch is not None: |
| 11694 | context_params.n_ubatch = min(int(context_params.n_batch), n_ubatch) |
| 11695 | if n_seq_max is not None: |
| 11696 | context_params.n_seq_max = n_seq_max |
| 11697 | if n_rs_seq is not None: |
| 11698 | context_params.n_rs_seq = n_rs_seq |
| 11699 | if n_threads is not None: |
| 11700 | context_params.n_threads = n_threads |
| 11701 | if n_threads_batch is not None: |
| 11702 | context_params.n_threads_batch = n_threads_batch |
| 11703 | if ctx_type is not None: |
| 11704 | context_params.ctx_type = ctx_type |
| 11705 | if n_outputs_max is not None: |
| 11706 | context_params.n_outputs_max = n_outputs_max |
| 11707 | if ctx_other is not None: |
| 11708 | context_params.ctx_other = ctx_other |
| 11709 | if rope_scaling_type is not None: |
| 11710 | context_params.rope_scaling_type = rope_scaling_type |
| 11711 | if pooling_type is not None: |
| 11712 | context_params.pooling_type = pooling_type |
| 11713 | if attention_type is not None: |