Skip to content

Commit 5778b81

Browse files
committed
PSQTを削除した。
モデルサイズを変更した。 最後にネットワークパラメーターを保存するようにした。
1 parent 49d4a62 commit 5778b81

18 files changed

+30
-602
lines changed

cross_check_eval.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def eval_model_batch(model, batch: data_loader.SparseBatchPtr):
4949
black_values,
5050
outcome,
5151
score,
52-
psqt_indices,
5352
layer_stack_indices,
5453
) = batch.contents.get_tensors("cuda")
5554

@@ -62,7 +61,6 @@ def eval_model_batch(model, batch: data_loader.SparseBatchPtr):
6261
white_values,
6362
black_indices,
6463
black_values,
65-
psqt_indices,
6664
layer_stack_indices,
6765
)
6866
* 600.0

data_loader/_native.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class SparseBatch(ctypes.Structure):
2222
("black", ctypes.POINTER(ctypes.c_int)),
2323
("white_values", ctypes.POINTER(ctypes.c_float)),
2424
("black_values", ctypes.POINTER(ctypes.c_float)),
25-
("psqt_indices", ctypes.POINTER(ctypes.c_int)),
2625
("layer_stack_indices", ctypes.POINTER(ctypes.c_int)),
2726
]
2827

@@ -79,14 +78,6 @@ def get_tensors(self, device):
7978
.pin_memory()
8079
.to(device=device, non_blocking=True)
8180
)
82-
psqt_indices = (
83-
torch.from_numpy(
84-
np.ctypeslib.as_array(self.psqt_indices, shape=(self.size,))
85-
)
86-
.long()
87-
.pin_memory()
88-
.to(device=device, non_blocking=True)
89-
)
9081
layer_stack_indices = (
9182
torch.from_numpy(
9283
np.ctypeslib.as_array(self.layer_stack_indices, shape=(self.size,))
@@ -104,7 +95,6 @@ def get_tensors(self, device):
10495
black_values,
10596
outcome,
10697
score,
107-
psqt_indices,
10898
layer_stack_indices,
10999
)
110100

@@ -138,31 +128,6 @@ def _load_library(self):
138128
raise FileNotFoundError("Cannot find data_loader shared library.")
139129

140130
def _define_prototypes(self):
141-
# EXPORT FenBatchStream* CDECL create_fen_batch_stream(
142-
# int concurrency,
143-
# int num_files,
144-
# const char* const* filenames,
145-
# int batch_size,
146-
# bool cyclic,
147-
# DataloaderSkipConfig config
148-
# )
149-
self.dll.create_fen_batch_stream.restype = ctypes.c_void_p
150-
self.dll.create_fen_batch_stream.argtypes = [
151-
ctypes.c_int,
152-
ctypes.c_int,
153-
ctypes.POINTER(ctypes.c_char_p),
154-
ctypes.c_int,
155-
ctypes.c_bool,
156-
CDataloaderSkipConfig,
157-
]
158-
159-
# EXPORT void CDECL destroy_fen_batch_stream(FenBatchStream* stream)
160-
self.dll.destroy_fen_batch_stream.argtypes = [ctypes.c_void_p]
161-
162-
# EXPORT FenBatch* CDECL fetch_next_fen_batch(Stream<FenBatch>* stream)
163-
self.dll.fetch_next_fen_batch.restype = ctypes.POINTER(FenBatch)
164-
self.dll.fetch_next_fen_batch.argtypes = [ctypes.c_void_p]
165-
166131
# EXPORT Stream<SparseBatch>* CDECL create_sparse_batch_stream(
167132
# const char* feature_set_c,
168133
# int concurrency,
@@ -190,24 +155,6 @@ def _define_prototypes(self):
190155
self.dll.fetch_next_sparse_batch.restype = ctypes.POINTER(SparseBatch)
191156
self.dll.fetch_next_sparse_batch.argtypes = [ctypes.c_void_p]
192157

193-
# EXPORT SparseBatch* get_sparse_batch_from_fens(
194-
# const char* feature_set_c,
195-
# int num_fens,
196-
# const char* const* fens,
197-
# int* scores,
198-
# int* plies,
199-
# int* results
200-
# )
201-
self.dll.get_sparse_batch_from_fens.restype = ctypes.POINTER(SparseBatch)
202-
self.dll.get_sparse_batch_from_fens.argtypes = [
203-
ctypes.c_char_p,
204-
ctypes.c_int,
205-
ctypes.POINTER(ctypes.c_char_p),
206-
ctypes.POINTER(ctypes.c_int),
207-
ctypes.POINTER(ctypes.c_int),
208-
ctypes.POINTER(ctypes.c_int),
209-
]
210-
211158

212159
type SparseBatchPtr = ctypes._Pointer[SparseBatch]
213160
type FenBatchPtr = ctypes._Pointer[FenBatch]

ftperm.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ def forward_ft(
471471
white_values: torch.Tensor,
472472
black_indices: torch.Tensor,
473473
black_values: torch.Tensor,
474-
psqt_indices: torch.Tensor,
475474
layer_stack_indices: torch.Tensor,
476475
) -> torch.Tensor:
477476
wp, bp = model.input(white_indices, white_values, black_indices, black_values)
@@ -500,7 +499,6 @@ def eval_ft(model: NNUEModel, batch: data_loader.SparseBatchPtr) -> torch.Tensor
500499
black_values,
501500
outcome,
502501
score,
503-
psqt_indices,
504502
layer_stack_indices,
505503
) = batch.contents.get_tensors("cuda")
506504
res = forward_ft(
@@ -511,7 +509,6 @@ def eval_ft(model: NNUEModel, batch: data_loader.SparseBatchPtr) -> torch.Tensor
511509
white_values,
512510
black_indices,
513511
black_values,
514-
psqt_indices,
515512
layer_stack_indices,
516513
)
517514
return res

model/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 3 layer fully connected network
55
@dataclass
66
class ModelConfig:
7-
L1: int = 3072
7+
L1: int = 1536
88
L2: int = 15
99
L3: int = 32
1010

model/features/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
function `get_feature_block_clss` at module scope that returns the list
1212
of feature block classes in that module.
1313
"""
14-
from . import halfkp, halfka, halfka_v2, halfka_v2_hm
14+
from . import halfka_hm
1515

16-
_feature_modules: list[types.ModuleType] = [halfkp, halfka, halfka_v2, halfka_v2_hm]
16+
_feature_modules: list[types.ModuleType] = [halfka_hm]
1717

1818
_feature_blocks_by_name: dict[str, FeatureBlock] = dict()
1919

@@ -48,7 +48,7 @@ def get_available_feature_blocks_names() -> list[str]:
4848

4949

5050
def add_feature_args(parser: argparse.ArgumentParser) -> None:
51-
_default_feature_set_name = "HalfKAv2_hm^"
51+
_default_feature_set_name = "HalfKA_hm^"
5252
parser.add_argument(
5353
"--features",
5454
dest="features",

model/features/feature_set.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,3 @@ def get_virtual_to_real_features_gather_indices(self) -> list[list[int]]:
120120
real_offset += feature.num_real_features
121121
offset += feature.num_features
122122
return indices
123-
124-
def get_initial_psqt_features(self) -> list[int]:
125-
init = []
126-
for feature in self.features:
127-
init += feature.get_initial_psqt_features()
128-
return init

model/features/halfka.py

Lines changed: 0 additions & 100 deletions
This file was deleted.

model/features/halfka_v2.py

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)