@@ -13,6 +13,17 @@ test-rust: rust
1313	@echo " Running Rust unit tests (release mode, sequential on GPU $( TEST_GPU_DEVICE)  )" 
1414	@cd candle-binding &&  CUDA_VISIBLE_DEVICES=$(TEST_GPU_DEVICE )  cargo test  --release --lib -- --test-threads=1 --nocapture
1515
16+ #  Test Flash Attention(requires GPU and CUDA environment configured in system)
17+ #  Note: Ensure CUDA paths are set in your shell environment (e.g., ~/.bashrc)
18+ #    - PATH should include nvcc (e.g., /usr/local/cuda/bin)
19+ #    - LD_LIBRARY_PATH should include CUDA libs (e.g., /usr/local/cuda/lib64, /usr/lib/wsl/lib for WSL)
20+ #    - CUDA_HOME, CUDA_PATH should point to CUDA installation
21+ #  Note: Uses TEST_GPU_DEVICE env var (default: 2) to avoid GPU 0/1 which may be busy
22+ test-rust-flash-attn : rust-flash-attn
23+ 	@$(LOG_TARGET ) 
24+ 	@echo " Running Rust unit tests with Flash Attention 2 (GPU $( TEST_GPU_DEVICE)  )" 
25+ 	@cd candle-binding &&  CUDA_VISIBLE_DEVICES=$(TEST_GPU_DEVICE )  cargo test  --release --features flash-attn --lib -- --test-threads=1 --nocapture
26+ 
1627#  Test specific Rust module (with release optimization for performance)
1728#    Example: make test-rust-module MODULE=classifiers::lora::pii_lora_test
1829#    Example: make test-rust-module MODULE=classifiers::lora::pii_lora_test::test_pii_lora_pii_lora_classifier_new
@@ -26,6 +37,19 @@ test-rust-module: rust
2637	@echo " Running Rust tests for module: $( MODULE)   (release mode, GPU $( TEST_GPU_DEVICE)  )" 
2738	@cd candle-binding &&  CUDA_VISIBLE_DEVICES=$(TEST_GPU_DEVICE )  cargo test  --release $(MODULE )  --lib -- --test-threads=1 --nocapture
2839
40+ #  Test specific Flash Attention module (requires GPU and CUDA environment)
41+ #    Example: make test-rust-flash-attn-module MODULE=model_architectures::embedding::qwen3_embedding_test
42+ #    Example: make test-rust-flash-attn-module MODULE=model_architectures::embedding::qwen3_embedding_test::test_qwen3_embedding_forward
43+ test-rust-flash-attn-module : rust-flash-attn
44+ 	@$(LOG_TARGET ) 
45+ 	@if [ -z  " $( MODULE) "   ];  then  \ 
46+ 		echo  " Usage: make test-rust-flash-attn-module MODULE=<module_name>" ;  \ 
47+ 		echo  " Example: make test-rust-flash-attn-module MODULE=model_architectures::embedding::qwen3_embedding_test" ;  \ 
48+ 		exit  1;  \ 
49+ 	fi 
50+ 	@echo " Running Rust Flash Attention tests for module: $( MODULE)   (GPU $( TEST_GPU_DEVICE)  )" 
51+ 	@cd candle-binding &&  CUDA_VISIBLE_DEVICES=$(TEST_GPU_DEVICE )  cargo test  --release --features flash-attn $(MODULE )  --lib -- --nocapture
52+ 
2953#  Test the Rust library (Go binding tests)
3054test-binding : rust
3155	@$(LOG_TARGET ) 
@@ -66,3 +90,14 @@ rust: ## Ensure Rust is installed and build the Rust library
6690	fi  &&  \ 
6791	echo  " Building Rust library..."   &&  \ 
6892	cd  candle-binding &&  cargo build --release' 
93+ 
94+ rust-flash-attn : # # Build Rust library with Flash Attention 2 (requires CUDA environment)
95+ 	@$(LOG_TARGET ) 
96+ 	@echo " Building Rust library with Flash Attention 2 (requires CUDA)..." 
97+ 	@if command  -v nvcc > /dev/null 2>&1 ;  then  \ 
98+ 		echo  " ✅ nvcc found: $$ (nvcc --version | grep release)" ;  \ 
99+ 	else  \ 
100+ 		echo  " ❌ nvcc not found in PATH. Please configure CUDA environment." ;  \ 
101+ 		exit  1;  \ 
102+ 	fi 
103+ 	@cd candle-binding &&  cargo build --release --features flash-attn
0 commit comments