Feature Flags¶
mobius exposes runtime feature flags that control experimental or
environment-specific behaviour. Flags live in mobius._flags and are
for internal use only — external callers configure them via environment
variables (see below).
Available flags¶
Flag |
Environment variable |
Default |
Description |
|---|---|---|---|
|
|
|
Suppress “has no constant value” warnings from the initializer-deduplication pass. These warnings are expected noise when optimisation passes run before weights are loaded. Set |
|
|
|
Decompose grouped RMSNormalization into basic ops to work around an ORT <=1.24.4 CUDA kernel bug that produces wrong results when scale is 2D. Set |
|
|
|
Lower the ONNX default-domain opset declaration to 23 when creating ORT sessions on non-CPU execution providers (CUDA, TRT, etc.). ORT <=1.24.x EPs didn’t register kernels for opset 24 standard ops (Squeeze, Reshape, etc.) even though the semantics are unchanged. Lowering the import declaration lets the EP find its existing kernels. Set |
|
|
|
Emit Tencent custom Q1_0 (2-bit SEQ) tensors using native |
|
|
|
Emit a float additive attention bias on the external-KV static-cache |
Setting flags via environment variables¶
Environment variables are read when the global flags singleton is constructed
at import time. Set them before importing mobius (e.g., in a shell or .env):
# Example: disable warning suppression to see all deduplication warnings
export MOBIUS_SUPPRESS_DEDUP_WARNING=0
python -c "import mobius; mobius.build('Qwen/Qwen2.5-0.5B-Instruct')"
Accepted truthy values: 1, true, yes (case-insensitive).
Accepted falsy values: 0, false, no (case-insensitive).
Any other value falls back to the field default.
Setting flags programmatically (internal code only)¶
Internal modules can import flags directly and assign to it:
from mobius._flags import flags
flags.suppress_dedup_warning = False # disable
flags.suppress_dedup_warning = True # re-enable
Using override_flags() in tests¶
For tests that need a temporary flag value, use the override_flags context
manager. It restores the original values on exit, even if the test raises:
from mobius._flags import override_flags
def test_build_with_warnings(tmp_path):
with override_flags(suppress_dedup_warning=False):
pkg = mobius.build("Qwen/Qwen2.5-0.5B-Instruct")
# suppress_dedup_warning is restored here
override_flags raises ValueError for unknown flag names, catching typos early.
Thread safety:
override_flagsis not thread-safe — concurrent calls in different threads may interleave the save/restore cycle (TOCTOU). For pytest, this is safe withpytest -n autobecause xdist workers run in separate processes with independent flag singletons.
Listing all flags¶
from mobius._flags import list_flags
print(list_flags())
Adding new flags¶
Add a field to
_Flagsinsrc/mobius/_flags.py:my_new_flag: bool = dataclasses.field( default_factory=lambda: _env_bool("MOBIUS_MY_NEW_FLAG", False) ) """Short description of what my_new_flag controls."""
Wire the flag into the code path it controls.
Regenerate this page:
python docs/_generate_flags_docs.pyAdd tests in
src/mobius/_flags_test.pyfollowing existing patterns.