32 std::lock_guard<std::mutex> lock(mutex_);
35 unsigned int hw_threads = std::thread::hardware_concurrency();
36 int bg_threads = (hw_threads > 0)
37 ? std::max(1u, hw_threads / 2)
41 "maximum", 2048, 0, 0,
42 "Foreground generation, latency-sensitive"};
45 "balanced", 512, 0, 0,
46 "Default. Good throughput without monopolizing"};
49 "background", 256, bg_threads, bg_threads,
50 "Background tasks (compaction, scribe)"};
54 "Lowest resource usage (background NPCs, idle)"};
56 logger->info(
"Loaded 4 bundled GPU resource profiles "
57 "(background n_threads={})", bg_threads);
68 std::lock_guard<std::mutex> lock(mutex_);
69 if (profiles_.count(profile.
name) > 0) {
70 logger->warn(
"Profile '{}' already registered", profile.
name);
74 profiles_[profile.
name] = profile;
75 logger->info(
"Registered profile '{}' (n_batch={}, n_threads={})",
88 std::lock_guard<std::mutex> lock(mutex_);
89 auto it = profiles_.find(name);
90 if (it == profiles_.end()) {
94 logger->info(
"Deregistered profile '{}'", name);
106 std::lock_guard<std::mutex> lock(mutex_);
107 auto it = profiles_.find(name);
108 if (it != profiles_.end()) {
112 logger->warn(
"Profile '{}' not found, falling back to 'balanced'", name);
113 auto fallback = profiles_.find(
"balanced");
114 if (fallback != profiles_.end()) {
115 return fallback->second;
118 logger->error(
"Fallback profile 'balanced' also missing");
130 std::lock_guard<std::mutex> lock(mutex_);
131 return profiles_.count(name) > 0;
141 std::lock_guard<std::mutex> lock(mutex_);
142 std::vector<std::string> names;
143 names.reserve(profiles_.size());
144 for (
const auto& [k, _] : profiles_) {
147 std::sort(names.begin(), names.end());
158 std::lock_guard<std::mutex> lock(mutex_);
159 return profiles_.size();
bool register_profile(const GPUResourceProfile &profile)
Register a custom profile.
GPUResourceProfile get(const std::string &name) const
Get a profile by name.
size_t size() const
Number of registered profiles.
bool has(const std::string &name) const
Check if a profile name exists.
std::vector< std::string > list() const
List all registered profile names.
void load_bundled()
Initialize with bundled profiles (maximum, balanced, background, minimal).
bool deregister(const std::string &name)
Remove a profile by name.
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Activate model on GPU (WARM → ACTIVE).
ProfileRegistry – named GPU resource profile management.
Named GPU resource profile for controlling inference hardware knobs.
int n_batch
Batch size for prompt processing (1-2048)
std::string name
Profile name ("maximum", "balanced", "background", "minimal")
int n_threads
CPU threads for generation (0 = auto-detect)