Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@
transfer interruption, switching under load, accessibility, and recovery
from sleep or GPU reset. See flare-winui/README.md.

[ ] Qualify WinUI Serving GPU selection on a host with two CUDA GPUs. Load a
single-GPU core on GPU 1, save a different selection while serving, reload,
and verify that execution and dashboard memory move to the selected GPU.
Repeat with reordered CUDA_VISIBLE_DEVICES and different GPU architectures
to check device numbering, download selection, and compatibility filtering.

[ ] Run .github/workflows/release.yml on GitHub-hosted runners through
workflow_dispatch; it has never run there. The run must establish that
ubuntu-24.04-arm provides Docker for the clean-container check, that both
Expand Down
7 changes: 5 additions & 2 deletions flare-winui/Dashboard.inl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@
void update_hardware(flare_snapshot const* snapshot,flare_status const& status) {
auto count=flare_snapshot_gpu_count(snapshot);
flare_gpu gpu{};
if(count&&flare_snapshot_gpu(snapshot,0,&gpu)) {
for(size_t i=0;i<count;++i){flare_gpu candidate{};if(flare_snapshot_gpu(snapshot,i,&candidate)&&candidate.has_visible_ordinal&&candidate.visible_ordinal==0){gpu=candidate;break;}}
flare_runtime_settings runtime{};flare_snapshot_runtime_settings(snapshot,&runtime);
auto selected=runtime.active_gpu>=0?runtime.active_gpu:runtime.gpu;
bool found=false;
for(size_t i=0;i<count;++i){flare_gpu candidate{};if(flare_snapshot_gpu(snapshot,i,&candidate)&&candidate.has_visible_ordinal&&candidate.visible_ordinal==static_cast<uint32_t>(selected)){gpu=candidate;found=true;break;}}
if(found) {
auto name=wide(gpu.name);auto annotation=name.find(L" (");if(annotation!=std::wstring::npos)name.resize(annotation);
text(L"DeviceName",name);text(L"DeviceState",gpu.has_visible_ordinal?L"GPU detected":L"Not exposed to CUDA");
if(gpu.has_total_memory&&gpu.has_free_memory&&gpu.total_memory_bytes) {
Expand Down
3 changes: 2 additions & 1 deletion flare-winui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ paused, and cancelled entries remain, and downloaded data is kept for retries.

Model details inspect signed metadata without granting publisher consent or
loading the GPU. For this PC hides undownloaded repositories whose published
platform branches exclude the first visible GPU's platform, and local cores
platform branches exclude the selected serving GPU's platform, and local cores
whose inspected requirements are known to be incompatible. Missing build metadata
or an unknown GPU platform leaves a repository visible. Downloaded cores use
their inspected requirements even if the repository no longer publishes a
Expand All @@ -225,6 +225,7 @@ Reload model finishes accepted requests before releasing and loading the core.

| Setting | Runtime behavior |
|---|---|
| Serving GPU | Selects one visible NVIDIA GPU by device index, name, and total memory. Defaults to GPU 0 and respects inherited `CUDA_VISIBLE_DEVICES` numbering. Save applies the selection on the next load or reload; the dashboard continues to measure the active model's GPU until then. The desktop accepts single-GPU cores. |
| Serving memory limit | `30G` caps occupied memory, `-8G` reserves free memory, and `0.8` selects a total-memory fraction per GPU. Blank inherits the configured/core reserve. KV pages use the remainder after model and runtime allocations. |
| KV history capacity | One model context by default. Available memory and Context × concurrency are also selectable. The limit applies to KV history shared across requests. |
| Maximum concurrent requests | Blank inherits model/configuration/core defaults. An override must fit prepared capacity. |
Expand Down
40 changes: 37 additions & 3 deletions flare-winui/Settings.inl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
std::wstring runtime_prefix_directory_;
double runtime_memory_gib_{2},runtime_memory_percent_{80};
int runtime_memory_mode_{};
std::vector<std::pair<int32_t,std::wstring>> runtime_gpus_;
int32_t runtime_gpu_value() {
int index=control<ComboBox>(L"RuntimeGpu").SelectedIndex();
return index>=0&&static_cast<size_t>(index)<runtime_gpus_.size()?runtime_gpus_[index].first:-1;
}
void runtime_gpu_choices(flare_snapshot const* snapshot,int32_t selected) {
std::vector<std::pair<int32_t,std::wstring>> choices;
for(size_t i=0;i<flare_snapshot_gpu_count(snapshot);++i) {
flare_gpu gpu{};
if(!flare_snapshot_gpu(snapshot,i,&gpu)||!gpu.has_visible_ordinal)continue;
auto name=L"GPU "+std::to_wstring(gpu.visible_ordinal)+L" · "+wide(gpu.name);
if(gpu.has_total_memory)name+=L" · "+bytes(gpu.total_memory_bytes);
choices.emplace_back(static_cast<int32_t>(gpu.visible_ordinal),name);
}
if(std::none_of(choices.begin(),choices.end(),[&](auto const& item){return item.first==selected;}))
choices.emplace_back(selected,L"GPU "+std::to_wstring(selected)+L" · Unavailable");
std::sort(choices.begin(),choices.end());
auto choice=control<ComboBox>(L"RuntimeGpu");
if(choices!=runtime_gpus_) {
choice.Items().Clear();
for(auto const& item:choices)choice.Items().Append(box_value(hstring(item.second)));
runtime_gpus_=std::move(choices);
}
for(size_t i=0;i<runtime_gpus_.size();++i)if(runtime_gpus_[i].first==selected)choice.SelectedIndex(static_cast<int>(i));
}
static std::wstring runtime_decimal(double value) {
std::wostringstream output;output.imbue(std::locale::classic());
output<<std::setprecision(15)<<value;return output.str();
Expand Down Expand Up @@ -51,7 +76,8 @@
auto append=[&](std::wstring const& v){result+=std::to_wstring(v.size())+L":"+v;};
auto choice=[&](wchar_t const* name){append(std::to_wstring(control<ComboBox>(name).SelectedIndex()));};
auto slider=[&](wchar_t const* name){append(runtime_decimal(control<Slider>(name).Value()));};
if(key==L"memory"){choice(L"RuntimeMemoryMode");slider(L"RuntimeMemoryValue");}
if(key==L"gpu")append(std::to_wstring(runtime_gpu_value()));
else if(key==L"memory"){choice(L"RuntimeMemoryMode");slider(L"RuntimeMemoryValue");}
else if(key==L"host"){choice(L"RuntimeHostMode");append(std::wstring(control<TextBox>(L"RuntimeHost").Text()));}
else if(key==L"port")append(runtime_decimal(control<NumberBox>(L"RuntimePort").Value()));
else if(key==L"kv")choice(L"RuntimeKvLimit");
Expand All @@ -71,7 +97,7 @@
}
std::wstring runtime_form_signature() {
std::wstring result;
for(auto key:{L"memory",L"host",L"port",L"kv",L"concurrency",L"verify",L"disk_enabled",L"directory",L"ram",L"disk_limit",L"age",L"drain",L"storage",L"embedding",L"drafts",L"adaptive"}){
for(auto key:{L"gpu",L"memory",L"host",L"port",L"kv",L"concurrency",L"verify",L"disk_enabled",L"directory",L"ram",L"disk_limit",L"age",L"drain",L"storage",L"embedding",L"drafts",L"adaptive"}){
auto value=runtime_field_signature(key);result+=std::to_wstring(value.size())+L":"+value;
}
return result;
Expand All @@ -85,6 +111,7 @@
return selected==0?L"":selected==1?L"0":runtime_decimal(control<Slider>(slider).Value())+L"GiB";
}
void initialize_runtime_settings() {
control<ComboBox>(L"RuntimeGpu").SelectionChanged([this](auto const&,auto const&){runtime_settings_changed();});
clicked(L"RuntimeSettingsSave",[this]{save_runtime_settings();});
clicked(L"RuntimeSettingsReload",[this]{for(auto const& model:models_)if(!model.catalog()&&(model.flags&FLARE_MODEL_ACTIVE)){activate(model.id,model.name,true);break;}});
clicked(L"RuntimeSettingsRevert",[this]{runtime_settings_dirty_=false;runtime_settings_initialized_=false;runtime_settings_error_.clear();poll();});
Expand All @@ -110,6 +137,7 @@
control<TextBox>(L"RuntimeHost").Visibility(host==2?Visibility::Visible:Visibility::Collapsed);
text(L"RuntimeNetworkNote",host==1?L"Available to your network. Windows firewall rules apply.":host==2?L"Use an IPv4 or IPv6 address assigned to this PC.":L"Only applications on this PC can connect.");
bool editing=runtime_settings_operation_==0;
control<ComboBox>(L"RuntimeGpu").IsEnabled(editing);
for(auto name:{L"RuntimeMemoryMode",L"RuntimeMemoryValue",L"RuntimeHost",L"RuntimeHostMode",L"RuntimeKvLimit",L"RuntimeConcurrencyAuto",L"RuntimeVerify",L"RuntimePort",L"RuntimePrefixDiskEnabled",L"RuntimePrefixMemoryMode",L"RuntimePrefixMaxAge",L"RuntimeDraftMode",L"RuntimeAdaptiveVerification",L"RuntimeEmbeddingStorage",L"RuntimeEmbeddingCacheMode"})control<Control>(name).IsEnabled(editing);
bool disk=control<ToggleSwitch>(L"RuntimePrefixDiskEnabled").IsOn();
for(auto name:{L"RuntimePrefixBrowse",L"RuntimePrefixDiskLimitMode",L"RuntimePrefixDrain"})control<Control>(name).IsEnabled(disk&&editing);
Expand Down Expand Up @@ -139,6 +167,9 @@
}
void update_runtime_settings(flare_snapshot const* snapshot,flare_status const& status) {
flare_runtime_settings value{};if(!flare_snapshot_runtime_settings(snapshot,&value))return;
if(runtime_settings_initialized_&&runtime_original_[L"gpu"]!=std::to_wstring(value.gpu)) {
compatibilities_.clear();catalog_requested_=false;model_fingerprint_.clear();
}
runtime_settings_busy_=status.busy!=0;runtime_reload_pending_=value.pending_reload!=0;
if(runtime_settings_operation_&&value.last_settings_operation==runtime_settings_operation_) {
runtime_settings_operation_=0;runtime_settings_error_=wide(value.settings_error);
Expand All @@ -147,12 +178,14 @@
if(!runtime_settings_initialized_||(!runtime_settings_dirty_&&!runtime_settings_operation_)) {
struct ApplyingReset {bool& value;~ApplyingReset(){value=false;}} applying_reset{runtime_settings_applying_};
runtime_settings_applying_=true;
runtime_gpu_choices(snapshot,value.gpu);
runtime_original_={{L"memory",wide(value.memory_limit)},{L"host",wide(value.host)},{L"kv",wide(value.kv_cache_limit)},
{L"ram",wide(value.prefix_cache_memory)},{L"directory",wide(value.prefix_cache_disk)},{L"disk_limit",wide(value.prefix_cache_disk_limit)},
{L"age",wide(value.prefix_cache_max_age)},{L"drain",wide(value.prefix_cache_drain_on_shutdown)},
{L"storage",wide(value.embedding_table_storage)},{L"embedding",wide(value.embedding_table_cache_size)},
{L"concurrency",value.has_max_concurrency?std::to_wstring(value.max_concurrency):L""},
{L"drafts",value.has_mtp_draft_tokens?std::to_wstring(value.mtp_draft_tokens):L""}};
{L"drafts",value.has_mtp_draft_tokens?std::to_wstring(value.mtp_draft_tokens):L""},
{L"gpu",std::to_wstring(value.gpu)}};
auto host=runtime_original_[L"host"];
control<TextBox>(L"RuntimeHost").Text(host);
control<ComboBox>(L"RuntimeHostMode").SelectedIndex(host==L"127.0.0.1"?0:host==L"0.0.0.0"?1:2);
Expand Down Expand Up @@ -200,6 +233,7 @@
std::vector<std::string> strings;strings.reserve(16);
auto store=[&](std::wstring raw){strings.push_back(to_string(hstring(raw)));auto const& s=strings.back();return flare_string{s.data(),s.size()};};
flare_runtime_settings value{};
value.gpu=runtime_gpu_value();
int memory=control<ComboBox>(L"RuntimeMemoryMode").SelectedIndex();
double amount=control<Slider>(L"RuntimeMemoryValue").Value();
auto memoryText=memory==0?L"":memory==3?runtime_decimal(amount/100):std::wstring(memory==2?L"-":L"")+runtime_decimal(amount)+L"GiB";
Expand Down
1 change: 1 addition & 0 deletions flare-winui/Shell.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ LR"xaml(
<Grid x:Name="SettingsPage" Visibility="Collapsed" RowSpacing="12"><Grid.RowDefinitions><RowDefinition/><RowDefinition Height="Auto"/></Grid.RowDefinitions><ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" HorizontalScrollMode="Disabled" HorizontalContentAlignment="Stretch"><StackPanel Spacing="12"><StackPanel x:Name="RuntimeSettingsForm" Spacing="12">
<Border x:Name="ServerSettingsCard" Style="{StaticResource Card}"><StackPanel Spacing="12">
<TextBlock Text="Server" FontSize="17" FontWeight="SemiBold"/>
<ComboBox x:Name="RuntimeGpu" Header="Serving GPU" HorizontalAlignment="Stretch" AutomationProperties.Name="Serving GPU"/><TextBlock Text="Choose one GPU for a single-GPU core. Save, then load or reload the model to apply." Style="{StaticResource Caption}"/>
<Grid ColumnSpacing="16"><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition Width="128"/></Grid.ColumnDefinitions><ComboBox x:Name="RuntimeHostMode" Header="Connections" HorizontalAlignment="Stretch" SelectedIndex="0"><ComboBoxItem Content="This PC only"/><ComboBoxItem Content="All IPv4 interfaces"/><ComboBoxItem Content="Custom IP address"/></ComboBox><NumberBox x:Name="RuntimePort" Header="Port" Grid.Column="1" Minimum="1" Maximum="65535" Value="8000" SmallChange="1" SpinButtonPlacementMode="Compact" AutomationProperties.Name="Server port"/></Grid>
<TextBox x:Name="RuntimeHost" Header="Local IP address" Visibility="Collapsed" PlaceholderText="IPv4 or IPv6 address"/><TextBlock x:Name="RuntimeNetworkNote" Style="{StaticResource Caption}"/><TextBlock x:Name="RuntimeActiveBind" Style="{StaticResource Caption}"/><TextBlock x:Name="RuntimeAuthentication" Style="{StaticResource Caption}"/>
</StackPanel></Border>
Expand Down
1 change: 1 addition & 0 deletions flare-winui/bridge/include/flare.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ typedef struct flare_dashboard_point {
core defaults. Optional booleans: 0 inherit, 1 off, 2 on. Read-only output
fields are ignored on input; authentication secrets are never returned. */
typedef struct flare_runtime_settings {
int32_t gpu, active_gpu; /* Visible device index; active_gpu is -1 when stopped. */
flare_string memory_limit, kv_cache_limit, host;
flare_string prefix_cache_memory, prefix_cache_disk, prefix_cache_disk_limit;
flare_string embedding_table_storage, embedding_table_cache_size;
Expand Down
7 changes: 7 additions & 0 deletions flare-winui/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ mod dashboard_tests {

#[repr(C)]
pub struct FlareRuntimeSettings {
gpu: i32,
active_gpu: i32,
memory_limit: FlareString,
kv_cache_limit: FlareString,
host: FlareString,
Expand Down Expand Up @@ -1484,6 +1486,7 @@ unsafe fn runtime_input(
}
};
Ok(flare::settings::RuntimeSettings {
gpu: s.gpu,
memory_limit: copy(s.memory_limit)?,
kv_cache_limit: copy(s.kv_cache_limit)?,
host: copy(s.host)?,
Expand Down Expand Up @@ -1527,6 +1530,8 @@ pub unsafe extern "C" fn flare_snapshot_runtime_settings(
output(
out,
FlareRuntimeSettings {
gpu: s.gpu,
active_gpu: view.active_gpu.unwrap_or(-1),
memory_limit: text(&s.memory_limit),
kv_cache_limit: text(&s.kv_cache_limit),
host: text(&s.host),
Expand Down Expand Up @@ -1562,6 +1567,7 @@ mod runtime_settings_abi_tests {
#[test]
fn runtime_settings_abi_copies_options_and_borrows_only_snapshot_output() {
let mut view=Snapshot::default();
view.runtime_settings.gpu=2;view.active_gpu=Some(1);
view.runtime_settings.max_concurrency=Some(3);view.runtime_settings.mtp_draft_tokens=Some(0);
view.runtime_settings.adaptive_verification=Some(true);
view.runtime_settings.prefix_cache_disk="C:/模型/prefix-cache".into();
Expand All @@ -1572,6 +1578,7 @@ mod runtime_settings_abi_tests {
let mut out=std::mem::MaybeUninit::<FlareRuntimeSettings>::uninit();
assert_eq!(flare_snapshot_runtime_settings(held,out.as_mut_ptr()),1);
let mut found=out.assume_init();
assert_eq!((found.gpu,found.active_gpu),(2,1));
assert_eq!((found.has_max_concurrency,found.max_concurrency,found.has_mtp_draft_tokens,found.mtp_draft_tokens),(1,3,1,0));
assert_eq!((found.adaptive_verification,found.pending_reload,found.has_api_key,found.prefix_cache_disk_enabled),(2,1,1,0));
assert_eq!(found.last_settings_operation,42);
Expand Down
Loading
Loading