mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-10-18 14:43:29 +08:00
e80614fc2d
* feat(sft): support distributed activation reuse policies * feat(sft): add frozen-base INT8 LoRA training * fix(sft): make INT8 expert LoRA rank-zero authoritative * fix(sft): preserve DeepSeek router LoRA routing * feat(sft): enable persistent INT8 LoRA training * perf(sft): accelerate INT8 VNNI with oneDNN BRGEMM * perf(int8): fuse oneDNN compensation into backward repack * [feat]: support BF16 expert LoRA training * [fix]: honor forwarded activation policy in SFT workers * feat(sft): add native block-FP8 routed expert LoRA * feat(sft): expose explicit expert placeholder ownership * fix(sft): publish fused adapter artifacts atomically * feat(sft): own artifact and adapter lifecycle contracts * fix(sft): harden artifact and rank-local contracts * fix(sft): auto-adapt owner before adapter restore * style(sft): keep lifecycle comments concise * fix(sft): require fused adapter manifests * test(sft): use spawn for distributed workers * fix(sft): preserve runtime checkpoint metadata * fix(sft): validate wrapped runtime configuration * fix(sft): preserve expert format provenance * fix(sft): own routed experts during device dispatch * test(sft): lock explicit quantization conflict * fix(cpu): make shared memory buffers lifetime-safe * release: prepare v0.7.0
52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
/**
|
|
* @Description :
|
|
* @Author : chenht2022
|
|
* @Date : 2024-07-16 10:43:18
|
|
* @Version : 1.0.0
|
|
* @LastEditors : chenht
|
|
* @LastEditTime : 2024-10-09 11:08:07
|
|
* @Copyright (c) 2024 by KVCache.AI, All Rights Reserved.
|
|
**/
|
|
#ifndef CPUINFER_TASKQUEUE_H
|
|
#define CPUINFER_TASKQUEUE_H
|
|
|
|
#include <atomic>
|
|
#include <condition_variable>
|
|
#include <exception>
|
|
#include <functional>
|
|
#include <mutex>
|
|
#include <queue>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
class TaskQueue {
|
|
public:
|
|
TaskQueue();
|
|
~TaskQueue();
|
|
|
|
void enqueue(std::function<void()>);
|
|
|
|
void sync(size_t allow_n_pending);
|
|
|
|
private:
|
|
struct Node {
|
|
std::function<void()> task;
|
|
std::atomic<Node*> next;
|
|
Node() : task(nullptr), next(nullptr) {}
|
|
Node(const std::function<void()>& t) : task(t), next(nullptr) {}
|
|
};
|
|
|
|
std::atomic<Node*> head;
|
|
std::atomic<Node*> tail;
|
|
std::atomic<bool> done;
|
|
std::atomic<size_t> pending;
|
|
std::thread workerThread;
|
|
std::mutex mtx;
|
|
std::condition_variable cv;
|
|
std::exception_ptr first_exception;
|
|
|
|
void worker();
|
|
};
|
|
|
|
#endif
|