You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I encountered an error when running microsynth with n.cores > 1 (parallel execution enabled). The issue appears to be related to the get.stats1 function, specifically the handling of the reps object. The error does not occur when using single-core execution (n.cores = 1), which suggests it is linked to the way objects are passed or handled in parallel processing.
Steps to Reproduce:
Below is an example of the code used:
Observed Behaviour:
With n.cores = 10, the following error is raised during the parallelised calculation of survey statistics for permutation groups:
Calculating survey statistics for end.post = 89...
Completed survey statistics for main weights: Time = 0.04
Calculating survey statistics for permutation groups...
Parallelizing with n.cores = 10...
Error in get.stats1(data, w.tmp, Inter.tmp, mse.tmp, result.var, end.pre = end.pre, :
object 'reps' not found
The same code runs successfully when n.cores = 1, suggesting the issue lies with the parallelisation.
Likely Cause:
From inspecting the get.stats1 function (via getAnywhere(get.stats1)), it appears the reps object is defined in the main weights computation but is not propagated correctly to worker processes during parallel execution. Since reps is critical for group assignment, its absence in parallelised runs results in the error.
Expected Behaviour:
Parallel execution should replicate the behaviour of single-core execution, ensuring that all necessary objects, such as reps, are properly passed to worker threads or recreated locally.
Suggestions for Fix:
Recreate reps in Each Worker: Modify the code to ensure reps is computed within each thread.
if (is.null(reps)) {
reps <- assign.groups(as.numeric(treat), G = G.tmp)
}
Pass reps Explicitly: Use mechanisms such as parallel::clusterExport to share reps across worker threads.
Adjust Parallelisation Scope: If reps is not inherently tied to parallelisation, consider restructuring the computation to avoid requiring reps in parallelised sections.
Environment:
R Version: R version 4.4.0
Operating System: Windows 11
Additional Notes:
This issue may be affecting other parallelised computations in the package. Disabling parallelisation (n.cores = 1) serves as a workaround but significantly increases computation time for larger datasets.
The text was updated successfully, but these errors were encountered:
Description:
I encountered an error when running microsynth with n.cores > 1 (parallel execution enabled). The issue appears to be related to the get.stats1 function, specifically the handling of the reps object. The error does not occur when using single-core execution (n.cores = 1), which suggests it is linked to the way objects are passed or handled in parallel processing.
Steps to Reproduce:
Below is an example of the code used:
Observed Behaviour:
With n.cores = 10, the following error is raised during the parallelised calculation of survey statistics for permutation groups:
The same code runs successfully when n.cores = 1, suggesting the issue lies with the parallelisation.
Likely Cause:
From inspecting the get.stats1 function (via getAnywhere(get.stats1)), it appears the reps object is defined in the main weights computation but is not propagated correctly to worker processes during parallel execution. Since reps is critical for group assignment, its absence in parallelised runs results in the error.
Expected Behaviour:
Parallel execution should replicate the behaviour of single-core execution, ensuring that all necessary objects, such as reps, are properly passed to worker threads or recreated locally.
Suggestions for Fix:
Recreate reps in Each Worker: Modify the code to ensure reps is computed within each thread.
Pass reps Explicitly: Use mechanisms such as parallel::clusterExport to share reps across worker threads.
Adjust Parallelisation Scope: If reps is not inherently tied to parallelisation, consider restructuring the computation to avoid requiring reps in parallelised sections.
Environment:
R Version: R version 4.4.0
Operating System: Windows 11
Additional Notes:
This issue may be affecting other parallelised computations in the package. Disabling parallelisation (n.cores = 1) serves as a workaround but significantly increases computation time for larger datasets.
The text was updated successfully, but these errors were encountered: