salvus.project.tools.task_chains.compute_misfits_and_gradients.detail
Details for the misfit and gradient computations.
Functions
create_result_folders_on_all_sites()
create_result_folders_on_all_sites()def create_result_folders_on_all_sites(
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
]
) -> List[pathlib.Path]:
...All the results from a task chain have to go somewhere - for now this will just be a folder in the run directory which we’ll create for each site. There is an assumption in that they share a file system - so we can later on collect the results from these folders.
Parameters
sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — The site configuration dictionary.
Returns List[pathlib.Path]
extract_from_project()
extract_from_project()def extract_from_project(
p: salvus.project.project.Project,
simulation_configuration: str,
misfit_configuration: str,
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
],
wavefield_compression: Optional[
salvus.flow.collections.wavefield_compression.WavefieldCompression
],
) -> (
salvus.project.tools.task_chains.compute_misfits_and_gradients.detail.ProjectData
):
...Extract all the necessary pieces from an existing Salvus project.
Parameters
psalvus.project.project.Project — The project.simulation_configurationstr — The simulation configuration name.misfit_configurationstr — The misfit configuration name.sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — The site configuration dictionary.wavefield_compressionOptional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — If given, the simulation template will include checkpoints.
Returns salvus.project.tools.task_chains.compute_misfits_and_gradients.detail.ProjectData
extract_simulation_template()
extract_simulation_template()def extract_simulation_template(
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
],
project: salvus.project.project.Project,
simulation_configuration: str,
wavefield_compression: Optional[
salvus.flow.collections.wavefield_compression.WavefieldCompression
],
) -> salvus.flow.simple_config.simulation.waveform.Waveform:
...Gets a simulation template from a project and modifies it two-fold:
- Convert the mesh paths to absolute paths - this will then work on the remote system under the assumption of a shared file system.
- Create them as promise files so the paths will not be checked by flow which should speed up the process.
Parameters
sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — Sites this will run on. Used to extract information about GPUs and memory per rank.projectsalvus.project.project.Project — The project.simulation_configurationstr — Name of the simulation configuration.wavefield_compressionOptional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — Wavefield compression. Will store checkpoints if given.
Returns salvus.flow.simple_config.simulation.waveform.Waveform
generate_adjoint_input_file_from_forward_input_files()
generate_adjoint_input_file_from_forward_input_files()def generate_adjoint_input_file_from_forward_input_files(
mesh: salvus.mesh.unstructured_mesh.UnstructuredMesh,
w_forward: salvus.flow.simple_config.simulation.waveform.Waveform,
) -> salvus.flow.simple_config.simulation.waveform.Waveform:
...Generate a generic adjoint input file from a forward simulation objects.
Parameters
meshsalvus.mesh.unstructured_mesh.UnstructuredMesh — The mesh for the forward run. Currently needed to extract the gradient parameterization.w_forwardsalvus.flow.simple_config.simulation.waveform.Waveform — The forward simulation objects.
Returns salvus.flow.simple_config.simulation.waveform.Waveform
get_memory_per_rank()
get_memory_per_rank()def get_memory_per_rank(
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
]
) -> Optional[float]:
...Parse the memory per rank from a site configuration dict.
Parameters
sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — the sites.
Returns Optional[float]
get_use_cuda_gpus()
get_use_cuda_gpus()def get_use_cuda_gpus(
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
]
) -> bool:
...CUDA flags from a site configuration dict.
Parameters
sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — The sites.
Returns bool
perform_sanity_checks()
perform_sanity_checks()def perform_sanity_checks(
sites: Dict[
str,
salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
]
) -> None:
...Perform a range of sanity checks.
Parameters
sitesDict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig] — The sites.
Returns None
Classes
ProjectData
ProjectDataclass ProjectData(builtins.object):
def __init__(
self,
simulation_configuration: salvus.project.configuration.simulation_configuration.SimulationConfiguration,
simulation_template: salvus.flow.simple_config.simulation.waveform.Waveform,
mesh: salvus.mesh.unstructured_mesh.UnstructuredMesh,
mesh_filename: pathlib.Path,
misfit_configuration: salvus.project.configuration.misfit_configuration.MisfitConfiguration,
processing_configuration: salvus.project.configuration.processing.ProcessingConfiguration,
data_selection_configuration: Optional[
salvus.project.configuration.data_selection_configuration.DataSelectionConfiguration
],
event_block_filename: pathlib.Path,
data_proxy_filename: pathlib.Path,
) -> None:
...A container collection information from project.
Parameters
simulation_configurationsalvus.project.configuration.simulation_configuration.SimulationConfiguration — The simulation configuration objects.simulation_templatesalvus.flow.simple_config.simulation.waveform.Waveform — The simulation template.meshsalvus.mesh.unstructured_mesh.UnstructuredMesh — The unstructured mesh for the simulation.mesh_filenamepathlib.Path — Absolute path to the mesh.misfit_configurationsalvus.project.configuration.misfit_configuration.MisfitConfiguration — The misfit configuration.processing_configurationsalvus.project.configuration.processing.ProcessingConfiguration — The processing configuration.data_selection_configurationOptional[salvus.project.configuration.data_selection_configuration.DataSelectionConfiguration] — The data configuration, if any.event_block_filenamepathlib.Path — Path to the event block file.data_proxy_filenamepathlib.Path — Path to the data proxy.