Fix CI CUDA environment setup and commit lint fallback - #23
Closed
GuyPaddock wants to merge 35 commits into
Closed
Conversation
Switch CI CUDA jobs to micromamba with pinned 12.4 toolchain packages and run cargo via the environment runner. Add explicit tag detection to commit linting so the job skips cleanly when no baseline tag exists.
Install nvcc and cuBLAS packages in the micromamba env and remove the nvcc-less matrix preset that cannot build the CUDA feature.
Add Cargo.lock to version control so CI builds using --locked have a reproducible dependency set. Regenerated the lockfile to match the current Cargo.toml and ensured it builds without default features.
…n-errors Fix CUDA decode e2e test warnings
Add FFI binding for m40llm_validate_device_ptr and wire it through CudaContext so CUDA tests can verify device pointers.
…rust-tests fix(test): Expose CUDA device pointer validation to Rust
Remove an unused CUDA context import and drop unnecessary mut bindings so CUDA tests compile cleanly with warnings as errors.
…-imports-and-mutability fix(test): Fix CUDA test warnings
Skip the kv_layout test when KV cache creation fails so environments without CUDA support don't produce hard failures.
…v_index_math fix(test,ci): Handle KV cache test skip when CUDA unavailable
Ensure CUDA calls run on the selected device before allocating memory. - Validate cudaSetDevice during context creation. - Reuse device guard to prevent cudaMalloc failures when the device is not current.
Ensure m40llm_create_context returns null without referencing an undefined context pointer when cudaSetDevice fails.
…40-card fix(cuda,tests): Ensure CUDA device selection before GPU allocations
…ention kernel The CUDA attention kernel had two critical bugs causing numerical divergence: 1. Broken FP16 detection: Used pointer alignment checks to determine data type, which is unreliable and caused incorrect type casting between FP16/FP32. KV cache always stores FP16, so we now use direct FP16 access. 2. Dynamic memory allocation: Used malloc/free for scores buffer inside kernel, causing performance issues and potential memory leaks. Changes: - Replace void* parameters with const __half* for explicit FP16 typing - Remove is_fp16 detection logic and conditional casting - Directly access K/V as FP16 using __half2float() for compute - Eliminate malloc/free by recomputing scores in third pass - Maintain 3-pass algorithm structure (max, denom, output) Testing: - All attention tests pass: attention_last_token_matches_cpu_ref - Parity grid test passes: attention_last_token_cuda_parity_grid - Tolerance: < 1e-3 per element vs CPU reference This fixes the root cause of numerical divergence in attention computation.
Add debug output to understand build configuration and enable debug flags when DEBUG=true is set. This will help diagnose the missing C debug output issue. Co-authored-by: openhands <openhands@all-hands.dev>
- Clean up whitespace around .flag() calls - Remove extra blank line before comment - No functional changes, only formatting cleanup
…gging - Add device validation to check current vs expected device - Add comprehensive debug logging for device operations - Return specific error codes for different failure modes - Improve error handling and diagnostics
Add device validation checks to CUDA kernel wrapper functions: - m40llm_memcpy_h2d - m40llm_memcpy_d2h - m40llm_rope_f32 - m40llm_residual_add_f32 Each function now validates the CUDA context before executing operations, returning error codes on validation failure. Co-authored-by: openhands <openhands@all-hands.dev>
Add debug fprintf statements to m40llm_create_context to help diagnose device selection and context creation issues: - Log device_id parameter at function entry - Log when Tesla M40 (sm_52) is found during auto-selection - Log cudaSetDevice success/failure - Log created context pointer and selected device This aids debugging device initialization problems, especially with the M40 auto-selection logic. Co-authored-by: openhands <openhands@all-hands.dev>
Removes the -Wl,--whole-archive linking flags that were causing duplicate symbol errors during linking. The static library symbols are now linked normally without forcing inclusion of all symbols. Co-authored-by: openhands <openhands@all-hands.dev>
…mature deallocation Moves the device_free call to occur after logits computation to prevent premature deallocation of device memory that is still needed for the forward pass. Co-authored-by: openhands <openhands@all-hands.dev>
The map_lm_head function now returns the tensor name alongside the tensor view, allowing callers to identify which specific tensor was selected from the candidate list. This improves debugging and logging capabilities. Co-authored-by: openhands <openhands@all-hands.dev>
Initialize d_weights_base to host_base instead of null to prevent null pointer dereferences when accessing device memory. This ensures proper memory management and prevents potential segmentation faults. Co-authored-by: openhands <openhands@all-hands.dev>
Updates the test to handle the new map_lm_head return type which now includes the tensor name as the first element of the tuple. Co-authored-by: openhands <openhands@all-hands.dev>
- Add ctor crate for library initialization - Automatically set M40LLM_ENABLE_NVCC=1 when nvcc cfg is enabled - Fix unused variable warnings in src/infer.rs This fixes the root cause where tests had to manually set M40LLM_ENABLE_NVCC. The environment variable is now automatically set when CUDA kernels are available. Co-authored-by: openhands <openhands@all-hands.dev>
…pace Removes the duplicate m40llm_rope_f32 function implementation that was shadowing the extern "C" version. This eliminates symbol conflicts and ensures proper linking of the CUDA kernel. - Removes duplicate rope_f32 kernel (lines 245-276) - Removes forward declaration comment - Leaves only the extern "C" version for proper symbol visibility Co-authored-by: openhands <openhands@all-hands.dev>
Owner
Author
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.
Summary
Testing
Codex Task