Skip to content

Commit df13d30

Browse files
committed
Improved network, released v1.1.0
1 parent 31e2137 commit df13d30

File tree

13 files changed

+25
-252
lines changed

13 files changed

+25
-252
lines changed

.github/workflows/release-pipeline.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
working-directory: Sapling
2626
id: get_version
2727
run: |
28-
VERSION=1.0.5
28+
VERSION=1.1.0
2929
echo "Application version: $VERSION"
3030
echo "::set-output name=version::$VERSION"
3131

Sapling.Engine/BoardState.cs

-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
using Sapling.Engine.Evaluation;
2-
using System.Runtime.Intrinsics.X86;
3-
using System.Runtime.Intrinsics;
42

53
namespace Sapling.Engine;
6-
#if AVX512
7-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
8-
using VectorType = System.Runtime.Intrinsics.Vector512;
9-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
10-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
11-
#else
12-
using AvxIntrinsics = Avx2;
13-
using VectorType = Vector256;
14-
using VectorInt = Vector256<int>;
15-
using VectorShort = Vector256<short>;
16-
#endif
174

185
using System.Runtime.InteropServices;
196

Sapling.Engine/BoardStateExtensions.cs

-12
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,8 @@
33
using Sapling.Engine.MoveGen;
44
using Sapling.Engine.Pgn;
55
using System.Runtime.Intrinsics.X86;
6-
using System.Runtime.Intrinsics;
76

87
namespace Sapling.Engine;
9-
#if AVX512
10-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
11-
using VectorType = System.Runtime.Intrinsics.Vector512;
12-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
13-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
14-
#else
15-
using AvxIntrinsics = Avx2;
16-
using VectorType = Vector256;
17-
using VectorInt = Vector256<int>;
18-
using VectorShort = Vector256<short>;
19-
#endif
208

219
public static class BoardStateExtensions
2210
{

Sapling.Engine/Evaluation/NnueEvaluator.cs

-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
using System.Runtime.CompilerServices;
2-
using System.Runtime.Intrinsics;
3-
using System.Runtime.Intrinsics.X86;
42

53
namespace Sapling.Engine.Evaluation;
64

7-
#if AVX512
8-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
9-
using VectorType = System.Runtime.Intrinsics.Vector512;
10-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
11-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
12-
#else
13-
using AvxIntrinsics = Avx2;
14-
using VectorType = Vector256;
15-
using VectorInt = Vector256<int>;
16-
using VectorShort = Vector256<short>;
17-
#endif
18-
195
public static unsafe class NnueEvaluator
206
{
217
#if AVX512
+1-173
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
3-
using System.Runtime.Intrinsics;
4-
using System.Runtime.Intrinsics.X86;
53
using System.Text;
64

75
namespace Sapling.Engine.Evaluation;
8-
#if AVX512
9-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
10-
using VectorType = System.Runtime.Intrinsics.Vector512;
11-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
12-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
13-
#else
14-
using AvxIntrinsics = Avx2;
15-
using VectorType = Vector256;
16-
using VectorInt = Vector256<int>;
17-
using VectorShort = Vector256<short>;
18-
#endif
19-
206
public static class NnueWeights
217
{
228
public const int InputSize = 768;
@@ -152,162 +138,4 @@ public static unsafe void Dispose()
152138
Marshal.FreeHGlobal((IntPtr)OutputWeights);
153139
}
154140
}
155-
}
156-
157-
//using System.Reflection;
158-
//using System.Runtime.InteropServices;
159-
//using System.Runtime.Intrinsics;
160-
//using System.Runtime.Intrinsics.X86;
161-
//using System.Text;
162-
163-
//namespace Sapling.Engine.Evaluation;
164-
//#if AVX512
165-
//using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
166-
//using VectorType = System.Runtime.Intrinsics.Vector512;
167-
//using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
168-
//using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
169-
//#else
170-
//using AvxIntrinsics = Avx2;
171-
//using VectorType = Vector256;
172-
//using VectorInt = Vector256<int>;
173-
//using VectorShort = Vector256<short>;
174-
//#endif
175-
176-
//public static class NnueWeights
177-
//{
178-
// public const int InputSize = 768;
179-
// public const int Layer1Size = 768;
180-
181-
// public const short OutputBuckets = 8;
182-
183-
// public static readonly unsafe VectorShort* FeatureWeights;
184-
// public static readonly unsafe VectorShort* FeatureBiases;
185-
// public static readonly unsafe VectorShort* OutputWeights;
186-
// public static readonly unsafe short* OutputBiases;
187-
188-
// static unsafe NnueWeights()
189-
// {
190-
// var assembly = Assembly.GetAssembly(typeof(GameState));
191-
// var info = assembly.GetName();
192-
// var name = info.Name;
193-
// using var stream = assembly
194-
// .GetManifestResourceStream($"{name}.Resources.sapling.nnue")!;
195-
196-
// var featureWeightsCount = InputSize * Layer1Size;
197-
// var featureBiasesCount = Layer1Size;
198-
// var outputWeightsCount = Layer1Size * 2 * OutputBuckets;
199-
// var outputBiasesCount = OutputBuckets;
200-
201-
202-
// var featureWeights = stackalloc short[featureWeightsCount];
203-
// var featureBiases = stackalloc short[featureBiasesCount];
204-
// var outputWeights = stackalloc short[outputWeightsCount];
205-
// var outputBiases = stackalloc short[outputBiasesCount];
206-
207-
// using var reader = new BinaryReader(stream, Encoding.UTF8, false);
208-
// for (var i = 0; i < featureWeightsCount; i++)
209-
// {
210-
// featureWeights[i] = reader.ReadInt16();
211-
// }
212-
213-
// for (var i = 0; i < featureBiasesCount; i++)
214-
// {
215-
// featureBiases[i] = reader.ReadInt16();
216-
// }
217-
218-
// for (var i = 0; i < outputWeightsCount; i++)
219-
// {
220-
// outputWeights[i] = reader.ReadInt16();
221-
// }
222-
223-
// var transposedWeights = stackalloc short[outputWeightsCount];
224-
225-
// // Transposing logic
226-
// for (var i = 0; i < 2 * Layer1Size; i++)
227-
// {
228-
// for (var j = 0; j < OutputBuckets; j++)
229-
// {
230-
// // Original index calculation
231-
// var originalIndex = i * OutputBuckets + j;
232-
233-
// // Transposed index calculation
234-
// var transposedIndex = j * 2 * Layer1Size + i;
235-
236-
// // Assign value to transposed position
237-
// transposedWeights[transposedIndex] = outputWeights[originalIndex];
238-
// }
239-
// }
240-
241-
// outputWeights = transposedWeights;
242-
243-
// for (var i = 0; i < outputBiasesCount; i++)
244-
// {
245-
// outputBiases[i] = reader.ReadInt16();
246-
// }
247-
248-
// // Allocate unmanaged memory
249-
// FeatureWeights = AlignedAllocZeroedShort((nuint)featureWeightsCount);
250-
// FeatureBiases = AlignedAllocZeroedShort((nuint)featureBiasesCount);
251-
// OutputWeights = AlignedAllocZeroedShort((nuint)outputWeightsCount);
252-
// OutputBiases = AlignedAllocZeroed((nuint)outputBiasesCount);
253-
254-
// // Copy managed array to unmanaged memory
255-
// Buffer.MemoryCopy(featureWeights, FeatureWeights, featureWeightsCount * sizeof(short),
256-
// featureWeightsCount * sizeof(short));
257-
258-
// Buffer.MemoryCopy(featureBiases, FeatureBiases, featureBiasesCount * sizeof(short),
259-
// featureBiasesCount * sizeof(short));
260-
261-
// Buffer.MemoryCopy(outputWeights, OutputWeights, outputWeightsCount * sizeof(short),
262-
// outputWeightsCount * sizeof(short));
263-
264-
// Buffer.MemoryCopy(outputBiases, OutputBiases, outputBiasesCount * sizeof(short),
265-
// outputBiasesCount * sizeof(short));
266-
// }
267-
268-
// public static unsafe VectorShort* AlignedAllocZeroedShort(nuint items)
269-
// {
270-
// const nuint alignment = 64;
271-
// var bytes = sizeof(short) * items;
272-
// var block = NativeMemory.AlignedAlloc(bytes, alignment);
273-
// if (block == null)
274-
// {
275-
// throw new OutOfMemoryException("Failed to allocate aligned memory.");
276-
// }
277-
278-
// NativeMemory.Clear(block, bytes);
279-
// return (VectorShort*)block;
280-
// }
281-
282-
// public static unsafe short* AlignedAllocZeroed(nuint items)
283-
// {
284-
// const nuint alignment = 64;
285-
// var bytes = sizeof(short) * items;
286-
// var block = NativeMemory.AlignedAlloc(bytes, alignment);
287-
// if (block == null)
288-
// {
289-
// throw new OutOfMemoryException("Failed to allocate aligned memory.");
290-
// }
291-
292-
// NativeMemory.Clear(block, bytes);
293-
// return (short*)block;
294-
// }
295-
296-
// public static unsafe void Dispose()
297-
// {
298-
// if (FeatureWeights != null)
299-
// {
300-
// Marshal.FreeHGlobal((IntPtr)FeatureWeights);
301-
// }
302-
303-
// if (FeatureBiases != null)
304-
// {
305-
// Marshal.FreeHGlobal((IntPtr)FeatureBiases);
306-
// }
307-
308-
// if (OutputWeights != null)
309-
// {
310-
// Marshal.FreeHGlobal((IntPtr)OutputWeights);
311-
// }
312-
// }
313-
//}
141+
}

Sapling.Engine/GlobalUsings.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// GlobalUsings.cs
2+
#if AVX512
3+
global using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
4+
global using VectorType = System.Runtime.Intrinsics.Vector512;
5+
global using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
6+
global using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
7+
#else
8+
global using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx2;
9+
global using VectorType = System.Runtime.Intrinsics.Vector256;
10+
global using VectorInt = System.Runtime.Intrinsics.Vector256<int>;
11+
global using VectorShort = System.Runtime.Intrinsics.Vector256<short>;
12+
#endif
Binary file not shown.

Sapling.Engine/Resources/WeightsHistory/log.txt

+8
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,12 @@ SuperBatches: 180
125125
Data: 1.3bn positions
126126
WDL: 0.4
127127
LR: CosineDecayLR 0.001 * 0.3 * 0.3 * 0.3
128+
SuperBatches: 180
129+
130+
----------------------------------
131+
15_hl1024.bin
132+
----------------------------------
133+
Data: 1bn positions
134+
WDL: 0.4
135+
LR: CosineDecayLR 0.001 * 0.3 * 0.3 * 0.3
128136
SuperBatches: 180

Sapling.Engine/Resources/sapling.nnue

0 Bytes
Binary file not shown.

Sapling.Engine/Search/NegaMaxSearch.cs

-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55
using Sapling.Engine.Transpositions;
66

77
namespace Sapling.Engine.Search;
8-
#if AVX512
9-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
10-
using VectorType = System.Runtime.Intrinsics.Vector512;
11-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
12-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
13-
#else
14-
using AvxIntrinsics = Avx2;
15-
using VectorType = Vector256;
16-
using VectorInt = Vector256<int>;
17-
using VectorShort = Vector256<short>;
18-
#endif
198

209
public partial class Searcher
2110
{

Sapling.Engine/Search/QuiescenceSearch.cs

-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
using System.Runtime.CompilerServices;
22
using System.Runtime.InteropServices;
3-
using System.Runtime.Intrinsics;
43
using System.Runtime.Intrinsics.X86;
54
using Sapling.Engine.Evaluation;
65
using Sapling.Engine.MoveGen;
76
using Sapling.Engine.Transpositions;
87

98
namespace Sapling.Engine.Search;
10-
#if AVX512
11-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
12-
using VectorType = System.Runtime.Intrinsics.Vector512;
13-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
14-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
15-
#else
16-
using AvxIntrinsics = Avx2;
17-
using VectorType = Vector256;
18-
using VectorInt = Vector256<int>;
19-
using VectorShort = Vector256<short>;
20-
#endif
219

2210
public partial class Searcher
2311
{

Sapling.Engine/Search/Searcher.cs

-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
using System.Runtime.InteropServices;
2-
using System.Runtime.Intrinsics;
3-
using System.Runtime.Intrinsics.X86;
42
using System.Text;
53
using Sapling.Engine.MoveGen;
64
using Sapling.Engine.Transpositions;
75

86
namespace Sapling.Engine.Search;
9-
#if AVX512
10-
using AvxIntrinsics = System.Runtime.Intrinsics.X86.Avx512BW;
11-
using VectorType = System.Runtime.Intrinsics.Vector512;
12-
using VectorInt = System.Runtime.Intrinsics.Vector512<int>;
13-
using VectorShort = System.Runtime.Intrinsics.Vector512<short>;
14-
#else
15-
using AvxIntrinsics = Avx2;
16-
using VectorType = Vector256;
17-
using VectorInt = Vector256<int>;
18-
using VectorShort = Vector256<short>;
19-
#endif
207

218
public unsafe partial class Searcher
229
{

Sapling/Sapling.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Nullable>enable</Nullable>
88
<ApplicationIcon>logo.ico</ApplicationIcon>
99
<Title>Sapling</Title>
10-
<AssemblyVersion>1.0.5.0</AssemblyVersion>
11-
<FileVersion>1.0.5.0</FileVersion>
12-
<Version>1.0.5.0</Version>
10+
<AssemblyVersion>1.1.0.0</AssemblyVersion>
11+
<FileVersion>1.1.0.0</FileVersion>
12+
<Version>1.1.0.0</Version>
1313
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1414
</PropertyGroup>
1515

0 commit comments

Comments
 (0)