#pragma once /** * @file parvulus_c_api.h * @brief Pure C ABI interface for high-frequency PARVULUS robot policy inference. * * Standalone native CUDA/cuBLAS runtime with ZERO PyTorch, LibTorch, or Python dependencies. * Designed for high-frequency (136 Hz) physical robot manipulation loops (ROS 2, FCI, MuJoCo). */ #include #include #ifdef __cplusplus extern "C" { #endif typedef void* ParvulusHandle; /** * @brief Initializes a PARVULUS engine context on the designated CUDA device. * @param device_id CUDA device index (0, 1, 2, ...). * @return Opaque handle to the initialized engine, or NULL on error. */ ParvulusHandle parvulus_create(int device_id); /** * @brief Loads model weights, optional task language representations, and normalization scales. * @param handle Valid ParvulusHandle. * @param weights_path Path to flat model weights binary (parvulus_model_weights.bin). * @param embeddings_path Path to pre-cached task language embeddings binary (optional, can be NULL). * @param scale_path Path to 7-DoF action scale binary (optional, can be NULL). * @return true if loading succeeded, false otherwise. */ bool parvulus_load( ParvulusHandle handle, const char* weights_path, const char* embeddings_path, const char* scale_path ); /** * @brief Sets the active 256-dim task conditioning vector on GPU VRAM. * All subsequent chunk predictions will use this vector until updated. * * @param handle Valid ParvulusHandle. * @param task_vector Array of 256 float32 values. * @return true if successfully uploaded to GPU, false otherwise. */ bool parvulus_set_task_vector(ParvulusHandle handle, const float* task_vector); /** * @brief Sets the active task conditioning from a pre-cached task description string. * * @param handle Valid ParvulusHandle. * @param task_description String matching an entry in task_embeddings.bin. * @return true if found and set, false if string was not in cache. */ bool parvulus_set_task_string(ParvulusHandle handle, const char* task_description); /** * @brief Generates an 8-step continuous action chunk from dual 256x256 RGB observations. * * @param handle Valid ParvulusHandle. * @param agent_img Contiguous [256, 256, 3] uint8 RGB camera frame (agent POV). * @param wrist_img Contiguous [256, 256, 3] uint8 RGB camera frame (eye-in-hand POV). * @param task_description Optional task string (pass NULL to use active task conditioning vector). * @param out_actions Output buffer of length 56 (8 steps x 7 DoF: dx, dy, dz, drx, dry, drz, gripper). * @param num_euler_steps Number of ODE flow integration steps (typically 4 or 10). * @param custom_z0 Optional initial noise buffer [56 floats] for deterministic testing (NULL for random). * @return true if prediction succeeded, false on error. */ bool parvulus_predict_chunk( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const char* task_description, float* out_actions, int num_euler_steps, const float* custom_z0 ); /** * @brief Predicts an action chunk directly using a 256-dim task conditioning vector. * Updates the active task vector on GPU and generates the action chunk. */ bool parvulus_predict_chunk_with_vector( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const float* task_vector, float* out_actions, int num_euler_steps, const float* custom_z0 ); /** * @brief Alias for parvulus_predict_chunk_with_vector. */ bool parvulus_predict_chunk_with_emb( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const float* text_embedding, float* out_actions, int num_euler_steps, const float* custom_z0 ); /** * @brief Registers or updates a task description string and its 256-dim embedding dynamically in memory. */ bool parvulus_register_task_embedding( ParvulusHandle handle, const char* task_description, const float* text_embedding ); /** * @brief Destroys engine instance and releases all GPU allocations. */ void parvulus_destroy(ParvulusHandle handle); #ifdef __cplusplus } #endif