red-candle 1.0.0.pre.2 → 1.0.0.pre.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +12 -0
- data/LICENSE +22 -0
- data/Rakefile +95 -0
- data/bin/console +11 -0
- data/bin/setup +17 -0
- data/ext/candle/rustfmt.toml +63 -0
- data/lib/candle/version.rb +1 -1
- metadata +7 -2
- data/ext/candle/build.rs +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375ffec5c2293170bdb0e78ffe2584c8a963968d3226b601d12ddcc040c256ec
|
4
|
+
data.tar.gz: ea2490c59eca2480728afb7169fc3a24f4270e63491648c1d09fd111707dcb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9011c72cbe2a065917f26774862bb1f82489e6d5354376cb616df7cea18646ca60ccd5e68282f39b23f89eead196ab41ce70cdaaca224f97aef61914559f653f
|
7
|
+
data.tar.gz: 4a48101bdcffeecd1bc687dacc7eee7dc42ddbb417b05cce57b97abad83cefe90d965be5c0a8256b8f5c9ba90d80f1159c5392097558acf93a3095913a68a2ad
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 kojix2
|
4
|
+
Copyright (c) 2024 Christopher Petersen
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
require "rake/extensiontask"
|
6
|
+
|
7
|
+
ENV['CANDLE_TEST_SKIP_LLM'] = 'true'
|
8
|
+
|
9
|
+
task default: :test
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.deps << :compile
|
12
|
+
t.libs << "test"
|
13
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
14
|
+
end
|
15
|
+
|
16
|
+
spec = Bundler.load_gemspec("candle.gemspec")
|
17
|
+
Rake::ExtensionTask.new("candle", spec) do |c|
|
18
|
+
c.lib_dir = "lib/candle"
|
19
|
+
c.cross_compile = true
|
20
|
+
c.cross_platform = %w[
|
21
|
+
aarch64-linux
|
22
|
+
arm64-darwin
|
23
|
+
x64-mingw-ucrt
|
24
|
+
x64-mingw32
|
25
|
+
x86_64-darwin
|
26
|
+
x86_64-linux
|
27
|
+
x86_64-linux-musl
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Run device compatibility tests"
|
32
|
+
Rake::TestTask.new("test:device") do |t|
|
33
|
+
t.deps << :compile
|
34
|
+
t.libs << "test"
|
35
|
+
t.test_files = FileList["test/device_compatibility_test.rb"]
|
36
|
+
t.verbose = true
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Run benchmark tests"
|
40
|
+
Rake::TestTask.new("test:benchmark") do |t|
|
41
|
+
ENV['CANDLE_RUN_BENCHMARKS'] = 'true'
|
42
|
+
t.deps << :compile
|
43
|
+
t.libs << "test"
|
44
|
+
t.test_files = FileList["test/benchmarks/**/*_test.rb"]
|
45
|
+
t.verbose = true
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Run all tests including benchmarks"
|
49
|
+
task "test:all" => [:test, "test:benchmark"]
|
50
|
+
|
51
|
+
desc "Run tests on specific devices"
|
52
|
+
namespace :test do
|
53
|
+
%w[cpu metal cuda].each do |device|
|
54
|
+
desc "Run tests on #{device.upcase} only"
|
55
|
+
task "device:#{device}" => :compile do
|
56
|
+
ENV['CANDLE_TEST_DEVICES'] = device
|
57
|
+
Rake::Task["test:device"].invoke
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Run benchmarks with device tests"
|
63
|
+
task "test:device:benchmark" => :compile do
|
64
|
+
ENV['CANDLE_RUN_BENCHMARKS'] = 'true'
|
65
|
+
ENV['CANDLE_TEST_VERBOSE'] = 'true'
|
66
|
+
Rake::Task["test:device"].invoke
|
67
|
+
Rake::Task["test:benchmark"].invoke
|
68
|
+
end
|
69
|
+
|
70
|
+
namespace :doc do
|
71
|
+
task default: %i[rustdoc yard]
|
72
|
+
|
73
|
+
desc "Generate YARD documentation"
|
74
|
+
task :yard do
|
75
|
+
sh <<~CMD
|
76
|
+
yard doc \
|
77
|
+
--plugin rustdoc -- lib tmp/doc/candle.json
|
78
|
+
CMD
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Generate Rust documentation as JSON"
|
82
|
+
task :rustdoc do
|
83
|
+
sh <<~CMD
|
84
|
+
cargo +nightly rustdoc \
|
85
|
+
--target-dir tmp/doc/target \
|
86
|
+
-p candle \
|
87
|
+
-- -Zunstable-options --output-format json \
|
88
|
+
--document-private-items
|
89
|
+
CMD
|
90
|
+
|
91
|
+
cp "tmp/doc/target/doc/candle.json", "tmp/doc/candle.json"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
task doc: "doc:default"
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "candle"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
# Check if Rust is installed
|
7
|
+
if ! command -v cargo &> /dev/null
|
8
|
+
then
|
9
|
+
echo "Rust is not installed. Please install Rust: https://www.rust-lang.org/tools/install"
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
# Install Ruby dependencies
|
14
|
+
bundle install
|
15
|
+
|
16
|
+
# Build Rust extension
|
17
|
+
bundle exec rake compile
|
@@ -0,0 +1,63 @@
|
|
1
|
+
max_width = 100
|
2
|
+
hard_tabs = false
|
3
|
+
tab_spaces = 4
|
4
|
+
newline_style = "Auto"
|
5
|
+
use_small_heuristics = "Default"
|
6
|
+
indent_style = "Block"
|
7
|
+
wrap_comments = false
|
8
|
+
format_code_in_doc_comments = false
|
9
|
+
comment_width = 80
|
10
|
+
normalize_comments = false
|
11
|
+
normalize_doc_attributes = false
|
12
|
+
format_strings = false
|
13
|
+
format_macro_matchers = false
|
14
|
+
format_macro_bodies = true
|
15
|
+
empty_item_single_line = true
|
16
|
+
struct_lit_single_line = true
|
17
|
+
fn_single_line = false
|
18
|
+
where_single_line = false
|
19
|
+
imports_indent = "Block"
|
20
|
+
imports_layout = "Mixed"
|
21
|
+
imports_granularity="Crate"
|
22
|
+
reorder_imports = true
|
23
|
+
reorder_modules = true
|
24
|
+
reorder_impl_items = false
|
25
|
+
type_punctuation_density = "Wide"
|
26
|
+
space_before_colon = false
|
27
|
+
space_after_colon = true
|
28
|
+
spaces_around_ranges = false
|
29
|
+
binop_separator = "Front"
|
30
|
+
remove_nested_parens = true
|
31
|
+
combine_control_expr = true
|
32
|
+
overflow_delimited_expr = false
|
33
|
+
struct_field_align_threshold = 0
|
34
|
+
enum_discrim_align_threshold = 0
|
35
|
+
match_arm_blocks = true
|
36
|
+
force_multiline_blocks = false
|
37
|
+
fn_params_layout = "Tall"
|
38
|
+
brace_style = "SameLineWhere"
|
39
|
+
control_brace_style = "AlwaysSameLine"
|
40
|
+
trailing_semicolon = true
|
41
|
+
trailing_comma = "Vertical"
|
42
|
+
match_block_trailing_comma = false
|
43
|
+
blank_lines_upper_bound = 1
|
44
|
+
blank_lines_lower_bound = 0
|
45
|
+
edition = "2021"
|
46
|
+
version = "One"
|
47
|
+
inline_attribute_width = 0
|
48
|
+
merge_derives = true
|
49
|
+
use_try_shorthand = false
|
50
|
+
use_field_init_shorthand = false
|
51
|
+
force_explicit_abi = true
|
52
|
+
condense_wildcard_suffixes = false
|
53
|
+
color = "Auto"
|
54
|
+
#required_version = "1.4.12"
|
55
|
+
unstable_features = false
|
56
|
+
disable_all_formatting = false
|
57
|
+
skip_children = false
|
58
|
+
hide_parse_errors = false
|
59
|
+
error_on_line_overflow = false
|
60
|
+
error_on_unformatted = false
|
61
|
+
ignore = []
|
62
|
+
emit_mode = "Files"
|
63
|
+
make_backup = false
|
data/lib/candle/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red-candle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Petersen
|
@@ -36,10 +36,15 @@ extra_rdoc_files: []
|
|
36
36
|
files:
|
37
37
|
- Cargo.lock
|
38
38
|
- Cargo.toml
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
39
41
|
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/console
|
44
|
+
- bin/setup
|
40
45
|
- ext/candle/Cargo.toml
|
41
|
-
- ext/candle/build.rs
|
42
46
|
- ext/candle/extconf.rb
|
47
|
+
- ext/candle/rustfmt.toml
|
43
48
|
- ext/candle/src/lib.rs
|
44
49
|
- ext/candle/src/llm/generation_config.rs
|
45
50
|
- ext/candle/src/llm/mistral.rs
|
data/ext/candle/build.rs
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
use std::env;
|
2
|
-
use std::path::Path;
|
3
|
-
|
4
|
-
fn main() {
|
5
|
-
// Register our custom cfg flags with rustc
|
6
|
-
println!("cargo::rustc-check-cfg=cfg(force_cpu)");
|
7
|
-
println!("cargo::rustc-check-cfg=cfg(has_cuda)");
|
8
|
-
println!("cargo::rustc-check-cfg=cfg(has_metal)");
|
9
|
-
println!("cargo::rustc-check-cfg=cfg(has_mkl)");
|
10
|
-
println!("cargo::rustc-check-cfg=cfg(has_accelerate)");
|
11
|
-
|
12
|
-
println!("cargo:rerun-if-changed=build.rs");
|
13
|
-
println!("cargo:rerun-if-env-changed=CANDLE_FORCE_CPU");
|
14
|
-
println!("cargo:rerun-if-env-changed=CANDLE_CUDA_PATH");
|
15
|
-
println!("cargo:rerun-if-env-changed=CUDA_ROOT");
|
16
|
-
println!("cargo:rerun-if-env-changed=CUDA_PATH");
|
17
|
-
println!("cargo:rerun-if-env-changed=CANDLE_FEATURES");
|
18
|
-
println!("cargo:rerun-if-env-changed=CANDLE_ENABLE_CUDA");
|
19
|
-
|
20
|
-
// Check if we should force CPU only
|
21
|
-
if env::var("CANDLE_FORCE_CPU").is_ok() {
|
22
|
-
println!("cargo:rustc-cfg=force_cpu");
|
23
|
-
println!("cargo:warning=CANDLE_FORCE_CPU is set, disabling all acceleration");
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
|
27
|
-
// Detect CUDA availability
|
28
|
-
let cuda_available = detect_cuda();
|
29
|
-
let cuda_enabled = env::var("CANDLE_ENABLE_CUDA").is_ok();
|
30
|
-
|
31
|
-
if cuda_available && cuda_enabled {
|
32
|
-
println!("cargo:rustc-cfg=has_cuda");
|
33
|
-
println!("cargo:warning=CUDA detected and enabled via CANDLE_ENABLE_CUDA");
|
34
|
-
} else if cuda_available && !cuda_enabled {
|
35
|
-
println!("cargo:warning=CUDA detected but not enabled. To enable CUDA support (coming soon), set CANDLE_ENABLE_CUDA=1");
|
36
|
-
}
|
37
|
-
|
38
|
-
// Detect Metal availability (macOS only)
|
39
|
-
#[cfg(target_os = "macos")]
|
40
|
-
{
|
41
|
-
println!("cargo:rustc-cfg=has_metal");
|
42
|
-
println!("cargo:warning=Metal detected (macOS), Metal acceleration will be available");
|
43
|
-
}
|
44
|
-
|
45
|
-
// Detect MKL availability
|
46
|
-
if detect_mkl() {
|
47
|
-
println!("cargo:rustc-cfg=has_mkl");
|
48
|
-
println!("cargo:warning=Intel MKL detected, MKL acceleration will be available");
|
49
|
-
}
|
50
|
-
|
51
|
-
// Detect Accelerate framework (macOS)
|
52
|
-
#[cfg(target_os = "macos")]
|
53
|
-
{
|
54
|
-
println!("cargo:rustc-cfg=has_accelerate");
|
55
|
-
println!("cargo:warning=Accelerate framework detected (macOS)");
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
fn detect_cuda() -> bool {
|
60
|
-
// Check environment variables first
|
61
|
-
if env::var("CANDLE_CUDA_PATH").is_ok() {
|
62
|
-
return true;
|
63
|
-
}
|
64
|
-
|
65
|
-
if env::var("CUDA_ROOT").is_ok() || env::var("CUDA_PATH").is_ok() {
|
66
|
-
return true;
|
67
|
-
}
|
68
|
-
|
69
|
-
// Check common CUDA installation paths
|
70
|
-
let cuda_paths = [
|
71
|
-
"/usr/local/cuda",
|
72
|
-
"/opt/cuda",
|
73
|
-
"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA",
|
74
|
-
"C:\\CUDA",
|
75
|
-
];
|
76
|
-
|
77
|
-
for path in &cuda_paths {
|
78
|
-
if Path::new(path).exists() {
|
79
|
-
return true;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
// Check if nvcc is in PATH
|
84
|
-
if let Ok(path_var) = env::var("PATH") {
|
85
|
-
for path in env::split_paths(&path_var) {
|
86
|
-
if path.join("nvcc").exists() || path.join("nvcc.exe").exists() {
|
87
|
-
return true;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
false
|
93
|
-
}
|
94
|
-
|
95
|
-
fn detect_mkl() -> bool {
|
96
|
-
// Check environment variables
|
97
|
-
if env::var("MKLROOT").is_ok() || env::var("MKL_ROOT").is_ok() {
|
98
|
-
return true;
|
99
|
-
}
|
100
|
-
|
101
|
-
// Check common MKL installation paths
|
102
|
-
let mkl_paths = [
|
103
|
-
"/opt/intel/mkl",
|
104
|
-
"/opt/intel/oneapi/mkl/latest",
|
105
|
-
"C:\\Program Files (x86)\\Intel\\oneAPI\\mkl\\latest",
|
106
|
-
"C:\\Program Files\\Intel\\oneAPI\\mkl\\latest",
|
107
|
-
];
|
108
|
-
|
109
|
-
for path in &mkl_paths {
|
110
|
-
if Path::new(path).exists() {
|
111
|
-
return true;
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
false
|
116
|
-
}
|