Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit a256c2a

Browse files
committed
Merge branch 'dev' of https://github.com/menloresearch/cortex.cpp into s/chore/tool
2 parents 43bf80f + 7fda186 commit a256c2a

3 files changed

Lines changed: 96 additions & 3 deletions

File tree

.github/workflows/template-build-macos.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ jobs:
253253
cd engine
254254
make codesign-binary CODE_SIGN=true DEVELOPER_ID="${{ secrets.DEVELOPER_ID }}" DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" DESTINATION_BINARY_SERVER_NAME="${{ steps.set-output-params.outputs.destination_binary_server_name }}"
255255
256+
- name: Code Signing binaries for separate binary
257+
run: |
258+
codesign --force -s "${{ secrets.DEVELOPER_ID }}" --options=runtime --entitlements="./engine/templates/macos/entitlements.plist" ./cortex-${{ inputs.new_version }}-mac-arm64/${{ steps.set-output-params.outputs.destination_binary_name }}
259+
codesign --force -s "${{ secrets.DEVELOPER_ID }}" --options=runtime --entitlements="./engine/templates/macos/entitlements.plist" ./cortex-${{ inputs.new_version }}-mac-arm64/${{ steps.set-output-params.outputs.destination_binary_server_name }}
260+
261+
codesign --force -s "${{ secrets.DEVELOPER_ID }}" --options=runtime --entitlements="./engine/templates/macos/entitlements.plist" ./cortex-${{ inputs.new_version }}-mac-amd64/${{ steps.set-output-params.outputs.destination_binary_name }}
262+
codesign --force -s "${{ secrets.DEVELOPER_ID }}" --options=runtime --entitlements="./engine/templates/macos/entitlements.plist" ./cortex-${{ inputs.new_version }}-mac-amd64/${{ steps.set-output-params.outputs.destination_binary_server_name }}
263+
256264
- name: Notary macOS Binary
257265
run: |
258266
curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b /usr/local/bin
@@ -265,6 +273,18 @@ jobs:
265273
QUILL_NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
266274
QUILL_NOTARY_KEY: "/tmp/notary-key.p8"
267275

276+
- name: Notary macOS Binary for separate binary
277+
run: |
278+
# Notarize the binary
279+
quill notarize ./cortex-${{ inputs.new_version }}-mac-arm64/${{ steps.set-output-params.outputs.destination_binary_name }}
280+
quill notarize ./cortex-${{ inputs.new_version }}-mac-arm64/${{ steps.set-output-params.outputs.destination_binary_server_name }}
281+
quill notarize ./cortex-${{ inputs.new_version }}-mac-amd64/${{ steps.set-output-params.outputs.destination_binary_name }}
282+
quill notarize ./cortex-${{ inputs.new_version }}-mac-amd64/${{ steps.set-output-params.outputs.destination_binary_server_name }}
283+
env:
284+
QUILL_NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
285+
QUILL_NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
286+
QUILL_NOTARY_KEY: "/tmp/notary-key.p8"
287+
268288
- name: Build network Installers
269289
shell: bash
270290
run: |
@@ -310,6 +330,24 @@ jobs:
310330
xcrun notarytool submit ${{ steps.set-output-params.outputs.package_name }}-local.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait
311331
312332
- name: Package
333+
run: |
334+
mkdir temp
335+
# Mac arm64
336+
mv cortex-${{ inputs.new_version }}-mac-arm64 temp/cortex
337+
cd temp
338+
tar -czvf cortex-arm64.tar.gz cortex
339+
mv cortex-arm64.tar.gz ../cortex-arm64.tar.gz
340+
cd ..
341+
rm -rf temp/cortex
342+
343+
# Mac amd64
344+
mv cortex-${{ inputs.new_version }}-mac-amd64 temp/cortex
345+
cd temp
346+
tar -czvf cortex-amd64.tar.gz cortex
347+
mv cortex-amd64.tar.gz ../cortex-amd64.tar.gz
348+
cd ..
349+
350+
- name: Package for separate binary
313351
run: |
314352
cd engine
315353
make package
@@ -320,6 +358,18 @@ jobs:
320358
name: cortex-${{ inputs.new_version }}-mac-universal
321359
path: ./engine/cortex
322360

361+
- name: Upload Artifact
362+
uses: actions/upload-artifact@v4
363+
with:
364+
name: cortex-${{ inputs.new_version }}-mac-arm64-signed
365+
path: ./cortex-${{ inputs.new_version }}-mac-arm64
366+
367+
- name: Upload Artifact
368+
uses: actions/upload-artifact@v4
369+
with:
370+
name: cortex-${{ inputs.new_version }}-mac-amd64-signed
371+
path: ./cortex-${{ inputs.new_version }}-mac-amd64
372+
323373
- name: Upload Artifact
324374
uses: actions/upload-artifact@v4
325375
with:
@@ -358,6 +408,28 @@ jobs:
358408
asset_name: cortex-${{ inputs.new_version }}-mac-universal.tar.gz
359409
asset_content_type: application/zip
360410

411+
- name: Upload release assert if public provider is github
412+
if: inputs.public_provider == 'github'
413+
env:
414+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
415+
uses: actions/upload-release-asset@v1.0.1
416+
with:
417+
upload_url: ${{ inputs.upload_url }}
418+
asset_path: ./cortex-arm64.tar.gz
419+
asset_name: cortex-${{ inputs.new_version }}-mac-arm64.tar.gz
420+
asset_content_type: application/zip
421+
422+
- name: Upload release assert if public provider is github
423+
if: inputs.public_provider == 'github'
424+
env:
425+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
426+
uses: actions/upload-release-asset@v1.0.1
427+
with:
428+
upload_url: ${{ inputs.upload_url }}
429+
asset_path: ./cortex-amd64.tar.gz
430+
asset_name: cortex-${{ inputs.new_version }}-mac-amd64.tar.gz
431+
asset_content_type: application/zip
432+
361433
- name: Upload release assert if public provider is github
362434
if: inputs.public_provider == 'github'
363435
env:

engine/extensions/local-engine/local_engine.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const std::unordered_set<std::string> kIgnoredParams = {
2020
"user_prompt", "min_keep", "mirostat", "mirostat_eta",
2121
"mirostat_tau", "text_model", "version", "n_probs",
2222
"object", "penalize_nl", "precision", "size",
23-
"stop", "tfs_z", "typ_p"};
23+
"stop", "tfs_z", "typ_p", "caching_enabled"};
2424

2525
const std::unordered_map<std::string, std::string> kParamsMap = {
2626
{"cpu_threads", "--threads"},
@@ -67,6 +67,19 @@ std::vector<std::string> ConvertJsonToParamsVector(const Json::Value& root) {
6767
res.push_back("--embedding");
6868
}
6969
continue;
70+
} else if (member == "cache_type") {
71+
if (!root[member].isNull()) {
72+
res.push_back("-ctk");
73+
res.push_back(root[member].asString());
74+
res.push_back("-ctv");
75+
res.push_back(root[member].asString());
76+
}
77+
continue;
78+
} else if (member == "use_mmap") {
79+
if (!root[member].asBool()) {
80+
res.push_back("--no-mmap");
81+
}
82+
continue;
7083
}
7184

7285
res.push_back("--" + member);

engine/services/engine_service.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,13 @@ EngineService::GetInstalledEngineVariants(const std::string& engine) const {
772772
// try to find version.txt
773773
auto version_txt_path = version_entry.path() / "version.txt";
774774
if (!std::filesystem::exists(version_txt_path)) {
775-
continue;
775+
// create new one
776+
std::ofstream meta(version_txt_path, std::ios::out);
777+
meta << "name: " << entry.path().filename() << std::endl;
778+
meta << "version: " << version_entry.path().filename() << std::endl;
779+
meta.close();
780+
CTL_INF("name: " << entry.path().filename().string() << ", version: "
781+
<< version_entry.path().filename().string());
776782
}
777783

778784
try {
@@ -865,7 +871,9 @@ void EngineService::RegisterEngineLibPath() {
865871

866872
// register deps
867873
std::vector<std::filesystem::path> paths{};
868-
paths.push_back(cuda_path);
874+
if (std::filesystem::exists(cuda_path)) {
875+
paths.push_back(cuda_path);
876+
}
869877
paths.push_back(engine_dir_path);
870878

871879
CTL_DBG("Registering dylib for "

0 commit comments

Comments
 (0)