Skip to content

Commit 77b8c37

Browse files
authored
Inference Engine with LibTorch and CUDA Support
Inference Engine with LibTorch and CUDA Support
2 parents 85a5433 + 63dcd15 commit 77b8c37

29 files changed

Lines changed: 1587 additions & 831 deletions

.gitignore

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
.ipynb_checkpoints/
2+
__pycache__/
3+
env/
4+
venv/
5+
cleaned.txt
6+
libtorch-win-shared-with-deps-2.11.0+cpu (2)
7+
frontend/node_modules/
8+
frontend/dist/
19
.venv
2-
*.pt
3-
*.bin
4-
*.exe
5-
build/
6-
libtorch/
7-
CMakePresets.json
10+
build
11+
CMakeCache.txt

.vscode/c++.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"C:/LibTorch/include",
8+
"C:/LibTorch/include/torch/csrc/api/include"
9+
],
10+
"defines": [
11+
"_DEBUG",
12+
"UNICODE",
13+
"_UNICODE"
14+
],
15+
"windowsSdkVersion": "10.0.19041.0",
16+
"compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
17+
"cStandard": "c17",
18+
"cppStandard": "c++17",
19+
"intelliSenseMode": "windows-msvc-x64",
20+
"configurationProvider": "ms-vscode.cmake-tools"
21+
}
22+
],
23+
"version": 4
24+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.fontSize": 13
3+
}

.vscode/task.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: g++.exe build active file",
6+
"command": "C:\\MinGW\\bin\\g++.exe",
7+
"args": [
8+
"-fdiagnostics-color=always",
9+
"-g",
10+
"-std=gnu++17",
11+
"-I${workspaceFolder}",
12+
"-I${workspaceFolder}\\include",
13+
"${file}",
14+
"-o",
15+
"${fileDirname}\\${fileBasenameNoExtension}.exe"
16+
],
17+
"options": {
18+
"cwd": "${fileDirname}"
19+
},
20+
"problemMatcher": [
21+
"$gcc"
22+
],
23+
"group": {
24+
"kind": "build",
25+
"isDefault": true
26+
},
27+
"detail": "Task generated by Debugger."
28+
}
29+
],
30+
"version": "2.0.0"
31+
}

CMakePresets.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 10,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "mingw-debug",
11+
"displayName": "MinGW Debug",
12+
"generator": "MinGW Makefiles",
13+
"binaryDir": "${sourceDir}/build/mingw-debug",
14+
"cacheVariables": {
15+
"CMAKE_BUILD_TYPE": "Debug",
16+
"CMAKE_C_COMPILER": "C:/MinGW/bin/gcc.exe",
17+
"CMAKE_CXX_COMPILER": "C:/MinGW/bin/g++.exe",
18+
"QUADTRIX_ENABLE_TORCH": "ON"
19+
}
20+
},
21+
{
22+
"name": "mingw-release",
23+
"displayName": "MinGW Release",
24+
"generator": "MinGW Makefiles",
25+
"binaryDir": "${sourceDir}/build/mingw-release",
26+
"cacheVariables": {
27+
"CMAKE_BUILD_TYPE": "Release",
28+
"CMAKE_C_COMPILER": "C:/MinGW/bin/gcc.exe",
29+
"CMAKE_CXX_COMPILER": "C:/MinGW/bin/g++.exe",
30+
"QUADTRIX_ENABLE_TORCH": "ON"
31+
}
32+
}
33+
],
34+
"buildPresets": [
35+
{
36+
"name": "build-mingw-debug",
37+
"configurePreset": "mingw-debug"
38+
},
39+
{
40+
"name": "build-mingw-release",
41+
"configurePreset": "mingw-release"
42+
}
43+
]
44+
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Quadtrix.cpp
22
<img width="934" height="239" alt="image" src="https://github.com/user-attachments/assets/7470b7db-1c5a-4695-8a38-fe8292a19986" />
33

4+
LibTorch C++ setup notes are in [TORCH_CPP_README.md](/C:/Users/Admin/Documents/GitHub/Quadtrix.cpp/TORCH_CPP_README.md).
5+
6+
If you use `MinGW.org GCC-6.3.0-1`, read that file first because the Torch C++ target on Windows needs a different toolchain.
7+

engine/best_model.pt

38.1 MB
Binary file not shown.

engine/data/data_set.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from datasets import load_dataset
2+
import os
3+
4+
# Settings
5+
target_size_mb = 30
6+
target_size_bytes = target_size_mb * 1024 * 1024
7+
output_file = "cleaned.txt"
8+
9+
print(f"Streaming TinyStories until {target_size_mb} MB is reached...")
10+
11+
# We use streaming=True so we don't download the whole 2GB+ file at once
12+
dataset = load_dataset("roneneldan/TinyStories", split="train", streaming=True)
13+
14+
current_size = 0
15+
with open(output_file, "w", encoding="utf-8") as f:
16+
for entry in dataset:
17+
story_text = entry["text"] + "\n\n"
18+
19+
# Calculate size of this story in bytes
20+
story_bytes = len(story_text.encode('utf-8'))
21+
22+
if current_size + story_bytes > target_size_bytes:
23+
break
24+
25+
f.write(story_text)
26+
current_size += story_bytes
27+
28+
print(f"Done! Created '{output_file}' ({current_size / (1024*1024):.2f} MB)")

engine/gpt_inference.exe

50 KB
Binary file not shown.

engine/model.bin

25.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)