| 324 | |
| 325 | template <typename TBinCalcMapper, typename TScoreCalcMapper> |
| 326 | void MapGenericRemoteCalcScore( |
| 327 | double scoreStDev, |
| 328 | TVector<TCandidatesContext>* candidatesContexts, |
| 329 | TLearnContext* ctx) { |
| 330 | |
| 331 | Y_ASSERT(ctx->Params.SystemOptions->IsMaster()); |
| 332 | |
| 333 | auto scoreDistribution = GetScoreDistribution(ctx->Params.ObliviousTreeOptions->RandomScoreType); |
| 334 | |
| 335 | // Flatten candidateLists from all contexts to ensure even parallelization |
| 336 | TCandidateList allCandidatesList; |
| 337 | for (auto& candidatesContext : *candidatesContexts) { |
| 338 | allCandidatesList.insert( |
| 339 | allCandidatesList.end(), |
| 340 | candidatesContext.CandidateList.begin(), |
| 341 | candidatesContext.CandidateList.end()); |
| 342 | } |
| 343 | |
| 344 | NPar::TJobDescription job; |
| 345 | NPar::Map(&job, new TBinCalcMapper(), &allCandidatesList); |
| 346 | NPar::RemoteMap(&job, new TScoreCalcMapper); |
| 347 | NPar::TJobExecutor exec(&job, TMasterEnvironment::GetRef().SharedTrainData); |
| 348 | TVector<typename TScoreCalcMapper::TOutput> allScores; |
| 349 | exec.GetRemoteMapResults(&allScores); |
| 350 | // set best split for each candidate |
| 351 | Y_ASSERT(allCandidatesList.size() == allScores.size()); |
| 352 | const ui64 randSeed = ctx->LearnProgress->Rand.GenRand(); |
| 353 | |
| 354 | size_t allScoresOffset = 0; |
| 355 | for (auto& candidatesContext : *candidatesContexts) { |
| 356 | auto& candidateList = candidatesContext.CandidateList; |
| 357 | ctx->LocalExecutor->ExecRange( |
| 358 | [&] (int candidateIdx) { |
| 359 | auto& candidates = candidateList[candidateIdx].Candidates; |
| 360 | CB_ENSURE(candidates.size() > 0, "Some score calcer did not produce ay scores"); |
| 361 | |
| 362 | SetBestScore( |
| 363 | randSeed + candidateIdx, |
| 364 | allScores[allScoresOffset + candidateIdx], |
| 365 | scoreDistribution, |
| 366 | scoreStDev, |
| 367 | candidatesContext, |
| 368 | &candidates); |
| 369 | }, |
| 370 | 0, |
| 371 | candidateList.ysize(), |
| 372 | NPar::TLocalExecutor::WAIT_COMPLETE); |
| 373 | allScoresOffset += candidateList.size(); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | void MapRemotePairwiseCalcScore( |
| 378 | double scoreStDev, |
nothing calls this directly
no test coverage detected