diff --git a/docs/DETAILS.md b/docs/DETAILS.md index bac07e5f0f..5af8a18056 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -769,7 +769,7 @@ a leading dot or a trailing dot or space. The request must be `Content-Type: application/json` (else `415`) and come from no browser page, Strata's own or a trusted origin (another site's `Origin` gets `403`, also with an API key); the Host and API-key checks apply as -everywhere. Errors: `501` without `--slot-save-path`; `400` for a slot other than 0, an unknown action, a refused +everywhere. Errors: `501` without `--slot-save-path` or with parallel requests; `400` for a slot other than 0, an unknown action, a refused file name, or a file the engine refuses as invalid (not a session file, corrupt, another model or configuration, over this session's limits; the session is as it was); `404` for a restore of a missing file; `503` while the model is not loaded, when the RAM to read the file is not there or an allocation failed; `507` when the disk has no room (the @@ -831,7 +831,8 @@ limits (context and cells, checkpoints, layers, each running-state array, each K and then the usual snapshot validation - all before any device write, and a refusal leaves the current session as it was. A transfer failure after the device writes began ends the engine (`FATAL`) rather than decode from a partial state; the server reports `500` and starts it again. A restore does not park the outgoing session. Not supported with -`--layer-split`, `--peer-device` or `--prompt-cache 0` (the RAM conversation cache need not be on). On Linux the file +`--layer-split`, `--peer-device`, `--batch` (the config's `"parallel"`, #465; the server answers `501`) or +`--prompt-cache 0` (the RAM conversation cache need not be on). On Linux the file moves with `O_DIRECT` in 16 MiB blocks when the filesystem takes it (buffered I/O otherwise, or with `STRATA_SESSION_BUFFERED=1`); on Windows with buffered I/O. The engine has been run on Linux/CUDA only. An earlier revision's CPU file-I/O test passed as a 32-bit Windows executable under Wine; the current code has not been built diff --git a/serve/server.py b/serve/server.py index a9889bd645..fcb57f61bc 100644 --- a/serve/server.py +++ b/serve/server.py @@ -2167,6 +2167,10 @@ class Service: "type": "invalid_request_error" if code < 500 else "server_error"}} if not self.slot_save_path or not hasattr(self.engine, "session_file"): return error(501, "slot save/restore is disabled (start the server with --slot-save-path DIR)") + if getattr(self.engine, "batch", 0): + # #465 parallel requests do not hold the FIFO and share the engine's control lines: a session file + # could interleave with a request being admitted, so the two are not combined (the engine refuses too) + return error(501, "slot save/restore is not available with parallel requests (\"parallel\" / --batch)") if slot != "0": return error(400, "this server has one slot: 0") if action not in ("save", "restore"): diff --git a/serve/test_slots.py b/serve/test_slots.py index f2df6f138c..d276ddbed4 100644 --- a/serve/test_slots.py +++ b/serve/test_slots.py @@ -420,6 +420,17 @@ class Slots(unittest.TestCase): self.svc.slot_save_path = saved self.assertEqual(s, 501, b) + def test_refused_with_parallel_requests(self): + """#465: batch slots do not hold the FIFO, so a session file is refused before anything reaches the engine.""" + self.engine.batch = 2 + try: + s, b = self.post("/slots/0?action=save", {"filename": "p.bin"}) + finally: + self.engine.batch = 0 + self.assertEqual(s, 501, b) + self.assertIn("parallel", b["error"]["message"]) + self.assertEqual(self.engine.proc.sent, []) + def test_waits_for_a_running_request(self): """A save never interleaves with a generation: it takes the same FIFO.""" self.svc.fifo.acquire() diff --git a/src/core/expert_source.cpp b/src/core/expert_source.cpp index c096af0508..895f2bcacd 100644 --- a/src/core/expert_source.cpp +++ b/src/core/expert_source.cpp @@ -3220,6 +3220,7 @@ bool ArenaExpertSource::open(const std::string& pack_dir, int64_t n_layers, int6 note_ = "mapped read-only from " + path + " (STRATA_ARENA_MMAP: not locked, not pinned)"; gib_per_s_ = 0.0; load_seconds_ = load_read_s_ = load_copy_s_ = 0.0; + record_inputs(path, gguf_, lay, from_gguf); // session files: the mapped experts.bin is a model input return true; } } diff --git a/src/program/generate.cpp b/src/program/generate.cpp index e86942d445..b3edcee76b 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -7622,6 +7622,7 @@ int main(int argc, char** argv) { if (path.empty()) { refuse("missing path"); continue; } if (!stages.empty() || multi_gpu) { refuse("session files do not support --layer-split"); continue; } if (o.peer_device >= 1) { refuse("session files do not support --peer-device"); continue; } + if (o.batch > 0) { refuse("session files do not support --batch (parallel requests)"); continue; } if (o.prompt_cache <= 0) { refuse("session files need --prompt-cache > 0"); continue; } if (!ver.wait_commit(err)) { std::printf("ERR %s\n", err.c_str());