MCPcopy Create free account
hub / github.com/evilsocket/cake / test_large_tensor_transfer

Function test_large_tensor_transfer

cake-core/tests/protocol.rs:326–353  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

324
325#[tokio::test]
326async fn test_large_tensor_transfer() {
327 let mock = MockWorker::bind().await;
328 let addr = mock.addr();
329 let worker = tokio::spawn(async move { mock.handle_one(None).await });
330
331 let (mut stream, _) = connect_and_handshake(addr, None).await;
332
333 // Realistic hidden state size: (1, 5120) x F16 = 10,240 bytes
334 let tensor = make_f16_tensor(&[1, 5120]);
335 let orig_bytes: Vec<u8> = tensor.data().to_vec();
336 assert_eq!(orig_bytes.len(), 10240);
337
338 Message::single_op("model.layers.0", &tensor, 0, 0)
339 .to_writer(&mut stream)
340 .await
341 .unwrap();
342
343 let (_, resp) = Message::from_reader(&mut stream).await.unwrap();
344 match resp {
345 Message::Tensor(raw) => {
346 assert_eq!(raw.data, orig_bytes);
347 }
348 other => panic!("expected Tensor, got {:?}", other),
349 }
350
351 drop(stream);
352 let _ = worker.await;
353}
354
355// ============================================================================
356// Benchmarks (run with: cargo test --test protocol -- --ignored --nocapture)

Callers

nothing calls this directly

Calls 7

connect_and_handshakeFunction · 0.85
addrMethod · 0.80
handle_oneMethod · 0.80
to_vecMethod · 0.80
dataMethod · 0.80
to_writerMethod · 0.80
make_f16_tensorFunction · 0.70

Tested by

no test coverage detected