Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/** @import { Derived, Effect, Value } from '#client' */2 3import {4 BLOCK_EFFECT,5 BOUNDARY_EFFECT,6 BRANCH_EFFECT,7 CLEAN,8 CONNECTED,9 DERIVED,10 DIRTY,11 EFFECT,12 ASYNC,13 DESTROYED,14 INERT,15 MAYBE_DIRTY,16 RENDER_EFFECT,17 ROOT_EFFECT,18 WAS_MARKED,19 MANAGED_EFFECT20} from '#client/constants';21import { snapshot } from '../../shared/clone.js';22import { untrack } from '../runtime.js';23 24/**25 *26 * @param {Effect} effect27 */28export function root(effect) {29 while (effect.parent !== null) {30 effect = effect.parent;31 }32 33 return effect;34}35 36/**37 *38 * @param {Effect} effect39 * @param {boolean} append_effect40 * @returns {string}41 */42function effect_label(effect, append_effect = false) {43 const flags = effect.f;44 45 let label = `(unknown ${append_effect ? 'effect' : ''})`;46 47 if ((flags & ROOT_EFFECT) !== 0) {48 label = 'root';49 } else if ((flags & BOUNDARY_EFFECT) !== 0) {50 label = 'boundary';51 } else if ((flags & BLOCK_EFFECT) !== 0) {52 label = 'block';53 } else if ((flags & MANAGED_EFFECT) !== 0) {54 label = 'managed';55 } else if ((flags & ASYNC) !== 0) {56 label = 'async';57 } else if ((flags & BRANCH_EFFECT) !== 0) {58 label = 'branch';59 } else if ((flags & RENDER_EFFECT) !== 0) {60 label = 'render effect';61 } else if ((flags & EFFECT) !== 0) {62 label = 'effect';63 }64 65 if (append_effect && !label.endsWith('effect')) {66 label += ' effect';67 }68 69 return label;70}71 72/**73 * @param {Effect} effect74 * @param {Effect[]} highlighted75 */76export function log_effect_tree(effect, highlighted = [], depth = 0, is_reachable = true) {77 const flags = effect.f;78 let label = effect_label(effect);79 80 let status =81 (flags & CLEAN) !== 0 ? 'clean' : (flags & MAYBE_DIRTY) !== 0 ? 'maybe dirty' : 'dirty';82 83 let styles = [`font-weight: ${status === 'clean' ? 'normal' : 'bold'}`];84 85 if (status !== 'clean' && !is_reachable) {86 label = `⚠️ ${label}`;87 styles.push(`color: red`);88 }89 90 if ((flags & INERT) !== 0) {91 styles.push('font-style: italic');92 }93 94 if (highlighted.includes(effect)) {95 styles.push('background-color: yellow');96 }97 98 // eslint-disable-next-line no-console99 console.group(`%c${label} (${status})`, styles.join('; '));100 101 if (depth === 0) {102 const callsite = new Error().stack103 ?.split('\n')[2]104 .replace(/\s+at (?: \w+\(?)?(.+)\)?/, (m, $1) => $1.replace(/\?[^:]+/, ''));105 106 // eslint-disable-next-line no-console107 console.log(callsite);108 } else {109 // eslint-disable-next-line no-console110 console.groupCollapsed(`%cfn`, `font-weight: normal`);111 // eslint-disable-next-line no-console112 console.log(effect.fn);113 // eslint-disable-next-line no-console114 console.groupEnd();115 }116 117 if (effect.deps !== null) {118 // eslint-disable-next-line no-console119 console.groupCollapsed('%cdeps', 'font-weight: normal');120 121 for (const dep of effect.deps) {122 log_dep(dep);123 }124 125 // eslint-disable-next-line no-console126 console.groupEnd();127 }128 129 if (effect.nodes) {130 // eslint-disable-next-line no-console131 console.log(effect.nodes.start);132 133 if (effect.nodes.start !== effect.nodes.end) {134 // eslint-disable-next-line no-console135 console.log(effect.nodes.end);136 }137 }138 139 var child_is_reachable = is_reachable && ((flags & BRANCH_EFFECT) === 0 || (flags & CLEAN) === 0);140 141 let child = effect.first;142 while (child !== null) {143 log_effect_tree(child, highlighted, depth + 1, child_is_reachable);144 child = child.next;145 }146 147 // eslint-disable-next-line no-console148 console.groupEnd();149}150 151/**152 *153 * @param {Value} dep154 */155function log_dep(dep) {156 if ((dep.f & DERIVED) !== 0) {157 const derived = /** @type {Derived} */ (dep);158 159 // eslint-disable-next-line no-console160 console.groupCollapsed(161 `%c$derived %c${dep.label ?? '<unknown>'}`,162 'font-weight: bold; color: CornflowerBlue',163 'font-weight: normal',164 untrack(() => snapshot(derived.v))165 );166 167 if (derived.deps) {168 for (const d of derived.deps) {169 log_dep(d);170 }171 }172 173 // eslint-disable-next-line no-console174 console.groupEnd();175 } else {176 // eslint-disable-next-line no-console177 console.log(178 `%c$state %c${dep.label ?? '<unknown>'}`,179 'font-weight: bold; color: CornflowerBlue',180 'font-weight: normal',181 untrack(() => snapshot(dep.v))182 );183 }184}185 186/**187 * Logs all reactions of a source or derived transitively188 * @param {Derived | Value} signal189 */190export function log_reactions(signal) {191 /** @type {Set<Derived | Value>} */192 const visited = new Set();193 194 /**195 * Returns an array of flag names that are set on the given flags bitmask196 * @param {number} flags197 * @returns {string[]}198 */199 function get_derived_flag_names(flags) {200 /** @type {string[]} */201 const names = [];202 203 if ((flags & CLEAN) !== 0) names.push('CLEAN');204 if ((flags & DIRTY) !== 0) names.push('DIRTY');205 if ((flags & MAYBE_DIRTY) !== 0) names.push('MAYBE_DIRTY');206 if ((flags & CONNECTED) !== 0) names.push('CONNECTED');207 if ((flags & WAS_MARKED) !== 0) names.push('WAS_MARKED');208 if ((flags & INERT) !== 0) names.push('INERT');209 if ((flags & DESTROYED) !== 0) names.push('DESTROYED');210 211 return names;212 }213 214 /**215 * @param {Derived | Value} d216 * @param {number} depth217 */218 function log_derived(d, depth) {219 const flags = d.f;220 const flag_names = get_derived_flag_names(flags);221 const flags_str = flag_names.length > 0 ? `(${flag_names.join(', ')})` : '(no flags)';222 223 // eslint-disable-next-line no-console224 console.group(225 `%c${flags & DERIVED ? '$derived' : '$state'} %c${d.label ?? '<unknown>'} %c${flags_str}`,226 'font-weight: bold; color: CornflowerBlue',227 'font-weight: normal; color: inherit',228 'font-weight: normal; color: gray'229 );230 231 // eslint-disable-next-line no-console232 console.log(untrack(() => snapshot(d.v)));233 234 if ('fn' in d) {235 // eslint-disable-next-line no-console236 console.log('%cfn:', 'font-weight: bold', d.fn);237 }238 239 if (d.reactions !== null && d.reactions.length > 0) {240 // eslint-disable-next-line no-console241 console.group('%creactions', 'font-weight: bold');242 243 for (const reaction of d.reactions) {244 if ((reaction.f & DERIVED) !== 0) {245 const derived_reaction = /** @type {Derived} */ (reaction);246 247 if (visited.has(derived_reaction)) {248 // eslint-disable-next-line no-console249 console.log(250 `%c$derived %c${derived_reaction.label ?? '<unknown>'} %c(already seen)`,251 'font-weight: bold; color: CornflowerBlue',252 'font-weight: normal; color: inherit',253 'font-weight: bold; color: orange'254 );255 } else {256 visited.add(derived_reaction);257 log_derived(derived_reaction, depth + 1);258 }259 } else {260 // It's an effect261 const label = effect_label(/** @type {Effect} */ (reaction), true);262 const status = (flags & MAYBE_DIRTY) !== 0 ? 'maybe dirty' : 'dirty';263 264 // Collect parent statuses265 /** @type {string[]} */266 const parent_statuses = [];267 let show = false;268 let current = /** @type {Effect} */ (reaction).parent;269 while (current !== null) {270 const parent_flags = current.f;271 if ((parent_flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {272 const parent_status = (parent_flags & CLEAN) !== 0 ? 'clean' : 'not clean';273 if (parent_status === 'clean' && parent_statuses.includes('not clean')) show = true;274 parent_statuses.push(parent_status);275 }276 if (!current.parent) break;277 current = current.parent;278 }279 280 // Check if reaction is reachable from root281 const seen_effects = new Set();282 let reachable = false;283 /**284 * @param {Effect | null} effect285 */286 function check_reachable(effect) {287 if (effect === null || reachable) return;288 if (effect === reaction) {289 reachable = true;290 return;291 }292 if (effect.f & DESTROYED) return;293 if (seen_effects.has(effect)) {294 throw new Error('');295 }296 seen_effects.add(effect);297 let child = effect.first;298 while (child !== null) {299 check_reachable(child);300 child = child.next;301 }302 }303 try {304 if (current) check_reachable(current);305 } catch (e) {306 // eslint-disable-next-line no-console307 console.log(308 `%c⚠️ Circular reference detected in effect tree`,309 'font-weight: bold; color: red',310 seen_effects311 );312 }313 314 if (!reachable) {315 // eslint-disable-next-line no-console316 console.log(317 `%c⚠️ Effect is NOT reachable from its parent chain`,318 'font-weight: bold; color: red'319 );320 }321 322 const parent_status_str = show ? ` (${parent_statuses.join(', ')})` : '';323 324 // eslint-disable-next-line no-console325 console.log(326 `%c${label} (${status})${parent_status_str}`,327 `font-weight: bold; color: ${parent_status_str ? 'red' : 'green'}`,328 reaction329 );330 }331 }332 333 // eslint-disable-next-line no-console334 console.groupEnd();335 } else {336 // eslint-disable-next-line no-console337 console.log('%cno reactions', 'font-style: italic; color: gray');338 }339 340 // eslint-disable-next-line no-console341 console.groupEnd();342 }343 344 // eslint-disable-next-line no-console345 console.group(`%cDerived Reactions Graph`, 'font-weight: bold; color: purple');346 347 visited.add(signal);348 log_derived(signal, 0);349 350 // eslint-disable-next-line no-console351 console.groupEnd();352}353 354/**355 * Traverses an effect tree and logs branches where a non-clean branch exists below a clean branch356 * @param {Effect} effect357 */358export function log_inconsistent_branches(effect) {359 const root_effect = root(effect);360 361 /**362 * @typedef {{363 * effect: Effect,364 * status: 'clean' | 'maybe dirty' | 'dirty',365 * parent_clean: boolean,366 * children: BranchInfo[]367 * }} BranchInfo368 */369 370 /**371 * Collects branch effects from the tree372 * @param {Effect} eff373 * @param {boolean} parent_clean - whether any ancestor branch is clean374 * @returns {BranchInfo[]}375 */376 function collect_branches(eff, parent_clean) {377 /** @type {BranchInfo[]} */378 const branches = [];379 const flags = eff.f;380 const is_branch = (flags & BRANCH_EFFECT) !== 0;381 382 if (is_branch) {383 const status =384 (flags & CLEAN) !== 0 ? 'clean' : (flags & MAYBE_DIRTY) !== 0 ? 'maybe dirty' : 'dirty';385 386 /** @type {BranchInfo[]} */387 const child_branches = [];388 389 let child = eff.first;390 while (child !== null) {391 child_branches.push(...collect_branches(child, status === 'clean'));392 child = child.next;393 }394 395 branches.push({396 effect: eff,397 status,398 parent_clean,399 children: child_branches400 });401 } else {402 // Not a branch, continue traversing403 let child = eff.first;404 while (child !== null) {405 branches.push(...collect_branches(child, parent_clean));406 child = child.next;407 }408 }409 410 return branches;411 }412 413 /**414 * Checks if a branch tree contains any inconsistencies (non-clean below clean)415 * @param {BranchInfo} branch416 * @param {boolean} ancestor_clean417 * @returns {boolean}418 */419 function has_inconsistency(branch, ancestor_clean) {420 const is_inconsistent = ancestor_clean && branch.status !== 'clean';421 if (is_inconsistent) return true;422 423 const new_ancestor_clean = ancestor_clean || branch.status === 'clean';424 for (const child of branch.children) {425 if (has_inconsistency(child, new_ancestor_clean)) return true;426 }427 return false;428 }429 430 /**431 * Logs a branch and its children, but only if there are inconsistencies432 * @param {BranchInfo} branch433 * @param {boolean} ancestor_clean434 * @param {number} depth435 */436 function log_branch(branch, ancestor_clean, depth) {437 const is_inconsistent = ancestor_clean && branch.status !== 'clean';438 const new_ancestor_clean = ancestor_clean || branch.status === 'clean';439 440 // Only log if this branch or any descendant has an inconsistency441 if (!has_inconsistency(branch, ancestor_clean) && !is_inconsistent) {442 return;443 }444 445 const style = is_inconsistent446 ? 'font-weight: bold; color: red'447 : branch.status === 'clean'448 ? 'font-weight: normal; color: green'449 : 'font-weight: bold; color: orange';450 451 const warning = is_inconsistent ? ' ⚠️ INCONSISTENT' : '';452 453 // eslint-disable-next-line no-console454 console.group(`%cbranch (${branch.status})${warning}`, style);455 456 // eslint-disable-next-line no-console457 console.log('%ceffect:', 'font-weight: bold', branch.effect);458 459 if (branch.effect.fn) {460 // eslint-disable-next-line no-console461 console.log('%cfn:', 'font-weight: bold', branch.effect.fn);462 }463 464 if (branch.effect.deps !== null) {465 // eslint-disable-next-line no-console466 console.groupCollapsed('%cdeps', 'font-weight: normal');467 for (const dep of branch.effect.deps) {468 log_dep(dep);469 }470 // eslint-disable-next-line no-console471 console.groupEnd();472 }473 474 if (is_inconsistent) {475 log_effect_tree(branch.effect);476 } else if (branch.children.length > 0) {477 // eslint-disable-next-line no-console478 console.group('%cchild branches', 'font-weight: bold');479 for (const child of branch.children) {480 log_branch(child, new_ancestor_clean, depth + 1);481 }482 // eslint-disable-next-line no-console483 console.groupEnd();484 }485 486 // eslint-disable-next-line no-console487 console.groupEnd();488 }489 490 const branches = collect_branches(root_effect, false);491 492 // Check if there are any inconsistencies at all493 let has_any_inconsistency = false;494 for (const branch of branches) {495 if (has_inconsistency(branch, false)) {496 has_any_inconsistency = true;497 break;498 }499 }500 501 if (!has_any_inconsistency) {502 // eslint-disable-next-line no-console503 console.log('%cNo inconsistent branches found', 'font-weight: bold; color: green');504 return;505 }506 507 // eslint-disable-next-line no-console508 console.group(`%cInconsistent Branches (non-clean below clean)`, 'font-weight: bold; color: red');509 510 for (const branch of branches) {511 log_branch(branch, false, 0);512 }513 514 // eslint-disable-next-line no-console515 console.groupEnd();516 517 return true;518}519 