Conversation
…am for FlagGems integration - Add csrc/aten/backends/ascend/acl_stream.h: centralized singleton ACL stream - Add csrc/runtime/flagos_stream_api.cc: exports FlagOS_GetCurrentStream() C API - Update op_api_common.h to use shared GetDefaultAclStream() - Update CMakeLists.txt to auto-detect FLAGGEMS_DIR from installed flag_gems package
… dependency liboperators.so (FlagGems) needs FlagOS_GetCurrentStream which was in torch_fl._C. This creates a circular load dependency. Solution: build it as a separate libflagos_stream.so loaded with RTLD_GLOBAL before _C.
…ck pointer bug - Set GEMS_VENDOR=ascend and provide torch.npu/torch_npu shims so FlagGems uses ASCEND codegen config (prefer_block_pointer=False) - Route most ops through flagos_python (FlagGems Triton) in ascend config - Keep embedding/embedding_dense_backward on ascend C++ backend - Keep factory ops (new_ones, zeros, etc.) on ascend C++ backend
…pec compatibility
…ransformers NPU imports
FlagGems has a deep lazy import chain (fused → FLA → utils → models → sqlalchemy) that can exceed Python's recursion limit when triggered inside PyTorch dispatch. Import it during _lazy_init() to avoid this.
1. python_op_caller.cc: OptionalIntArrayRefToPython now passes empty arrays as [] instead of None, so FlagGems sum_dim_comm takes the dim==[] path (calls local sum() directly) instead of the dim==None path (calls torch.sum which re-dispatches → infinite recursion). 2. sum.cc: Normalize dim=None to dim=[] before calling FlagGems sum_dim. 3. flagos/__init__.py: Eagerly import flag_gems during _lazy_init() to avoid deep import chain (fused→FLA→utils→models→sqlalchemy) exceeding Python recursion limit when triggered inside PyTorch dispatch stack. 4. Revert sum.dim_IntList back to flagos_python (no longer needs ascend).
When FLAGGEMS_PYTHON=1 and FLAGGEMS_KERNEL=0, only the Python wrappers (python_op_caller + python_wrapper/*.cc) are compiled. This avoids the need for FlagGems C++ library (liboperators.so) when only using FlagGems via Python dispatch. Build command: ACCELERATOR=ascend FLAGGEMS_PYTHON=1 FLAGGEMS_KERNEL=0 CUDA_KERNEL=0 \ ASCEND_KERNEL=1 CMAKE_BUILD_PARALLEL_LEVEL=32 pip install --no-build-isolation -e .
…/mean to ascend - sum: When dim is None/empty, call flag_gems.ops.sum directly instead of sum_dim. FlagGems sum_dim with dim=[] fails because Python () != [] check. This fixes 'grad can be implicitly created only for scalar outputs' in silu_backward, embedding_dense_backward, and slice_backward tests. - acos: Route to ascend backend (triton-ascend compiler error) - mean.dim: Route to ascend backend (FlagGems non-inner dim uses CUDA context) - Add CallPythonOp_TD helper for (Tensor, optional<dtype>) signature
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.
No description provided.