Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c0e3561
Upgrade to C++20 and update lc0 integration
ContradNamiseb Jan 7, 2026
ca9c16f
Write one game per chunk file instead of batching
ContradNamiseb Jan 7, 2026
bedd763
Remove Boost dependency, use lc0 native HashCat for hashing
ContradNamiseb Jan 8, 2026
9d1ffab
Add GitHub Actions workflow with multi-platform build and pre-release
ContradNamiseb Jan 8, 2026
eb8825f
Fix CI build: add proto/net.pb.h stub to main repo
ContradNamiseb Jan 8, 2026
ef013a4
Fix clang build: use system zlib on Linux
ContradNamiseb Jan 8, 2026
0575288
Fix MSVC build: add compatibility flags for polyglot legacy code
ContradNamiseb Jan 8, 2026
e994655
Fix MSVC build: force include <array> and relax conformance
ContradNamiseb Jan 8, 2026
5f00299
Fix MSVC build: target legacy flags to polyglot and suppress warnings
ContradNamiseb Jan 8, 2026
20bfdd5
Migrate Windows CI to MinGW+Ninja with verbose logging
ContradNamiseb Jan 8, 2026
d09379b
Fix MinGW build: resolve getopt.h collision using -iquote
ContradNamiseb Jan 8, 2026
fc9ebf9
Fix include paths: restore polyglot/src, guard MinGW getopt.h
ContradNamiseb Jan 8, 2026
bfb3daa
Fix CI: upload only executable, not entire build directory
ContradNamiseb Jan 8, 2026
60779e4
Fix Lichess mode crash: escape regex brackets and add error handling
ContradNamiseb Jan 8, 2026
4736546
Add Stockfish evaluation integration for Q-value generation
ContradNamiseb Jan 8, 2026
cd72ffc
Update README with Stockfish mode and all CLI options
ContradNamiseb Jan 8, 2026
2fffda9
Fix Stockfish UCI init: use select() for non-blocking reads
ContradNamiseb Jan 8, 2026
da73242
Add version banner to main() to verify binary update
ContradNamiseb Jan 8, 2026
dec92e4
Enhance file validation: strictly require .pgn extension
ContradNamiseb Jan 8, 2026
94bbbc4
Add 30s timeout to Stockfish evaluate() to prevent infinite hangs
ContradNamiseb Jan 8, 2026
b41be03
feat: Add Stockfish evaluation with move history, differentiated Q va…
ContradNamiseb Jan 8, 2026
d95b9cb
WIP: Latest stockfish-eval changes before master port
ContradNamiseb Jan 9, 2026
4c3fed8
feat: Port parsing improvements from stockfish-eval branch
ContradNamiseb Jan 9, 2026
2a20854
feat: Add static evaluation for normal mode
ContradNamiseb Jan 9, 2026
4c70e6e
feat: Add static evaluation for normal mode
ContradNamiseb Jan 9, 2026
1900773
fix: Add bounds checking to prevent Windows crash from invalid MoveTo…
ContradNamiseb Jan 9, 2026
bb33a0a
fix: Add bounds checking to prevent Windows crash from invalid MoveTo…
ContradNamiseb Jan 9, 2026
35819e9
fix: Convert polyglot 0x88 squares to Lc0 0-63 format
ContradNamiseb Jan 9, 2026
e58bcfa
fix: Convert polyglot 0x88 squares to Lc0 0-63 format
ContradNamiseb Jan 9, 2026
58d545c
fix: Remove m.Flip() - Lc0 always uses white's perspective
ContradNamiseb Jan 9, 2026
f981e5a
fix: Remove m.Flip() - Lc0 always uses white's perspective
ContradNamiseb Jan 9, 2026
9105ced
Fix board perspective synchronization in PGN game processing
ContradNamiseb Jan 9, 2026
d8e7413
Delete release job from cmake-multi-platform.yml
ContradNamiseb Jan 9, 2026
b95bb1d
ci: Restore pre-release workflow job
ContradNamiseb Jan 9, 2026
22bc39b
Fix board perspective synchronization in PGN game processing
ContradNamiseb Jan 9, 2026
66364a6
Delete release job from cmake-multi-platform.yml
ContradNamiseb Jan 9, 2026
1c40d4b
ci: Restore pre-release workflow job
ContradNamiseb Jan 9, 2026
a66e683
Fix move representation (Classical/EP/Flip) and add -output flag
ContradNamiseb Jan 9, 2026
62d0b3a
Port move representation fixes and -output logic to master
ContradNamiseb Jan 9, 2026
a553ec7
Fix move conversion logic and V6 training data field population
ContradNamiseb Jan 9, 2026
4293a26
Address PR review: fix board indexing, UCI castling, played_q, WDL dr…
Copilot Aug 15, 2026
a5d5223
Address code review: remove dead return, include windows.h in header,…
Copilot Aug 15, 2026
7c04f7a
Fix pipe FD leak on failure and remove leftover commented code
Copilot Aug 15, 2026
88ced75
Fix fork FD leak and make readLine non-blocking with persistent buffer
Copilot Aug 15, 2026
fbf0d2a
Merge branch 'master' into stockfish-eval
Copilot Aug 15, 2026
9c7736f
Merge pull request #1 from Bonan14/stockfish-eval
ContradNamiseb Aug 15, 2026
f0ee354
Initial plan
Copilot Aug 15, 2026
a5607dc
Fix release asset name collisions
Copilot Aug 15, 2026
3eae9d6
Harden release asset extension handling
Copilot Aug 15, 2026
4e70401
Simplify release asset renaming
Copilot Aug 15, 2026
7ea3430
Merge pull request #3 from Bonan14/copilot/fix-failing-github-actions…
ContradNamiseb Aug 15, 2026
27f58fa
Update README options table for static eval and branch options
Copilot Aug 15, 2026
8858a0f
Apply remaining changes
Copilot Aug 15, 2026
7096a97
Merge pull request #4 from Bonan14/copilot/edit-options-table
ContradNamiseb Aug 15, 2026
0c9cedf
Add PGN eval mode, WDL reconstruction, policy distribution scaling, a…
ContradNamiseb Aug 18, 2026
1ff5d18
Keep one writer per run, and stop holding its lock across gzip
ContradNamiseb Aug 20, 2026
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
127 changes: 127 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: cl
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Update submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake zlib1g-dev ninja-build

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
choco install ninja -y

- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-G Ninja
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --verbose

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }}

- name: Upload Build Artifact
uses: actions/upload-artifact@v4.4.3
with:
name: trainingdata-tool-${{ matrix.os }}-${{ matrix.c_compiler }}
path: |
${{ steps.strings.outputs.build-output-dir }}/trainingdata-tool
${{ steps.strings.outputs.build-output-dir }}/trainingdata-tool.exe
if-no-files-found: ignore

release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: write

steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Create timestamp
id: timestamp
run: echo "time=$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT"

- name: Prepare release assets
shell: bash
run: |
mkdir -p release-assets
for file in artifacts/*/*; do
[ -f "$file" ] || continue
artifact_name="$(basename "$(dirname "$file")")"
basename_file="$(basename "$file")"
cp "$file" "release-assets/${artifact_name}-${basename_file}"
done

- name: Create Pre-release
uses: softprops/action-gh-release@v1
with:
tag_name: pre-release-${{ steps.timestamp.outputs.time }}
name: Pre-release ${{ steps.timestamp.outputs.time }}
prerelease: true
files: release-assets/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ Makefile
trainingdata-tool

Project\.cbp

__pycache__/
*.pyc

# Analysis output, not source
graphify-out/
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
url = https://github.com/DanielUranga/polyglot.git
[submodule "lc0"]
path = lc0
url = https://github.com/CallOn84/lc0.git
branch = trainingdata-tool
url = https://github.com/LeelaChessZero/lc0.git
branch = master
74 changes: 62 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
project(trainingdata-tool)

set(CMAKE_REQUIRED_FLAGS -std=c++17)
set(CMAKE_REQUIRED_FLAGS -std=c++20)

file(GLOB_RECURSE sources src/*.cpp src/*.h)

set (
lc0
"lc0/src/chess/bitboard.cc"
"lc0/src/chess/board.cc"
"lc0/src/chess/position.cc"
"lc0/src/neural/encoder.cc"
"lc0/src/neural/writer.cc"
"lc0/src/trainingdata/writer.cc"
"lc0/src/utils/commandline.cc"
"lc0/src/utils/logging.cc"
"lc0/src/utils/random.cc"
"lc0/src/utils/string.cc"
)

if (WIN32)
Expand All @@ -26,32 +27,81 @@ else (WIN32)
endif (WIN32)

AUX_SOURCE_DIRECTORY(polyglot/src polyglot)
AUX_SOURCE_DIRECTORY(zlib zlib)

# Use system zlib on Unix to avoid old bundled zlib issues with modern compilers
if (UNIX)
find_package(ZLIB REQUIRED)
set(ZLIB_LIBS ZLIB::ZLIB)
set(ZLIB_INCLUDE ${ZLIB_INCLUDE_DIRS})
else()
AUX_SOURCE_DIRECTORY(zlib zlib_sources)
set(ZLIB_LIBS "")
set(ZLIB_INCLUDE "zlib")
endif()

# Add source to this project's executable.
add_executable(trainingdata-tool ${sources} ${lc0} ${lc0_filesystem} ${polyglot} ${zlib})
if (UNIX)
add_executable(trainingdata-tool ${sources} ${lc0} ${lc0_filesystem} ${polyglot})
else()
add_executable(trainingdata-tool ${sources} ${lc0} ${lc0_filesystem} ${polyglot} ${zlib_sources})
endif()

set_target_properties(trainingdata-tool PROPERTIES
CXX_STANDARD 17
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS ON
)

if (UNIX)
target_link_libraries(trainingdata-tool -lpthread -lstdc++fs)
target_link_libraries(trainingdata-tool -lpthread -lstdc++fs ${ZLIB_LIBS})
endif(UNIX)

find_package(Boost 1.65.0)
set(CMAKE_BUILD_TYPE Release)

include_directories(
"lc0/src"
"lc0/src/chess"
"lc0/src/neural"
"src"
"polyglot/src"
"zlib"
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE}
"."
)

# For MinGW: pre-define __GETOPT_H__ to prevent polyglot's getopt.h from
# being used when system unistd.h includes <getopt.h>. This avoids the
# "undefined reference to getopt_internal" error.
if (MINGW)
add_compile_definitions(__GETOPT_H__)
endif()

add_compile_definitions(NO_PEXT)

# MSVC-specific settings for compatibility with legacy C code in polyglot and lc0 quirks
# MSVC-specific settings for compatibility with legacy C code in polyglot and lc0 quirks
if (MSVC)
# Disable deprecation warnings for unsafe CRT functions and other noisy warnings
# 4996: unsafe function (strcpy vs strcpy_s)
# 4267, 4244: conversion loss of data
# 4390: empty controlled statement
# 4018: signed/unsigned mismatch
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_options(/wd4996 /wd4267 /wd4244 /wd4390 /wd4018)

# Relax conformance mode to allow some legacy C++ constructs
add_compile_options(/permissive)

# Force include <array> because lc0/src/neural/encoder.cc uses std::array but doesn't include it
add_compile_options(/FIarray)

# Specific flags for polyglot files to handle const char* conversions
# We try to force them to use older C++ standard semantics where possible
set_source_files_properties(${polyglot} PROPERTIES
COMPILE_OPTIONS "/Zc:strictStrings-;/permissive"
)
elseif (MINGW)
# MinGW/GCC also needs lenient handling for legacy C code
set_source_files_properties(${polyglot} PROPERTIES
COMPILE_OPTIONS "-fpermissive;-Wno-write-strings"
)
endif()

# TODO: Add tests and install targets if needed.
40 changes: 40 additions & 0 deletions PULL_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# PR Title
Upgrade to C++20, update lc0 integration, and add one-game-per-file output

# PR Description

## Summary
This PR modernizes the trainingdata-tool by upgrading to C++20, updating the lc0 integration to work with the latest lc0 codebase, and improving the output format to write one game per chunk file.

## Changes

### Build System Updates
- Upgraded C++ standard from C++17 to C++20
- Set explicit Release build type
- Simplified include directories
- Added `lc0/src/utils/string.cc` to fix linker error for `StrSplit` function

### lc0 Integration Updates
- Updated lc0 source file paths to match latest lc0 structure:
- Removed `lc0/src/chess/bitboard.cc` (no longer needed)
- Changed `lc0/src/neural/writer.cc` to `lc0/src/trainingdata/writer.cc`
- Updated `.gitmodules` for lc0 submodule
- Added `absl/` library dependency

### Training Data Format Upgrade
- Upgraded from V4 to V6 training data format
- Replaced `V4TrainingDataHashUtil.h` with `V6TrainingDataHashUtil.h`
- Updated related source files for V6 compatibility

### Output Format Improvement
- Modified `TrainingDataWriter` to write one game per chunk file
- Each game's training positions are now isolated in their own `.gz` file
- Removed batching logic that previously combined multiple games into one file

## Testing
- Successfully built on Linux with GCC
- Verified output: Converting 5 games produces 5 separate files with varying sizes reflecting different game lengths

---

*Made with Gemini and Claude*
Loading