Repository navigation
feat(ftorch): Declare full set of stub methods; buildlib usability improvements; add GNU support - #2
Open
johnpaulalex wants to merge 5 commits into
Open
johnpaulalex wants to merge 5 commits into
johnpaulalex wants to merge 5 commits into
Conversation
…t, and model deletion in stub
- Gate TORCH_DIR check behind USE_FTORCH=TRUE so default builds without FTorch do not require PyTorch or TORCH_DIR. - Remove fallback WGET download of unpinned nightly LibTorch archives, failing fast with an actionable error message. - Run FTMakefile unconditionally so changes to USE_FTORCH reconfigure CMake properly.
…LibTorch linking CIME passes -DCMAKE_SYSTEM_NAME=Catamount to CMake on Cray systems, which disables shared library support in CMake (setting TARGET_SUPPORTS_SHARED_LIBS to FALSE, defaulting library suffixes to .a, and omitting -Wl,-soname). This prevents CMake from locating libtorch.so and prevents building shared wrapper libraries. Add cmake/enable_shared_libs.cmake and register it via CMAKE_PROJECT_INCLUDE so CMake re-enables shared libraries for both top-level and nested FTorch targets without modifying CIME or upstream FTorch.
12 tasks done
Author
|
@ekluzek here's half of the CTSM Ftorch support (the other is CTSM #4265). fyi @jedwards4b @briandobbins |
|
Marking as next to assign reviewers, milestone, priorities, etc. |
|
I can't mark as next, I'll leave this up to CSEG to evaluate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
This PR resolves several CIME build system and Fortran interface issues when building CESM/CTSM with
libraries/FTorchacrossintelandgnucompilers and acrossUSE_FTORCH=TRUEandUSE_FTORCH=FALSE:Mock out full set of ftorch methods when
USE_FTORCH=FALSE(FTorch_cesm_interface.F90):torch_tensor_from_arrayvariants (including with and without the 'layout' params) andtorch_delete.device_index,requires_grad,is_training) matching upstreamftorchand initializestorch_kCPU = 0as a parameter constant.buildlib usability improvements (
buildlib):TORCH_DIRcheck (torch_dir and os.path.isdir(torch_dir)) behindif case.get_value("USE_FTORCH"):. Fixes the root cause of theTORCH_DIR=NoneTypeErrororiginally reported in ESCOMP/CTSM#3214.WGETdownload of unpinnedlibtorch-shared-with-deps-latest.zipnightlies duringcase.build, failing fast viaexpect(...)with an actionable error message (showing how to point to a pre-existing copy or download one).FTMakefileunconditionally inbuildlib(removingif not os.path.isfile(os.path.join(bldroot,"Makefile")):), ensuring CMake reconfigures properly if a user flipsUSE_FTORCHand rebuilds an existing case (or whencreate_testcases share aSHAREDLIBROOT).Add GNU Support (
CMakeLists.txt):ftorch.modin${CMAKE_BINARY_DIR}/modules(reverting theexternal/ftorchoverride fromv0.0.4to align with upstreamCambridge-ICCS/FTorch's default output directory) to matchINCLDIR += -I$(FTORCH_DIR)/modulesincime/CIME/Tools/Makefile. This makes GNU (gfortran) builds work (existing-but-not-mainline CAM branches were only tested with Intelifx, which embeds transitiveuse ftorchsymbols insideftorch_cesm_interface.mod, whereasgfortranrequiresftorch.moditself to be on-Iwhen compiling any caller ofFTorch_cesm_interface).Enable libtorch.so shared linking (
CMakeLists.txt):libtorch.so), but our Cray cmake configs disable shared libs (they used to be unsupported).TARGET_SUPPORTS_SHARED_LIBS TRUE,CMAKE_SHARED_LIBRARY_SUFFIX ".so",CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a", and-Wl,-sonameacross both top-level and nested FTorch builds without modifying CIME or upstream FTorch.Related issues / PRs
buildlibroot cause of ESCOMP/CTSM#3214) by enabling feat(ftorch): finish CTSM FTorch integration: add system test calling FTorch inference CTSM#4265.Testing performed
(USE_FTORCH=TRUE/FALSE, use_ftorch_demo=.true./.false.)CTSM system test permutations on NCAR Derecho acrossintel(multi-rank Cray MPI) andgnu(mpi-serial), plus 3 system tests inside a full top-levelCESMcheckout (/glade/work/jpalex/src/cesm,$SRCROOT= CESM root):cesm_ftorch_test1(USE_FTORCH=TRUE,intelMPI,use_ftorch_demo=.true.),cesm_ftorch_false1(USE_FTORCH=FALSE,intelMPI), andcesm_ftorch_gnu1(USE_FTORCH=FALSE,gnumpi-serial).FTorch_cesm_interfacecaller patterns (jedwards4b/PUMAS@1nn_tau_emulator,leap-stc/Integration_team@CAM_Convection_YOG, andm2lines/clubb_ML@clubb_4ncar_with_mlwithtorch_delete(model)) pluslayout-free FTorchv1.1.0calls compile and link cleanly across(intel, gnu)(USE_FTORCH=TRUE, FALSE).T15) on NCAR Derecho with this PR + feat(ftorch): finish CTSM FTorch integration: add system test calling FTorch inference CTSM#4265:SMS_D_Ld1.f10_f10_mg37.I2000Clm60Sp.derecho_intel.clm-default--clm-nofireemis--clm-ftorch_demopassed. Runtime loglnd.logverified:FTORCH INFERENCE SUCCESSFUL: output = 1.00000000000000.Google Gemini Argon 4 was used to write the code and tests, followed by human-guided verification.