Skip to content

Commit 2ec76aa

Browse files
committed
Merge branch 'master' into conv2d-implicit
2 parents 735886b + 00681df commit 2ec76aa

File tree

78 files changed

+2369
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2369
-904
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,21 +1063,46 @@ jobs:
10631063
run: |
10641064
git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
10651065
1066-
- name: Install
1066+
- name: Cache ROCm Installation
1067+
id: cache-rocm
1068+
uses: actions/cache@v4
1069+
with:
1070+
path: C:\Program Files\AMD\ROCm
1071+
key: rocm-6.1-${{ runner.os }}-v1
1072+
restore-keys: |
1073+
rocm-6.1-${{ runner.os }}-
1074+
1075+
- name: Install ROCm
1076+
if: steps.cache-rocm.outputs.cache-hit != 'true'
10671077
id: depends
10681078
run: |
10691079
$ErrorActionPreference = "Stop"
10701080
write-host "Downloading AMD HIP SDK Installer"
10711081
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
10721082
write-host "Installing AMD HIP SDK"
10731083
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
1074-
$proc.WaitForExit(600000)
1084+
$completed = $proc.WaitForExit(600000)
1085+
if (-not $completed) {
1086+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
1087+
$proc.Kill()
1088+
exit 1
1089+
}
1090+
if ($proc.ExitCode -ne 0) {
1091+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
1092+
exit 1
1093+
}
10751094
write-host "Completed AMD HIP SDK installation"
10761095
10771096
- name: Verify ROCm
10781097
id: verify
10791098
run: |
1080-
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
1099+
# Find and test ROCm installation
1100+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
1101+
if (-not $clangPath) {
1102+
Write-Error "ROCm installation not found"
1103+
exit 1
1104+
}
1105+
& $clangPath.FullName --version
10811106
10821107
- name: Install ccache
10831108
uses: ggml-org/[email protected]

.github/workflows/release.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,27 +544,52 @@ jobs:
544544
run: |
545545
git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
546546
547+
- name: Cache ROCm Installation
548+
id: cache-rocm
549+
uses: actions/cache@v4
550+
with:
551+
path: C:\Program Files\AMD\ROCm
552+
key: rocm-6.1-${{ runner.os }}-v1
553+
restore-keys: |
554+
rocm-6.1-${{ runner.os }}-
555+
547556
- name: ccache
548557
uses: ggml-org/[email protected]
549558
with:
550559
key: windows-latest-cmake-hip-${{ matrix.name }}-x64
551560
evict-old-files: 1d
552561

553-
- name: Install
562+
- name: Install ROCm
563+
if: steps.cache-rocm.outputs.cache-hit != 'true'
554564
id: depends
555565
run: |
556566
$ErrorActionPreference = "Stop"
557567
write-host "Downloading AMD HIP SDK Installer"
558568
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
559569
write-host "Installing AMD HIP SDK"
560570
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
561-
$proc.WaitForExit(600000)
571+
$completed = $proc.WaitForExit(600000)
572+
if (-not $completed) {
573+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
574+
$proc.Kill()
575+
exit 1
576+
}
577+
if ($proc.ExitCode -ne 0) {
578+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
579+
exit 1
580+
}
562581
write-host "Completed AMD HIP SDK installation"
563582
564583
- name: Verify ROCm
565584
id: verify
566585
run: |
567-
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
586+
# Find and test ROCm installation
587+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
588+
if (-not $clangPath) {
589+
Write-Error "ROCm installation not found"
590+
exit 1
591+
}
592+
& $clangPath.FullName --version
568593
569594
- name: Build
570595
id: cmake_build

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
- Use the following format for the squashed commit title: `<module> : <commit title> (#<issue_number>)`. For example: `utils : fix typo in utils.py (#1234)`
1717
- Optionally pick a `<module>` from here: https://github.com/ggml-org/llama.cpp/wiki/Modules
1818
- Consider adding yourself to [CODEOWNERS](CODEOWNERS)
19+
- Let authors, who are also collaborators, merge their own PRs
20+
- When merging a PR by a contributor, make sure you have a good understanding of the changes
21+
- Be mindful of maintenance: most of the work going into a feature happens after the PR is merged. If the PR author is not committed to contribute long-term, someone else needs to take responsibility (you)
1922

2023
# Coding guidelines
2124

common/json-schema-to-grammar.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,10 @@ class SchemaConverter {
843843
_build_object_rule(
844844
properties, required, name,
845845
schema.contains("additionalProperties") ? schema["additionalProperties"] : json()));
846-
} else if ((schema_type.is_null() || schema_type == "object") && schema.contains("allOf")) {
846+
} else if ((schema_type.is_null() || schema_type == "object" || schema_type == "string") && schema.contains("allOf")) {
847847
std::unordered_set<std::string> required;
848848
std::vector<std::pair<std::string, json>> properties;
849+
std::map<std::string, size_t> enum_values;
849850
std::string hybrid_name = name;
850851
std::function<void(const json &, bool)> add_component = [&](const json & comp_schema, bool is_required) {
851852
if (comp_schema.contains("$ref")) {
@@ -857,6 +858,14 @@ class SchemaConverter {
857858
required.insert(prop.key());
858859
}
859860
}
861+
} else if (comp_schema.contains("enum")) {
862+
for (const auto & v : comp_schema["enum"]) {
863+
const auto rule = _generate_constant_rule(v);
864+
if (enum_values.find(rule) == enum_values.end()) {
865+
enum_values[rule] = 0;
866+
}
867+
enum_values[rule] += 1;
868+
}
860869
} else {
861870
// todo warning
862871
}
@@ -870,6 +879,17 @@ class SchemaConverter {
870879
add_component(t, true);
871880
}
872881
}
882+
if (!enum_values.empty()) {
883+
std::vector<std::string> enum_intersection;
884+
for (const auto & p : enum_values) {
885+
if (p.second == schema["allOf"].size()) {
886+
enum_intersection.push_back(p.first);
887+
}
888+
}
889+
if (!enum_intersection.empty()) {
890+
return _add_rule(rule_name, "(" + string_join(enum_intersection, " | ") + ") space");
891+
}
892+
}
873893
return _add_rule(rule_name, _build_object_rule(properties, required, hybrid_name, json()));
874894
} else if ((schema_type.is_null() || schema_type == "array") && (schema.contains("items") || schema.contains("prefixItems"))) {
875895
json items = schema.contains("items") ? schema["items"] : schema["prefixItems"];

convert_hf_to_gguf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6701,6 +6701,8 @@ def set_gguf_parameters(self):
67016701
self.gguf_writer.add_embedding_length(self.hparams["d_model"])
67026702
self.gguf_writer.add_feed_forward_length(self.hparams["d_ff"])
67036703
self.gguf_writer.add_block_count(self.hparams["num_layers"])
6704+
if (dec_n_layer := self.hparams.get("num_decoder_layers")) is not None:
6705+
self.gguf_writer.add_decoder_block_count(dec_n_layer)
67046706
self.gguf_writer.add_head_count(self.hparams["num_heads"])
67056707
self.gguf_writer.add_key_length(self.hparams["d_kv"])
67066708
self.gguf_writer.add_value_length(self.hparams["d_kv"])

docs/backend/CANN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,7 @@ Converting the matmul weight format from ND to NZ to improve performance. Enable
314314
### GGML_CANN_ACL_GRAPH
315315

316316
Operators are executed using ACL graph execution, rather than in op-by-op (eager) mode. Enabled by default.
317+
318+
### GGML_CANN_GRAPH_CACHE_CAPACITY
319+
320+
Maximum number of compiled CANN graphs kept in the LRU cache, default is 12. When the number of cached graphs exceeds this capacity, the least recently used graph will be evicted.

examples/eval-callback/eval-callback.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ static std::string ggml_ne_string(const ggml_tensor * t) {
2828
return str;
2929
}
3030

31+
static inline float ggml_compute_bf16_to_fp32(ggml_bf16_t h) {
32+
union {
33+
float f;
34+
uint32_t i;
35+
} u;
36+
u.i = (uint32_t)h.bits << 16;
37+
return u.f;
38+
}
39+
3140
static float ggml_get_float_value(uint8_t * data, ggml_type type, const size_t * nb, size_t i0, size_t i1, size_t i2, size_t i3) {
3241
size_t i = i3 * nb[3] + i2 * nb[2] + i1 * nb[1] + i0 * nb[0];
3342
float v;
@@ -43,6 +52,8 @@ static float ggml_get_float_value(uint8_t * data, ggml_type type, const size_t *
4352
v = (float) *(int16_t *) &data[i];
4453
} else if (type == GGML_TYPE_I8) {
4554
v = (float) *(int8_t *) &data[i];
55+
} else if (type == GGML_TYPE_BF16) {
56+
v = ggml_compute_bf16_to_fp32(*(ggml_bf16_t *) &data[i]);
4657
} else {
4758
GGML_ABORT("fatal error");
4859
}

examples/json_schema_to_grammar.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,10 @@ def visit(self, schema, name):
586586
properties = list(schema.get('properties', {}).items())
587587
return self._add_rule(rule_name, self._build_object_rule(properties, required, name, schema.get('additionalProperties')))
588588

589-
elif schema_type in (None, 'object') and 'allOf' in schema:
589+
elif schema_type in (None, 'object', 'string') and 'allOf' in schema:
590590
required = set()
591591
properties = []
592+
enum_sets = []
592593
hybrid_name = name
593594
def add_component(comp_schema, is_required):
594595
if (ref := comp_schema.get('$ref')) is not None:
@@ -600,13 +601,25 @@ def add_component(comp_schema, is_required):
600601
if is_required:
601602
required.add(prop_name)
602603

604+
if 'enum' in comp_schema:
605+
enum_sets.append(set(comp_schema['enum']))
606+
603607
for t in schema['allOf']:
604608
if 'anyOf' in t:
605609
for tt in t['anyOf']:
606610
add_component(tt, is_required=False)
607611
else:
608612
add_component(t, is_required=True)
609613

614+
if enum_sets:
615+
enum_intersection = enum_sets[0]
616+
for s in enum_sets[1:]:
617+
enum_intersection &= s
618+
619+
if enum_intersection:
620+
rule = '(' + ' | '.join((self._generate_constant_rule(v) for v in sorted(enum_intersection))) + ') space'
621+
return self._add_rule(rule_name, rule)
622+
610623
return self._add_rule(rule_name, self._build_object_rule(properties, required, hybrid_name, additional_properties=None))
611624

612625
elif schema_type in (None, 'array') and ('items' in schema or 'prefixItems' in schema):
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
--extra-index-url https://download.pytorch.org/whl/cpu
2-
torch~=2.6.0
3-
torchvision~=0.21.0
4-
transformers~=4.55.0
5-
huggingface-hub~=0.34.0
2+
torch
3+
torchvision
4+
transformers
5+
huggingface-hub
6+
accelerate

0 commit comments

Comments
 (0)