okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
299fb68ea
main
1#define DPCT_PROFILING_ENABLED 2#include <sycl/sycl.hpp> 3#include <dpct/dpct.hpp> 4#include "strata/sycl_queue.hpp" 5#include "strata/core/native_dense.hpp" 6#include <cstdlib> 7#include "strata/core/weights.hpp" 8#include "strata/artifact/gguf_reader.hpp" 9#include "strata/kernels/native_mmvq.hpp" 10#include "strata/platform/memory.hpp" 11 12#include <algorithm> 13#include <climits> 14#include <cstdio> 15#include <cstdlib> 16#include <exception> 17#include <limits> 18#include <memory> 19#include <mutex> 20#include <set> 21#include <cmath> 22#include <cstring> 23#include <vector> 24 25namespace strata::core { 26namespace { 27int g_layer_lb = -1 ,g_layer_le = -1 ;// set_layer_range; -1: every layer 28bool in_range (const std::string & name ) { 29if (g_layer_lb < 0 || name .rfind ("blk." ,0 )!= 0 )return true; 30const int l = std::atoi (name .c_str ()+ 4 ); 31return l >=g_layer_lb && l < g_layer_le ; 32} 33// S23 experiment (STRATA_HC_Q8=1): the hyper-connection projections' Q8_0 bytes for the verify read 34bool hc_q8_env () { 35static const bool on = [] {const char * v = std::getenv ("STRATA_HC_Q8" );return v != nullptr && v [0 ]== '1' ; }(); 36return on ; 37} 38bool hc_q8_name (const std::string & name ) { 39if (name == "output_hc_down.weight" || name == "output_hc_up.weight" )return true;// S25: the final mixer too 40if (name .rfind ("blk." ,0 )!= 0 )return false; 41static const char * suffixes []= {".hc_attn_down.weight" ,".hc_attn_up.weight" ,".hc_attn_inject.weight" , 42".hc_ffn_down.weight" ,".hc_ffn_up.weight" ,".hc_ffn_inject.weight" }; 43for (const char * suffix :suffixes )if (name .ends_with (suffix ))return true; 44return false; 45} 46// S25: the GGUF keeps the inject rows as F32 - quantized here to Q8_0 (ggml's reference rounding) so the Q8_0 read 47// covers every hc projection 48uint16_t half_bits (float f ) { 49uint32_t x ; 50 std::memcpy (& x ,& f ,4 ); 51const uint32_t sign = (x >>16 )& 0x8000u ; 52int32_t e = (int32_t ) ((x >>23 )& 0xff )- 127 + 15 ; 53uint32_t m = x & 0x7fffffu ; 54if (e <=0 ) {// subnormal or zero 55if (e < -10 )return (uint16_t )sign ; 56m |=0x800000u ; 57const uint32_t shift = (uint32_t ) (14 - e ); 58uint32_t h = m >>shift ; 59const uint32_t rem = m & ((1u <<shift )- 1 ),half = 1u << (shift - 1 ); 60if (rem > half || (rem == half && (h & 1u )))++ h ; 61return (uint16_t ) (sign |h ); 62 } 63if (e >=31 )return (uint16_t ) (sign |0x7c00u ); 64uint32_t h = ((uint32_t )e <<10 ) | (m >>13 ); 65const uint32_t rem = m & 0x1fffu ; 66if (rem > 0x1000u || (rem == 0x1000u && (h & 1u )))++ h ; 67return (uint16_t ) (sign |h ); 68} 69std::vector < uint8_t > q8_0_of (const float * x ,uint64_t n ) { 70 std::vector < uint8_t > out ((size_t ) (n /32 * 34 )); 71for (uint64_t b = 0 ;b < n /32 ;++ b ) { 72float amax = 0.0f ; 73for (int j = 0 ;j < 32 ;++ j )amax = (std::max )(amax , std::fabs (x [b * 32 + j ])); 74const float d = amax /127.0f ,id = d != 0.0f ?1.0f /d :0.0f ; 75uint8_t * o = out .data ()+ b * 34 ; 76const uint16_t hb = half_bits (d ); 77 std::memcpy (o ,& hb ,2 ); 78for (int j = 0 ;j < 32 ;++ j )o [2 + j ]= (uint8_t ) (int8_t ) std::lround (x [b * 32 + j ]* id ); 79 } 80return out ; 81} 82bool eligible (const strata::TensorInfo & tensor ,bool include_ple_key ) { 83const auto & name = tensor .name ; 84if (name .rfind ("blk." ,0 )!= 0 )return false; 85// Match the native PLE kernel: Q2_0, IQ3_XXS, IQ4_XS and Q8_0 (UD-Q4_K_XL). Other keys retain the packed BF16 86// fallback. 87if (name == "blk.1.ple_key.weight" ) 88return include_ple_key && (tensor .type == 42 || tensor .type == 18 || tensor .type == 23 || tensor .type == 8 ); 89static const char * suffixes []= {".attn_qkv.weight" ,".attn_gate.weight" ,".ssm_out.weight" , 90".attn_q.weight" ,".attn_k.weight" ,".attn_v.weight" ,".attn_output.weight" , 91".ffn_gate_shexp.weight" ,".ffn_up_shexp.weight" ,".ffn_down_shexp.weight" }; 92for (const char * suffix :suffixes )if (name .ends_with (suffix ))return true; 93return false; 94} 95// The native dense matrices (one allocation each, ~300 of them) are carved out of a few big blocks. On an Arc A-series card 96// (i915) every kernel launch costs the host time proportional to the number of live device allocations (12 us with none, 97// 131 us with 300, 1.8 ms with 3000) and the kernels themselves run slower; the allocation size does not matter. 98// STRATA_DENSE_SLAB_MIB=<n>: block size in MiB (default 256 under the i915 driver, 0 = one allocation per matrix, which is 99// what every other driver does); matrices of half a block or more keep their own allocation. 100struct DenseSlab { 101struct Block {void * base ;size_t size ;size_t used ; }; 102 std::mutex mu ; 103 std::vector < Block > blocks ; 104}; 105DenseSlab & dense_slab () {static DenseSlab s ;return s ; } 106size_t dense_slab_bytes () { 107static const size_t v = [] { 108if (const char * e = std::getenv ("STRATA_DENSE_SLAB_MIB" ))return (size_t ) (std::atol (e )> 0 ? std::atol (e ) :0 ) <<20 ; 109// on by default where it is measured: an Arc A-series card under the i915 driver (A750: 4K-token prompt 112.6 -> 110// 185.6 tok/s, output bit-identical); other drivers and cards keep one allocation per matrix 111return strata::intel_gpu_driver ()== "i915" ? ((size_t )256 <<20 ) : (size_t )0 ; 112 }(); 113return v ; 114} 115bool dense_slab_owns (const void * p ) { 116DenseSlab & s = dense_slab (); 117 std::lock_guard < std::mutex > lk (s .mu ); 118for (const auto & b :s .blocks )if ((uintptr_t )p >= (uintptr_t )b .base && (uintptr_t )p < (uintptr_t )b .base + b .size )return true; 119return false; 120} 121void * dense_alloc (size_t bytes ) { 122const size_t sb = dense_slab_bytes (); 123const size_t need = (bytes + 255 )& ~(size_t )255 ; 124if (sb == 0 || need >=sb /2 )return strata::malloc_device_guarded (bytes , dpct::get_in_order_queue ()); 125DenseSlab & s = dense_slab (); 126 std::lock_guard < std::mutex > lk (s .mu ); 127for (auto & b :s .blocks )// first fit: a gap left by a big matrix is filled by a later small one 128if (b .size - b .used >=need ) {void * p = (uint8_t * )b .base + b .used ;b .used += need ;return p ; } 129void * base = strata::malloc_device_guarded (sb , dpct::get_in_order_queue (),"native dense block" ); 130if (base == nullptr )return nullptr ; 131s .blocks .push_back ({base ,sb ,need }); 132return base ; 133} 134void dense_slab_free_blocks () { 135DenseSlab & s = dense_slab (); 136 std::lock_guard < std::mutex > lk (s .mu ); 137for (auto & b :s .blocks ) { strata::device_alloc_unregister (b .base ); sycl::free (b .base , dpct::get_in_order_queue ()); } 138s .blocks .clear (); 139} 140struct DeviceFree { 141void 142 operator()(void * p )const { 143if (p && !dense_slab_owns (p )) sycl::free (p , dpct::get_in_order_queue ()); 144 } 145}; 146using DevicePtr = std::unique_ptr < void ,DeviceFree > ; 147struct Pending { 148WeightRef * ref ; 149int type ; 150uint64_t bytes ; 151DevicePtr data ; 152DevicePtr packed ;// STRATA_Q8_PACKED=1 copy, or null 153}; 154// The block with the most unused room is copied into an allocation of exactly its used size (and freed): the VRAM the 155// last, part-filled block would waste is the expert cache's (192 slots became 53 on an 8 GB card without this). 156// Called before the matrices' pointers are published, so the Pending items are the only holders of them. 157bool dense_slab_trim (std::vector < Pending >& pending ) { 158DenseSlab & s = dense_slab (); 159size_t at = s .blocks .size (),best = 0 ; 160for (size_t i = 0 ;i < s .blocks .size ();++ i ) 161if (s .blocks [i ].size - s .blocks [i ].used > best ) {best = s .blocks [i ].size - s .blocks [i ].used ;at = i ; } 162if (at == s .blocks .size ()|| best < ((size_t )4 <<20 ))return true; 163DenseSlab ::Block old = s .blocks [at ]; 164void * fresh = strata::malloc_device_guarded (old .used , dpct::get_in_order_queue (),"native dense block" ); 165if (fresh == nullptr )return true;// keep the part-filled block 166 dpct::get_in_order_queue ().memcpy (fresh ,old .base ,old .used ).wait (); 167auto rebase = [& ](DevicePtr & d ) { 168const uintptr_t a = (uintptr_t )d .get (); 169if (d && a >= (uintptr_t )old .base && a < (uintptr_t )old .base + old .used ) 170 (void )d .release (),d .reset ((uint8_t * )fresh + (a - (uintptr_t )old .base )); 171 }; 172for (auto & item :pending ) {rebase (item .data );rebase (item .packed ); } 173 { 174 std::lock_guard < std::mutex > lk (s .mu ); 175s .blocks [at ]= {fresh ,old .used ,old .used };// the new block now owns those pointers 176 } 177 strata::device_alloc_unregister (old .base ); 178 sycl::free (old .base , dpct::get_in_order_queue ()); 179return true; 180} 181} 182 183// the shared header declares the static member (b60aab1b); this port only needs the env switch 184bool NativeDense ::hc_q8_requested () {return hc_q8_env (); } 185 186bool NativeDense ::served_names (const std::vector < std::string >& shards ,bool include_ple_key , 187 std::set < std::string >& out , std::string & err ) { 188try { 189for (const auto & path :shards ) { 190 strata::GgufFile gguf (path ); 191for (const auto & tensor :gguf .tensors ()) 192if (eligible (tensor ,include_ple_key )&& strata::kernels::native_mmvq_supported (tensor .type )&& 193tensor .shape .size ()== 2 ) 194out .insert (tensor .name ); 195 } 196return true; 197 }catch (const std::exception & error ) { 198err = std::string ("native dense: " )+ error .what (); 199return false; 200 } 201} 202 203void NativeDense ::set_layer_range (int lb ,int le ) {g_layer_lb = lb ;g_layer_le = le ; } 204bool NativeDense ::keep_unquantized_ple_key (const std::string & pack_dir , std::set < std::string >& skip , 205 std::string & err ) { 206const std::string key = "blk.1.ple_key.weight" ; 207if (!skip .count (key ))return true; 208int code_bits = -1 ; 209if (!WeightTable ::index_code_bits (pack_dir ,key ,code_bits ,err ))return false; 210if (code_bits == 0 )skip .erase (key ); 211return true; 212} 213 214NativeDense ::~NativeDense () { 215for (const void * p :packed_keys_ ) strata::kernels::native_q8_0_packed_unregister (p ); 216if (scratch_ ) sycl::free (scratch_ , dpct::get_in_order_queue ()); 217for (void * p :weights_ ) 218if (!dense_slab_owns (p ))DPCT_CHECK_ERROR (sycl::free (p , dpct::get_in_order_queue ())); 219dense_slab_free_blocks (); 220} 221 222bool NativeDense ::load (const std::vector < std::string > & shards , 223WeightTable & table , std::string & err , 224bool include_ple_key ,int64_t layer_lo , 225int64_t layer_hi )try { 226auto outside = [& ](const std::string & name ) {// a blk.<l>. tensor of another stage's layers 227if (layer_hi < 0 || name .rfind ("blk." ,0 )!= 0 )return false; 228const long l = std::strtol (name .c_str ()+ 4 ,nullptr ,10 ); 229return l < layer_lo || l >=layer_hi ; 230 }; 231if (scratch_ || !weights_ .empty ()) {err = "native dense: already loaded" ;return false; } 232if (shards .empty ()) {err = "native dense: at least one GGUF shard is required" ;return false; } 233try { 234 std::vector < Pending > pending ; 235 std::set < std::string > seen ; 236int max_in = 0 ; 237uint64_t total = 0 ,hc_q8_bytes = 0 ; 238uint64_t split_count = 0 ,split_tensors = 0 ; 239 std::set < uint64_t > split_numbers ; 240bool have_architecture = false; 241for (const auto & path :shards ) { 242 strata::GgufFile gguf (path ); 243const auto * count = gguf .get ("split.count" ); 244const auto * number = gguf .get ("split.no" ); 245const auto * tensors = gguf .get ("split.tensors.count" ); 246if (gguf .get ("general.architecture" )) { 247err = strata::check_engine_architecture (gguf ); 248if (!err .empty ())return false; 249have_architecture = true; 250if (count && number && tensors && number -> u == 0 && count -> u > 1 ) { 251split_count = count -> u ; 252split_tensors = tensors -> u ; 253 } 254 }else if (!have_architecture || !split_count || !count || !number || !tensors || 255count -> u != split_count || number -> u == 0 || number -> u >=split_count || 256tensors -> u != split_tensors ) { 257err = "native dense: additional shard must match the architecture-validated first shard's split metadata" ; 258return false; 259 } 260if (number && !split_numbers .insert (number -> u ).second ) { 261err = "native dense: duplicate split shard number" ;return false; 262 } 263 std::vector < uint64_t > offsets ; 264for (const auto & tensor :gguf .tensors ())offsets .push_back (tensor .offset ); 265 std::sort (offsets .begin (),offsets .end ()); 266if (std::adjacent_find (offsets .begin (),offsets .end ())!= offsets .end ()) { 267err = "native dense: tensor payload offsets overlap" ;return false; 268 } 269// Validate every directory span, including tensors we do not upload: 270// an ignored tensor must not overlap the native matrix that follows it. 271const uint64_t payload = gguf .file_size ()- gguf .data_start (); 272for (const auto & tensor :gguf .tensors ()) { 273int block_elements = 0 ,block_bytes = 0 ; 274uint64_t elements = 1 ; 275if (tensor .shape .empty ()|| !strata::block_geometry (tensor .type ,block_elements ,block_bytes )|| 276tensor .shape [0 ] % (uint64_t )block_elements != 0 ) { 277err = "native dense: invalid block geometry " + tensor .name ;return false; 278 } 279for (uint64_t dimension :tensor .shape ) { 280if (!dimension || elements > (std::numeric_limits < uint64_t > ::max )() /dimension ) { 281err = "native dense: invalid tensor extent " + tensor .name ;return false; 282 } 283elements *=dimension ; 284 } 285const uint64_t blocks = elements / (uint64_t )block_elements ; 286if (blocks > (std::numeric_limits < uint64_t > ::max )() / (uint64_t )block_bytes ) { 287err = "native dense: tensor byte count overflow " + tensor .name ;return false; 288 } 289const uint64_t bytes = blocks * (uint64_t )block_bytes ; 290if (tensor .offset > payload || bytes > payload - tensor .offset ) { 291err = "native dense: truncated payload " + tensor .name ;return false; 292 } 293const auto next = std::upper_bound (offsets .begin (),offsets .end (),tensor .offset ); 294if (next != offsets .end ()&& bytes > * next - tensor .offset ) { 295err = "native dense: overlapping payload " + tensor .name ;return false; 296 } 297// the uploads below read these: ask for them now so the reads overlap 298if (eligible (tensor ,include_ple_key )&& !outside (tensor .name )&& 299 strata::kernels::native_mmvq_supported (tensor .type )) 300 strata::platform::advise_willneed (gguf .tensor_data (tensor ),bytes ); 301 } 302for (const auto & tensor :gguf .tensors ()) { 303if (!eligible (tensor ,include_ple_key )|| outside (tensor .name ))continue ; 304if (!in_range (tensor .name )&& tensor .name .find ("ple" )== std::string::npos )continue ; 305if (!seen .insert (tensor .name ).second ) { 306err = "native dense: duplicate tensor " + tensor .name ;return false; 307 } 308auto found = table .table_ .find (tensor .name ); 309if (found == table .table_ .end ()) { 310err = "native dense: tensor absent from canonical table: " + tensor .name ;return false; 311 } 312auto & ref = found -> second ; 313if (ref .native_data ) {err = "native dense: override already attached" ;return false; } 314if (!strata::kernels::native_mmvq_supported (tensor .type ))continue ; 315// #326: the pack keeps an unquantized (--compat-bf16) key, which the PLE reads from the arena 316if (tensor .name == "blk.1.ple_key.weight" && !ref .quantized ())continue ; 317if (!ref .quantized ()|| tensor .shape .size ()!= 2 || 318ref .ne0 <=0 || ref .ne0 > INT_MAX || ref .ne1 <=0 || ref .ne1 > INT_MAX || 319tensor .shape [0 ]!= (uint64_t )ref .ne0 || tensor .shape [1 ]!= (uint64_t )ref .ne1 ) { 320err = "native dense: incompatible matrix " + tensor .name ;return false; 321 } 322const auto bytes = strata::kernels::native_mmvq_weight_bytes ( 323tensor .type , (int )ref .ne0 , (int )ref .ne1 ); 324void * allocation = nullptr ; 325auto status = 326DPCT_CHECK_ERROR (allocation = dense_alloc (bytes )); 327DevicePtr data (allocation ); 328if (status == 0 ) 329status = DPCT_CHECK_ERROR ( 330 dpct::get_in_order_queue () 331 .memcpy (data .get (),gguf .tensor_data (tensor ),bytes ) 332 .wait ()); 333/* 334DPCT1000: Error handling if-stmt was detected but could not 335be rewritten. 336*/ 337if (status != 0 ) { 338/* 339DPCT1009: SYCL reports errors using exceptions and does 340not use error codes. Please replace the 341"get_error_string_dummy(...)" with a real error-handling 342function. 343*/ 344/* 345DPCT1001: The statement could not be removed. 346*/ 347err = "native dense upload " + tensor .name + ": " + 348 dpct::get_error_string_dummy (status ); 349return false; 350 } 351max_in = (std::max )(max_in , (int )ref .ne0 ); 352total += bytes ; 353// STRATA_Q8_PACKED=1: a second, packed copy of an eligible Q8_0 matrix for the decode MMVQ (the GGUF 354// copy stays: the prompt path's GEMMs read it). 355DevicePtr packed ; 356if (tensor .type == 8 && tensor .name != "blk.1.ple_key.weight" && // the PLE has its own kernel 357 strata::kernels::native_q8_0_packed_enabled ()&& 358 strata::kernels::native_q8_0_packed_eligible ((int )ref .ne0 , (int )ref .ne1 )) { 359 std::vector < uint8_t > host (bytes ); 360 strata::kernels::native_q8_0_pack_host (gguf .tensor_data (tensor ),host .data (), (int )ref .ne0 , 361 (int )ref .ne1 ); 362void * packed_allocation = nullptr ; 363auto packed_status = DPCT_CHECK_ERROR ( 364packed_allocation = dense_alloc (bytes )); 365packed .reset (packed_allocation ); 366if (packed_status == 0 ) 367packed_status = DPCT_CHECK_ERROR ( 368 dpct::get_in_order_queue () 369 .memcpy (packed .get (),host .data (),bytes ) 370 .wait ()); 371/* 372DPCT1000: Error handling if-stmt was detected but could 373not be rewritten. 374*/ 375if (packed_status != 0 ) { 376/* 377DPCT1009: SYCL reports errors using exceptions and 378does not use error codes. Please replace the 379"get_error_string_dummy(...)" with a real error-handling 380function. 381*/ 382/* 383DPCT1001: The statement could not be removed. 384*/ 385err = "native dense packed upload " + tensor .name + 386": " + 387 dpct::get_error_string_dummy (packed_status ); 388return false; 389 } 390 } 391pending .push_back (Pending {& ref , (int )tensor .type ,bytes , std::move (data ), std::move (packed )}); 392 } 393if (hc_q8_requested ()) 394for (const auto & tensor :gguf .tensors ()) { 395// S25: the F32 inject rows hold BF16-exact values: the read takes the pack's BF16 rows unless 396// STRATA_HC_Q8_INJECT=1 asks for a Q8_0 copy 397static const bool q8_inject = [] {const char * v = std::getenv ("STRATA_HC_Q8_INJECT" );return v && v [0 ]== '1' ; }(); 398const bool f32_inject = q8_inject && tensor .type == 0 && tensor .name .ends_with ("_inject.weight" ); 399if ((tensor .type != 8 && !f32_inject )|| !hc_q8_name (tensor .name )|| tensor .shape .size ()!= 2 )continue ; 400auto found = table .table_ .find (tensor .name ); 401if (found == table .table_ .end ()|| found -> second .hc_q8 != nullptr )continue ; 402auto & ref = found -> second ; 403if (tensor .shape [0 ]!= (uint64_t )ref .ne0 || tensor .shape [1 ]!= (uint64_t )ref .ne1 || ref .ne0 %32 != 0 ) { 404err = "native dense (STRATA_HC_Q8): incompatible matrix " + tensor .name ;return false; 405 } 406const uint64_t bytes = (uint64_t )ref .ne0 /32 * 34 * (uint64_t )ref .ne1 ; 407void * p = nullptr ; 408 std::vector < uint8_t > q8 ; 409if (f32_inject )q8 = q8_0_of ((const float * )gguf .tensor_data (tensor ), (uint64_t )ref .ne0 * (uint64_t )ref .ne1 ); 410if (DPCT_CHECK_ERROR ( 411p = (void * )strata::malloc_device_guarded ( 412bytes , dpct::get_in_order_queue ()))!= 0 || 413/* 414DPCT1114: cudaMemcpy is migrated to 415asynchronization memcpy, assuming in the original code 416the source host memory is pageable memory. If the memory 417is not pageable, call wait() on event return by memcpy 418API to ensure synchronization behavior. 419*/ 420DPCT_CHECK_ERROR (dpct::get_in_order_queue ().memcpy ( 421p , 422f32_inject ? (const void * )q8 .data () 423 :gguf .tensor_data (tensor ), 424bytes ).wait ())!= 0 ) { 425err = "native dense (STRATA_HC_Q8) upload " + tensor .name ;return false; 426 } 427ref .hc_q8 = p ; 428weights_ .push_back (p ); 429hc_q8_bytes += bytes ; 430 } 431 } 432if (pending .empty ()) {err = "native dense: no supported GDN/QSA matrices in supplied shards" ;return false; } 433void * allocation = nullptr ; 434const auto status = 435DPCT_CHECK_ERROR (allocation = (void * )strata::malloc_device_guarded ( 436 strata::kernels::native_q8_1_bytes (max_in ), 437 dpct::get_in_order_queue ())); 438DevicePtr scratch (allocation ); 439/* 440DPCT1009: SYCL reports errors using exceptions and does not use 441error codes. Please replace the "get_error_string_dummy(...)" with a 442real error-handling function. 443*/ 444/* 445DPCT1001: The statement could not be removed. 446*/ 447/* 448DPCT1000: Error handling if-stmt was detected but could not be 449rewritten. 450*/ 451if (status != 0 ) { 452err = std::string ("native dense scratch: " )+ 453 dpct::get_error_string_dummy (status ); 454return false; 455 } 456// All checks and allocations finish before publishing any reference. 457dense_slab_trim (pending ); 458weights_ .reserve (pending .size ()); 459uint64_t packed_bytes = 0 ; 460size_t packed_count = 0 ; 461for (auto & item :pending ) { 462item .ref -> native_data = item .data .get (); 463item .ref -> native_type = item .type ; 464item .ref -> native_q8_1 = scratch .get (); 465if (item .packed ) { 466 strata::kernels::native_q8_0_packed_register (item .data .get (),item .packed .get (), (int )item .ref -> ne0 , 467 (int )item .ref -> ne1 ); 468packed_keys_ .push_back (item .data .get ()); 469packed_bytes += item .bytes ; 470++ packed_count ; 471weights_ .push_back (item .packed .release ()); 472 } 473weights_ .push_back (item .data .release ()); 474 } 475if (packed_count ) 476 std::fprintf (stderr ,"native dense: STRATA_Q8_PACKED=1 packed %zu Q8_0 matrices for decode (+%.1f MiB)\n" , 477packed_count ,packed_bytes /1048576.0 ); 478scratch_ = scratch .release (); 479bytes_ = total + hc_q8_bytes ; 480if (hc_q8_requested ()) 481 std::fprintf (stderr ,"strata: STRATA_HC_Q8=1: %.2f GiB of Q8_0 hyper-connection projections for the verify read\n" , 482 (double )hc_q8_bytes /1073741824.0 ); 483return true; 484 }catch (const std::exception & error ) { 485err = std::string ("native dense: " )+ error .what (); 486return false; 487 } 488} 489catch (sycl::exception const & exc ) { 490 std::cerr <<exc .what () <<"Exception caught at file:" <<__FILE__ 491 <<", line:" <<__LINE__ << std::endl ; 492 std::exit (1 ); 493} 494}// namespace strata::core