Finish DS4 execution parity

This commit is contained in:
Georg Bauer
2026-07-26 20:44:23 +02:00
parent fd3f8e45dc
commit 0d80c217c4
15 changed files with 16905 additions and 195 deletions

View File

@@ -148,6 +148,22 @@ void ds4_gpu_set_streaming_expert_cache_expert_bytes(uint64_t bytes);
uint64_t ds4_gpu_recommended_working_set_size(void);
uint32_t ds4_gpu_stream_expert_cache_configured_count(void);
uint32_t ds4_gpu_stream_expert_cache_current_count(void);
typedef struct ds4_gpu_stream_expert_cache_stats {
uint32_t configured_count;
uint32_t current_count;
uint64_t hits;
uint64_t misses;
uint64_t evictions;
uint64_t wraps;
uint64_t buffer_allocs;
uint64_t buffer_reuses;
uint64_t evict_advise_bytes;
uint64_t willneed_advise_bytes;
uint64_t pread_bytes;
double pread_ms;
} ds4_gpu_stream_expert_cache_stats;
void ds4_gpu_stream_expert_cache_get_stats(
ds4_gpu_stream_expert_cache_stats *stats);
typedef struct ds4_gpu_stream_expert_table {
const void *model_map;
uint64_t model_size;

View File

@@ -368,6 +368,25 @@ static uint64_t g_stream_expert_timing_cache_all_missing_layers;
static uint64_t g_stream_expert_timing_cache_mixed_layers;
static uint64_t g_stream_expert_timing_cache_resident_experts;
static uint64_t g_stream_expert_timing_cache_missing_experts;
void ds4_gpu_stream_expert_cache_get_stats(
ds4_gpu_stream_expert_cache_stats *stats) {
if (!stats) return;
*stats = (ds4_gpu_stream_expert_cache_stats) {
.configured_count = ds4_gpu_stream_expert_cache_configured_count(),
.current_count = g_stream_expert_cache_entry_count,
.hits = g_stream_expert_cache_hits,
.misses = g_stream_expert_cache_misses,
.evictions = g_stream_expert_cache_evictions,
.wraps = g_stream_expert_cache_wraps,
.buffer_allocs = g_stream_expert_cache_buffer_allocs,
.buffer_reuses = g_stream_expert_cache_buffer_reuses,
.evict_advise_bytes = g_stream_expert_cache_evict_advise_bytes,
.willneed_advise_bytes = g_stream_expert_cache_willneed_advise_bytes,
.pread_bytes = g_stream_expert_cache_pread_bytes,
.pread_ms = g_stream_expert_cache_pread_ms,
};
}
typedef struct {
uint64_t selected_calls;
double selected_read_ms;
@@ -32798,7 +32817,18 @@ int ds4_gpu_glm_routed_moe_one_tensor(
downbuf = ds4_gpu_wrap_model_range(model_map, model_size,
down_offset, down_tensor_bytes,
&down_inner);
if (!gatebuf || !upbuf || !downbuf) return 0;
if (!gatebuf || !upbuf || !downbuf) {
fprintf(stderr,
"ds4: Metal GLM routed MoE could not map resident fallback layer=%u "
"streaming=%d force_resident=%d gate_type=%u down_type=%u budget=%u\n",
layer_index,
g_ssd_streaming_mode,
force_resident,
gate_type,
down_type,
ds4_gpu_stream_expert_cache_configured_budget());
return 0;
}
}
id<MTLComputePipelineState> pair_pipeline =