{"record":{"id":"5899c664e9ec5006","repo":"sgl-project/sglang","slug":"expert-pack-direct-i-o-is-unavailable-on-this-plat","errorCode":null,"errorMessage":"expert-pack direct I/O is unavailable on this platform","messagePattern":"expert-pack direct I/O is unavailable on this platform","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":190,"sourceCode":"    store.cache_vram_reserve_mib = int(cache_vram_reserve_mib)\n    store.kernel_backend = \"custom\"\n    store.stage_slot_count = int(stage_slots)\n    store.read_splits = int(read_splits)\n    store.direct_io = bool(direct_io)\n    store.stats_flush_interval = int(stats_flush_interval)\n    if (\n        store.cache_vram_mib <= 0\n        or store.cache_vram_reserve_mib <= 0\n        or store.stage_slot_count <= 0\n        or store.read_splits <= 0\n    ):\n        raise ValueError(\n            \"expert cache and staging budgets, and read splits, must be positive\"\n        )\n    if store.stats_flush_interval < 0:\n        raise ValueError(\"expert-pack stats flush interval cannot be negative\")\n    if store.direct_io and not hasattr(os, \"O_DIRECT\"):\n        raise ValueError(\"expert-pack direct I/O is unavailable on this platform\")\n    open_flags = os.O_RDONLY | (os.O_DIRECT if store.direct_io else 0)\n    store._fd = os.open(store.path, open_flags)\n    store._lock = threading.RLock()\n    store._cache = None\n    store._cache_slots = []\n    store._key_to_slot = {}\n    store._key_frequency = {}\n    store._lru = OrderedDict()\n    store._staging = []\n    store._stage_events = []\n    store._stage_cursor = 0\n    store._transfer_stream = None\n    store._read_executor = None\n    store._active_keys = set()\n    store._route_calls_by_layer = [0] * store.header.num_layers\n    store._route_tokens_by_layer = [0] * store.header.num_layers\n    store.stats_path = Path(stats_path).resolve() if stats_path else None\n    store._last_stats_flush_calls = 0","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L172-L208","documentation":"ExpertPackStore was configured with direct_io=True, but the platform's os module lacks O_DIRECT (e.g. macOS or Windows). Direct I/O is only available on Linux, and the store fails fast rather than silently falling back to buffered I/O with different performance characteristics.","triggerScenarios":"Constructing ExpertPackStore(direct_io=True) on macOS or Windows where os.O_DIRECT does not exist; also some container/filesystem combos where the constant is unavailable.","commonSituations":"Developing on a Mac against packs produced for Linux servers; configs tuned for Linux deployed unchanged to other platforms; CIFS/FUSE mounts without O_DIRECT support in the build.","solutions":["Set direct_io=False on non-Linux platforms","Gate the flag on platform: direct_io=(sys.platform == 'linux')","Keep the direct-I/O tuning only in the Linux deployment config"],"exampleFix":"# before\nstore = ExpertPackStore(p, direct_io=True)  # on macOS -> ValueError\n\n# after\nimport sys\nstore = ExpertPackStore(p, direct_io=(sys.platform == \"linux\"))","handlingStrategy":"validation","validationCode":"import sys, os\ndirect_io = bool(direct_io) and sys.platform == \"linux\" and hasattr(os, \"O_DIRECT\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Platform-gate direct_io in shared configs","Keep performance-tuned direct-I/O settings in Linux-only deployment profiles"],"tags":["moe","expert-pack","direct-io","platform-support","configuration"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}