pymllm.configs.global_config¶
Global configuration singleton aggregating all sub-configs.
Classes¶
Singleton that holds every sub-config pymllm needs. |
Functions¶
Module Contents¶
- class pymllm.configs.global_config.GlobalConfig¶
Singleton that holds every sub-config pymllm needs.
Usage:
from pymllm.configs import get_global_config cfg = get_global_config() cfg.model.model_path cfg.model.hidden_size cfg.quantization.method cfg.server.host
Note
Always use
get_instance()(or the module-levelget_global_config()shortcut) to obtain the singleton.GlobalConfig()is safe to call multiple times — the second and subsequent calls return the existing instance without re-initialising fields.- quantization: pymllm.configs.quantization_config.QuantizationConfig¶
- classmethod get_instance()¶
- Return type:
- classmethod reset()¶
Destroy the singleton (useful in tests).
- Return type:
None
- pymllm.configs.global_config.make_args(parser=None)¶
Create an
argparseparser with two-level GlobalConfig CLI options.The generated options follow the naming pattern
--<section>.<field>so each sub-config can be configured independently:serveroptions map toServerConfigfields.modeloptions map toModelConfigfields.quantizationoptions map toQuantizationConfigfields.
Examples
--server.host 0.0.0.0--server.port 8080--server.sleep_on_idle(implicit true)--server.sleep_on_idle false(explicit false)--quantization.method awq
Design notes¶
Options are generated from dataclass metadata, which keeps the CLI surface synchronized with config definitions and avoids manual drift.
Parser defaults are suppressed (
argparse.SUPPRESS), soread_argscan reliably detect whether a value was explicitly provided by the user.Only CLI-friendly scalar fields are exposed; runtime-only fields are skipped automatically.
- Parameters:
parser (Optional[argparse.ArgumentParser])
- Return type:
argparse.ArgumentParser
- pymllm.configs.global_config.read_args(argv=None, parser=None)¶
Parse CLI args and apply overrides to the singleton
GlobalConfig.- Parameters:
argv (Optional[Sequence[str]]) – Optional argument vector. If
None,argparsereads fromsys.argv(standard CLI behavior).parser (Optional[argparse.ArgumentParser]) – Optional parser to use. When omitted, this function builds one through
make_args().
- Returns:
GlobalConfig – The singleton config instance after CLI overrides have been applied.
Behavior
——–
Parse all generated
--section.fieldoptions.
2. Apply only explicitly provided options (no accidental overwrite by parser – defaults).
Rebuild
ServerConfigwhen server fields change so validation in –ServerConfig.__post_init__and_validateremains enforced.
4. Keep
server.model_pathandmodel.model_pathaligned when only one – side is explicitly overridden (the same precedence used by runtime config loading conventions).
- Return type:
- pymllm.configs.global_config.get_global_config()¶
Return the global config singleton.
- Return type: