Compare commits
2 Commits
14ae41d2db
...
9e0f21023d
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e0f21023d | |||
| 87b45a1484 |
@ -28,12 +28,13 @@ set(SOURCES
|
||||
xenith/converter.cpp
|
||||
help.h
|
||||
xenith/ollama_api/handler.cpp
|
||||
xenith/ollama_api/handler.h
|
||||
xenith/ollama_api/server.h
|
||||
xenith/ollama_api/handler.hpp
|
||||
xenith/ollama_api/server.hpp
|
||||
xenith/ollama_api/server.cpp
|
||||
xenith/ui/tui/tui.cpp
|
||||
xenith/ui/tui.h
|
||||
xenith/ui/tui.hpp
|
||||
xenith/ui/tui/mouse.cpp
|
||||
xenith/ui/tui/message.cpp
|
||||
)
|
||||
|
||||
# Заголовочные файлы (для удобства в IDE)
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
| файл | что делает |
|
||||
|---|---|
|
||||
| `xenith/core/tensor.h` | матрицы, три формы GEMM, RMSNorm, RNG, пул потоков |
|
||||
| `xenith/core/tensor.hpp` | матрицы, три формы GEMM, RMSNorm, RNG, пул потоков |
|
||||
| `xenith/core/model.cpp` | конфигурация, инициализация, прямой проход, RoPE, Adam |
|
||||
| `xenith/core/backward.cpp` | обратный проход (ручной, без автомиффов) |
|
||||
| `xenith/core/trainer.cpp` | цикл обучения, расписание lr, чекпоинты, валидация |
|
||||
|
||||
13
main.cpp
13
main.cpp
@ -1,8 +1,8 @@
|
||||
#include "xenith/core/checkpoint.h"
|
||||
#include "xenith/core/generate.h"
|
||||
#include "xenith/core/train.h"
|
||||
#include "xenith/core/checkpoint.hpp"
|
||||
#include "xenith/core/generate.hpp"
|
||||
#include "xenith/core/train.hpp"
|
||||
#include "xenith/core/gradcheck.h"
|
||||
#include "xenith/ui/tui.h"
|
||||
#include "xenith/ui/tui.hpp"
|
||||
#include <cstdio>
|
||||
#include "help.h"
|
||||
#include <cstdlib>
|
||||
@ -358,10 +358,9 @@ static int cmd_update(const Args& a) {
|
||||
|
||||
static int cmd_tui(const Args& a)
|
||||
{
|
||||
ui::Tui tui = ui::Tui();
|
||||
while (tui.is_running())
|
||||
while (ui::app.is_running())
|
||||
{
|
||||
tui.update();
|
||||
ui::app.update();
|
||||
}
|
||||
std::cout << "\033[2J\033[H" << std::flush;
|
||||
return 0;
|
||||
|
||||
15
settings.h
15
settings.h
@ -1,15 +0,0 @@
|
||||
#ifndef XENITH_SETTINGS_H
|
||||
#define XENITH_SETTINGS_H
|
||||
#pragma once
|
||||
#include "xenith/preprocessing/tokenizer.h"
|
||||
|
||||
struct llm_prm
|
||||
{
|
||||
bool use_mmap = true;
|
||||
bool use_mlock = false;
|
||||
int num_thread = 1;
|
||||
unsigned int num_gpu = 256;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,4 +1,4 @@
|
||||
#include "converter.h"
|
||||
#include "converter.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "train.h"
|
||||
#include "train.hpp"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "checkpoint.h"
|
||||
#include "checkpoint.hpp"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "model.h"
|
||||
#include "model.hpp"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -1,4 +1,4 @@
|
||||
#include "generate.h"
|
||||
#include "generate.hpp"
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// generate.h — генерация текста с KV-кэшем
|
||||
#pragma once
|
||||
#include "checkpoint.h"
|
||||
#include "checkpoint.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// gradcheck.cpp — проверяем, что обратный проход совпадает с численным
|
||||
// и заодно меряем скорость.
|
||||
#include "gradcheck.h"
|
||||
#include "generate.h"
|
||||
#include "train.h"
|
||||
#include "generate.hpp"
|
||||
#include "train.hpp"
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// gradcheck.h — численная проверка градиентов и бенчмарк
|
||||
#pragma once
|
||||
#include "checkpoint.h"
|
||||
#include "checkpoint.hpp"
|
||||
|
||||
namespace xt {
|
||||
int run_gradcheck(bool verbose);
|
||||
@ -1,4 +1,4 @@
|
||||
#include "model.h"
|
||||
#include "model.hpp"
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "tensor.h"
|
||||
#include "tensor.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "model.h"
|
||||
#include "checkpoint.h"
|
||||
#include "model.hpp"
|
||||
#include "checkpoint.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace xt {
|
||||
@ -1,5 +1,5 @@
|
||||
#include "train.h"
|
||||
#include "checkpoint.h"
|
||||
#include "train.hpp"
|
||||
#include "checkpoint.hpp"
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#include "handler.h"
|
||||
#include "handler.hpp"
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef XENITH_HANDLER_H
|
||||
#define XENITH_HANDLER_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -63,7 +63,4 @@ namespace api
|
||||
std::string digest;
|
||||
models_details details;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
#include "server.h"
|
||||
#include "server.hpp"
|
||||
|
||||
namespace api
|
||||
{
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
#ifndef XENITH_SERVER_H
|
||||
#define XENITH_SERVER_H
|
||||
#include "handler.h"
|
||||
|
||||
namespace api
|
||||
{
|
||||
class server
|
||||
{
|
||||
server();
|
||||
~server();
|
||||
};
|
||||
}
|
||||
|
||||
#endif //XENITH_SERVER_H
|
||||
13
xenith/ollama_api/server.hpp
Normal file
13
xenith/ollama_api/server.hpp
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "handler.hpp"
|
||||
|
||||
namespace api
|
||||
{
|
||||
class server
|
||||
{
|
||||
server();
|
||||
~server();
|
||||
};
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "./xenith/libs/cpp-httplib-0.57.1/httplib.h"
|
||||
#include "./xenith/libs/cpp-httplib-0.57.1/httplib.hpp"
|
||||
#include "./xenith/libs/json-3.12.0/nlohmann/json.hpp"
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "tokenizer.h"
|
||||
#include "tokenizer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include "./../converter.h"
|
||||
#include "./../converter.hpp"
|
||||
#include "models/test_model.h"
|
||||
|
||||
void proccesing_promt(const std::string& text, Model& mdl, uint32_t layer_idx = 0);
|
||||
@ -1,12 +1,7 @@
|
||||
#ifndef XENITH_TUI_H
|
||||
#define XENITH_TUI_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <termios.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -52,7 +47,6 @@ namespace ui
|
||||
inline static bool running = true;
|
||||
inline static int width = 80;
|
||||
inline static int height = 24;
|
||||
|
||||
struct SplitDesc {
|
||||
enum Type { VERTICAL, HORIZONTAL };
|
||||
Type type;
|
||||
@ -60,22 +54,17 @@ namespace ui
|
||||
std::vector<std::unique_ptr<SplitDesc>> children;
|
||||
SplitDesc(Type t, int pos) : type(t), position(pos) {}
|
||||
};
|
||||
|
||||
struct border_charset {
|
||||
std::string_view top_left, top_right, bottom_left, bottom_right;
|
||||
std::string_view bottom, top, horizontal, vertical, bg;
|
||||
std::string_view cross, tee_up, tee_down, tee_left, tee_right;
|
||||
};
|
||||
|
||||
// Ваша структура, которая теперь будет использоваться по назначению
|
||||
struct TuiCell {
|
||||
std::string ch; // UTF-8 последовательность (например, "│" или "┌")
|
||||
int width; // Ширина на экране (обычно 1)
|
||||
|
||||
std::string ch;
|
||||
int width;
|
||||
TuiCell() : ch(" "), width(1) {}
|
||||
TuiCell(const std::string& c, int w) : ch(c), width(w) {}
|
||||
};
|
||||
|
||||
inline static struct termios orig_termios;
|
||||
inline static const border_charset border_clip {
|
||||
.top_left="╭", .top_right="╮", .bottom_left="╰", .bottom_right="╯",
|
||||
@ -99,7 +88,6 @@ namespace ui
|
||||
.top_left="▟", .top_right="▙", .bottom_left="▜", .bottom_right="▛",
|
||||
.bottom="█", .top="█", .vertical="█", .bg="█"
|
||||
};
|
||||
|
||||
static void get_console_size();
|
||||
static bool wait_for_input_or_timeout(int timeout_ms);
|
||||
void apply_color() const;
|
||||
@ -118,13 +106,11 @@ namespace ui
|
||||
static void invert_color();
|
||||
static void draw_button(int x, int y, int w, int h, std::string_view label, border_charset charset = border_solid);
|
||||
static void invert_color_off();
|
||||
|
||||
// --- ОБНОВЛЕННЫЕ СИГНАТУРЫ ---
|
||||
void draw_split_border(int w, int h, border_charset charset, int x, int y, const SplitDesc* root);
|
||||
static void apply_splits_recursive(std::vector<std::vector<TuiCell>>& grid, int offset_x, int offset_y, int w, int h, border_charset charset, const SplitDesc* split);
|
||||
static void apply_single_split(std::vector<std::vector<TuiCell>>& grid, int offset_x, int offset_y, int w, int h, border_charset charset, const SplitDesc* split);
|
||||
static void draw_border_to_buffer(std::vector<std::vector<TuiCell>>& grid, int w, int h, border_charset charset);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Tui app = Tui();
|
||||
}
|
||||
7
xenith/ui/tui/message.cpp
Normal file
7
xenith/ui/tui/message.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "message.h"
|
||||
#include "./../tui.hpp"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
#include "../tui.h"
|
||||
#include "../tui.hpp"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
#include "../tui.h"
|
||||
#include "../tui.hpp"
|
||||
|
||||
#include <chrono>
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace ui
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user