Download src/core/harness.h from Snapkitty/bsh-harness: direct link, hf CLI and curl.
- Browser
- Download file 4.35 kB
-
https://huggingface.co/Snapkitty/bsh-harness/resolve/main/src/core/harness.h
- Command line
-
hf download hf://Snapkitty/bsh-harness/src/core/harness.h
-
curl -L -o harness.h https://huggingface.co/Snapkitty/bsh-harness/resolve/main/src/core/harness.h
4.35 kB
| /* | |
| * Binary Substrate Harness (BSH) - Core Header | |
| * | |
| * Copyright (C) 2026 SNAPKITTYWEST | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU Affero General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License. | |
| * See LICENSE file for details. | |
| * | |
| * Zero-dependency transformer inference on bare metal | |
| */ | |
| /* ============================================================================ | |
| SYSCALL DEFINITIONS (System V AMD64 ABI) | |
| ============================================================================ */ | |
| /* ============================================================================ | |
| NEURAL OPERATION PRIMITIVES | |
| ============================================================================ */ | |
| void softmax_fma(float* restrict output, const float* restrict input, size_t count); | |
| void gemm_micro_kernel(float* C, const float* A, const float* B, | |
| size_t M, size_t N, size_t K); | |
| void attention_sdpa(float* restrict output, const float* restrict Q, | |
| const float* restrict K, const float* restrict V, | |
| size_t seq_len, size_t d_k); | |
| /* ============================================================================ | |
| MEMORY MANAGEMENT | |
| ============================================================================ */ | |
| extern uint8_t ingestion_buffer[INGESTION_BUFFER_SIZE]; | |
| extern uint8_t execution_arena[EXECUTION_ARENA_SIZE]; | |
| extern uint8_t output_buffer[OUTPUT_BUFFER_SIZE]; | |
| /* ============================================================================ | |
| DIGITAL TWIN STATE MODEL | |
| ============================================================================ */ | |
| typedef struct { | |
| uint64_t sequence_number; | |
| uint64_t timestamp_utc_sec; | |
| uint8_t source_identifier[32]; | |
| uint8_t previous_state_hash[32]; | |
| uint8_t current_state_hash[32]; | |
| uint64_t memory_arena_offset; | |
| uint64_t payload_bytes; | |
| uint8_t payload_data[4096]; | |
| } digital_twin_state_t; | |
| /* ============================================================================ | |
| CRYSTAL TENSOR FORMAT | |
| ============================================================================ */ | |
| typedef struct __attribute__((packed)) { | |
| uint32_t magic; | |
| uint16_t version; | |
| uint16_t dtype; | |
| uint32_t rank; | |
| uint32_t flags; | |
| uint64_t shape[4]; | |
| uint64_t payload_bytes; | |
| uint64_t alignment; | |
| uint32_t reserved[2]; | |
| } xtensor_header_t; | |
| typedef struct { | |
| const xtensor_header_t* header; | |
| const void* data; | |
| size_t total_size; | |
| } crystal_tensor_t; | |
| crystal_tensor_t load_crystal_tensor(const char* filepath); | |
| int verify_crystal_integrity(const crystal_tensor_t* t, const uint8_t expected_hash[32]); | |
| /* ============================================================================ | |
| H100-SPECIFIC PRIMITIVES | |
| ============================================================================ */ | |
| typedef struct { | |
| uint64_t global_address; | |
| uint32_t shape[4]; | |
| uint32_t strides[4]; | |
| } tma_descriptor_t; | |
| typedef struct { | |
| uint32_t m_size; | |
| uint32_t n_size; | |
| uint32_t k_size; | |
| uint8_t dtype_a; | |
| uint8_t dtype_b; | |
| } wgmma_config_t; | |
| void h100_tma_transfer(uint8_t* smem_dest, const tma_descriptor_t* desc, | |
| uint32_t m_idx, uint32_t n_idx); | |
| void h100_wgmma_mma(float* output, const tma_descriptor_t* desc_a, | |
| const tma_descriptor_t* desc_b, const wgmma_config_t* cfg); | |
| /* ============================================================================ | |
| UTILITY FUNCTIONS | |
| ============================================================================ */ | |
| void sha256_compute(const uint8_t* data, size_t len, uint8_t hash[32]); | |
| extern const float exp_poly_coeffs[6]; | |
| float fast_reciprocal(float x); | |