pymllm.configs.global_config

Global configuration singleton aggregating all sub-configs.

Classes

GlobalConfig

Singleton that holds every sub-config pymllm needs.

Functions

make_args([parser])

Create an argparse parser with two-level GlobalConfig CLI options.

read_args([argv, parser])

Parse CLI args and apply overrides to the singleton GlobalConfig.

get_global_config()

Return the global config singleton.

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-level get_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.

server: pymllm.configs.server_config.ServerConfig
model: pymllm.configs.model_config.ModelConfig
quantization: pymllm.configs.quantization_config.QuantizationConfig
classmethod get_instance()
Return type:

GlobalConfig

classmethod reset()

Destroy the singleton (useful in tests).

Return type:

None

pymllm.configs.global_config.make_args(parser=None)

Create an argparse parser with two-level GlobalConfig CLI options.

The generated options follow the naming pattern --<section>.<field> so each sub-config can be configured independently:

  • server options map to ServerConfig fields.

  • model options map to ModelConfig fields.

  • quantization options map to QuantizationConfig fields.

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), so read_args can 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, argparse reads from sys.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

  • ——–

    1. Parse all generated --section.field options.

  • 2. Apply only explicitly provided options (no accidental overwrite by parser – defaults).

    1. Rebuild ServerConfig when server fields change so validation in – ServerConfig.__post_init__ and _validate remains enforced.

  • 4. Keep server.model_path and model.model_path aligned when only one – side is explicitly overridden (the same precedence used by runtime config loading conventions).

Return type:

GlobalConfig

pymllm.configs.global_config.get_global_config()

Return the global config singleton.

Return type:

GlobalConfig