From 40b83d2cecd7eb0e3031e5104c72c455a2e23468 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 12 Jan 2024 20:28:47 +0000 Subject: [PATCH] remove "meta" field on uploaded controllers (was unused anyways) --- aicirt/src/api.rs | 4 ---- aicirt/src/main.rs | 36 +++++------------------------------- harness/vllm_server.py | 2 +- pyaici/cli.py | 2 +- pyaici/comms.py | 4 ++-- rllm/src/server/server.rs | 8 +------- 6 files changed, 10 insertions(+), 46 deletions(-) diff --git a/aicirt/src/api.rs b/aicirt/src/api.rs index 69c714e1..6117aa54 100644 --- a/aicirt/src/api.rs +++ b/aicirt/src/api.rs @@ -113,15 +113,12 @@ impl SequenceResult { #[derive(Serialize, Deserialize)] pub struct MkModuleReq { pub binary: String, - #[serde(default)] - pub meta: Value, } #[derive(Serialize, Deserialize)] pub struct MkModuleResp { pub module_id: String, pub wasm_size: usize, - pub meta_size: usize, pub compiled_size: usize, pub time: u64, } @@ -139,7 +136,6 @@ pub struct TagInfo { pub updated_at: u64, // unix time pub updated_by: String, pub wasm_size: u64, - pub meta_size: u64, pub compiled_size: u64, } diff --git a/aicirt/src/main.rs b/aicirt/src/main.rs index e03fe897..17986c94 100644 --- a/aicirt/src/main.rs +++ b/aicirt/src/main.rs @@ -51,10 +51,6 @@ struct Cli { #[arg(short, long)] module: Option, - /// Path to .json metadata for module to install - #[arg(short = 'j', long)] - module_meta: Option, - /// Tokenizer to use; try --tokenizer list to see options #[arg(short, long, default_value = "llama")] tokenizer: String, @@ -184,10 +180,6 @@ impl ModuleRegistry { } } - fn meta_path(&self, module_id: &str) -> PathBuf { - self.cache_path.join(format!("{}.json", module_id)) - } - fn sys_meta_path(&self, module_id: &str) -> PathBuf { self.cache_path.join(format!("{}-sys.json", module_id)) } @@ -244,26 +236,17 @@ impl ModuleRegistry { Ok(self.elf_path(module_id)) } - fn create_module( - &self, - wasm_bytes: Vec, - meta_bytes: Vec, - auth: AuthInfo, - ) -> Result { + fn create_module(&self, wasm_bytes: Vec, auth: AuthInfo) -> Result { let timer = Instant::now(); - // make sure meta_bytes is valid JSON - let _: Value = serde_json::from_slice(&meta_bytes)?; - - let mut hasher = Sha256::new(); - hasher.update(&meta_bytes); + let mut hasher = ::new(); hasher.update(&wasm_bytes); let module_id = hex::encode(hasher.finalize()); let module_id = &module_id; if self.module_needs_check(module_id) { - match self.write_and_compile(module_id, &meta_bytes, &wasm_bytes, &auth) { + match self.write_and_compile(module_id, &wasm_bytes, &auth) { Err(e) => { let mut lck = self.modules.lock().unwrap(); lck.remove(module_id); @@ -287,7 +270,6 @@ impl ModuleRegistry { Ok(serde_json::to_value(MkModuleResp { module_id: module_id.to_string(), wasm_size: wasm_bytes.len(), - meta_size: meta_bytes.len(), compiled_size, time, })?) @@ -296,13 +278,11 @@ impl ModuleRegistry { fn write_and_compile( &self, module_id: &String, - meta_bytes: &Vec, wasm_bytes: &Vec, auth: &AuthInfo, ) -> Result<()> { fs::create_dir_all(&self.cache_path)?; Ok(if !self.wasm_path(module_id).exists() { - fs::write(self.meta_path(module_id), meta_bytes)?; fs::write(self.wasm_path(module_id), wasm_bytes)?; fs::write( self.sys_meta_path(module_id), @@ -319,8 +299,7 @@ impl ModuleRegistry { fn mk_module(&self, req: MkModuleReq, auth: AuthInfo) -> Result { let wasm_bytes = base64::engine::general_purpose::STANDARD.decode(req.binary)?; - let meta_bytes = serde_json::to_vec(&req.meta)?; - self.create_module(wasm_bytes, meta_bytes, auth) + self.create_module(wasm_bytes, auth) } fn set_tags(&self, req: SetTagsReq, auth: AuthInfo) -> Result { @@ -358,7 +337,6 @@ impl ModuleRegistry { updated_at: get_unix_time(), updated_by: auth.user.clone(), wasm_size: self.wasm_path(&req.module_id).metadata()?.len(), - meta_size: self.meta_path(&req.module_id).metadata()?.len(), compiled_size: self.elf_path(&req.module_id).metadata()?.len(), }; @@ -1063,13 +1041,9 @@ fn install_from_cmdline(cli: &Cli, wasm_ctx: WasmContext, shm: Shm) { name.to_string() } else { let wasm_bytes = fs::read(name).unwrap(); - let meta_bytes = match cli.module_meta.as_deref() { - Some(name) => fs::read(name).unwrap(), - None => serde_json::to_vec(&Value::Null).unwrap(), - }; let json = reg - .create_module(wasm_bytes, meta_bytes, AuthInfo::local_user()) + .create_module(wasm_bytes, AuthInfo::local_user()) .unwrap(); json["module_id"].as_str().unwrap().to_string() }; diff --git a/harness/vllm_server.py b/harness/vllm_server.py index e1be6a65..c47bc49b 100644 --- a/harness/vllm_server.py +++ b/harness/vllm_server.py @@ -107,7 +107,7 @@ async def check_length( @app.post("/v1/aici_modules") async def upload_aici_module(request: Request): contents = await request.body() - return await aici.upload_module_async(contents, {}) + return await aici.upload_module_async(contents) @app.get("/v1/models") diff --git a/pyaici/cli.py b/pyaici/cli.py index 9c053802..ec57aac3 100644 --- a/pyaici/cli.py +++ b/pyaici/cli.py @@ -135,7 +135,7 @@ def main_inner(): "-c", metavar="MODULE_ID", type=str, - help="tag name or hex module id", + help="tag name or hex module id (sha256 of .wasm file)", ) run_cmd.add_argument( "--upload", diff --git a/pyaici/comms.py b/pyaici/comms.py index 610509e7..82accfd1 100644 --- a/pyaici/comms.py +++ b/pyaici/comms.py @@ -369,10 +369,10 @@ def replay(self, prev_trace: str): ch.send(obj["cmd"]) ch.expect("replay") - async def upload_module_async(self, wasm: bytes, meta={}): + async def upload_module_async(self, wasm: bytes): b64 = base64.b64encode(wasm).decode("utf-8") return await self.side_cmd.exec_async( - "mk_module", {"binary": b64, "meta": meta} + "mk_module", {"binary": b64} ) async def instantiate_async( diff --git a/rllm/src/server/server.rs b/rllm/src/server/server.rs index e35812d5..c0397b9f 100644 --- a/rllm/src/server/server.rs +++ b/rllm/src/server/server.rs @@ -166,13 +166,7 @@ async fn upload_aici_module( let binary = base64::engine::general_purpose::STANDARD.encode(body); let r = data .side_cmd_ch - .mk_module( - MkModuleReq { - binary, - meta: serde_json::Value::Null, - }, - auth_info(&req), - ) + .mk_module(MkModuleReq { binary }, auth_info(&req)) .await .map_err(APIError::just_msg)?; Ok(web::Json(r))