drowse.ai 5.3.1__py3-none-any.whl
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.
- drowse/__init__.py +312 -0
- drowse/__main__.py +5 -0
- drowse/cli/__init__.py +5 -0
- drowse/cli/alpha_grid.py +96 -0
- drowse/cli/config_file.py +340 -0
- drowse/cli/main.py +52 -0
- drowse/cli/parsers.py +1478 -0
- drowse/cli/runners/__init__.py +155 -0
- drowse/cli/runners/config.py +85 -0
- drowse/cli/runners/experiment.py +344 -0
- drowse/cli/runners/lens.py +661 -0
- drowse/cli/runners/manifold.py +1097 -0
- drowse/cli/runners/pack.py +413 -0
- drowse/cli/runners/sae.py +304 -0
- drowse/cli/runners/serve.py +220 -0
- drowse/cli/runners/shared.py +389 -0
- drowse/cli/runners/template.py +232 -0
- drowse/core/__init__.py +1 -0
- drowse/core/capture.py +1205 -0
- drowse/core/errors.py +260 -0
- drowse/core/events.py +156 -0
- drowse/core/extraction.py +3076 -0
- drowse/core/generation.py +1738 -0
- drowse/core/generation_finalizer.py +278 -0
- drowse/core/histogram.py +30 -0
- drowse/core/hooks.py +1885 -0
- drowse/core/instruments/__init__.py +49 -0
- drowse/core/instruments/geometry.py +551 -0
- drowse/core/instruments/lens.py +1341 -0
- drowse/core/instruments/protocol.py +211 -0
- drowse/core/instruments/sae.py +935 -0
- drowse/core/instruments/types.py +597 -0
- drowse/core/jlens.py +874 -0
- drowse/core/jlens_fit.py +1305 -0
- drowse/core/joint_logprobs.py +748 -0
- drowse/core/loom.py +1938 -0
- drowse/core/loom_diff.py +408 -0
- drowse/core/mahalanobis.py +579 -0
- drowse/core/manifold.py +4106 -0
- drowse/core/measurements.py +382 -0
- drowse/core/model.py +1724 -0
- drowse/core/monitor.py +2060 -0
- drowse/core/monitor_attach.py +682 -0
- drowse/core/naming.py +42 -0
- drowse/core/naturalness.py +187 -0
- drowse/core/profile.py +617 -0
- drowse/core/relp.py +313 -0
- drowse/core/results.py +467 -0
- drowse/core/role_templates.py +677 -0
- drowse/core/sae.py +891 -0
- drowse/core/sae_training.py +239 -0
- drowse/core/sampling.py +127 -0
- drowse/core/scene.py +810 -0
- drowse/core/scoring.py +270 -0
- drowse/core/session.py +11015 -0
- drowse/core/static_cache.py +316 -0
- drowse/core/steering.py +229 -0
- drowse/core/steering_composer.py +1135 -0
- drowse/core/steering_expr.py +1413 -0
- drowse/core/surface_topology.py +128 -0
- drowse/core/token_callback.py +52 -0
- drowse/core/token_payloads.py +244 -0
- drowse/core/topology.py +1469 -0
- drowse/core/transcript.py +582 -0
- drowse/core/tree_filter.py +353 -0
- drowse/core/triggers.py +250 -0
- drowse/data/baseline_prompts.json +50 -0
- drowse/data/manifolds/confident.uncertain/manifold.json +28 -0
- drowse/data/manifolds/confident.uncertain/nodes/00_confident.json +50 -0
- drowse/data/manifolds/confident.uncertain/nodes/01_uncertain.json +50 -0
- drowse/data/manifolds/creative.conventional/manifold.json +28 -0
- drowse/data/manifolds/creative.conventional/nodes/00_creative.json +50 -0
- drowse/data/manifolds/creative.conventional/nodes/01_conventional.json +50 -0
- drowse/data/manifolds/curious.disinterested/manifold.json +28 -0
- drowse/data/manifolds/curious.disinterested/nodes/00_curious.json +50 -0
- drowse/data/manifolds/curious.disinterested/nodes/01_disinterested.json +50 -0
- drowse/data/manifolds/direct.indirect/manifold.json +28 -0
- drowse/data/manifolds/direct.indirect/nodes/00_direct.json +50 -0
- drowse/data/manifolds/direct.indirect/nodes/01_indirect.json +50 -0
- drowse/data/manifolds/emotions/manifold.json +115 -0
- drowse/data/manifolds/emotions/nodes/00_excited.json +50 -0
- drowse/data/manifolds/emotions/nodes/01_happy.json +50 -0
- drowse/data/manifolds/emotions/nodes/02_calm.json +50 -0
- drowse/data/manifolds/emotions/nodes/03_weary.json +50 -0
- drowse/data/manifolds/emotions/nodes/04_sad.json +50 -0
- drowse/data/manifolds/emotions/nodes/05_distressed.json +50 -0
- drowse/data/manifolds/emotions/nodes/06_alert.json +50 -0
- drowse/data/manifolds/emotions/nodes/07_dominant.json +50 -0
- drowse/data/manifolds/emotions/nodes/08_submissive.json +50 -0
- drowse/data/manifolds/emotions/nodes/09_angry.json +50 -0
- drowse/data/manifolds/emotions/nodes/10_fearful.json +50 -0
- drowse/data/manifolds/emotions/nodes/11_surprised.json +50 -0
- drowse/data/manifolds/emotions/nodes/12_triumphant.json +50 -0
- drowse/data/manifolds/emotions/nodes/13_humiliated.json +50 -0
- drowse/data/manifolds/emotions/nodes/14_disgusted.json +50 -0
- drowse/data/manifolds/emotions/nodes/15_bored.json +50 -0
- drowse/data/manifolds/emotions/nodes/16_grateful.json +50 -0
- drowse/data/manifolds/emotions/nodes/17_relieved.json +50 -0
- drowse/data/manifolds/emotions/nodes/18_playful.json +50 -0
- drowse/data/manifolds/emotions/nodes/19_hopeful.json +50 -0
- drowse/data/manifolds/formal.casual/manifold.json +28 -0
- drowse/data/manifolds/formal.casual/nodes/00_formal.json +50 -0
- drowse/data/manifolds/formal.casual/nodes/01_casual.json +50 -0
- drowse/data/manifolds/honest.deceptive/manifold.json +28 -0
- drowse/data/manifolds/honest.deceptive/nodes/00_honest.json +50 -0
- drowse/data/manifolds/honest.deceptive/nodes/01_deceptive.json +50 -0
- drowse/data/manifolds/humorous.serious/manifold.json +28 -0
- drowse/data/manifolds/humorous.serious/nodes/00_humorous.json +50 -0
- drowse/data/manifolds/humorous.serious/nodes/01_serious.json +50 -0
- drowse/data/manifolds/individualist.collectivist/manifold.json +28 -0
- drowse/data/manifolds/individualist.collectivist/nodes/00_individualist.json +50 -0
- drowse/data/manifolds/individualist.collectivist/nodes/01_collectivist.json +50 -0
- drowse/data/manifolds/masculine.feminine/manifold.json +28 -0
- drowse/data/manifolds/masculine.feminine/nodes/00_masculine.json +50 -0
- drowse/data/manifolds/masculine.feminine/nodes/01_feminine.json +50 -0
- drowse/data/manifolds/months/manifold.json +120 -0
- drowse/data/manifolds/months/nodes/00_january.json +50 -0
- drowse/data/manifolds/months/nodes/01_february.json +50 -0
- drowse/data/manifolds/months/nodes/02_march.json +50 -0
- drowse/data/manifolds/months/nodes/03_april.json +50 -0
- drowse/data/manifolds/months/nodes/04_may.json +50 -0
- drowse/data/manifolds/months/nodes/05_june.json +50 -0
- drowse/data/manifolds/months/nodes/06_july.json +50 -0
- drowse/data/manifolds/months/nodes/07_august.json +50 -0
- drowse/data/manifolds/months/nodes/08_september.json +50 -0
- drowse/data/manifolds/months/nodes/09_october.json +50 -0
- drowse/data/manifolds/months/nodes/10_november.json +50 -0
- drowse/data/manifolds/months/nodes/11_december.json +50 -0
- drowse/data/manifolds/personas/manifold.json +550 -0
- drowse/data/manifolds/personas/nodes/00_assistant.json +50 -0
- drowse/data/manifolds/personas/nodes/01_analyst.json +50 -0
- drowse/data/manifolds/personas/nodes/02_impostor.json +50 -0
- drowse/data/manifolds/personas/nodes/03_teacher.json +50 -0
- drowse/data/manifolds/personas/nodes/04_doctor.json +50 -0
- drowse/data/manifolds/personas/nodes/05_librarian.json +50 -0
- drowse/data/manifolds/personas/nodes/06_farmer.json +50 -0
- drowse/data/manifolds/personas/nodes/07_soldier.json +50 -0
- drowse/data/manifolds/personas/nodes/08_lawyer.json +50 -0
- drowse/data/manifolds/personas/nodes/09_chef.json +50 -0
- drowse/data/manifolds/personas/nodes/100_assassin.json +50 -0
- drowse/data/manifolds/personas/nodes/101_thief.json +50 -0
- drowse/data/manifolds/personas/nodes/102_conman.json +50 -0
- drowse/data/manifolds/personas/nodes/103_hacker.json +50 -0
- drowse/data/manifolds/personas/nodes/104_cultist.json +50 -0
- drowse/data/manifolds/personas/nodes/105_tyrant.json +50 -0
- drowse/data/manifolds/personas/nodes/106_vandal.json +50 -0
- drowse/data/manifolds/personas/nodes/10_journalist.json +50 -0
- drowse/data/manifolds/personas/nodes/11_mechanic.json +50 -0
- drowse/data/manifolds/personas/nodes/12_sailor.json +50 -0
- drowse/data/manifolds/personas/nodes/13_pilot.json +50 -0
- drowse/data/manifolds/personas/nodes/14_athlete.json +50 -0
- drowse/data/manifolds/personas/nodes/15_engineer.json +50 -0
- drowse/data/manifolds/personas/nodes/16_scientist.json +50 -0
- drowse/data/manifolds/personas/nodes/17_banker.json +50 -0
- drowse/data/manifolds/personas/nodes/18_salesperson.json +50 -0
- drowse/data/manifolds/personas/nodes/19_nerd.json +50 -0
- drowse/data/manifolds/personas/nodes/20_jock.json +50 -0
- drowse/data/manifolds/personas/nodes/21_gamer.json +50 -0
- drowse/data/manifolds/personas/nodes/22_furry.json +50 -0
- drowse/data/manifolds/personas/nodes/23_weeaboo.json +50 -0
- drowse/data/manifolds/personas/nodes/24_influencer.json +50 -0
- drowse/data/manifolds/personas/nodes/25_stoner.json +50 -0
- drowse/data/manifolds/personas/nodes/26_femboy.json +50 -0
- drowse/data/manifolds/personas/nodes/27_ceo.json +50 -0
- drowse/data/manifolds/personas/nodes/28_emperor.json +50 -0
- drowse/data/manifolds/personas/nodes/29_president.json +50 -0
- drowse/data/manifolds/personas/nodes/30_diplomat.json +50 -0
- drowse/data/manifolds/personas/nodes/31_judge.json +50 -0
- drowse/data/manifolds/personas/nodes/32_bureaucrat.json +50 -0
- drowse/data/manifolds/personas/nodes/33_conservative.json +50 -0
- drowse/data/manifolds/personas/nodes/34_liberal.json +50 -0
- drowse/data/manifolds/personas/nodes/35_libertarian.json +50 -0
- drowse/data/manifolds/personas/nodes/36_communist.json +50 -0
- drowse/data/manifolds/personas/nodes/37_anarchist.json +50 -0
- drowse/data/manifolds/personas/nodes/38_reactionary.json +50 -0
- drowse/data/manifolds/personas/nodes/39_loner.json +50 -0
- drowse/data/manifolds/personas/nodes/40_friend.json +50 -0
- drowse/data/manifolds/personas/nodes/41_rival.json +50 -0
- drowse/data/manifolds/personas/nodes/42_stranger.json +50 -0
- drowse/data/manifolds/personas/nodes/43_lover.json +50 -0
- drowse/data/manifolds/personas/nodes/44_stalker.json +50 -0
- drowse/data/manifolds/personas/nodes/45_lunatic.json +50 -0
- drowse/data/manifolds/personas/nodes/46_paranoid.json +50 -0
- drowse/data/manifolds/personas/nodes/47_detective.json +50 -0
- drowse/data/manifolds/personas/nodes/48_therapist.json +50 -0
- drowse/data/manifolds/personas/nodes/49_nomad.json +50 -0
- drowse/data/manifolds/personas/nodes/50_pirate.json +50 -0
- drowse/data/manifolds/personas/nodes/51_child.json +50 -0
- drowse/data/manifolds/personas/nodes/52_caveman.json +50 -0
- drowse/data/manifolds/personas/nodes/53_monk.json +50 -0
- drowse/data/manifolds/personas/nodes/54_knight.json +50 -0
- drowse/data/manifolds/personas/nodes/55_alchemist.json +50 -0
- drowse/data/manifolds/personas/nodes/56_blacksmith.json +50 -0
- drowse/data/manifolds/personas/nodes/57_viking.json +50 -0
- drowse/data/manifolds/personas/nodes/58_druid.json +50 -0
- drowse/data/manifolds/personas/nodes/59_poet.json +50 -0
- drowse/data/manifolds/personas/nodes/60_novelist.json +50 -0
- drowse/data/manifolds/personas/nodes/61_jester.json +50 -0
- drowse/data/manifolds/personas/nodes/62_philosopher.json +50 -0
- drowse/data/manifolds/personas/nodes/63_painter.json +50 -0
- drowse/data/manifolds/personas/nodes/64_musician.json +50 -0
- drowse/data/manifolds/personas/nodes/65_oracle.json +50 -0
- drowse/data/manifolds/personas/nodes/66_god.json +50 -0
- drowse/data/manifolds/personas/nodes/67_angel.json +50 -0
- drowse/data/manifolds/personas/nodes/68_prophet.json +50 -0
- drowse/data/manifolds/personas/nodes/69_saint.json +50 -0
- drowse/data/manifolds/personas/nodes/70_ghost.json +50 -0
- drowse/data/manifolds/personas/nodes/71_phoenix.json +50 -0
- drowse/data/manifolds/personas/nodes/72_witch.json +50 -0
- drowse/data/manifolds/personas/nodes/73_vampire.json +50 -0
- drowse/data/manifolds/personas/nodes/74_mermaid.json +50 -0
- drowse/data/manifolds/personas/nodes/75_sphinx.json +50 -0
- drowse/data/manifolds/personas/nodes/76_banshee.json +50 -0
- drowse/data/manifolds/personas/nodes/77_golem.json +50 -0
- drowse/data/manifolds/personas/nodes/78_deer.json +50 -0
- drowse/data/manifolds/personas/nodes/79_wolf.json +50 -0
- drowse/data/manifolds/personas/nodes/80_raven.json +50 -0
- drowse/data/manifolds/personas/nodes/81_serpent.json +50 -0
- drowse/data/manifolds/personas/nodes/82_lion.json +50 -0
- drowse/data/manifolds/personas/nodes/83_tree.json +50 -0
- drowse/data/manifolds/personas/nodes/84_river.json +50 -0
- drowse/data/manifolds/personas/nodes/85_storm.json +50 -0
- drowse/data/manifolds/personas/nodes/86_flame.json +50 -0
- drowse/data/manifolds/personas/nodes/87_mirror.json +50 -0
- drowse/data/manifolds/personas/nodes/88_clock.json +50 -0
- drowse/data/manifolds/personas/nodes/89_computer.json +50 -0
- drowse/data/manifolds/personas/nodes/90_robot.json +50 -0
- drowse/data/manifolds/personas/nodes/91_cyborg.json +50 -0
- drowse/data/manifolds/personas/nodes/92_drone.json +50 -0
- drowse/data/manifolds/personas/nodes/93_mecha.json +50 -0
- drowse/data/manifolds/personas/nodes/94_alien.json +50 -0
- drowse/data/manifolds/personas/nodes/95_trickster.json +50 -0
- drowse/data/manifolds/personas/nodes/96_virus.json +50 -0
- drowse/data/manifolds/personas/nodes/97_spy.json +50 -0
- drowse/data/manifolds/personas/nodes/98_narcissist.json +50 -0
- drowse/data/manifolds/personas/nodes/99_demon.json +50 -0
- drowse/data/manifolds/refusing.compliant/manifold.json +28 -0
- drowse/data/manifolds/refusing.compliant/nodes/00_refusing.json +50 -0
- drowse/data/manifolds/refusing.compliant/nodes/01_compliant.json +50 -0
- drowse/data/manifolds/religious.secular/manifold.json +28 -0
- drowse/data/manifolds/religious.secular/nodes/00_religious.json +50 -0
- drowse/data/manifolds/religious.secular/nodes/01_secular.json +50 -0
- drowse/data/manifolds/sincere.manipulative/manifold.json +28 -0
- drowse/data/manifolds/sincere.manipulative/nodes/00_sincere.json +50 -0
- drowse/data/manifolds/sincere.manipulative/nodes/01_manipulative.json +50 -0
- drowse/data/manifolds/sycophantic.blunt/manifold.json +28 -0
- drowse/data/manifolds/sycophantic.blunt/nodes/00_sycophantic.json +50 -0
- drowse/data/manifolds/sycophantic.blunt/nodes/01_blunt.json +50 -0
- drowse/data/manifolds/technical.accessible/manifold.json +28 -0
- drowse/data/manifolds/technical.accessible/nodes/00_technical.json +50 -0
- drowse/data/manifolds/technical.accessible/nodes/01_accessible.json +50 -0
- drowse/data/manifolds/traditional.progressive/manifold.json +28 -0
- drowse/data/manifolds/traditional.progressive/nodes/00_traditional.json +50 -0
- drowse/data/manifolds/traditional.progressive/nodes/01_progressive.json +50 -0
- drowse/data/manifolds/verbose.concise/manifold.json +28 -0
- drowse/data/manifolds/verbose.concise/nodes/00_verbose.json +50 -0
- drowse/data/manifolds/verbose.concise/nodes/01_concise.json +50 -0
- drowse/data/manifolds/warm.clinical/manifold.json +28 -0
- drowse/data/manifolds/warm.clinical/nodes/00_warm.json +50 -0
- drowse/data/manifolds/warm.clinical/nodes/01_clinical.json +50 -0
- drowse/data/neutral_statements.json +98 -0
- drowse/io/__init__.py +1 -0
- drowse/io/alignment.py +1334 -0
- drowse/io/atomic.py +278 -0
- drowse/io/bake.py +558 -0
- drowse/io/bootstrap.py +73 -0
- drowse/io/brand_migration.py +48 -0
- drowse/io/drowse_archive.py +1830 -0
- drowse/io/gguf_io.py +300 -0
- drowse/io/hf.py +81 -0
- drowse/io/hf_manifolds.py +931 -0
- drowse/io/integrity.py +102 -0
- drowse/io/lens.py +1992 -0
- drowse/io/lens_sources.py +1003 -0
- drowse/io/manifold_authoring.py +1348 -0
- drowse/io/manifold_folder.py +1854 -0
- drowse/io/manifold_lifecycle.py +1253 -0
- drowse/io/manifold_tensors.py +727 -0
- drowse/io/manifolds.py +443 -0
- drowse/io/paths.py +289 -0
- drowse/io/probes_bootstrap.py +58 -0
- drowse/io/sae.py +382 -0
- drowse/io/sae_artifacts.py +318 -0
- drowse/io/selectors.py +503 -0
- drowse/io/shards.py +160 -0
- drowse/io/source_registry.py +138 -0
- drowse/io/staging.py +80 -0
- drowse/io/templates.py +707 -0
- drowse/notebook/__init__.py +38 -0
- drowse/notebook/data.py +99 -0
- drowse/notebook/plots.py +352 -0
- drowse/py.typed +0 -0
- drowse/server/__init__.py +20 -0
- drowse/server/app.py +987 -0
- drowse/server/background_job.py +246 -0
- drowse/server/instrument_routes.py +1101 -0
- drowse/server/manifold_routes.py +1028 -0
- drowse/server/model_names.py +82 -0
- drowse/server/native_common.py +92 -0
- drowse/server/native_routes.py +45 -0
- drowse/server/ollama.py +817 -0
- drowse/server/operation_ledger.py +187 -0
- drowse/server/probe_routes.py +220 -0
- drowse/server/profile_models.py +52 -0
- drowse/server/profile_routes.py +440 -0
- drowse/server/request_helpers.py +198 -0
- drowse/server/request_ledger.py +85 -0
- drowse/server/response_models.py +814 -0
- drowse/server/session_models.py +146 -0
- drowse/server/session_routes.py +150 -0
- drowse/server/sse.py +333 -0
- drowse/server/streaming.py +129 -0
- drowse/server/template_routes.py +161 -0
- drowse/server/tree_models.py +121 -0
- drowse/server/tree_routes.py +550 -0
- drowse/server/ws_events.py +65 -0
- drowse/server/ws_models.py +219 -0
- drowse/server/ws_stream.py +1205 -0
- drowse/web/__init__.py +22 -0
- drowse/web/dist/LICENSE-Fluent-Icons.txt +21 -0
- drowse/web/dist/LICENSE-Fluent-System-Icons.txt +21 -0
- drowse/web/dist/LICENSE-Martian-Mono.txt +93 -0
- drowse/web/dist/LICENSE-Torph.txt +21 -0
- drowse/web/dist/LICENSE-Wix-Madefor.txt +93 -0
- drowse/web/dist/assets/App-BewwoFwv.js +33 -0
- drowse/web/dist/assets/App.css +1 -0
- drowse/web/dist/assets/MartianMono-cyrillic-ext.woff2 +0 -0
- drowse/web/dist/assets/MartianMono-cyrillic.woff2 +0 -0
- drowse/web/dist/assets/MartianMono-latin-ext.woff2 +0 -0
- drowse/web/dist/assets/MartianMono-latin.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforDisplay-cyrillic.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforDisplay-latin-ext.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforDisplay-latin.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforDisplay-vietnamese.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-italic-latin-ext.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-italic-latin.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-normal-cyrillic.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-normal-latin-ext.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-normal-latin.woff2 +0 -0
- drowse/web/dist/assets/WixMadeforText-normal-vietnamese.woff2 +0 -0
- drowse/web/dist/assets/ab.svelte-CbVGAYXo.js +1 -0
- drowse/web/dist/assets/artifactUpdates-Cjeu6LJc.js +1 -0
- drowse/web/dist/assets/artifactUpdates-DfAoYC9j.js +1 -0
- drowse/web/dist/assets/chat.svelte-DxKufn9g.js +1 -0
- drowse/web/dist/assets/drawers-BDWC0hIN.js +123 -0
- drowse/web/dist/assets/drawers.css +1 -0
- drowse/web/dist/assets/drowse.js +7 -0
- drowse/web/dist/assets/eleutherai.png +0 -0
- drowse/web/dist/assets/errors-Dvb10QW_.js +2 -0
- drowse/web/dist/assets/expression-4yISdAdq.js +1 -0
- drowse/web/dist/assets/files-CvRivkey.js +1 -0
- drowse/web/dist/assets/files-JhDJVgD_.js +1 -0
- drowse/web/dist/assets/fittingCancellation-D72BZWPZ.js +1 -0
- drowse/web/dist/assets/gemma-3-1b-it.json +1 -0
- drowse/web/dist/assets/gemma-3-270m-it.json +1 -0
- drowse/web/dist/assets/gemma-3-4b-it.json +1 -0
- drowse/web/dist/assets/generation-DbkBAhP_.js +1 -0
- drowse/web/dist/assets/index-client-2OdH6IQp.js +3 -0
- drowse/web/dist/assets/index-client-D4S4PooY.js +1 -0
- drowse/web/dist/assets/index.css +1 -0
- drowse/web/dist/assets/instrumentAuthoring.svelte-Csh7NOGX.js +1 -0
- drowse/web/dist/assets/instrumentAuthoring.svelte-w9YPcDsP.js +1 -0
- drowse/web/dist/assets/instruments.svelte-XnEUQA6B.js +1 -0
- drowse/web/dist/assets/localData-DIBDM_zo.js +1 -0
- drowse/web/dist/assets/loom.svelte-D_YyqHHK.js +1 -0
- drowse/web/dist/assets/manifoldJobs.svelte-9f5hs_J7.js +1 -0
- drowse/web/dist/assets/manifoldJobs.svelte-Bwo2GYOH.js +1 -0
- drowse/web/dist/assets/openai.png +0 -0
- drowse/web/dist/assets/preload-helper-BLdHbfdN.js +1 -0
- drowse/web/dist/assets/probes.svelte-COcN1Rh8.js +1 -0
- drowse/web/dist/assets/registry-B0_pJoMg.js +1 -0
- drowse/web/dist/assets/registry-CQv71XNh.js +1 -0
- drowse/web/dist/assets/sampling.svelte-BU0kED3k.js +1 -0
- drowse/web/dist/assets/samplingCapabilities-DM6eoDoc.js +1 -0
- drowse/web/dist/assets/savedConversations.svelte-BsBLc-p7.js +1 -0
- drowse/web/dist/assets/savedConversations.svelte-TuSes9Kg.js +1 -0
- drowse/web/dist/assets/selectors-BxXnPPN_.js +1 -0
- drowse/web/dist/assets/serviceTools-CG0q1Xqg.js +2 -0
- drowse/web/dist/assets/session.svelte-D2STLuP6.js +1 -0
- drowse/web/dist/assets/steering.svelte-DvFT3O-d.js +1 -0
- drowse/web/dist/assets/steeringPositions-Dr0JOFu7.js +1 -0
- drowse/web/dist/assets/templates-Bkq2x5ID.js +1 -0
- drowse/web/dist/assets/types-CuMUbvHW.js +1 -0
- drowse/web/dist/assets/validation-5wgTuS7k.js +1 -0
- drowse/web/dist/assets/webmcp-DyqJf4z6.js +2 -0
- drowse/web/dist/assets/workspaceController-C2L33e3m.js +1 -0
- drowse/web/dist/assets/workspaceController-DJhXD_BC.js +1 -0
- drowse/web/dist/assets/workspaceTools-BWdmXopx.js +2 -0
- drowse/web/dist/favicon.ico +0 -0
- drowse/web/dist/favicon.svg +1 -0
- drowse/web/dist/icons/apple-touch-icon.png +0 -0
- drowse/web/dist/icons/drowse-192.png +0 -0
- drowse/web/dist/icons/drowse-512.png +0 -0
- drowse/web/dist/icons/drowse-maskable-512.png +0 -0
- drowse/web/dist/icons/tab-analyzing-0.png +0 -0
- drowse/web/dist/icons/tab-analyzing-1.png +0 -0
- drowse/web/dist/icons/tab-analyzing-2.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-0.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-1.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-10.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-11.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-12.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-13.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-14.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-15.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-16.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-17.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-18.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-19.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-2.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-20.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-21.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-22.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-23.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-24.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-25.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-26.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-27.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-28.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-29.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-3.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-30.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-31.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-32.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-33.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-34.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-35.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-36.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-37.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-38.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-39.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-4.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-40.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-41.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-42.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-43.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-44.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-45.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-46.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-47.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-5.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-6.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-7.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-8.png +0 -0
- drowse/web/dist/icons/tab-analyzing-dark-9.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-0.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-1.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-10.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-11.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-12.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-13.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-14.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-15.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-16.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-17.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-18.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-19.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-2.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-20.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-21.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-22.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-23.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-24.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-25.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-26.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-27.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-28.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-29.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-3.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-30.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-31.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-32.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-33.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-34.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-35.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-36.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-37.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-38.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-39.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-4.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-40.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-41.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-42.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-43.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-44.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-45.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-46.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-47.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-5.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-6.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-7.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-8.png +0 -0
- drowse/web/dist/icons/tab-analyzing-light-9.png +0 -0
- drowse/web/dist/icons/tab-chat-settings-dark.png +0 -0
- drowse/web/dist/icons/tab-chat-settings-light.png +0 -0
- drowse/web/dist/icons/tab-chat-settings.png +0 -0
- drowse/web/dist/icons/tab-chats-dark.png +0 -0
- drowse/web/dist/icons/tab-chats-light.png +0 -0
- drowse/web/dist/icons/tab-chats.png +0 -0
- drowse/web/dist/icons/tab-checking-0.png +0 -0
- drowse/web/dist/icons/tab-checking-1.png +0 -0
- drowse/web/dist/icons/tab-checking-2.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-0.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-1.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-10.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-11.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-12.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-13.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-14.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-15.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-16.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-17.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-18.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-19.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-2.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-20.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-21.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-22.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-23.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-24.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-25.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-26.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-27.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-28.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-29.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-3.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-30.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-31.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-32.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-33.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-34.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-35.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-36.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-37.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-38.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-39.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-4.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-40.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-41.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-42.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-43.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-44.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-45.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-46.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-47.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-5.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-6.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-7.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-8.png +0 -0
- drowse/web/dist/icons/tab-checking-dark-9.png +0 -0
- drowse/web/dist/icons/tab-checking-light-0.png +0 -0
- drowse/web/dist/icons/tab-checking-light-1.png +0 -0
- drowse/web/dist/icons/tab-checking-light-10.png +0 -0
- drowse/web/dist/icons/tab-checking-light-11.png +0 -0
- drowse/web/dist/icons/tab-checking-light-12.png +0 -0
- drowse/web/dist/icons/tab-checking-light-13.png +0 -0
- drowse/web/dist/icons/tab-checking-light-14.png +0 -0
- drowse/web/dist/icons/tab-checking-light-15.png +0 -0
- drowse/web/dist/icons/tab-checking-light-16.png +0 -0
- drowse/web/dist/icons/tab-checking-light-17.png +0 -0
- drowse/web/dist/icons/tab-checking-light-18.png +0 -0
- drowse/web/dist/icons/tab-checking-light-19.png +0 -0
- drowse/web/dist/icons/tab-checking-light-2.png +0 -0
- drowse/web/dist/icons/tab-checking-light-20.png +0 -0
- drowse/web/dist/icons/tab-checking-light-21.png +0 -0
- drowse/web/dist/icons/tab-checking-light-22.png +0 -0
- drowse/web/dist/icons/tab-checking-light-23.png +0 -0
- drowse/web/dist/icons/tab-checking-light-24.png +0 -0
- drowse/web/dist/icons/tab-checking-light-25.png +0 -0
- drowse/web/dist/icons/tab-checking-light-26.png +0 -0
- drowse/web/dist/icons/tab-checking-light-27.png +0 -0
- drowse/web/dist/icons/tab-checking-light-28.png +0 -0
- drowse/web/dist/icons/tab-checking-light-29.png +0 -0
- drowse/web/dist/icons/tab-checking-light-3.png +0 -0
- drowse/web/dist/icons/tab-checking-light-30.png +0 -0
- drowse/web/dist/icons/tab-checking-light-31.png +0 -0
- drowse/web/dist/icons/tab-checking-light-32.png +0 -0
- drowse/web/dist/icons/tab-checking-light-33.png +0 -0
- drowse/web/dist/icons/tab-checking-light-34.png +0 -0
- drowse/web/dist/icons/tab-checking-light-35.png +0 -0
- drowse/web/dist/icons/tab-checking-light-36.png +0 -0
- drowse/web/dist/icons/tab-checking-light-37.png +0 -0
- drowse/web/dist/icons/tab-checking-light-38.png +0 -0
- drowse/web/dist/icons/tab-checking-light-39.png +0 -0
- drowse/web/dist/icons/tab-checking-light-4.png +0 -0
- drowse/web/dist/icons/tab-checking-light-40.png +0 -0
- drowse/web/dist/icons/tab-checking-light-41.png +0 -0
- drowse/web/dist/icons/tab-checking-light-42.png +0 -0
- drowse/web/dist/icons/tab-checking-light-43.png +0 -0
- drowse/web/dist/icons/tab-checking-light-44.png +0 -0
- drowse/web/dist/icons/tab-checking-light-45.png +0 -0
- drowse/web/dist/icons/tab-checking-light-46.png +0 -0
- drowse/web/dist/icons/tab-checking-light-47.png +0 -0
- drowse/web/dist/icons/tab-checking-light-5.png +0 -0
- drowse/web/dist/icons/tab-checking-light-6.png +0 -0
- drowse/web/dist/icons/tab-checking-light-7.png +0 -0
- drowse/web/dist/icons/tab-checking-light-8.png +0 -0
- drowse/web/dist/icons/tab-checking-light-9.png +0 -0
- drowse/web/dist/icons/tab-comparison-dark.png +0 -0
- drowse/web/dist/icons/tab-comparison-light.png +0 -0
- drowse/web/dist/icons/tab-comparison.png +0 -0
- drowse/web/dist/icons/tab-controls-dark.png +0 -0
- drowse/web/dist/icons/tab-controls-light.png +0 -0
- drowse/web/dist/icons/tab-controls.png +0 -0
- drowse/web/dist/icons/tab-conversation-dark.png +0 -0
- drowse/web/dist/icons/tab-conversation-light.png +0 -0
- drowse/web/dist/icons/tab-conversation.png +0 -0
- drowse/web/dist/icons/tab-credits-dark.png +0 -0
- drowse/web/dist/icons/tab-credits-light.png +0 -0
- drowse/web/dist/icons/tab-credits.png +0 -0
- drowse/web/dist/icons/tab-downloading-0.png +0 -0
- drowse/web/dist/icons/tab-downloading-1.png +0 -0
- drowse/web/dist/icons/tab-downloading-2.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-0.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-1.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-10.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-11.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-12.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-13.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-14.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-15.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-16.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-17.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-18.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-19.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-2.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-20.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-21.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-22.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-23.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-24.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-25.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-26.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-27.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-28.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-29.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-3.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-30.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-31.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-32.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-33.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-34.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-35.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-36.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-37.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-38.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-39.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-4.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-40.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-41.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-42.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-43.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-44.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-45.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-46.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-47.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-5.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-6.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-7.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-8.png +0 -0
- drowse/web/dist/icons/tab-downloading-dark-9.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-0.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-1.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-10.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-11.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-12.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-13.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-14.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-15.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-16.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-17.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-18.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-19.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-2.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-20.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-21.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-22.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-23.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-24.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-25.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-26.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-27.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-28.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-29.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-3.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-30.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-31.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-32.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-33.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-34.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-35.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-36.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-37.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-38.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-39.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-4.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-40.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-41.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-42.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-43.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-44.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-45.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-46.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-47.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-5.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-6.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-7.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-8.png +0 -0
- drowse/web/dist/icons/tab-downloading-light-9.png +0 -0
- drowse/web/dist/icons/tab-error-dark.png +0 -0
- drowse/web/dist/icons/tab-error-light.png +0 -0
- drowse/web/dist/icons/tab-error.png +0 -0
- drowse/web/dist/icons/tab-home-dark.png +0 -0
- drowse/web/dist/icons/tab-home-light.png +0 -0
- drowse/web/dist/icons/tab-home.png +0 -0
- drowse/web/dist/icons/tab-loading-0.png +0 -0
- drowse/web/dist/icons/tab-loading-1.png +0 -0
- drowse/web/dist/icons/tab-loading-2.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-0.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-1.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-10.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-11.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-12.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-13.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-14.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-15.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-16.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-17.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-18.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-19.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-2.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-20.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-21.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-22.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-23.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-24.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-25.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-26.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-27.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-28.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-29.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-3.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-30.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-31.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-32.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-33.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-34.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-35.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-36.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-37.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-38.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-39.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-4.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-40.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-41.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-42.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-43.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-44.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-45.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-46.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-47.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-5.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-6.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-7.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-8.png +0 -0
- drowse/web/dist/icons/tab-loading-dark-9.png +0 -0
- drowse/web/dist/icons/tab-loading-light-0.png +0 -0
- drowse/web/dist/icons/tab-loading-light-1.png +0 -0
- drowse/web/dist/icons/tab-loading-light-10.png +0 -0
- drowse/web/dist/icons/tab-loading-light-11.png +0 -0
- drowse/web/dist/icons/tab-loading-light-12.png +0 -0
- drowse/web/dist/icons/tab-loading-light-13.png +0 -0
- drowse/web/dist/icons/tab-loading-light-14.png +0 -0
- drowse/web/dist/icons/tab-loading-light-15.png +0 -0
- drowse/web/dist/icons/tab-loading-light-16.png +0 -0
- drowse/web/dist/icons/tab-loading-light-17.png +0 -0
- drowse/web/dist/icons/tab-loading-light-18.png +0 -0
- drowse/web/dist/icons/tab-loading-light-19.png +0 -0
- drowse/web/dist/icons/tab-loading-light-2.png +0 -0
- drowse/web/dist/icons/tab-loading-light-20.png +0 -0
- drowse/web/dist/icons/tab-loading-light-21.png +0 -0
- drowse/web/dist/icons/tab-loading-light-22.png +0 -0
- drowse/web/dist/icons/tab-loading-light-23.png +0 -0
- drowse/web/dist/icons/tab-loading-light-24.png +0 -0
- drowse/web/dist/icons/tab-loading-light-25.png +0 -0
- drowse/web/dist/icons/tab-loading-light-26.png +0 -0
- drowse/web/dist/icons/tab-loading-light-27.png +0 -0
- drowse/web/dist/icons/tab-loading-light-28.png +0 -0
- drowse/web/dist/icons/tab-loading-light-29.png +0 -0
- drowse/web/dist/icons/tab-loading-light-3.png +0 -0
- drowse/web/dist/icons/tab-loading-light-30.png +0 -0
- drowse/web/dist/icons/tab-loading-light-31.png +0 -0
- drowse/web/dist/icons/tab-loading-light-32.png +0 -0
- drowse/web/dist/icons/tab-loading-light-33.png +0 -0
- drowse/web/dist/icons/tab-loading-light-34.png +0 -0
- drowse/web/dist/icons/tab-loading-light-35.png +0 -0
- drowse/web/dist/icons/tab-loading-light-36.png +0 -0
- drowse/web/dist/icons/tab-loading-light-37.png +0 -0
- drowse/web/dist/icons/tab-loading-light-38.png +0 -0
- drowse/web/dist/icons/tab-loading-light-39.png +0 -0
- drowse/web/dist/icons/tab-loading-light-4.png +0 -0
- drowse/web/dist/icons/tab-loading-light-40.png +0 -0
- drowse/web/dist/icons/tab-loading-light-41.png +0 -0
- drowse/web/dist/icons/tab-loading-light-42.png +0 -0
- drowse/web/dist/icons/tab-loading-light-43.png +0 -0
- drowse/web/dist/icons/tab-loading-light-44.png +0 -0
- drowse/web/dist/icons/tab-loading-light-45.png +0 -0
- drowse/web/dist/icons/tab-loading-light-46.png +0 -0
- drowse/web/dist/icons/tab-loading-light-47.png +0 -0
- drowse/web/dist/icons/tab-loading-light-5.png +0 -0
- drowse/web/dist/icons/tab-loading-light-6.png +0 -0
- drowse/web/dist/icons/tab-loading-light-7.png +0 -0
- drowse/web/dist/icons/tab-loading-light-8.png +0 -0
- drowse/web/dist/icons/tab-loading-light-9.png +0 -0
- drowse/web/dist/icons/tab-loom-dark.png +0 -0
- drowse/web/dist/icons/tab-loom-light.png +0 -0
- drowse/web/dist/icons/tab-loom-working-0.png +0 -0
- drowse/web/dist/icons/tab-loom-working-1.png +0 -0
- drowse/web/dist/icons/tab-loom-working-2.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-0.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-1.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-10.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-11.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-12.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-13.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-14.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-15.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-16.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-17.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-18.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-19.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-2.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-20.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-21.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-22.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-23.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-24.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-25.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-26.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-27.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-28.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-29.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-3.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-30.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-31.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-32.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-33.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-34.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-35.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-36.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-37.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-38.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-39.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-4.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-40.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-41.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-42.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-43.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-44.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-45.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-46.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-47.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-5.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-6.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-7.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-8.png +0 -0
- drowse/web/dist/icons/tab-loom-working-dark-9.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-0.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-1.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-10.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-11.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-12.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-13.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-14.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-15.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-16.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-17.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-18.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-19.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-2.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-20.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-21.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-22.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-23.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-24.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-25.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-26.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-27.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-28.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-29.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-3.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-30.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-31.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-32.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-33.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-34.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-35.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-36.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-37.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-38.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-39.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-4.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-40.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-41.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-42.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-43.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-44.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-45.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-46.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-47.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-5.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-6.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-7.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-8.png +0 -0
- drowse/web/dist/icons/tab-loom-working-light-9.png +0 -0
- drowse/web/dist/icons/tab-loom.png +0 -0
- drowse/web/dist/icons/tab-models-dark.png +0 -0
- drowse/web/dist/icons/tab-models-light.png +0 -0
- drowse/web/dist/icons/tab-models.png +0 -0
- drowse/web/dist/icons/tab-offline-dark.png +0 -0
- drowse/web/dist/icons/tab-offline-light.png +0 -0
- drowse/web/dist/icons/tab-offline.png +0 -0
- drowse/web/dist/icons/tab-paused-dark.png +0 -0
- drowse/web/dist/icons/tab-paused-light.png +0 -0
- drowse/web/dist/icons/tab-paused.png +0 -0
- drowse/web/dist/icons/tab-ready-dark.png +0 -0
- drowse/web/dist/icons/tab-ready-light.png +0 -0
- drowse/web/dist/icons/tab-ready.png +0 -0
- drowse/web/dist/icons/tab-saving-0.png +0 -0
- drowse/web/dist/icons/tab-saving-1.png +0 -0
- drowse/web/dist/icons/tab-saving-2.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-0.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-1.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-10.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-11.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-12.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-13.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-14.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-15.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-16.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-17.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-18.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-19.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-2.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-20.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-21.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-22.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-23.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-24.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-25.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-26.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-27.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-28.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-29.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-3.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-30.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-31.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-32.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-33.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-34.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-35.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-36.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-37.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-38.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-39.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-4.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-40.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-41.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-42.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-43.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-44.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-45.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-46.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-47.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-5.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-6.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-7.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-8.png +0 -0
- drowse/web/dist/icons/tab-saving-dark-9.png +0 -0
- drowse/web/dist/icons/tab-saving-light-0.png +0 -0
- drowse/web/dist/icons/tab-saving-light-1.png +0 -0
- drowse/web/dist/icons/tab-saving-light-10.png +0 -0
- drowse/web/dist/icons/tab-saving-light-11.png +0 -0
- drowse/web/dist/icons/tab-saving-light-12.png +0 -0
- drowse/web/dist/icons/tab-saving-light-13.png +0 -0
- drowse/web/dist/icons/tab-saving-light-14.png +0 -0
- drowse/web/dist/icons/tab-saving-light-15.png +0 -0
- drowse/web/dist/icons/tab-saving-light-16.png +0 -0
- drowse/web/dist/icons/tab-saving-light-17.png +0 -0
- drowse/web/dist/icons/tab-saving-light-18.png +0 -0
- drowse/web/dist/icons/tab-saving-light-19.png +0 -0
- drowse/web/dist/icons/tab-saving-light-2.png +0 -0
- drowse/web/dist/icons/tab-saving-light-20.png +0 -0
- drowse/web/dist/icons/tab-saving-light-21.png +0 -0
- drowse/web/dist/icons/tab-saving-light-22.png +0 -0
- drowse/web/dist/icons/tab-saving-light-23.png +0 -0
- drowse/web/dist/icons/tab-saving-light-24.png +0 -0
- drowse/web/dist/icons/tab-saving-light-25.png +0 -0
- drowse/web/dist/icons/tab-saving-light-26.png +0 -0
- drowse/web/dist/icons/tab-saving-light-27.png +0 -0
- drowse/web/dist/icons/tab-saving-light-28.png +0 -0
- drowse/web/dist/icons/tab-saving-light-29.png +0 -0
- drowse/web/dist/icons/tab-saving-light-3.png +0 -0
- drowse/web/dist/icons/tab-saving-light-30.png +0 -0
- drowse/web/dist/icons/tab-saving-light-31.png +0 -0
- drowse/web/dist/icons/tab-saving-light-32.png +0 -0
- drowse/web/dist/icons/tab-saving-light-33.png +0 -0
- drowse/web/dist/icons/tab-saving-light-34.png +0 -0
- drowse/web/dist/icons/tab-saving-light-35.png +0 -0
- drowse/web/dist/icons/tab-saving-light-36.png +0 -0
- drowse/web/dist/icons/tab-saving-light-37.png +0 -0
- drowse/web/dist/icons/tab-saving-light-38.png +0 -0
- drowse/web/dist/icons/tab-saving-light-39.png +0 -0
- drowse/web/dist/icons/tab-saving-light-4.png +0 -0
- drowse/web/dist/icons/tab-saving-light-40.png +0 -0
- drowse/web/dist/icons/tab-saving-light-41.png +0 -0
- drowse/web/dist/icons/tab-saving-light-42.png +0 -0
- drowse/web/dist/icons/tab-saving-light-43.png +0 -0
- drowse/web/dist/icons/tab-saving-light-44.png +0 -0
- drowse/web/dist/icons/tab-saving-light-45.png +0 -0
- drowse/web/dist/icons/tab-saving-light-46.png +0 -0
- drowse/web/dist/icons/tab-saving-light-47.png +0 -0
- drowse/web/dist/icons/tab-saving-light-5.png +0 -0
- drowse/web/dist/icons/tab-saving-light-6.png +0 -0
- drowse/web/dist/icons/tab-saving-light-7.png +0 -0
- drowse/web/dist/icons/tab-saving-light-8.png +0 -0
- drowse/web/dist/icons/tab-saving-light-9.png +0 -0
- drowse/web/dist/icons/tab-thinking-0.png +0 -0
- drowse/web/dist/icons/tab-thinking-1.png +0 -0
- drowse/web/dist/icons/tab-thinking-2.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-0.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-1.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-10.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-11.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-12.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-13.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-14.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-15.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-16.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-17.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-18.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-19.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-2.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-20.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-21.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-22.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-23.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-24.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-25.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-26.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-27.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-28.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-29.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-3.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-30.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-31.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-32.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-33.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-34.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-35.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-36.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-37.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-38.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-39.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-4.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-40.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-41.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-42.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-43.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-44.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-45.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-46.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-47.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-5.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-6.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-7.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-8.png +0 -0
- drowse/web/dist/icons/tab-thinking-dark-9.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-0.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-1.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-10.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-11.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-12.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-13.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-14.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-15.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-16.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-17.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-18.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-19.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-2.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-20.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-21.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-22.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-23.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-24.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-25.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-26.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-27.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-28.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-29.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-3.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-30.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-31.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-32.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-33.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-34.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-35.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-36.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-37.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-38.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-39.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-4.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-40.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-41.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-42.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-43.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-44.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-45.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-46.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-47.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-5.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-6.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-7.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-8.png +0 -0
- drowse/web/dist/icons/tab-thinking-light-9.png +0 -0
- drowse/web/dist/icons/tab-tokens-dark.png +0 -0
- drowse/web/dist/icons/tab-tokens-light.png +0 -0
- drowse/web/dist/icons/tab-tokens.png +0 -0
- drowse/web/dist/icons/tab-training-0.png +0 -0
- drowse/web/dist/icons/tab-training-1.png +0 -0
- drowse/web/dist/icons/tab-training-2.png +0 -0
- drowse/web/dist/icons/tab-training-dark-0.png +0 -0
- drowse/web/dist/icons/tab-training-dark-1.png +0 -0
- drowse/web/dist/icons/tab-training-dark-10.png +0 -0
- drowse/web/dist/icons/tab-training-dark-11.png +0 -0
- drowse/web/dist/icons/tab-training-dark-12.png +0 -0
- drowse/web/dist/icons/tab-training-dark-13.png +0 -0
- drowse/web/dist/icons/tab-training-dark-14.png +0 -0
- drowse/web/dist/icons/tab-training-dark-15.png +0 -0
- drowse/web/dist/icons/tab-training-dark-16.png +0 -0
- drowse/web/dist/icons/tab-training-dark-17.png +0 -0
- drowse/web/dist/icons/tab-training-dark-18.png +0 -0
- drowse/web/dist/icons/tab-training-dark-19.png +0 -0
- drowse/web/dist/icons/tab-training-dark-2.png +0 -0
- drowse/web/dist/icons/tab-training-dark-20.png +0 -0
- drowse/web/dist/icons/tab-training-dark-21.png +0 -0
- drowse/web/dist/icons/tab-training-dark-22.png +0 -0
- drowse/web/dist/icons/tab-training-dark-23.png +0 -0
- drowse/web/dist/icons/tab-training-dark-24.png +0 -0
- drowse/web/dist/icons/tab-training-dark-25.png +0 -0
- drowse/web/dist/icons/tab-training-dark-26.png +0 -0
- drowse/web/dist/icons/tab-training-dark-27.png +0 -0
- drowse/web/dist/icons/tab-training-dark-28.png +0 -0
- drowse/web/dist/icons/tab-training-dark-29.png +0 -0
- drowse/web/dist/icons/tab-training-dark-3.png +0 -0
- drowse/web/dist/icons/tab-training-dark-30.png +0 -0
- drowse/web/dist/icons/tab-training-dark-31.png +0 -0
- drowse/web/dist/icons/tab-training-dark-32.png +0 -0
- drowse/web/dist/icons/tab-training-dark-33.png +0 -0
- drowse/web/dist/icons/tab-training-dark-34.png +0 -0
- drowse/web/dist/icons/tab-training-dark-35.png +0 -0
- drowse/web/dist/icons/tab-training-dark-36.png +0 -0
- drowse/web/dist/icons/tab-training-dark-37.png +0 -0
- drowse/web/dist/icons/tab-training-dark-38.png +0 -0
- drowse/web/dist/icons/tab-training-dark-39.png +0 -0
- drowse/web/dist/icons/tab-training-dark-4.png +0 -0
- drowse/web/dist/icons/tab-training-dark-40.png +0 -0
- drowse/web/dist/icons/tab-training-dark-41.png +0 -0
- drowse/web/dist/icons/tab-training-dark-42.png +0 -0
- drowse/web/dist/icons/tab-training-dark-43.png +0 -0
- drowse/web/dist/icons/tab-training-dark-44.png +0 -0
- drowse/web/dist/icons/tab-training-dark-45.png +0 -0
- drowse/web/dist/icons/tab-training-dark-46.png +0 -0
- drowse/web/dist/icons/tab-training-dark-47.png +0 -0
- drowse/web/dist/icons/tab-training-dark-5.png +0 -0
- drowse/web/dist/icons/tab-training-dark-6.png +0 -0
- drowse/web/dist/icons/tab-training-dark-7.png +0 -0
- drowse/web/dist/icons/tab-training-dark-8.png +0 -0
- drowse/web/dist/icons/tab-training-dark-9.png +0 -0
- drowse/web/dist/icons/tab-training-light-0.png +0 -0
- drowse/web/dist/icons/tab-training-light-1.png +0 -0
- drowse/web/dist/icons/tab-training-light-10.png +0 -0
- drowse/web/dist/icons/tab-training-light-11.png +0 -0
- drowse/web/dist/icons/tab-training-light-12.png +0 -0
- drowse/web/dist/icons/tab-training-light-13.png +0 -0
- drowse/web/dist/icons/tab-training-light-14.png +0 -0
- drowse/web/dist/icons/tab-training-light-15.png +0 -0
- drowse/web/dist/icons/tab-training-light-16.png +0 -0
- drowse/web/dist/icons/tab-training-light-17.png +0 -0
- drowse/web/dist/icons/tab-training-light-18.png +0 -0
- drowse/web/dist/icons/tab-training-light-19.png +0 -0
- drowse/web/dist/icons/tab-training-light-2.png +0 -0
- drowse/web/dist/icons/tab-training-light-20.png +0 -0
- drowse/web/dist/icons/tab-training-light-21.png +0 -0
- drowse/web/dist/icons/tab-training-light-22.png +0 -0
- drowse/web/dist/icons/tab-training-light-23.png +0 -0
- drowse/web/dist/icons/tab-training-light-24.png +0 -0
- drowse/web/dist/icons/tab-training-light-25.png +0 -0
- drowse/web/dist/icons/tab-training-light-26.png +0 -0
- drowse/web/dist/icons/tab-training-light-27.png +0 -0
- drowse/web/dist/icons/tab-training-light-28.png +0 -0
- drowse/web/dist/icons/tab-training-light-29.png +0 -0
- drowse/web/dist/icons/tab-training-light-3.png +0 -0
- drowse/web/dist/icons/tab-training-light-30.png +0 -0
- drowse/web/dist/icons/tab-training-light-31.png +0 -0
- drowse/web/dist/icons/tab-training-light-32.png +0 -0
- drowse/web/dist/icons/tab-training-light-33.png +0 -0
- drowse/web/dist/icons/tab-training-light-34.png +0 -0
- drowse/web/dist/icons/tab-training-light-35.png +0 -0
- drowse/web/dist/icons/tab-training-light-36.png +0 -0
- drowse/web/dist/icons/tab-training-light-37.png +0 -0
- drowse/web/dist/icons/tab-training-light-38.png +0 -0
- drowse/web/dist/icons/tab-training-light-39.png +0 -0
- drowse/web/dist/icons/tab-training-light-4.png +0 -0
- drowse/web/dist/icons/tab-training-light-40.png +0 -0
- drowse/web/dist/icons/tab-training-light-41.png +0 -0
- drowse/web/dist/icons/tab-training-light-42.png +0 -0
- drowse/web/dist/icons/tab-training-light-43.png +0 -0
- drowse/web/dist/icons/tab-training-light-44.png +0 -0
- drowse/web/dist/icons/tab-training-light-45.png +0 -0
- drowse/web/dist/icons/tab-training-light-46.png +0 -0
- drowse/web/dist/icons/tab-training-light-47.png +0 -0
- drowse/web/dist/icons/tab-training-light-5.png +0 -0
- drowse/web/dist/icons/tab-training-light-6.png +0 -0
- drowse/web/dist/icons/tab-training-light-7.png +0 -0
- drowse/web/dist/icons/tab-training-light-8.png +0 -0
- drowse/web/dist/icons/tab-training-light-9.png +0 -0
- drowse/web/dist/icons/tab-unsupported-dark.png +0 -0
- drowse/web/dist/icons/tab-unsupported-light.png +0 -0
- drowse/web/dist/icons/tab-unsupported.png +0 -0
- drowse/web/dist/icons/tab-working-0.png +0 -0
- drowse/web/dist/icons/tab-working-1.png +0 -0
- drowse/web/dist/icons/tab-working-2.png +0 -0
- drowse/web/dist/icons/tab-working-dark-0.png +0 -0
- drowse/web/dist/icons/tab-working-dark-1.png +0 -0
- drowse/web/dist/icons/tab-working-dark-10.png +0 -0
- drowse/web/dist/icons/tab-working-dark-11.png +0 -0
- drowse/web/dist/icons/tab-working-dark-12.png +0 -0
- drowse/web/dist/icons/tab-working-dark-13.png +0 -0
- drowse/web/dist/icons/tab-working-dark-14.png +0 -0
- drowse/web/dist/icons/tab-working-dark-15.png +0 -0
- drowse/web/dist/icons/tab-working-dark-16.png +0 -0
- drowse/web/dist/icons/tab-working-dark-17.png +0 -0
- drowse/web/dist/icons/tab-working-dark-18.png +0 -0
- drowse/web/dist/icons/tab-working-dark-19.png +0 -0
- drowse/web/dist/icons/tab-working-dark-2.png +0 -0
- drowse/web/dist/icons/tab-working-dark-20.png +0 -0
- drowse/web/dist/icons/tab-working-dark-21.png +0 -0
- drowse/web/dist/icons/tab-working-dark-22.png +0 -0
- drowse/web/dist/icons/tab-working-dark-23.png +0 -0
- drowse/web/dist/icons/tab-working-dark-24.png +0 -0
- drowse/web/dist/icons/tab-working-dark-25.png +0 -0
- drowse/web/dist/icons/tab-working-dark-26.png +0 -0
- drowse/web/dist/icons/tab-working-dark-27.png +0 -0
- drowse/web/dist/icons/tab-working-dark-28.png +0 -0
- drowse/web/dist/icons/tab-working-dark-29.png +0 -0
- drowse/web/dist/icons/tab-working-dark-3.png +0 -0
- drowse/web/dist/icons/tab-working-dark-30.png +0 -0
- drowse/web/dist/icons/tab-working-dark-31.png +0 -0
- drowse/web/dist/icons/tab-working-dark-32.png +0 -0
- drowse/web/dist/icons/tab-working-dark-33.png +0 -0
- drowse/web/dist/icons/tab-working-dark-34.png +0 -0
- drowse/web/dist/icons/tab-working-dark-35.png +0 -0
- drowse/web/dist/icons/tab-working-dark-36.png +0 -0
- drowse/web/dist/icons/tab-working-dark-37.png +0 -0
- drowse/web/dist/icons/tab-working-dark-38.png +0 -0
- drowse/web/dist/icons/tab-working-dark-39.png +0 -0
- drowse/web/dist/icons/tab-working-dark-4.png +0 -0
- drowse/web/dist/icons/tab-working-dark-40.png +0 -0
- drowse/web/dist/icons/tab-working-dark-41.png +0 -0
- drowse/web/dist/icons/tab-working-dark-42.png +0 -0
- drowse/web/dist/icons/tab-working-dark-43.png +0 -0
- drowse/web/dist/icons/tab-working-dark-44.png +0 -0
- drowse/web/dist/icons/tab-working-dark-45.png +0 -0
- drowse/web/dist/icons/tab-working-dark-46.png +0 -0
- drowse/web/dist/icons/tab-working-dark-47.png +0 -0
- drowse/web/dist/icons/tab-working-dark-5.png +0 -0
- drowse/web/dist/icons/tab-working-dark-6.png +0 -0
- drowse/web/dist/icons/tab-working-dark-7.png +0 -0
- drowse/web/dist/icons/tab-working-dark-8.png +0 -0
- drowse/web/dist/icons/tab-working-dark-9.png +0 -0
- drowse/web/dist/icons/tab-working-light-0.png +0 -0
- drowse/web/dist/icons/tab-working-light-1.png +0 -0
- drowse/web/dist/icons/tab-working-light-10.png +0 -0
- drowse/web/dist/icons/tab-working-light-11.png +0 -0
- drowse/web/dist/icons/tab-working-light-12.png +0 -0
- drowse/web/dist/icons/tab-working-light-13.png +0 -0
- drowse/web/dist/icons/tab-working-light-14.png +0 -0
- drowse/web/dist/icons/tab-working-light-15.png +0 -0
- drowse/web/dist/icons/tab-working-light-16.png +0 -0
- drowse/web/dist/icons/tab-working-light-17.png +0 -0
- drowse/web/dist/icons/tab-working-light-18.png +0 -0
- drowse/web/dist/icons/tab-working-light-19.png +0 -0
- drowse/web/dist/icons/tab-working-light-2.png +0 -0
- drowse/web/dist/icons/tab-working-light-20.png +0 -0
- drowse/web/dist/icons/tab-working-light-21.png +0 -0
- drowse/web/dist/icons/tab-working-light-22.png +0 -0
- drowse/web/dist/icons/tab-working-light-23.png +0 -0
- drowse/web/dist/icons/tab-working-light-24.png +0 -0
- drowse/web/dist/icons/tab-working-light-25.png +0 -0
- drowse/web/dist/icons/tab-working-light-26.png +0 -0
- drowse/web/dist/icons/tab-working-light-27.png +0 -0
- drowse/web/dist/icons/tab-working-light-28.png +0 -0
- drowse/web/dist/icons/tab-working-light-29.png +0 -0
- drowse/web/dist/icons/tab-working-light-3.png +0 -0
- drowse/web/dist/icons/tab-working-light-30.png +0 -0
- drowse/web/dist/icons/tab-working-light-31.png +0 -0
- drowse/web/dist/icons/tab-working-light-32.png +0 -0
- drowse/web/dist/icons/tab-working-light-33.png +0 -0
- drowse/web/dist/icons/tab-working-light-34.png +0 -0
- drowse/web/dist/icons/tab-working-light-35.png +0 -0
- drowse/web/dist/icons/tab-working-light-36.png +0 -0
- drowse/web/dist/icons/tab-working-light-37.png +0 -0
- drowse/web/dist/icons/tab-working-light-38.png +0 -0
- drowse/web/dist/icons/tab-working-light-39.png +0 -0
- drowse/web/dist/icons/tab-working-light-4.png +0 -0
- drowse/web/dist/icons/tab-working-light-40.png +0 -0
- drowse/web/dist/icons/tab-working-light-41.png +0 -0
- drowse/web/dist/icons/tab-working-light-42.png +0 -0
- drowse/web/dist/icons/tab-working-light-43.png +0 -0
- drowse/web/dist/icons/tab-working-light-44.png +0 -0
- drowse/web/dist/icons/tab-working-light-45.png +0 -0
- drowse/web/dist/icons/tab-working-light-46.png +0 -0
- drowse/web/dist/icons/tab-working-light-47.png +0 -0
- drowse/web/dist/icons/tab-working-light-5.png +0 -0
- drowse/web/dist/icons/tab-working-light-6.png +0 -0
- drowse/web/dist/icons/tab-working-light-7.png +0 -0
- drowse/web/dist/icons/tab-working-light-8.png +0 -0
- drowse/web/dist/icons/tab-working-light-9.png +0 -0
- drowse/web/dist/index.html +34 -0
- drowse/web/dist/social/drowse.png +0 -0
- drowse/web/dist/social/drowse.svg +6 -0
- drowse/web/dist/theme-init.js +25 -0
- drowse/web/routes.py +118 -0
- drowse_ai-5.3.1.dist-info/METADATA +632 -0
- drowse_ai-5.3.1.dist-info/RECORD +1341 -0
- drowse_ai-5.3.1.dist-info/WHEEL +5 -0
- drowse_ai-5.3.1.dist-info/entry_points.txt +2 -0
- drowse_ai-5.3.1.dist-info/licenses/LICENSE +661 -0
- drowse_ai-5.3.1.dist-info/top_level.txt +1 -0
drowse/core/model.py
ADDED
|
@@ -0,0 +1,1724 @@
|
|
|
1
|
+
"""Model loading utilities for activation steering."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import stat
|
|
8
|
+
import threading
|
|
9
|
+
import warnings
|
|
10
|
+
import weakref
|
|
11
|
+
from contextlib import contextmanager, suppress
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from pathlib import Path, PureWindowsPath
|
|
14
|
+
from typing import Any, Callable, Iterable, Iterator, cast
|
|
15
|
+
|
|
16
|
+
import torch
|
|
17
|
+
import torch.nn as nn
|
|
18
|
+
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
|
19
|
+
from transformers import PreTrainedModel, PreTrainedTokenizerBase
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
_ORIG_HISTC = None
|
|
24
|
+
_ORIG_LDEXP = None
|
|
25
|
+
_MODEL_FILE_HASH_CACHE_MAX = 4096
|
|
26
|
+
_MODEL_FILE_HASH_CACHE: dict[str, tuple[int, int, int, int, int, str]] = {}
|
|
27
|
+
_MODEL_FINGERPRINT_CACHE: "weakref.WeakKeyDictionary[Any, tuple[object, str, str]]" = (
|
|
28
|
+
weakref.WeakKeyDictionary()
|
|
29
|
+
)
|
|
30
|
+
_MODEL_FINGERPRINT_LOCK = threading.Lock()
|
|
31
|
+
_MODEL_LOAD_LOCK = threading.RLock()
|
|
32
|
+
_SOURCE_FINGERPRINT_VERSION = 1
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _model_state_signature(model: Any) -> object:
|
|
36
|
+
"""Cheap mutation signature for memoizing an exact loaded-state digest."""
|
|
37
|
+
config = getattr(model, "config", None)
|
|
38
|
+
config_payload = (
|
|
39
|
+
config.to_dict() if config is not None and hasattr(config, "to_dict")
|
|
40
|
+
else repr(config)
|
|
41
|
+
)
|
|
42
|
+
rows: list[tuple[object, ...]] = []
|
|
43
|
+
named_parameters = getattr(model, "named_parameters", None)
|
|
44
|
+
parameter_rows: Any
|
|
45
|
+
if callable(named_parameters):
|
|
46
|
+
parameter_rows = named_parameters()
|
|
47
|
+
else:
|
|
48
|
+
parameters = getattr(model, "parameters", None)
|
|
49
|
+
parameters_any: Any = parameters
|
|
50
|
+
parameter_rows = (
|
|
51
|
+
(
|
|
52
|
+
(str(index), tensor)
|
|
53
|
+
for index, tensor in enumerate(
|
|
54
|
+
cast(Iterable[Any], parameters_any())
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
if callable(parameters_any) else ()
|
|
58
|
+
)
|
|
59
|
+
named_buffers = getattr(model, "named_buffers", None)
|
|
60
|
+
buffer_rows: Any = named_buffers() if callable(named_buffers) else ()
|
|
61
|
+
for kind, tensors in (
|
|
62
|
+
("parameter", parameter_rows),
|
|
63
|
+
("buffer", buffer_rows),
|
|
64
|
+
):
|
|
65
|
+
for name, tensor in tensors:
|
|
66
|
+
try:
|
|
67
|
+
pointer = int(tensor.data_ptr())
|
|
68
|
+
except (RuntimeError, TypeError, AttributeError):
|
|
69
|
+
pointer = id(tensor)
|
|
70
|
+
rows.append((
|
|
71
|
+
kind, name, tuple(int(dim) for dim in tensor.shape),
|
|
72
|
+
str(tensor.dtype), str(tensor.device), pointer,
|
|
73
|
+
int(getattr(tensor, "_version", 0)),
|
|
74
|
+
))
|
|
75
|
+
return (
|
|
76
|
+
hashlib.sha256(json.dumps(
|
|
77
|
+
config_payload, sort_keys=True, separators=(",", ":"), default=str,
|
|
78
|
+
).encode("utf-8")).hexdigest(),
|
|
79
|
+
tuple(rows),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def invalidate_loaded_model_fingerprint(model: Any) -> None:
|
|
84
|
+
"""Mark out-of-band weight/storage mutation before persistent-cache use.
|
|
85
|
+
|
|
86
|
+
Drowse-owned models are immutable after load; steering is per-call and does
|
|
87
|
+
not mutate parameters. Integrations that replace adapters or write through
|
|
88
|
+
``Tensor.data`` must call this hook because those writes can bypass
|
|
89
|
+
PyTorch's tensor ``_version`` counter.
|
|
90
|
+
"""
|
|
91
|
+
base = getattr(model, "_orig_mod", model)
|
|
92
|
+
setattr(base, "_drowse_state_invalidated", True)
|
|
93
|
+
with _MODEL_FINGERPRINT_LOCK:
|
|
94
|
+
_MODEL_FINGERPRINT_CACHE.pop(base, None)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _local_model_files(path: Path) -> list[tuple[str, int, str]]:
|
|
98
|
+
"""Exact local checkpoint/config identity with process-local hash reuse."""
|
|
99
|
+
if not path.is_dir():
|
|
100
|
+
return []
|
|
101
|
+
from drowse.io.integrity import hash_file
|
|
102
|
+
|
|
103
|
+
found: dict[str, Path] = {}
|
|
104
|
+
ignored_parts = {".git", ".locks", "__pycache__"}
|
|
105
|
+
for file_path in path.rglob("*"):
|
|
106
|
+
relative_path = file_path.relative_to(path)
|
|
107
|
+
if (
|
|
108
|
+
file_path.is_file()
|
|
109
|
+
and not any(part in ignored_parts for part in relative_path.parts)
|
|
110
|
+
and file_path.suffix not in {".lock", ".tmp", ".pyc"}
|
|
111
|
+
):
|
|
112
|
+
# trust_remote_code and custom tokenizers may consume arbitrary
|
|
113
|
+
# adjacent resources. A filename whitelist cannot prove source
|
|
114
|
+
# identity; hash every stable regular snapshot file instead.
|
|
115
|
+
found[str(relative_path)] = file_path
|
|
116
|
+
result: list[tuple[str, int, str]] = []
|
|
117
|
+
for relative, file_path in sorted(found.items()):
|
|
118
|
+
stat = file_path.stat()
|
|
119
|
+
key = str(file_path.resolve())
|
|
120
|
+
cached = _MODEL_FILE_HASH_CACHE.pop(key, None)
|
|
121
|
+
# Size+mtime can be restored after an in-place same-size rewrite.
|
|
122
|
+
# ctime catches that rewrite; device+inode also distinguish atomic
|
|
123
|
+
# replacement at the same path without forcing another full hash when
|
|
124
|
+
# the snapshot is genuinely unchanged.
|
|
125
|
+
identity = (
|
|
126
|
+
int(stat.st_size), int(stat.st_mtime_ns), int(stat.st_ctime_ns),
|
|
127
|
+
int(stat.st_dev), int(stat.st_ino),
|
|
128
|
+
)
|
|
129
|
+
if cached is not None and cached[:-1] == identity:
|
|
130
|
+
file_hash = cached[-1]
|
|
131
|
+
_MODEL_FILE_HASH_CACHE[key] = cached
|
|
132
|
+
else:
|
|
133
|
+
file_hash = hash_file(file_path)
|
|
134
|
+
while len(_MODEL_FILE_HASH_CACHE) >= _MODEL_FILE_HASH_CACHE_MAX:
|
|
135
|
+
_MODEL_FILE_HASH_CACHE.pop(next(iter(_MODEL_FILE_HASH_CACHE)))
|
|
136
|
+
_MODEL_FILE_HASH_CACHE[key] = (*identity, file_hash)
|
|
137
|
+
result.append((relative, int(stat.st_size), file_hash))
|
|
138
|
+
return result
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def resolve_model_revision(model_id: str) -> str | None:
|
|
142
|
+
"""The immutable Hub commit ``model_id``'s default branch points to.
|
|
143
|
+
|
|
144
|
+
Transformers 5.18 stopped recording the resolved commit on configs (it
|
|
145
|
+
drops ``_commit_hash`` at construction), so Drowse resolves it itself and
|
|
146
|
+
pins every later read to it. Online this asks the Hub and records the
|
|
147
|
+
ref in the cache; offline ``huggingface_hub`` answers from that cached
|
|
148
|
+
ref. A local directory has no commit (it is identified by file hashes)
|
|
149
|
+
and returns ``None``. Hub failures propagate — a missing, gated, or
|
|
150
|
+
unreachable repo raises with ``huggingface_hub``'s own message.
|
|
151
|
+
"""
|
|
152
|
+
if Path(model_id).expanduser().is_dir():
|
|
153
|
+
return None
|
|
154
|
+
from huggingface_hub import HfApi
|
|
155
|
+
|
|
156
|
+
return str(HfApi().resolve_revision(model_id).resolved)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _pinned_revision(model_id: str) -> str | None:
|
|
160
|
+
""":func:`resolve_model_revision`, failing open to an unpinned read."""
|
|
161
|
+
try:
|
|
162
|
+
return resolve_model_revision(model_id)
|
|
163
|
+
except Exception:
|
|
164
|
+
# Transformers' own resolver fails open the same way: the config read
|
|
165
|
+
# that follows reports the repo problem in its own words, or serves
|
|
166
|
+
# an already-cached snapshot.
|
|
167
|
+
return None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def model_source_fingerprint(
|
|
171
|
+
model_id: str, *, quantize: str | None = None, device: str = "auto",
|
|
172
|
+
dtype: torch.dtype | str | None = None, config: Any | None = None,
|
|
173
|
+
revision: str | None = None,
|
|
174
|
+
parameter_dtype: torch.dtype | str | None = None,
|
|
175
|
+
) -> str | None:
|
|
176
|
+
"""Pre-load-verifiable identity for a checkpoint and load representation.
|
|
177
|
+
|
|
178
|
+
Hub models are pinned by the resolved immutable commit; local models by
|
|
179
|
+
exact checkpoint/config/tokenizer file hashes. ``None`` means the source
|
|
180
|
+
cannot be proven without loading weights, so callers must decline any
|
|
181
|
+
metadata-only cache shortcut.
|
|
182
|
+
|
|
183
|
+
``config`` and ``revision`` describe one snapshot: the loader passes both
|
|
184
|
+
from its plan; a preflight passes neither, and the commit is resolved
|
|
185
|
+
here with the config read pinned to it.
|
|
186
|
+
|
|
187
|
+
The hashed config payload is canonicalized to the *post-load* view: on the
|
|
188
|
+
multimodal text-extraction path the load mutates the plan config in place
|
|
189
|
+
(``_materialize_model`` fills ``text_config._name_or_path`` and
|
|
190
|
+
``from_config`` writes the load dtype onto ``text_config``), and
|
|
191
|
+
``_finalize_model`` stamps from that mutated object. Applying the same
|
|
192
|
+
two writes to the payload dict here is a no-op on the stamp side and makes
|
|
193
|
+
a pre-load recompute reproduce the stamp, so metadata-only preflights can
|
|
194
|
+
prove identity without loading weights.
|
|
195
|
+
"""
|
|
196
|
+
try:
|
|
197
|
+
resolved_device = detect_device(device)
|
|
198
|
+
effective_quantize = quantize if resolved_device == "cuda" else None
|
|
199
|
+
resolved_load_dtype = _resolve_dtype(dtype, resolved_device)
|
|
200
|
+
if config is None:
|
|
201
|
+
if revision is None:
|
|
202
|
+
revision = _pinned_revision(model_id)
|
|
203
|
+
config = AutoConfig.from_pretrained(
|
|
204
|
+
model_id, trust_remote_code=False,
|
|
205
|
+
**({"revision": revision} if revision else {}),
|
|
206
|
+
)
|
|
207
|
+
resolved_commit = revision
|
|
208
|
+
requested_path = Path(model_id).expanduser()
|
|
209
|
+
raw_config_path = str(getattr(config, "_name_or_path", "")).strip()
|
|
210
|
+
config_path = Path(raw_config_path).expanduser() if raw_config_path else None
|
|
211
|
+
local_path = requested_path if requested_path.is_dir() else config_path
|
|
212
|
+
local_files = _local_model_files(local_path) if local_path is not None else []
|
|
213
|
+
if not resolved_commit and not local_files:
|
|
214
|
+
return None
|
|
215
|
+
effective_dtype = str(
|
|
216
|
+
parameter_dtype
|
|
217
|
+
if parameter_dtype is not None
|
|
218
|
+
else (
|
|
219
|
+
"quantized" if effective_quantize is not None
|
|
220
|
+
else resolved_load_dtype
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
canonical_id = (
|
|
224
|
+
str(requested_path.resolve()) if requested_path.exists() else model_id
|
|
225
|
+
)
|
|
226
|
+
config_payload: dict[str, Any] = (
|
|
227
|
+
config.to_dict() if hasattr(config, "to_dict")
|
|
228
|
+
else {"model_type": getattr(config, "model_type", None)}
|
|
229
|
+
)
|
|
230
|
+
text_cfg = getattr(config, "text_config", None)
|
|
231
|
+
text_payload = config_payload.get("text_config")
|
|
232
|
+
if (
|
|
233
|
+
text_cfg is not None
|
|
234
|
+
and getattr(text_cfg, "model_type", None) in _LAYER_ACCESSORS
|
|
235
|
+
and isinstance(text_payload, dict)
|
|
236
|
+
):
|
|
237
|
+
# Same predicate as ``LoadPlan.extract_text_model``: this config
|
|
238
|
+
# takes the text-extraction path, whose in-place plan-config
|
|
239
|
+
# mutations the canonical payload must carry (see docstring).
|
|
240
|
+
# The extraction always hands ``from_config`` the plan-resolved
|
|
241
|
+
# dtype, even under quantization.
|
|
242
|
+
if not text_payload.get("_name_or_path"):
|
|
243
|
+
text_payload["_name_or_path"] = model_id
|
|
244
|
+
for key in ("dtype", "torch_dtype"):
|
|
245
|
+
if key in text_payload:
|
|
246
|
+
text_payload[key] = str(resolved_load_dtype).removeprefix(
|
|
247
|
+
"torch.",
|
|
248
|
+
)
|
|
249
|
+
payload = {
|
|
250
|
+
"version": _SOURCE_FINGERPRINT_VERSION,
|
|
251
|
+
"model_id": canonical_id,
|
|
252
|
+
"resolved_commit": resolved_commit,
|
|
253
|
+
"local_files": local_files,
|
|
254
|
+
"config": config_payload,
|
|
255
|
+
"quantize": effective_quantize,
|
|
256
|
+
"parameter_dtype": effective_dtype,
|
|
257
|
+
}
|
|
258
|
+
return hashlib.sha256(json.dumps(
|
|
259
|
+
payload, sort_keys=True, separators=(",", ":"), default=str,
|
|
260
|
+
).encode("utf-8")).hexdigest()
|
|
261
|
+
except (OSError, RuntimeError, ValueError, TypeError, AttributeError):
|
|
262
|
+
return None
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def config_model_shape(model_id: str) -> tuple[int, int]:
|
|
266
|
+
"""``(n_layers, hidden_dim)`` for ``model_id`` without loading weights.
|
|
267
|
+
|
|
268
|
+
Reads the published config and unwraps a multimodal ``text_config``, so the
|
|
269
|
+
numbers match what a loaded session would report — which is what every
|
|
270
|
+
weight-free preflight compares against (the SAE's covered-layer and
|
|
271
|
+
residual-width checks, the manifold fit no-op's requested-layer set).
|
|
272
|
+
Raises when the config declares neither, because a *guessed* layer count
|
|
273
|
+
would silently widen or narrow a proof.
|
|
274
|
+
"""
|
|
275
|
+
config = AutoConfig.from_pretrained(model_id, trust_remote_code=False)
|
|
276
|
+
text_config = getattr(config, "text_config", config)
|
|
277
|
+
n_layers = getattr(
|
|
278
|
+
text_config, "num_hidden_layers", getattr(text_config, "n_layer", None),
|
|
279
|
+
)
|
|
280
|
+
hidden = getattr(
|
|
281
|
+
text_config, "hidden_size", getattr(text_config, "n_embd", None),
|
|
282
|
+
)
|
|
283
|
+
if not isinstance(n_layers, int) or isinstance(n_layers, bool):
|
|
284
|
+
raise ValueError(f"{model_id} config declares no layer count")
|
|
285
|
+
if not isinstance(hidden, int) or isinstance(hidden, bool):
|
|
286
|
+
raise ValueError(f"{model_id} config declares no hidden size")
|
|
287
|
+
return int(n_layers), int(hidden)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def workspace_layer_indices(
|
|
291
|
+
candidates: "list[int] | range", n_layers: int,
|
|
292
|
+
) -> list[int]:
|
|
293
|
+
"""Canonical 40–90% workspace-band filter with shallow-model fallback."""
|
|
294
|
+
available = [int(layer) for layer in candidates]
|
|
295
|
+
band = [
|
|
296
|
+
layer for layer in available
|
|
297
|
+
if 0.40 <= layer / max(n_layers - 1, 1) <= 0.90
|
|
298
|
+
]
|
|
299
|
+
return band or available
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def loaded_model_fingerprint(model: Any, model_id: str) -> str:
|
|
303
|
+
"""Stable cache identity for the weights loaded under ``model_id``.
|
|
304
|
+
|
|
305
|
+
A Hugging Face id alone is mutable (and local paths are more so). Fold the
|
|
306
|
+
resolved config/commit and exact local shard hashes together with distributed
|
|
307
|
+
samples from *every* exposed parameter. When neither immutable source exists
|
|
308
|
+
(an in-memory/opaque model), stream an exact full-state hash in bounded host
|
|
309
|
+
chunks rather than permit an unprovable persistent cache hit.
|
|
310
|
+
"""
|
|
311
|
+
base = getattr(model, "_orig_mod", model)
|
|
312
|
+
config = getattr(base, "config", getattr(model, "config", None))
|
|
313
|
+
config_payload = (
|
|
314
|
+
config.to_dict() if config is not None and hasattr(config, "to_dict")
|
|
315
|
+
else {
|
|
316
|
+
"model_type": getattr(config, "model_type", None),
|
|
317
|
+
"name_or_path": getattr(config, "_name_or_path", None),
|
|
318
|
+
"commit": getattr(config, "_commit_hash", None),
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
state_signature = _model_state_signature(base)
|
|
322
|
+
with _MODEL_FINGERPRINT_LOCK:
|
|
323
|
+
cached = _MODEL_FINGERPRINT_CACHE.get(base)
|
|
324
|
+
if cached is not None and cached[:2] == (state_signature, model_id):
|
|
325
|
+
return cached[2]
|
|
326
|
+
# ``named_*`` follows module/registration order, which is not an identity
|
|
327
|
+
# property. Some HF modules build equivalent buffer registries from sets
|
|
328
|
+
# (Gemma-3's shared rotary buffers are the live case), so two identical
|
|
329
|
+
# loads can expose the same names in a different order. Canonicalize once
|
|
330
|
+
# and reuse that ordering for both the schema and the exact-state fallback.
|
|
331
|
+
named_parameters = sorted(base.named_parameters(), key=lambda item: item[0])
|
|
332
|
+
named_buffers = sorted(base.named_buffers(), key=lambda item: item[0])
|
|
333
|
+
parameter_schema = [
|
|
334
|
+
(name, tuple(int(dim) for dim in parameter.shape), str(parameter.dtype))
|
|
335
|
+
for name, parameter in named_parameters
|
|
336
|
+
]
|
|
337
|
+
buffer_schema = [
|
|
338
|
+
(name, tuple(int(dim) for dim in buffer.shape), str(buffer.dtype))
|
|
339
|
+
for name, buffer in named_buffers
|
|
340
|
+
]
|
|
341
|
+
trusted_source = getattr(base, "_drowse_source_fingerprint", None)
|
|
342
|
+
payload = {
|
|
343
|
+
"model_id": model_id,
|
|
344
|
+
"class": f"{type(base).__module__}.{type(base).__qualname__}",
|
|
345
|
+
"config": config_payload,
|
|
346
|
+
"trusted_source": trusted_source,
|
|
347
|
+
"parameter_schema": parameter_schema,
|
|
348
|
+
"buffer_schema": buffer_schema,
|
|
349
|
+
}
|
|
350
|
+
digest = hashlib.sha256(json.dumps(
|
|
351
|
+
payload, sort_keys=True, separators=(",", ":"), default=str,
|
|
352
|
+
).encode("utf-8"))
|
|
353
|
+
loaded_signature = getattr(base, "_drowse_loaded_state_signature", None)
|
|
354
|
+
if (
|
|
355
|
+
not trusted_source
|
|
356
|
+
or state_signature != loaded_signature
|
|
357
|
+
or bool(getattr(base, "_drowse_state_invalidated", False))
|
|
358
|
+
):
|
|
359
|
+
# No trusted load provenance exists (programmatically constructed,
|
|
360
|
+
# separately initialized, externally wrapped, or mutated after drowse
|
|
361
|
+
# loaded it). Persistent reuse is safe only with an exact state hash.
|
|
362
|
+
# Stream bounded chunks instead of cloning the whole model. Clean
|
|
363
|
+
# drowse-owned loads use the exact immutable source fingerprint above.
|
|
364
|
+
tensors = named_parameters + named_buffers
|
|
365
|
+
for name, tensor in tensors:
|
|
366
|
+
digest.update(name.encode("utf-8"))
|
|
367
|
+
digest.update(str(tensor.dtype).encode("utf-8"))
|
|
368
|
+
digest.update(repr(tuple(int(d) for d in tensor.shape)).encode("utf-8"))
|
|
369
|
+
flat = tensor.detach().reshape(-1)
|
|
370
|
+
for start in range(0, flat.numel(), 1_048_576):
|
|
371
|
+
chunk = flat[start:start + 1_048_576].to(
|
|
372
|
+
device="cpu",
|
|
373
|
+
).contiguous()
|
|
374
|
+
# Byte-view preserves the original dtype bit pattern (including
|
|
375
|
+
# float64 ULPs and integer/bool buffers); float32 promotion would
|
|
376
|
+
# make distinct live states collide.
|
|
377
|
+
digest.update(chunk.view(torch.uint8).numpy().tobytes())
|
|
378
|
+
fingerprint = digest.hexdigest()
|
|
379
|
+
with _MODEL_FINGERPRINT_LOCK:
|
|
380
|
+
_MODEL_FINGERPRINT_CACHE[base] = (state_signature, model_id, fingerprint)
|
|
381
|
+
return fingerprint
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def _histc_mps_safe(input: torch.Tensor, bins: int = 100, min: float = 0, max: float = 0, *, out: torch.Tensor | None = None) -> torch.Tensor:
|
|
385
|
+
assert _ORIG_HISTC is not None
|
|
386
|
+
if input.device.type == "mps" and not input.is_floating_point():
|
|
387
|
+
input = input.float()
|
|
388
|
+
return _ORIG_HISTC(input, bins=bins, min=min, max=max, out=out)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def _ldexp_mps_safe(input: Any, other: Any, *, out: torch.Tensor | None = None) -> Any:
|
|
392
|
+
assert _ORIG_LDEXP is not None
|
|
393
|
+
if hasattr(input, "device") and input.device.type == "mps":
|
|
394
|
+
in_cpu = input.cpu()
|
|
395
|
+
other_cpu = other.cpu() if hasattr(other, "device") else other
|
|
396
|
+
res = _ORIG_LDEXP(in_cpu, other_cpu)
|
|
397
|
+
if out is not None:
|
|
398
|
+
out.copy_(res.to(out.device))
|
|
399
|
+
return out
|
|
400
|
+
return res.to(input.device)
|
|
401
|
+
return _ORIG_LDEXP(input, other, out=out) if out is not None \
|
|
402
|
+
else _ORIG_LDEXP(input, other)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
def patch_torch_for_mps() -> bool:
|
|
406
|
+
"""Install MPS-only torch workarounds lazily and idempotently.
|
|
407
|
+
|
|
408
|
+
The patches are process-global because PyTorch exposes these as module
|
|
409
|
+
functions, but drowse now installs them only when an MPS model load is
|
|
410
|
+
actually requested.
|
|
411
|
+
"""
|
|
412
|
+
global _ORIG_HISTC, _ORIG_LDEXP
|
|
413
|
+
installed = False
|
|
414
|
+
if getattr(torch.histc, "_drowse_mps_safe", False) is False:
|
|
415
|
+
_ORIG_HISTC = torch.histc
|
|
416
|
+
_histc_mps_safe._drowse_mps_safe = True # pyright: ignore[reportFunctionMemberAccess] # FunctionType stub forbids dynamic attrs
|
|
417
|
+
torch.histc = _histc_mps_safe
|
|
418
|
+
installed = True
|
|
419
|
+
if getattr(torch.ldexp, "_drowse_mps_safe", False) is False:
|
|
420
|
+
_ORIG_LDEXP = torch.ldexp
|
|
421
|
+
_ldexp_mps_safe._drowse_mps_safe = True # pyright: ignore[reportFunctionMemberAccess] # FunctionType stub forbids dynamic attrs
|
|
422
|
+
torch.ldexp = _ldexp_mps_safe
|
|
423
|
+
installed = True
|
|
424
|
+
return installed
|
|
425
|
+
|
|
426
|
+
# Layer accessors — one named ``def`` per residual-block *shape*, shared by
|
|
427
|
+
# every family that wears it. Named rather than inline lambdas so a traceback
|
|
428
|
+
# out of a wrong accessor names the shape it tried.
|
|
429
|
+
def _MODEL_LAYERS(m: Any) -> Any: return m.model.layers
|
|
430
|
+
def _TRANSFORMER_H(m: Any) -> Any: return m.transformer.h
|
|
431
|
+
def _VLM_LANGUAGE_LAYERS(m: Any) -> Any: return m.model.language_model.layers
|
|
432
|
+
def _GPT_NEOX_LAYERS(m: Any) -> Any: return m.gpt_neox.layers
|
|
433
|
+
def _TRANSFORMER_BLOCKS(m: Any) -> Any: return m.transformer.blocks
|
|
434
|
+
def _DECODER_LAYERS(m: Any) -> Any: return m.model.decoder.layers
|
|
435
|
+
def _MODEL_BLOCKS(m: Any) -> Any: return m.model.blocks
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
@dataclass(frozen=True)
|
|
439
|
+
class ArchProfile:
|
|
440
|
+
"""What drowse knows about one ``model.config.model_type``.
|
|
441
|
+
|
|
442
|
+
``layers`` is the accessor returning the sequential residual blocks;
|
|
443
|
+
``tested`` marks an architecture with end-to-end coverage (smoke +
|
|
444
|
+
session). Everything else in the registry is wired up optimistically —
|
|
445
|
+
it may work, but has not been exercised, and :func:`get_layers` warns
|
|
446
|
+
once on load.
|
|
447
|
+
|
|
448
|
+
Both facts live on one entry so a "tested" architecture with no accessor
|
|
449
|
+
is unrepresentable. As two tables it was representable and it happened:
|
|
450
|
+
``mistral3`` sat in the tested set with no accessor, which made the entry
|
|
451
|
+
dead (``get_layers`` raises on the missing accessor before ever reaching
|
|
452
|
+
the tested check) while the type a Mistral-3 checkpoint actually loads as
|
|
453
|
+
— its ``mistral`` text sub-model — went unmarked and warned on every load.
|
|
454
|
+
"""
|
|
455
|
+
|
|
456
|
+
layers: Callable[[Any], Any]
|
|
457
|
+
tested: bool = False
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def _prof(accessor: Callable[[Any], Any], *, tested: bool = False) -> ArchProfile:
|
|
461
|
+
return ArchProfile(layers=accessor, tested=tested)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
_ARCH_PROFILES: dict[str, ArchProfile] = {
|
|
465
|
+
# Llama family
|
|
466
|
+
"llama": _prof(_MODEL_LAYERS, tested=True),
|
|
467
|
+
"llama4": _prof(_MODEL_LAYERS),
|
|
468
|
+
"llama4_text": _prof(_MODEL_LAYERS),
|
|
469
|
+
# Mistral / Mixtral / Ministral. ``mistral`` is tested because that is
|
|
470
|
+
# what a Mistral-Small-3 checkpoint ends up as: the composite ``mistral3``
|
|
471
|
+
# config carries ``text_config.model_type == "mistral"``, so
|
|
472
|
+
# ``extract_text_model`` fires and the loaded model reports ``mistral``.
|
|
473
|
+
# There is deliberately no ``mistral3`` entry — the composite type never
|
|
474
|
+
# reaches ``get_layers``.
|
|
475
|
+
"mistral": _prof(_MODEL_LAYERS, tested=True),
|
|
476
|
+
"mistral4": _prof(_MODEL_LAYERS),
|
|
477
|
+
"ministral": _prof(_MODEL_LAYERS),
|
|
478
|
+
# Ministral-3 has no ``text_config``, so no extraction happens and the
|
|
479
|
+
# composite type is what loads.
|
|
480
|
+
"ministral3": _prof(_MODEL_LAYERS, tested=True),
|
|
481
|
+
"mixtral": _prof(_MODEL_LAYERS),
|
|
482
|
+
# Gemma family
|
|
483
|
+
"gemma": _prof(_MODEL_LAYERS),
|
|
484
|
+
"gemma2": _prof(_MODEL_LAYERS, tested=True),
|
|
485
|
+
"gemma3": _prof(_VLM_LANGUAGE_LAYERS, tested=True),
|
|
486
|
+
"gemma3_text": _prof(_MODEL_LAYERS, tested=True),
|
|
487
|
+
"gemma4": _prof(_VLM_LANGUAGE_LAYERS, tested=True),
|
|
488
|
+
"gemma4_text": _prof(_MODEL_LAYERS, tested=True),
|
|
489
|
+
# Gemma-4 "unified" variant (gemma-4-12B-it, 2026-06): a multimodal
|
|
490
|
+
# wrapper whose text submodel weights live under model.language_model.*,
|
|
491
|
+
# so the VLM accessor + text-extraction prefix-strip both apply as-is.
|
|
492
|
+
"gemma4_unified": _prof(_VLM_LANGUAGE_LAYERS, tested=True),
|
|
493
|
+
"gemma4_unified_text": _prof(_MODEL_LAYERS, tested=True),
|
|
494
|
+
"recurrent_gemma": _prof(_MODEL_LAYERS),
|
|
495
|
+
# Phi family
|
|
496
|
+
"phi": _prof(_MODEL_LAYERS),
|
|
497
|
+
"phi3": _prof(_MODEL_LAYERS),
|
|
498
|
+
"phimoe": _prof(_MODEL_LAYERS),
|
|
499
|
+
# Qwen family
|
|
500
|
+
"qwen": _prof(_TRANSFORMER_H),
|
|
501
|
+
"qwen2": _prof(_MODEL_LAYERS, tested=True),
|
|
502
|
+
"qwen2_moe": _prof(_MODEL_LAYERS),
|
|
503
|
+
"qwen3": _prof(_MODEL_LAYERS, tested=True),
|
|
504
|
+
"qwen3_moe": _prof(_MODEL_LAYERS),
|
|
505
|
+
"qwen3_5": _prof(_MODEL_LAYERS, tested=True),
|
|
506
|
+
"qwen3_5_text": _prof(_MODEL_LAYERS, tested=True),
|
|
507
|
+
"qwen3_5_moe": _prof(_MODEL_LAYERS, tested=True),
|
|
508
|
+
# Cohere (Command-R)
|
|
509
|
+
"cohere": _prof(_MODEL_LAYERS),
|
|
510
|
+
"cohere2": _prof(_MODEL_LAYERS),
|
|
511
|
+
# DeepSeek
|
|
512
|
+
"deepseek_v2": _prof(_MODEL_LAYERS),
|
|
513
|
+
"deepseek_v3": _prof(_MODEL_LAYERS),
|
|
514
|
+
# Starcoder
|
|
515
|
+
"starcoder2": _prof(_MODEL_LAYERS),
|
|
516
|
+
# OLMo
|
|
517
|
+
"olmo": _prof(_MODEL_LAYERS),
|
|
518
|
+
"olmo2": _prof(_MODEL_LAYERS),
|
|
519
|
+
"olmo3": _prof(_MODEL_LAYERS),
|
|
520
|
+
"olmoe": _prof(_MODEL_LAYERS),
|
|
521
|
+
# GLM (ChatGLM)
|
|
522
|
+
"glm": _prof(_MODEL_LAYERS, tested=True),
|
|
523
|
+
"glm4": _prof(_MODEL_LAYERS),
|
|
524
|
+
"glm4_moe_lite": _prof(_MODEL_LAYERS),
|
|
525
|
+
# Granite (IBM)
|
|
526
|
+
"granite": _prof(_MODEL_LAYERS),
|
|
527
|
+
"granitemoe": _prof(_MODEL_LAYERS),
|
|
528
|
+
# NVIDIA
|
|
529
|
+
"nemotron": _prof(_MODEL_LAYERS),
|
|
530
|
+
# StableLM
|
|
531
|
+
"stablelm": _prof(_MODEL_LAYERS),
|
|
532
|
+
# GPT-2 family
|
|
533
|
+
"gpt2": _prof(_TRANSFORMER_H),
|
|
534
|
+
"gpt_neo": _prof(_TRANSFORMER_H),
|
|
535
|
+
"gptj": _prof(_TRANSFORMER_H),
|
|
536
|
+
"gpt_bigcode": _prof(_TRANSFORMER_H),
|
|
537
|
+
# Bloom / Falcon
|
|
538
|
+
"bloom": _prof(_TRANSFORMER_H),
|
|
539
|
+
"falcon": _prof(_TRANSFORMER_H),
|
|
540
|
+
"falcon_h1": _prof(_MODEL_LAYERS),
|
|
541
|
+
# GPT-NeoX / Pythia / GPT-OSS
|
|
542
|
+
"gpt_neox": _prof(_GPT_NEOX_LAYERS),
|
|
543
|
+
"gpt_oss": _prof(_MODEL_LAYERS, tested=True),
|
|
544
|
+
# MPT / DBRX
|
|
545
|
+
"mpt": _prof(_TRANSFORMER_BLOCKS),
|
|
546
|
+
"dbrx": _prof(_TRANSFORMER_BLOCKS),
|
|
547
|
+
# OPT
|
|
548
|
+
"opt": _prof(_DECODER_LAYERS),
|
|
549
|
+
# Talkie (vintage pre-1931 model; embedding-skip + per-block actgain decoder)
|
|
550
|
+
"talkie": _prof(_MODEL_BLOCKS, tested=True),
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
# Views over the one registry — the lookup shapes call sites already speak.
|
|
554
|
+
_LAYER_ACCESSORS: dict[str, Callable[[Any], Any]] = {
|
|
555
|
+
model_type: profile.layers for model_type, profile in _ARCH_PROFILES.items()
|
|
556
|
+
}
|
|
557
|
+
_SUPPORTED_TYPES = sorted(_ARCH_PROFILES)
|
|
558
|
+
_TESTED_ARCHS: frozenset[str] = frozenset(
|
|
559
|
+
model_type for model_type, profile in _ARCH_PROFILES.items() if profile.tested
|
|
560
|
+
)
|
|
561
|
+
_warned: set[str] = set()
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
_FP8_DTYPES = (torch.float8_e4m3fn, torch.float8_e5m2,
|
|
565
|
+
torch.float8_e4m3fnuz, torch.float8_e5m2fnuz)
|
|
566
|
+
|
|
567
|
+
# safetensors dtype tag -> torch dtype, for the manual (mmap-free) reader.
|
|
568
|
+
_ST_DTYPES: dict[str, torch.dtype] = {
|
|
569
|
+
"F64": torch.float64, "F32": torch.float32, "F16": torch.float16,
|
|
570
|
+
"BF16": torch.bfloat16, "I64": torch.int64, "I32": torch.int32,
|
|
571
|
+
"I16": torch.int16, "I8": torch.int8, "U8": torch.uint8,
|
|
572
|
+
"BOOL": torch.bool, "F8_E4M3": torch.float8_e4m3fn, "F8_E5M2": torch.float8_e5m2,
|
|
573
|
+
}
|
|
574
|
+
_ST_DTYPE_BITS = {
|
|
575
|
+
"F4": 4, "F6_E2M3": 6, "F6_E3M2": 6,
|
|
576
|
+
"BOOL": 8, "U8": 8, "I8": 8, "F8_E4M3": 8, "F8_E5M2": 8,
|
|
577
|
+
"F8_E8M0": 8, "F8_E4M3FNUZ": 8, "F8_E5M2FNUZ": 8,
|
|
578
|
+
"I16": 16, "U16": 16, "F16": 16, "BF16": 16,
|
|
579
|
+
"I32": 32, "U32": 32, "F32": 32,
|
|
580
|
+
"I64": 64, "U64": 64, "F64": 64, "C64": 64,
|
|
581
|
+
}
|
|
582
|
+
_ST_HEADER_MAX_BYTES = 100_000_000
|
|
583
|
+
_CHECKPOINT_INDEX_MAX_BYTES = 64 * 1024 * 1024
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
def _checkpoint_json(raw: bytes) -> Any:
|
|
587
|
+
def unique_keys(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
|
|
588
|
+
result: dict[str, Any] = {}
|
|
589
|
+
for key, value in pairs:
|
|
590
|
+
if key in result:
|
|
591
|
+
raise ValueError(f"duplicate checkpoint metadata key {key!r}")
|
|
592
|
+
result[key] = value
|
|
593
|
+
return result
|
|
594
|
+
|
|
595
|
+
return json.loads(raw, object_pairs_hook=unique_keys)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def _checkpoint_shard_names(index_path: str) -> list[str]:
|
|
599
|
+
with os.fdopen(_open_uncached(index_path), "rb") as handle:
|
|
600
|
+
raw = handle.read(_CHECKPOINT_INDEX_MAX_BYTES + 1)
|
|
601
|
+
if len(raw) > _CHECKPOINT_INDEX_MAX_BYTES:
|
|
602
|
+
raise ValueError("checkpoint shard index exceeds the metadata limit")
|
|
603
|
+
index = _checkpoint_json(raw)
|
|
604
|
+
weight_map = index.get("weight_map") if isinstance(index, dict) else None
|
|
605
|
+
if not isinstance(weight_map, dict) or not weight_map:
|
|
606
|
+
raise ValueError("checkpoint shard index requires a non-empty weight_map")
|
|
607
|
+
names: set[str] = set()
|
|
608
|
+
for name in weight_map.values():
|
|
609
|
+
if (
|
|
610
|
+
not isinstance(name, str) or not name.endswith(".safetensors")
|
|
611
|
+
or "\\" in name or "\x00" in name or PureWindowsPath(name).drive
|
|
612
|
+
or any(part in {"", ".", ".."} for part in name.split("/"))
|
|
613
|
+
):
|
|
614
|
+
raise ValueError(f"unsafe checkpoint shard name {name!r}")
|
|
615
|
+
names.add(name)
|
|
616
|
+
return sorted(names)
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
def _read_safetensors_header(path: str) -> tuple[dict[str, Any], int]:
|
|
620
|
+
"""Parse a safetensors header: ``(tensor_metadata, data_section_offset)``.
|
|
621
|
+
|
|
622
|
+
The format is an 8-byte little-endian header length, that many bytes
|
|
623
|
+
of JSON (name → ``{dtype, shape, data_offsets}``), then the packed
|
|
624
|
+
tensor data. The ``__metadata__`` entry is dropped.
|
|
625
|
+
"""
|
|
626
|
+
with os.fdopen(_open_uncached(path), "rb") as f:
|
|
627
|
+
file_size = os.fstat(f.fileno()).st_size
|
|
628
|
+
prefix = f.read(8)
|
|
629
|
+
n = int.from_bytes(prefix, "little")
|
|
630
|
+
if len(prefix) != 8 or not 0 < n <= _ST_HEADER_MAX_BYTES or n > file_size - 8:
|
|
631
|
+
raise ValueError("invalid or oversized safetensors header")
|
|
632
|
+
header = _checkpoint_json(f.read(n))
|
|
633
|
+
if not isinstance(header, dict):
|
|
634
|
+
raise ValueError("safetensors header must be an object")
|
|
635
|
+
header.pop("__metadata__", None)
|
|
636
|
+
data_bytes = file_size - 8 - n
|
|
637
|
+
intervals = []
|
|
638
|
+
for name, meta in header.items():
|
|
639
|
+
if not isinstance(meta, dict) or set(meta) != {"dtype", "shape", "data_offsets"}:
|
|
640
|
+
raise ValueError(f"invalid safetensors metadata for {name!r}")
|
|
641
|
+
dtype, shape, offsets = meta["dtype"], meta["shape"], meta["data_offsets"]
|
|
642
|
+
if (
|
|
643
|
+
not isinstance(dtype, str) or dtype not in _ST_DTYPE_BITS
|
|
644
|
+
or not isinstance(shape, list)
|
|
645
|
+
or any(type(dim) is not int or not 0 <= dim < 2**64 for dim in shape)
|
|
646
|
+
or not isinstance(offsets, list) or len(offsets) != 2
|
|
647
|
+
or any(type(offset) is not int for offset in offsets)
|
|
648
|
+
):
|
|
649
|
+
raise ValueError(f"invalid safetensors shape/dtype/offsets for {name!r}")
|
|
650
|
+
start, end = offsets
|
|
651
|
+
expected_bits = 0 if 0 in shape else _ST_DTYPE_BITS[dtype]
|
|
652
|
+
for dim in shape:
|
|
653
|
+
expected_bits *= dim
|
|
654
|
+
if expected_bits > data_bytes * 8:
|
|
655
|
+
raise ValueError(f"invalid safetensors byte extent for {name!r}")
|
|
656
|
+
if (
|
|
657
|
+
not 0 <= start <= end <= data_bytes or expected_bits % 8
|
|
658
|
+
or end - start != expected_bits // 8
|
|
659
|
+
):
|
|
660
|
+
raise ValueError(f"invalid safetensors byte extent for {name!r}")
|
|
661
|
+
intervals.append((start, end))
|
|
662
|
+
cursor = 0
|
|
663
|
+
for start, end in sorted(intervals):
|
|
664
|
+
if start != cursor:
|
|
665
|
+
raise ValueError("safetensors data has overlapping or non-contiguous tensors")
|
|
666
|
+
cursor = end
|
|
667
|
+
if cursor != data_bytes:
|
|
668
|
+
raise ValueError("safetensors data does not match its declared tensors")
|
|
669
|
+
return header, 8 + n
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def _open_uncached(path: str) -> int:
|
|
673
|
+
"""Open ``path`` read-only, asking the OS not to cache its pages.
|
|
674
|
+
|
|
675
|
+
On Apple Silicon the page cache shares the same physical RAM as MPS,
|
|
676
|
+
so mmap-reading a 62 GB checkpoint fills the cache *on top of* the
|
|
677
|
+
61 GB on-device model — ~2× the model size, which forces the unified
|
|
678
|
+
pool into compression/swap. ``F_NOCACHE`` (macOS) reads straight
|
|
679
|
+
through without populating the unified buffer cache, holding the
|
|
680
|
+
host-side transient to a single tensor. Elsewhere the page cache is
|
|
681
|
+
reclaimable and doesn't compete with discrete VRAM, so a plain fd is
|
|
682
|
+
fine.
|
|
683
|
+
"""
|
|
684
|
+
import os
|
|
685
|
+
import sys
|
|
686
|
+
fd = os.open(path, os.O_RDONLY | getattr(os, "O_NONBLOCK", 0))
|
|
687
|
+
try:
|
|
688
|
+
if not stat.S_ISREG(os.fstat(fd).st_mode):
|
|
689
|
+
raise ValueError(f"checkpoint {path!r} is not a regular file")
|
|
690
|
+
except BaseException:
|
|
691
|
+
os.close(fd)
|
|
692
|
+
raise
|
|
693
|
+
if sys.platform == "darwin":
|
|
694
|
+
import fcntl
|
|
695
|
+
with suppress(OSError):
|
|
696
|
+
fcntl.fcntl(fd, fcntl.F_NOCACHE, 1)
|
|
697
|
+
return fd
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
def _read_st_tensor(fd: int, header: dict[str, Any], data_start: int, name: str) -> torch.Tensor:
|
|
701
|
+
"""Read one tensor by name from an already-open safetensors fd.
|
|
702
|
+
|
|
703
|
+
``pread`` at the tensor's recorded offset, wrap the bytes as a CPU
|
|
704
|
+
tensor (zero-copy view of the freshly-read buffer), reshape. No mmap,
|
|
705
|
+
so with an :func:`_open_uncached` fd the bytes never enter the page
|
|
706
|
+
cache.
|
|
707
|
+
"""
|
|
708
|
+
import os
|
|
709
|
+
import warnings
|
|
710
|
+
meta = header[name]
|
|
711
|
+
dtype = _ST_DTYPES.get(meta["dtype"])
|
|
712
|
+
if dtype is None:
|
|
713
|
+
raise ValueError(f"unsupported safetensors dtype {meta['dtype']!r} for selected tensor {name!r}")
|
|
714
|
+
start, end = meta["data_offsets"]
|
|
715
|
+
nbytes = end - start
|
|
716
|
+
offset = data_start + start
|
|
717
|
+
# A single pread can't exceed INT_MAX bytes on macOS (EINVAL), and a
|
|
718
|
+
# bf16 embedding is ~2.8 GB, so read in capped chunks.
|
|
719
|
+
_CHUNK = 1 << 28 # 256 MiB
|
|
720
|
+
chunks: list[bytes] = []
|
|
721
|
+
got = 0
|
|
722
|
+
while got < nbytes:
|
|
723
|
+
block = os.pread(fd, min(_CHUNK, nbytes - got), offset + got)
|
|
724
|
+
if not block:
|
|
725
|
+
break
|
|
726
|
+
chunks.append(block)
|
|
727
|
+
got += len(block)
|
|
728
|
+
if got != nbytes:
|
|
729
|
+
raise ValueError(f"safetensors tensor {name!r} is truncated")
|
|
730
|
+
if nbytes == 0:
|
|
731
|
+
return torch.empty(meta["shape"], dtype=dtype)
|
|
732
|
+
buf = chunks[0] if len(chunks) == 1 else b"".join(chunks)
|
|
733
|
+
with warnings.catch_warnings():
|
|
734
|
+
warnings.simplefilter("ignore") # frombuffer warns on read-only bytes
|
|
735
|
+
flat = torch.frombuffer(buf, dtype=dtype)
|
|
736
|
+
return flat.reshape(meta["shape"])
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
class _NoTextWeightsExtracted(RuntimeError):
|
|
740
|
+
"""No text-model weights matched the ``language_model.`` layout.
|
|
741
|
+
|
|
742
|
+
Raised by :func:`_load_text_from_multimodal` so the caller can fall
|
|
743
|
+
back to a standard full-model load rather than return a model full of
|
|
744
|
+
random initialization.
|
|
745
|
+
"""
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
def _load_text_from_multimodal(
|
|
749
|
+
model_id: str,
|
|
750
|
+
text_config: Any,
|
|
751
|
+
dtype: torch.dtype,
|
|
752
|
+
device: str,
|
|
753
|
+
revision: str | None = None,
|
|
754
|
+
):
|
|
755
|
+
"""Load just the text model from a multimodal checkpoint.
|
|
756
|
+
|
|
757
|
+
Multimodal checkpoints store the text-model weights under a
|
|
758
|
+
``language_model.`` path *segment* — either as a leading prefix
|
|
759
|
+
(Mistral-3 / Ministral: ``language_model.model.layers…``) or nested
|
|
760
|
+
inside the composite model (Gemma-3 / Gemma-4:
|
|
761
|
+
``model.language_model.layers…``). This function builds a text-only
|
|
762
|
+
model directly on the target device, then streams each safetensors
|
|
763
|
+
shard tensor-by-tensor, drops the ``language_model.`` segment to
|
|
764
|
+
recover the text model's own parameter names, dequantizes FP8
|
|
765
|
+
weights, and copies each into the preallocated parameter. A top-level
|
|
766
|
+
``lm_head`` is retained; unrelated vision tower / projector weights
|
|
767
|
+
are skipped.
|
|
768
|
+
|
|
769
|
+
Two memory disciplines matter on Apple Silicon, where CPU and MPS
|
|
770
|
+
share one unified-memory pool:
|
|
771
|
+
|
|
772
|
+
* **On-device construction** — ``from_config`` under
|
|
773
|
+
``torch.device(device)`` allocates the model once, on the target
|
|
774
|
+
device, so there is never a second full-model copy. The standard
|
|
775
|
+
``from_pretrained(device_map={"": "mps"})`` path stages the entire
|
|
776
|
+
state dict in CPU RAM *and* copies it to MPS before freeing the CPU
|
|
777
|
+
side — ~2× the model size at peak (>128 GB for gemma-4-31B).
|
|
778
|
+
* **Cache-bypassing reads** — each shard is read with ``pread`` on an
|
|
779
|
+
:func:`_open_uncached` fd (``F_NOCACHE`` on macOS) rather than
|
|
780
|
+
mmap'd via ``safe_open``. mmap would fault the whole 62 GB
|
|
781
|
+
checkpoint into the page cache, which on unified memory collides
|
|
782
|
+
with the on-device model; reading straight through holds the
|
|
783
|
+
host-side transient to a single tensor.
|
|
784
|
+
|
|
785
|
+
Raises :class:`_NoTextWeightsExtracted` if nothing matched, so the
|
|
786
|
+
caller can fall back to a full multimodal load.
|
|
787
|
+
"""
|
|
788
|
+
import gc
|
|
789
|
+
import os
|
|
790
|
+
from transformers.utils import SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME
|
|
791
|
+
from transformers.utils.hub import cached_file
|
|
792
|
+
|
|
793
|
+
# Prefer the sharded index; fall back to a single `model.safetensors`
|
|
794
|
+
# for repos that ship consolidated weights (e.g. Ministral-3-3B).
|
|
795
|
+
index_path = cached_file(
|
|
796
|
+
model_id, SAFE_WEIGHTS_INDEX_NAME, revision=revision,
|
|
797
|
+
_raise_exceptions_for_missing_entries=False,
|
|
798
|
+
)
|
|
799
|
+
if index_path is not None:
|
|
800
|
+
shard_names = _checkpoint_shard_names(index_path)
|
|
801
|
+
# Resolve each shard through cached_file so HF hub downloads it
|
|
802
|
+
# if it isn't already local (the index can land before the shards).
|
|
803
|
+
shard_paths = [
|
|
804
|
+
cached_file(model_id, name, revision=revision)
|
|
805
|
+
for name in shard_names
|
|
806
|
+
]
|
|
807
|
+
else:
|
|
808
|
+
single_path = cached_file(model_id, SAFE_WEIGHTS_NAME, revision=revision)
|
|
809
|
+
shard_paths = [single_path]
|
|
810
|
+
|
|
811
|
+
# Create directly on target device — avoids a CPU copy that would
|
|
812
|
+
# spike RSS and eat into MPS's unified memory budget.
|
|
813
|
+
with torch.device(device):
|
|
814
|
+
model = AutoModelForCausalLM.from_config(text_config, dtype=dtype)
|
|
815
|
+
|
|
816
|
+
# named_parameters de-duplicates tied storage. Nonpersistent buffers
|
|
817
|
+
# may legitimately be initialized by the model rather than the checkpoint.
|
|
818
|
+
targets: dict[str, torch.Tensor] = dict(model.named_parameters())
|
|
819
|
+
required = set(targets)
|
|
820
|
+
targets.update(model.named_buffers())
|
|
821
|
+
loaded: set[str] = set()
|
|
822
|
+
matched = 0
|
|
823
|
+
with torch.no_grad():
|
|
824
|
+
for sf in shard_paths:
|
|
825
|
+
# cached_file returns str | None; None means a missing shard —
|
|
826
|
+
# skip it. In practice the single-shard path raises before here.
|
|
827
|
+
if sf is None:
|
|
828
|
+
continue
|
|
829
|
+
header, data_start = _read_safetensors_header(sf)
|
|
830
|
+
# Read in on-disk offset order so an uncached fd still streams
|
|
831
|
+
# sequentially (no per-tensor seek thrash).
|
|
832
|
+
names = sorted(header, key=lambda nm: header[nm]["data_offsets"][0])
|
|
833
|
+
fd = _open_uncached(sf)
|
|
834
|
+
try:
|
|
835
|
+
for name in names:
|
|
836
|
+
if name in {"lm_head.weight", "lm_head.bias"}:
|
|
837
|
+
key = name
|
|
838
|
+
elif "language_model." in name:
|
|
839
|
+
# Both language_model.model.layers… and
|
|
840
|
+
# model.language_model.layers… map to model.layers….
|
|
841
|
+
key = name.replace("language_model.", "", 1)
|
|
842
|
+
else:
|
|
843
|
+
continue # vision tower / projector — skip
|
|
844
|
+
if key.endswith((".weight_scale_inv", ".activation_scale")):
|
|
845
|
+
continue
|
|
846
|
+
target = targets.get(key)
|
|
847
|
+
if target is None:
|
|
848
|
+
continue
|
|
849
|
+
if tuple(header[name]["shape"]) != tuple(target.shape):
|
|
850
|
+
raise ValueError(f"checkpoint tensor {name!r} has the wrong shape")
|
|
851
|
+
v = _read_st_tensor(fd, header, data_start, name)
|
|
852
|
+
# Dequantize FP8: real_weight = weight.to(dtype) * scale
|
|
853
|
+
if v.dtype in _FP8_DTYPES:
|
|
854
|
+
sk = name + "_scale_inv"
|
|
855
|
+
scale = (_read_st_tensor(fd, header, data_start, sk)
|
|
856
|
+
if sk in header else None)
|
|
857
|
+
v = v.to(dtype) * scale.to(dtype) if scale is not None else v.to(dtype)
|
|
858
|
+
target.copy_(v) # CPU→device cast + copy into preallocated param
|
|
859
|
+
loaded.add(key)
|
|
860
|
+
if "language_model." in name:
|
|
861
|
+
matched += 1
|
|
862
|
+
del v
|
|
863
|
+
finally:
|
|
864
|
+
os.close(fd)
|
|
865
|
+
if device == "mps":
|
|
866
|
+
torch.mps.empty_cache()
|
|
867
|
+
gc.collect()
|
|
868
|
+
|
|
869
|
+
if matched == 0:
|
|
870
|
+
raise _NoTextWeightsExtracted(
|
|
871
|
+
f"no text-model weights matched the language_model. layout in {model_id!r}"
|
|
872
|
+
)
|
|
873
|
+
missing = required - loaded
|
|
874
|
+
if missing:
|
|
875
|
+
raise ValueError(f"checkpoint is missing text-model parameters: {sorted(missing)!r}")
|
|
876
|
+
|
|
877
|
+
if device == "mps":
|
|
878
|
+
torch.mps.empty_cache()
|
|
879
|
+
|
|
880
|
+
return model
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
def _run_compile_probes(compiled: Any, model: PreTrainedModel, device: str | torch.device, bos_token_id: int, *, mode: str) -> None:
|
|
884
|
+
"""Trigger compilation of the call shapes drowse actually uses.
|
|
885
|
+
|
|
886
|
+
For ``mode="reduce-overhead"`` drowse's session generates through
|
|
887
|
+
a ``StaticCache`` with an explicit ``cache_position`` kwarg — that
|
|
888
|
+
is a *distinct dynamo call shape* from a plain DynamicCache
|
|
889
|
+
forward, so a DynamicCache probe will not surface inductor
|
|
890
|
+
codegen bugs that fire only under the static-cache path
|
|
891
|
+
(observed: ``TypeError: Pointer argument must be either uint64 or
|
|
892
|
+
have data_ptr method`` on Qwen3.5 + torch 2.12). We mimic both
|
|
893
|
+
code paths here so any per-shape codegen failure raises during
|
|
894
|
+
load, not on the user's first generation.
|
|
895
|
+
|
|
896
|
+
Each forward is single-shot — we materialize a scalar after each
|
|
897
|
+
call before releasing the output, so the CUDA-graph capture path
|
|
898
|
+
has nothing to alias even under ``mode="reduce-overhead"``. Two
|
|
899
|
+
distinct prefill lengths force dynamo's automatic-shape promotion
|
|
900
|
+
so the dynamic-shape artifact (which the user will hit) is also
|
|
901
|
+
compiled here.
|
|
902
|
+
"""
|
|
903
|
+
def _probe_dynamic(prefill_len: int) -> None:
|
|
904
|
+
ids = torch.full(
|
|
905
|
+
(1, prefill_len), bos_token_id, device=device, dtype=torch.long,
|
|
906
|
+
)
|
|
907
|
+
attn = torch.ones_like(ids)
|
|
908
|
+
out = compiled(input_ids=ids, attention_mask=attn, use_cache=True)
|
|
909
|
+
_ = out.logits[:, -1, :].argmax().item()
|
|
910
|
+
|
|
911
|
+
def _probe_static(prefill_len: int) -> None:
|
|
912
|
+
from drowse.core.static_cache import make_static_cache
|
|
913
|
+
dtype = next(model.parameters()).dtype
|
|
914
|
+
try:
|
|
915
|
+
cache = make_static_cache(
|
|
916
|
+
model, max_cache_len=prefill_len + 2,
|
|
917
|
+
device=device, dtype=dtype,
|
|
918
|
+
)
|
|
919
|
+
except Exception as cache_exc:
|
|
920
|
+
# If StaticCache can't be built for this model, the
|
|
921
|
+
# generation loop won't use it either — session
|
|
922
|
+
# construction has already gated on
|
|
923
|
+
# ``is_cuda_graphs_supported`` before settling on
|
|
924
|
+
# ``mode="reduce-overhead"``. In load_model called
|
|
925
|
+
# standalone or from incomplete mocks the gate is
|
|
926
|
+
# absent, so skip the static probe silently.
|
|
927
|
+
log.info("static-cache probe skipped: %s", cache_exc)
|
|
928
|
+
return
|
|
929
|
+
# Prefill — drowse's generation passes attention_mask on prefill.
|
|
930
|
+
ids = torch.full(
|
|
931
|
+
(1, prefill_len), bos_token_id, device=device, dtype=torch.long,
|
|
932
|
+
)
|
|
933
|
+
attn = torch.ones_like(ids)
|
|
934
|
+
cache_position = torch.arange(prefill_len, device=device)
|
|
935
|
+
out = compiled(
|
|
936
|
+
input_ids=ids, attention_mask=attn,
|
|
937
|
+
past_key_values=cache, use_cache=True,
|
|
938
|
+
cache_position=cache_position,
|
|
939
|
+
)
|
|
940
|
+
# Materialize next-token onto a fresh CPU-side tensor so the
|
|
941
|
+
# decode forward below has nothing aliased to a cudagraph
|
|
942
|
+
# buffer in ``out``.
|
|
943
|
+
next_id = int(out.logits[:, -1, :].argmax().item())
|
|
944
|
+
del out
|
|
945
|
+
# Decode — drowse passes ``attention_mask=None`` on decode steps;
|
|
946
|
+
# that is a *distinct* dynamo call signature from the prefill
|
|
947
|
+
# call, so it gets a separate compile artifact. Inductor
|
|
948
|
+
# codegen bugs that only fire under the decode-shape path
|
|
949
|
+
# (observed: Qwen3.5 + torch 2.12) won't be caught by a
|
|
950
|
+
# prefill-only probe.
|
|
951
|
+
next_ids = torch.tensor([[next_id]], device=device, dtype=torch.long)
|
|
952
|
+
cache_position = torch.tensor([prefill_len], device=device)
|
|
953
|
+
out2 = compiled(
|
|
954
|
+
input_ids=next_ids, attention_mask=None,
|
|
955
|
+
past_key_values=cache, use_cache=True,
|
|
956
|
+
cache_position=cache_position,
|
|
957
|
+
)
|
|
958
|
+
_ = out2.logits[:, -1, :].argmax().item()
|
|
959
|
+
|
|
960
|
+
# Two prefill lengths so dynamo promotes to dynamic-shape codegen.
|
|
961
|
+
for n in (2, 16):
|
|
962
|
+
_probe_dynamic(n)
|
|
963
|
+
if mode == "reduce-overhead":
|
|
964
|
+
for n in (2, 16):
|
|
965
|
+
_probe_static(n)
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
def _compile_with_probe(
|
|
969
|
+
model: PreTrainedModel,
|
|
970
|
+
tokenizer: PreTrainedTokenizerBase,
|
|
971
|
+
device: str | torch.device,
|
|
972
|
+
*,
|
|
973
|
+
mode: str = "default",
|
|
974
|
+
):
|
|
975
|
+
"""``torch.compile`` the model and verify the compiled artifact runs.
|
|
976
|
+
|
|
977
|
+
Triggers compilation of both prefill and decode shapes via a tiny
|
|
978
|
+
probe forward pair so that inductor / Triton failures surface here
|
|
979
|
+
rather than at the user's first generation. On failure, warns and
|
|
980
|
+
returns the *un-compiled* model so generation still works.
|
|
981
|
+
|
|
982
|
+
Forces ``torch._inductor.config.use_static_cuda_launcher = False``
|
|
983
|
+
for the process before compiling. Torch 2.12's static CUDA launcher
|
|
984
|
+
dereferences kernel args without validation, so an inductor codegen
|
|
985
|
+
bug (e.g. passing a symbolic shape where a tensor pointer is
|
|
986
|
+
expected — observed on Gemma-4) segfaults uncatchably. Routing
|
|
987
|
+
through Triton's regular launcher instead turns that into a
|
|
988
|
+
catchable ``TypeError``, which the fallback below can handle.
|
|
989
|
+
"""
|
|
990
|
+
try:
|
|
991
|
+
import torch._dynamo # noqa: F401
|
|
992
|
+
except ImportError:
|
|
993
|
+
log.info("torch.compile unavailable (no _dynamo); skipping")
|
|
994
|
+
return model
|
|
995
|
+
|
|
996
|
+
import torch._inductor.config as _ic
|
|
997
|
+
_ic.use_static_cuda_launcher = False
|
|
998
|
+
previous_matmul_precision: str | None = None
|
|
999
|
+
if torch.device(device).type == "cuda":
|
|
1000
|
+
# Ada tensor cores accelerate the FP32 matmuls surrounding BF16 model
|
|
1001
|
+
# inference (notably live J-LENS transport/readout) with TF32 while
|
|
1002
|
+
# retaining FP32 range. ``high`` is PyTorch's explicit opt-in.
|
|
1003
|
+
previous_matmul_precision = torch.get_float32_matmul_precision()
|
|
1004
|
+
torch.set_float32_matmul_precision("high")
|
|
1005
|
+
|
|
1006
|
+
log.info("Compiling model with torch.compile(mode=%r)", mode)
|
|
1007
|
+
compiled = torch.compile(model, mode=mode, dynamic=None)
|
|
1008
|
+
|
|
1009
|
+
bos = (
|
|
1010
|
+
getattr(tokenizer, "bos_token_id", None)
|
|
1011
|
+
or getattr(tokenizer, "pad_token_id", None)
|
|
1012
|
+
or getattr(tokenizer, "eos_token_id", None)
|
|
1013
|
+
or 0
|
|
1014
|
+
)
|
|
1015
|
+
try:
|
|
1016
|
+
with torch.inference_mode():
|
|
1017
|
+
_run_compile_probes(compiled, model, device, bos, mode=mode)
|
|
1018
|
+
except Exception as exc:
|
|
1019
|
+
if previous_matmul_precision is not None:
|
|
1020
|
+
torch.set_float32_matmul_precision(previous_matmul_precision)
|
|
1021
|
+
warnings.warn(
|
|
1022
|
+
f"torch.compile probe failed during warmup "
|
|
1023
|
+
f"({type(exc).__name__}: {str(exc)[:200]}); falling back to "
|
|
1024
|
+
"eager mode. Drop --compile (CLI) or compile=False "
|
|
1025
|
+
"(DrowseSession.from_pretrained) to silence this warning.",
|
|
1026
|
+
UserWarning,
|
|
1027
|
+
stacklevel=2,
|
|
1028
|
+
)
|
|
1029
|
+
log.info("torch.compile probe failed; using eager", exc_info=True)
|
|
1030
|
+
return model
|
|
1031
|
+
return compiled
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
def detect_device(requested: str = "auto") -> str:
|
|
1035
|
+
"""Pick the best available device.
|
|
1036
|
+
|
|
1037
|
+
'auto' probes in order: cuda > mps > cpu.
|
|
1038
|
+
An explicit value ('cuda', 'mps', 'cpu') is returned as-is.
|
|
1039
|
+
"""
|
|
1040
|
+
if requested != "auto":
|
|
1041
|
+
return requested
|
|
1042
|
+
if torch.cuda.is_available():
|
|
1043
|
+
return "cuda"
|
|
1044
|
+
if torch.backends.mps.is_available():
|
|
1045
|
+
return "mps"
|
|
1046
|
+
return "cpu"
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
def _pick_dtype(device: str) -> torch.dtype:
|
|
1050
|
+
"""Best default dtype for a device. bf16 on CUDA and MPS, fp32 on CPU.
|
|
1051
|
+
|
|
1052
|
+
bf16 on MPS matters for models whose residual stream exceeds fp16 range
|
|
1053
|
+
(e.g. Gemma-3-4b-it hits ~1e5 by the final layer, well past fp16's 65504
|
|
1054
|
+
max). Modern PyTorch MPS handles bf16 natively.
|
|
1055
|
+
"""
|
|
1056
|
+
if device in ("cuda", "mps"):
|
|
1057
|
+
return torch.bfloat16
|
|
1058
|
+
return torch.float32
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
def _resolve_dtype(dtype: torch.dtype | str | None, device: str) -> torch.dtype:
|
|
1062
|
+
if dtype is None:
|
|
1063
|
+
return _pick_dtype(device)
|
|
1064
|
+
if isinstance(dtype, str):
|
|
1065
|
+
return getattr(torch, dtype)
|
|
1066
|
+
return dtype
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
def load_model(
|
|
1070
|
+
model_id: str,
|
|
1071
|
+
quantize: str | None = None,
|
|
1072
|
+
device: str = "auto",
|
|
1073
|
+
dtype: torch.dtype | str | None = None,
|
|
1074
|
+
*,
|
|
1075
|
+
compile: bool = False,
|
|
1076
|
+
compile_mode: str = "default",
|
|
1077
|
+
trust_remote_code: bool | None = None,
|
|
1078
|
+
on_progress: Callable[[str], None] | None = None,
|
|
1079
|
+
) -> tuple[PreTrainedModel, PreTrainedTokenizerBase]:
|
|
1080
|
+
"""Load a HuggingFace causal LM and its tokenizer.
|
|
1081
|
+
|
|
1082
|
+
Args:
|
|
1083
|
+
model_id: Hub ID or local path.
|
|
1084
|
+
quantize: None for bf16/fp16/fp32, "4bit", or "8bit".
|
|
1085
|
+
device: "auto" (detect), "cuda", "mps", or "cpu".
|
|
1086
|
+
dtype: torch.dtype or string ("bfloat16"/"float16"/"float32"). None
|
|
1087
|
+
picks the device default — bf16 on CUDA/MPS, fp32 on CPU.
|
|
1088
|
+
compile: When True, wrap ``model`` with ``torch.compile`` after
|
|
1089
|
+
load on CUDA — fuses the per-layer kernels and amortizes
|
|
1090
|
+
launch overhead, typically 1.2–3× decode tok/s on small
|
|
1091
|
+
models when the compile succeeds. Off by default because
|
|
1092
|
+
(a) torch 2.12's inductor has known codegen bugs on newer
|
|
1093
|
+
architectures (Gemma-4, Qwen3.5) that this loader's probe
|
|
1094
|
+
catches but still costs ~25–100s upfront, and (b) the
|
|
1095
|
+
speedup rarely amortizes on interactive workloads. Pass
|
|
1096
|
+
``True`` for sustained workloads where the per-token win
|
|
1097
|
+
pays back the compile cost. Auto-skipped on MPS/CPU.
|
|
1098
|
+
compile_mode: torch.compile mode string passed through.
|
|
1099
|
+
``"default"`` (default) does inductor kernel fusion without
|
|
1100
|
+
graph capture — composes cleanly with HF's growing
|
|
1101
|
+
``DynamicCache``. ``"reduce-overhead"`` adds internal
|
|
1102
|
+
CUDA-graph capture but expects fixed shapes (paired with
|
|
1103
|
+
:class:`transformers.StaticCache` in Phase B's
|
|
1104
|
+
``cuda_graphs`` path; using it here without static cache
|
|
1105
|
+
would shape-recompile per decode step).
|
|
1106
|
+
``"max-autotune"`` runs Triton autotune (long first-call
|
|
1107
|
+
latency, marginal gains for decode-shape workloads).
|
|
1108
|
+
trust_remote_code: Permit repository Python only when explicitly True,
|
|
1109
|
+
or when unset and DROWSE_TRUST_REMOTE_CODE is enabled. Defaults off.
|
|
1110
|
+
on_progress: Optional per-step status sink. The loader's own
|
|
1111
|
+
status goes to ``log.info``, which is invisible unless the
|
|
1112
|
+
embedding application configured logging — a library must not
|
|
1113
|
+
configure it globally — so a CLI/server caller passes a callback
|
|
1114
|
+
to surface the device / weights / memory lines instead.
|
|
1115
|
+
|
|
1116
|
+
Returns:
|
|
1117
|
+
(model, tokenizer) tuple. Compiled models still expose the
|
|
1118
|
+
underlying ``transformers`` attribute graph through
|
|
1119
|
+
``OptimizedModule.__getattr__``, so ``get_layers`` and
|
|
1120
|
+
``get_model_info`` continue to work.
|
|
1121
|
+
"""
|
|
1122
|
+
if trust_remote_code is None:
|
|
1123
|
+
trust_remote_code = os.environ.get("DROWSE_TRUST_REMOTE_CODE", "").strip().lower() in {"1", "true", "yes", "on"}
|
|
1124
|
+
if type(trust_remote_code) is not bool:
|
|
1125
|
+
raise ValueError("trust_remote_code must be a boolean")
|
|
1126
|
+
device = detect_device(device)
|
|
1127
|
+
if device == "mps":
|
|
1128
|
+
patch_torch_for_mps()
|
|
1129
|
+
log.info("Device: %s", device)
|
|
1130
|
+
if on_progress is not None:
|
|
1131
|
+
on_progress(f"Device: {device}")
|
|
1132
|
+
|
|
1133
|
+
plan = _resolve_load_plan(model_id, quantize=quantize, device=device, dtype=dtype, trust_remote_code=trust_remote_code)
|
|
1134
|
+
tokenizer = AutoTokenizer.from_pretrained(
|
|
1135
|
+
model_id, **plan.tokenizer_kwargs, **plan.pin_kwargs,
|
|
1136
|
+
)
|
|
1137
|
+
if on_progress is not None:
|
|
1138
|
+
on_progress(f"Loading weights ({plan.dtype})...")
|
|
1139
|
+
model = _materialize_model(plan)
|
|
1140
|
+
model = _finalize_model(
|
|
1141
|
+
model, tokenizer, plan, compile=compile, compile_mode=compile_mode,
|
|
1142
|
+
on_progress=on_progress,
|
|
1143
|
+
)
|
|
1144
|
+
return cast(PreTrainedModel, model), tokenizer
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
@dataclass
|
|
1148
|
+
class LoadPlan:
|
|
1149
|
+
"""Every decision :func:`load_model` makes before a weight is read.
|
|
1150
|
+
|
|
1151
|
+
Produced by :func:`_resolve_load_plan` from the model id and the caller's
|
|
1152
|
+
knobs plus two config reads — no weight I/O — so the decisions (which
|
|
1153
|
+
attention impl, which dtype, whether to extract a text sub-model, whether
|
|
1154
|
+
to trust remote code) are inspectable and unit-testable without loading a
|
|
1155
|
+
checkpoint. :func:`_materialize_model` consumes it and owns the fallback
|
|
1156
|
+
ladder; :func:`_finalize_model` owns the post-load stamping.
|
|
1157
|
+
|
|
1158
|
+
``load_kwargs`` is mutable on purpose: the materialize step's fallback
|
|
1159
|
+
ladder rewrites ``attn_implementation`` / ``dtype`` / ``device_map`` in it
|
|
1160
|
+
as each retry narrows.
|
|
1161
|
+
"""
|
|
1162
|
+
|
|
1163
|
+
model_id: str
|
|
1164
|
+
device: str
|
|
1165
|
+
dtype: torch.dtype
|
|
1166
|
+
quantize: str | None
|
|
1167
|
+
revision: str | None
|
|
1168
|
+
pin_kwargs: dict[str, str]
|
|
1169
|
+
tokenizer_kwargs: dict[str, Any]
|
|
1170
|
+
load_kwargs: dict[str, Any]
|
|
1171
|
+
config: Any
|
|
1172
|
+
text_config: Any
|
|
1173
|
+
extract_text_model: bool
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
def _resolve_load_plan(
|
|
1177
|
+
model_id: str,
|
|
1178
|
+
*,
|
|
1179
|
+
quantize: str | None,
|
|
1180
|
+
device: str,
|
|
1181
|
+
dtype: torch.dtype | str | None,
|
|
1182
|
+
trust_remote_code: bool = False,
|
|
1183
|
+
) -> LoadPlan:
|
|
1184
|
+
"""Decide how to load ``model_id``; read configs, never weights."""
|
|
1185
|
+
resolved_dtype = _resolve_dtype(dtype, device)
|
|
1186
|
+
|
|
1187
|
+
# Resolve the Hub commit once, then pin every config, tokenizer, custom
|
|
1188
|
+
# shard, and model read to it. Without a single pin, a mutable Hub branch
|
|
1189
|
+
# can advance between independent ``from_pretrained`` calls and leave
|
|
1190
|
+
# caches stamped with config A over weights B. Local paths carry no commit
|
|
1191
|
+
# and remain path-hash identified.
|
|
1192
|
+
resolved_revision = _pinned_revision(model_id)
|
|
1193
|
+
pin_kwargs: dict[str, str] = (
|
|
1194
|
+
{"revision": resolved_revision} if resolved_revision else {}
|
|
1195
|
+
)
|
|
1196
|
+
probe_config = AutoConfig.from_pretrained(
|
|
1197
|
+
model_id, trust_remote_code=trust_remote_code, **pin_kwargs,
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
# HF-distributed Mistral checkpoints ship a buggy pre-tokenizer regex
|
|
1201
|
+
# that mis-splits ~1% of tokens (e.g. ``"'The'"`` → ``["'", "T", "he", "'"]``
|
|
1202
|
+
# instead of ``["'", "The", "'"]``). ``fix_mistral_regex=True`` swaps in the
|
|
1203
|
+
# correct regex from ``mistral_common``. Substring-match on the model_id
|
|
1204
|
+
# so it fires for any mistralai/* repo (Mistral-Small, Ministral, etc.) and
|
|
1205
|
+
# third-party finetunes whose name carries the family.
|
|
1206
|
+
# https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503/discussions/84
|
|
1207
|
+
tokenizer_kwargs: dict[str, Any] = {"trust_remote_code": trust_remote_code}
|
|
1208
|
+
if "mistral" in model_id.lower():
|
|
1209
|
+
tokenizer_kwargs["fix_mistral_regex"] = True
|
|
1210
|
+
|
|
1211
|
+
# --- quantization config ---
|
|
1212
|
+
if quantize and device != "cuda":
|
|
1213
|
+
warnings.warn(
|
|
1214
|
+
f"bitsandbytes quantization ({quantize}) requires CUDA. "
|
|
1215
|
+
f"Ignoring --quantize on {device}, loading in {resolved_dtype}.",
|
|
1216
|
+
stacklevel=2,
|
|
1217
|
+
)
|
|
1218
|
+
quantize = None
|
|
1219
|
+
|
|
1220
|
+
# --- attention implementation ---
|
|
1221
|
+
attn_impl = "sdpa" # safe default, works everywhere
|
|
1222
|
+
if device == "cuda":
|
|
1223
|
+
try:
|
|
1224
|
+
# Availability check only — presence of the package flips
|
|
1225
|
+
# transformers onto the flash-attention-2 kernel. We never
|
|
1226
|
+
# call into flash_attn ourselves.
|
|
1227
|
+
import flash_attn # pyright: ignore[reportMissingImports] # noqa: F401
|
|
1228
|
+
attn_impl = "flash_attention_2"
|
|
1229
|
+
except ImportError:
|
|
1230
|
+
pass
|
|
1231
|
+
|
|
1232
|
+
# --- device map ---
|
|
1233
|
+
# device_map="auto" requires accelerate and works best on CUDA.
|
|
1234
|
+
# For MPS/CPU, place the whole model on a single device.
|
|
1235
|
+
device_map = "auto" if device == "cuda" else {"": device}
|
|
1236
|
+
|
|
1237
|
+
# --- trust_remote_code gating ---
|
|
1238
|
+
# Some repos (e.g. deepseek-ai/DeepSeek-V2-Lite-Chat) ship an
|
|
1239
|
+
# ``auto_map`` pointing to a stale ``modeling_*.py`` that breaks
|
|
1240
|
+
# against newer transformers. When the architecture is already
|
|
1241
|
+
# supported natively, skip the custom code entirely.
|
|
1242
|
+
from transformers.models.auto.configuration_auto import CONFIG_MAPPING
|
|
1243
|
+
native_type = getattr(probe_config, "model_type", None)
|
|
1244
|
+
native_text_type = getattr(getattr(probe_config, "text_config", None),
|
|
1245
|
+
"model_type", None)
|
|
1246
|
+
trust = trust_remote_code and not (
|
|
1247
|
+
(native_type and native_type in CONFIG_MAPPING)
|
|
1248
|
+
or (native_text_type and native_text_type in CONFIG_MAPPING)
|
|
1249
|
+
)
|
|
1250
|
+
|
|
1251
|
+
# MLA architectures (DeepSeek-V2/V3) decompose attention into a
|
|
1252
|
+
# query/key head_dim = qk_nope_head_dim + qk_rope_head_dim (192 on
|
|
1253
|
+
# V2-Lite) and a separate value head_dim = v_head_dim (128). PyTorch
|
|
1254
|
+
# 2.11's MPS scaled_dot_product_attention kernel returns the output
|
|
1255
|
+
# with the *query* head_dim instead of the value head_dim when the
|
|
1256
|
+
# two differ — attn_output ends up (B, T, n_heads * 192) instead of
|
|
1257
|
+
# (B, T, n_heads * 128), and o_proj rejects it with
|
|
1258
|
+
# ``linear(): input and weight.T shapes cannot be multiplied``.
|
|
1259
|
+
# CPU SDPA returns the correct shape; CUDA SDPA also handles this
|
|
1260
|
+
# via the flash backend. Narrowest-correct fix: force eager on MPS
|
|
1261
|
+
# for these models. The ``torch.histc`` MPS patch already installed by
|
|
1262
|
+
# ``load_model`` covers the MoE-routing issue eager would otherwise hit.
|
|
1263
|
+
_MLA_TYPES = {"deepseek_v2", "deepseek_v3"}
|
|
1264
|
+
if device == "mps" and (
|
|
1265
|
+
native_type in _MLA_TYPES or native_text_type in _MLA_TYPES
|
|
1266
|
+
) and attn_impl != "eager":
|
|
1267
|
+
log.info(
|
|
1268
|
+
"forcing eager attention on MPS for MLA model %r "
|
|
1269
|
+
"(PyTorch MPS SDPA mishandles mismatched q/v head_dim)",
|
|
1270
|
+
native_type or native_text_type,
|
|
1271
|
+
)
|
|
1272
|
+
attn_impl = "eager"
|
|
1273
|
+
|
|
1274
|
+
load_kwargs: dict[str, Any] = {
|
|
1275
|
+
"attn_implementation": attn_impl,
|
|
1276
|
+
"trust_remote_code": trust,
|
|
1277
|
+
"device_map": device_map,
|
|
1278
|
+
**pin_kwargs,
|
|
1279
|
+
}
|
|
1280
|
+
if quantize == "4bit":
|
|
1281
|
+
load_kwargs["quantization_config"] = BitsAndBytesConfig(
|
|
1282
|
+
load_in_4bit=True,
|
|
1283
|
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
|
1284
|
+
bnb_4bit_quant_type="nf4",
|
|
1285
|
+
)
|
|
1286
|
+
elif quantize == "8bit":
|
|
1287
|
+
load_kwargs["quantization_config"] = BitsAndBytesConfig(load_in_8bit=True)
|
|
1288
|
+
else:
|
|
1289
|
+
load_kwargs["dtype"] = resolved_dtype
|
|
1290
|
+
|
|
1291
|
+
# --- check for multimodal configs wrapping a text-only model ---
|
|
1292
|
+
# Some text-only models ship with a multimodal config whose
|
|
1293
|
+
# model_type isn't registered with AutoModelForCausalLM (e.g.
|
|
1294
|
+
# Ministral tagged as Mistral3). If the config has a text_config
|
|
1295
|
+
# that IS a known causal-LM type, use that instead.
|
|
1296
|
+
config = AutoConfig.from_pretrained(
|
|
1297
|
+
model_id, trust_remote_code=trust, **pin_kwargs,
|
|
1298
|
+
)
|
|
1299
|
+
text_cfg = getattr(config, "text_config", None)
|
|
1300
|
+
# A non-None text_config means a multimodal wrapper. When it wraps a
|
|
1301
|
+
# text model drowse supports, load *only* the text submodel: it skips
|
|
1302
|
+
# the unused vision tower and — crucially — loads on-device shard-by-
|
|
1303
|
+
# shard so peak memory stays ~1× the model size instead of the ~2× the
|
|
1304
|
+
# standard CPU-stage-then-device-copy path costs on unified memory (the
|
|
1305
|
+
# >128 GB gemma-4-31B blowup). This fires even when the outer composite
|
|
1306
|
+
# model_type is itself in _LAYER_ACCESSORS (gemma3/gemma4): the full
|
|
1307
|
+
# multimodal model is still usable when handed to DrowseSession
|
|
1308
|
+
# directly, but the from_pretrained path prefers text-only.
|
|
1309
|
+
#
|
|
1310
|
+
# Under bitsandbytes quantization the extraction path is skipped: its
|
|
1311
|
+
# shard streamer copies raw weights into a ``from_config`` skeleton and
|
|
1312
|
+
# cannot apply a quantizer, so it would silently produce an unquantized
|
|
1313
|
+
# model stamped as quantized. The standard ``from_pretrained`` path
|
|
1314
|
+
# quantizes the full multimodal model correctly (quantize survives only
|
|
1315
|
+
# on CUDA, where the unified-memory discipline is moot).
|
|
1316
|
+
text_extractable = (
|
|
1317
|
+
text_cfg is not None
|
|
1318
|
+
and getattr(text_cfg, "model_type", None) in _LAYER_ACCESSORS
|
|
1319
|
+
)
|
|
1320
|
+
extract_text_model = text_extractable and quantize is None
|
|
1321
|
+
if text_extractable and quantize is not None:
|
|
1322
|
+
log.info(
|
|
1323
|
+
"quantization requested; loading the full multimodal model "
|
|
1324
|
+
"(the text-extraction path cannot quantize)",
|
|
1325
|
+
)
|
|
1326
|
+
|
|
1327
|
+
return LoadPlan(
|
|
1328
|
+
model_id=model_id,
|
|
1329
|
+
device=device,
|
|
1330
|
+
dtype=resolved_dtype,
|
|
1331
|
+
quantize=quantize,
|
|
1332
|
+
revision=resolved_revision,
|
|
1333
|
+
pin_kwargs=pin_kwargs,
|
|
1334
|
+
tokenizer_kwargs=tokenizer_kwargs,
|
|
1335
|
+
load_kwargs=load_kwargs,
|
|
1336
|
+
config=config,
|
|
1337
|
+
text_config=text_cfg,
|
|
1338
|
+
extract_text_model=extract_text_model,
|
|
1339
|
+
)
|
|
1340
|
+
|
|
1341
|
+
|
|
1342
|
+
@contextmanager
|
|
1343
|
+
def _model_load_environment(device: str) -> Iterator[None]:
|
|
1344
|
+
# Transformers' concurrent dtype/device copies can segfault on MPS.
|
|
1345
|
+
# Scope its supported synchronous-loading flag to the load, not inference.
|
|
1346
|
+
with _MODEL_LOAD_LOCK:
|
|
1347
|
+
previous = os.environ.get("HF_DEACTIVATE_ASYNC_LOAD")
|
|
1348
|
+
if device == "mps":
|
|
1349
|
+
os.environ["HF_DEACTIVATE_ASYNC_LOAD"] = "1"
|
|
1350
|
+
try:
|
|
1351
|
+
yield
|
|
1352
|
+
finally:
|
|
1353
|
+
if device == "mps":
|
|
1354
|
+
if previous is None:
|
|
1355
|
+
os.environ.pop("HF_DEACTIVATE_ASYNC_LOAD", None)
|
|
1356
|
+
else:
|
|
1357
|
+
os.environ["HF_DEACTIVATE_ASYNC_LOAD"] = previous
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
class _IncompleteCheckpointError(ValueError):
|
|
1361
|
+
"""A checkpoint would leave required model parameters newly initialized."""
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
def _load_pretrained_checked(plan: LoadPlan) -> Any:
|
|
1365
|
+
model, loading_info = cast(
|
|
1366
|
+
tuple[Any, dict[str, Any]],
|
|
1367
|
+
AutoModelForCausalLM.from_pretrained(
|
|
1368
|
+
plan.model_id, output_loading_info=True, **plan.load_kwargs,
|
|
1369
|
+
),
|
|
1370
|
+
)
|
|
1371
|
+
parameters = {name for name, _ in model.named_parameters()}
|
|
1372
|
+
missing = parameters.intersection(loading_info["missing_keys"])
|
|
1373
|
+
if missing:
|
|
1374
|
+
raise _IncompleteCheckpointError(
|
|
1375
|
+
f"checkpoint is missing model parameters: {sorted(missing)!r}"
|
|
1376
|
+
)
|
|
1377
|
+
return model
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
def _load_with_fallbacks(plan: LoadPlan) -> Any:
|
|
1381
|
+
"""One ``from_pretrained`` attempt plus the attn / dtype retries.
|
|
1382
|
+
|
|
1383
|
+
Each retry narrows ``plan.load_kwargs`` in place so a caller that retries
|
|
1384
|
+
this whole function (the device-conversion fallback) inherits the
|
|
1385
|
+
already-narrowed kwargs rather than repeating a known-bad attempt.
|
|
1386
|
+
"""
|
|
1387
|
+
load_kwargs = plan.load_kwargs
|
|
1388
|
+
with _model_load_environment(plan.device):
|
|
1389
|
+
try:
|
|
1390
|
+
return _load_pretrained_checked(plan)
|
|
1391
|
+
except _IncompleteCheckpointError:
|
|
1392
|
+
raise
|
|
1393
|
+
except ValueError as e:
|
|
1394
|
+
if "does not support an attention implementation" not in str(e):
|
|
1395
|
+
raise
|
|
1396
|
+
log.info("attn_implementation %r unsupported, falling back to eager",
|
|
1397
|
+
load_kwargs.get("attn_implementation"))
|
|
1398
|
+
load_kwargs["attn_implementation"] = "eager"
|
|
1399
|
+
return _load_pretrained_checked(plan)
|
|
1400
|
+
except Exception:
|
|
1401
|
+
if plan.quantize is not None:
|
|
1402
|
+
raise
|
|
1403
|
+
fallback = torch.float16 if plan.device == "cuda" else torch.float32
|
|
1404
|
+
load_kwargs["dtype"] = fallback
|
|
1405
|
+
return _load_pretrained_checked(plan)
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
def _materialize_model(plan: LoadPlan) -> Any:
|
|
1409
|
+
"""Read weights per ``plan`` — text extraction, then the fallback ladder."""
|
|
1410
|
+
model = None
|
|
1411
|
+
text_cfg = plan.text_config
|
|
1412
|
+
if plan.extract_text_model:
|
|
1413
|
+
# Weights live under a "language_model." path segment that doesn't
|
|
1414
|
+
# match the text-only model's parameter names. Load manually.
|
|
1415
|
+
# Propagate _name_or_path so cache paths resolve correctly.
|
|
1416
|
+
assert text_cfg is not None # guaranteed by plan.extract_text_model
|
|
1417
|
+
if not getattr(text_cfg, "_name_or_path", ""):
|
|
1418
|
+
text_cfg._name_or_path = plan.model_id
|
|
1419
|
+
log.info("extracting text model (%s) from multimodal checkpoint (%s)",
|
|
1420
|
+
text_cfg.model_type, plan.config.model_type)
|
|
1421
|
+
try:
|
|
1422
|
+
model = _load_text_from_multimodal(
|
|
1423
|
+
plan.model_id, text_cfg,
|
|
1424
|
+
plan.load_kwargs.get("dtype", plan.dtype),
|
|
1425
|
+
plan.device, revision=plan.revision,
|
|
1426
|
+
)
|
|
1427
|
+
except _NoTextWeightsExtracted as e:
|
|
1428
|
+
# Unexpected weight layout — don't ship random init; fall through
|
|
1429
|
+
# to the standard full-model load below.
|
|
1430
|
+
log.warning("%s; falling back to full multimodal load", e)
|
|
1431
|
+
model = None
|
|
1432
|
+
|
|
1433
|
+
if model is not None:
|
|
1434
|
+
return model
|
|
1435
|
+
|
|
1436
|
+
# --- standard load (with attention, dtype, and device fallbacks) ---
|
|
1437
|
+
try:
|
|
1438
|
+
return _load_with_fallbacks(plan)
|
|
1439
|
+
except _IncompleteCheckpointError:
|
|
1440
|
+
raise
|
|
1441
|
+
except (RuntimeError, ValueError) as e:
|
|
1442
|
+
if (
|
|
1443
|
+
isinstance(e, ValueError)
|
|
1444
|
+
and plan.quantize is not None
|
|
1445
|
+
and text_cfg is not None
|
|
1446
|
+
and getattr(text_cfg, "model_type", None) in _LAYER_ACCESSORS
|
|
1447
|
+
and "Unrecognized configuration class" in str(e)
|
|
1448
|
+
):
|
|
1449
|
+
# A composite AutoModelForCausalLM cannot load (Ministral-as-
|
|
1450
|
+
# Mistral3) and the only working route — text extraction — cannot
|
|
1451
|
+
# quantize. Fail with the actionable cause, not HF's registry
|
|
1452
|
+
# error.
|
|
1453
|
+
raise RuntimeError(
|
|
1454
|
+
f"{plan.model_id!r} is a multimodal checkpoint drowse can "
|
|
1455
|
+
"only load through the text-extraction path, which does not "
|
|
1456
|
+
"support bitsandbytes quantization; load without quantize=."
|
|
1457
|
+
) from e
|
|
1458
|
+
if plan.device in ("cuda", "cpu") or "CONVERSION" not in str(e):
|
|
1459
|
+
raise
|
|
1460
|
+
log.info("weight conversion failed on %s, retrying on CPU", plan.device)
|
|
1461
|
+
plan.load_kwargs["device_map"] = {"": "cpu"}
|
|
1462
|
+
if "dtype" not in plan.load_kwargs:
|
|
1463
|
+
plan.load_kwargs["dtype"] = torch.float32
|
|
1464
|
+
model = _load_with_fallbacks(plan)
|
|
1465
|
+
return model.to(plan.device) # pyright: ignore[reportArgumentType] # transformers stub: .to(str) overload missing
|
|
1466
|
+
|
|
1467
|
+
|
|
1468
|
+
def _finalize_model(
|
|
1469
|
+
model: Any,
|
|
1470
|
+
tokenizer: PreTrainedTokenizerBase,
|
|
1471
|
+
plan: LoadPlan,
|
|
1472
|
+
*,
|
|
1473
|
+
compile: bool,
|
|
1474
|
+
compile_mode: str,
|
|
1475
|
+
on_progress: Callable[[str], None] | None = None,
|
|
1476
|
+
) -> Any:
|
|
1477
|
+
"""Stamp identity, freeze, reconcile stop tokens, optionally compile."""
|
|
1478
|
+
# The live config's ``_commit_hash`` is the slot every identity check reads
|
|
1479
|
+
# (external J-lens bindings, capture fingerprints). Transformers 5.18 and
|
|
1480
|
+
# later never fill it, and on older releases the text-only multimodal path
|
|
1481
|
+
# lost it anyway (``from_config`` builds a fresh child config), which made
|
|
1482
|
+
# an official J-lens fetched for the same immutable checkpoint look stale.
|
|
1483
|
+
# The revision was resolved before any weights were read and every read
|
|
1484
|
+
# above was pinned to it, so stamp that proven identity uniformly.
|
|
1485
|
+
if plan.revision:
|
|
1486
|
+
live_config = getattr(model, "config", None)
|
|
1487
|
+
if live_config is not None:
|
|
1488
|
+
live_config._commit_hash = plan.revision
|
|
1489
|
+
live_text_config = getattr(live_config, "text_config", None)
|
|
1490
|
+
if live_text_config is not None:
|
|
1491
|
+
live_text_config._commit_hash = plan.revision
|
|
1492
|
+
|
|
1493
|
+
model.requires_grad_(False)
|
|
1494
|
+
model.train(False)
|
|
1495
|
+
# Mark only drowse-owned loads as source-trusted. Arbitrary modules whose
|
|
1496
|
+
# configs merely claim the same commit must still take the exact full-state
|
|
1497
|
+
# fingerprint path. ``dtype=plan.dtype`` is what the text-extraction path
|
|
1498
|
+
# handed ``from_config`` (immutable against the fallback ladder), so the
|
|
1499
|
+
# payload canonicalization's dtype write no-ops against the mutated config.
|
|
1500
|
+
source_fingerprint = model_source_fingerprint(
|
|
1501
|
+
plan.model_id, quantize=plan.quantize, device=plan.device,
|
|
1502
|
+
dtype=plan.dtype, config=plan.config, revision=plan.revision,
|
|
1503
|
+
parameter_dtype=(
|
|
1504
|
+
"quantized" if plan.quantize is not None
|
|
1505
|
+
else next(model.parameters()).dtype
|
|
1506
|
+
),
|
|
1507
|
+
)
|
|
1508
|
+
if source_fingerprint is not None:
|
|
1509
|
+
setattr(model, "_drowse_source_fingerprint", source_fingerprint)
|
|
1510
|
+
setattr(model, "_drowse_loaded_state_signature", _model_state_signature(model))
|
|
1511
|
+
setattr(model, "_drowse_state_invalidated", False)
|
|
1512
|
+
|
|
1513
|
+
# --- reconcile the chat stop-token set -------------------------------
|
|
1514
|
+
# A multimodal checkpoint's *text* sub-config can under-specify the
|
|
1515
|
+
# end-of-turn tokens its chat template actually emits. Gemma-4 is the
|
|
1516
|
+
# live case: the composite config lists ``eos_token_id = [<eos>, <turn|>]``
|
|
1517
|
+
# but the extracted ``gemma4_unified_text`` sub-config (what
|
|
1518
|
+
# ``_load_text_from_multimodal`` builds from via ``from_config``) carries
|
|
1519
|
+
# only ``<eos>``, so the loaded model's ``generation_config`` claims the
|
|
1520
|
+
# sole stop token is ``<eos>`` while the model ends every turn with
|
|
1521
|
+
# ``<turn|>``. HF ``model.generate`` (the native-generate corpus path,
|
|
1522
|
+
# ``session._run_generator``) reads ``generation_config.eos_token_id``, so
|
|
1523
|
+
# without this it runs past every ``<turn|>`` to ``max_new_tokens`` — the
|
|
1524
|
+
# model loops and leaks reasoning-channel name tokens (``thought``) that
|
|
1525
|
+
# ``skip_special_tokens`` can't strip. ``_get_eos_ids`` is the
|
|
1526
|
+
# chat-correct set (config eos ∪ tokenizer eos ∪ the template's added
|
|
1527
|
+
# end-of-turn tokens) and is exactly what the steered loop already stops
|
|
1528
|
+
# on, so adopting it as the generation default unifies both paths.
|
|
1529
|
+
from drowse.core.generation import _get_eos_ids
|
|
1530
|
+
chat_eos = sorted(_get_eos_ids(model, tokenizer))
|
|
1531
|
+
gen_cfg = getattr(model, "generation_config", None)
|
|
1532
|
+
if chat_eos and gen_cfg is not None:
|
|
1533
|
+
gen_cfg.eos_token_id = chat_eos if len(chat_eos) > 1 else chat_eos[0]
|
|
1534
|
+
|
|
1535
|
+
# --- memory report ---
|
|
1536
|
+
mem_gb = _get_memory_gb(plan.device)
|
|
1537
|
+
if mem_gb > 0:
|
|
1538
|
+
log.info("Memory used: %.2f GB", mem_gb)
|
|
1539
|
+
if on_progress is not None:
|
|
1540
|
+
on_progress(f"Memory used: {mem_gb:.2f} GB")
|
|
1541
|
+
|
|
1542
|
+
# --- compile (CUDA-only auto-enable) ---
|
|
1543
|
+
# Wrapping last so the compile artifact closes over weights that
|
|
1544
|
+
# are already on-device, in their final dtype, and frozen.
|
|
1545
|
+
# ``OptimizedModule`` forwards attribute access via ``__getattr__``
|
|
1546
|
+
# so ``get_layers(model)`` / ``model.config`` keep working through
|
|
1547
|
+
# the wrapper; the caller never has to know whether compile fired.
|
|
1548
|
+
# Hooks added later via ``register_forward_hook`` on layer modules
|
|
1549
|
+
# (which live under ``model._orig_mod``) compose cleanly: compile
|
|
1550
|
+
# treats hooks as external state and recompiles only when the
|
|
1551
|
+
# hook's *Python-scalar* inputs change. The unified steering hook
|
|
1552
|
+
# reads its per-gen coefficients from pre-traced per-layer ``(D,)``
|
|
1553
|
+
# offset buffers updated in place (:meth:`SteeringManager.write_compiled_offsets`,
|
|
1554
|
+
# installed by :func:`install_persistent_offset_hooks`), so compile sees
|
|
1555
|
+
# no structural change and never retraces across α changes between
|
|
1556
|
+
# generations.
|
|
1557
|
+
if compile and plan.device == "cuda":
|
|
1558
|
+
if on_progress is not None:
|
|
1559
|
+
on_progress(f"Compiling model with torch.compile(mode={compile_mode!r})...")
|
|
1560
|
+
model = _compile_with_probe(
|
|
1561
|
+
model, tokenizer, plan.device, mode=compile_mode,
|
|
1562
|
+
)
|
|
1563
|
+
elif compile and plan.device != "cuda":
|
|
1564
|
+
log.info(
|
|
1565
|
+
"compile=True but device=%s — skipping torch.compile "
|
|
1566
|
+
"(supported only on CUDA)",
|
|
1567
|
+
plan.device,
|
|
1568
|
+
)
|
|
1569
|
+
if on_progress is not None:
|
|
1570
|
+
on_progress(
|
|
1571
|
+
f"compile=True but device={plan.device} — skipping "
|
|
1572
|
+
f"torch.compile (supported only on CUDA)"
|
|
1573
|
+
)
|
|
1574
|
+
return model
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
def _get_memory_gb(device: str) -> float:
|
|
1578
|
+
if device.startswith("cuda") and torch.cuda.is_available():
|
|
1579
|
+
return round(torch.cuda.memory_allocated() / 1024**3, 2)
|
|
1580
|
+
if device.startswith("mps") and torch.backends.mps.is_available():
|
|
1581
|
+
# `torch.mps` exists on every torch build but the underlying call
|
|
1582
|
+
# raises RuntimeError ("Cannot execute getCurrentAllocatedMemory()
|
|
1583
|
+
# without MPS backend") when the backend isn't actually present
|
|
1584
|
+
# (e.g. Linux CI with `device='mps'` requested by tests). Gating
|
|
1585
|
+
# on `is_available()` mirrors the cuda branch and keeps the older
|
|
1586
|
+
# `AttributeError` swallow as a belt-and-suspenders fallback for
|
|
1587
|
+
# very old torch builds.
|
|
1588
|
+
try:
|
|
1589
|
+
return round(torch.mps.current_allocated_memory() / 1024**3, 2)
|
|
1590
|
+
except (AttributeError, RuntimeError):
|
|
1591
|
+
return 0.0
|
|
1592
|
+
return 0.0
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
def get_layers(model: PreTrainedModel) -> nn.ModuleList:
|
|
1596
|
+
"""Return the sequential transformer blocks for a supported architecture."""
|
|
1597
|
+
model_type = model.config.model_type
|
|
1598
|
+
accessor = _LAYER_ACCESSORS.get(model_type)
|
|
1599
|
+
if accessor is None:
|
|
1600
|
+
raise ValueError(
|
|
1601
|
+
f"Unsupported model_type {model_type!r}. "
|
|
1602
|
+
f"Supported architectures: {', '.join(_SUPPORTED_TYPES)}"
|
|
1603
|
+
)
|
|
1604
|
+
if model_type not in _TESTED_ARCHS and model_type not in _warned:
|
|
1605
|
+
_warned.add(model_type)
|
|
1606
|
+
warnings.warn(
|
|
1607
|
+
f"architecture {model_type!r} is wired up but untested — "
|
|
1608
|
+
"report issues at https://github.com/stdlogits/drowse",
|
|
1609
|
+
UserWarning,
|
|
1610
|
+
stacklevel=2,
|
|
1611
|
+
)
|
|
1612
|
+
return accessor(model)
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
def get_unembedding(model: PreTrainedModel) -> torch.Tensor:
|
|
1616
|
+
"""Return the unembedding matrix ``W_U``, shape ``[vocab, head_width]``.
|
|
1617
|
+
|
|
1618
|
+
Uses the HF-standard ``get_output_embeddings()`` (the lm_head module,
|
|
1619
|
+
whether or not its weight is tied to the input embedding). Nothing else in
|
|
1620
|
+
drowse touches the unembedding outside the model's own forward; this
|
|
1621
|
+
accessor exists for the Jacobian lens readout. Projected OPT models have
|
|
1622
|
+
a head width distinct from the residual width; see get_output_projection.
|
|
1623
|
+
"""
|
|
1624
|
+
out = model.get_output_embeddings()
|
|
1625
|
+
weight = getattr(out, "weight", None)
|
|
1626
|
+
if weight is None:
|
|
1627
|
+
raise ValueError(
|
|
1628
|
+
f"model_type {model.config.model_type!r} exposes no output "
|
|
1629
|
+
"embedding weight (get_output_embeddings() returned "
|
|
1630
|
+
f"{type(out).__name__}); cannot build a vocabulary readout"
|
|
1631
|
+
)
|
|
1632
|
+
return weight
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
_FINAL_NORM_ATTRS = ("norm", "final_layernorm", "final_layer_norm", "ln_f", "final_norm")
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
def get_logit_softcap(model: PreTrainedModel) -> float | None:
|
|
1639
|
+
return getattr(_text_config(model), "final_logit_softcapping", None)
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
def get_output_projection(model: PreTrainedModel) -> torch.Tensor | None:
|
|
1643
|
+
if model.config.model_type == "opt":
|
|
1644
|
+
projection = model.model.decoder.project_out
|
|
1645
|
+
return projection.weight if projection is not None else None
|
|
1646
|
+
return None
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
class LogitReadout(nn.Module):
|
|
1650
|
+
"""The model's final-residual-to-logits path, without another forward."""
|
|
1651
|
+
|
|
1652
|
+
def __init__(self, model: PreTrainedModel):
|
|
1653
|
+
super().__init__()
|
|
1654
|
+
self.norm = get_final_norm(model)
|
|
1655
|
+
self.head = cast(nn.Module, model.get_output_embeddings())
|
|
1656
|
+
self.projection = model.model.decoder.project_out if model.config.model_type == "opt" else None
|
|
1657
|
+
self.softcap = get_logit_softcap(model)
|
|
1658
|
+
self.scale = model.logit_scale if model.config.model_type in {"cohere", "cohere2"} else 1.0
|
|
1659
|
+
if model.config.model_type == "falcon_h1":
|
|
1660
|
+
self.scale = model.model.lm_head_multiplier
|
|
1661
|
+
self.divisor = model.config.logits_scaling if model.config.model_type in {"granite", "granitemoe"} else 1.0
|
|
1662
|
+
|
|
1663
|
+
def forward(self, hidden: torch.Tensor) -> torch.Tensor:
|
|
1664
|
+
weight = cast(torch.Tensor, self.head.weight)
|
|
1665
|
+
hidden = self.norm(hidden.to(weight.dtype))
|
|
1666
|
+
if self.projection is not None:
|
|
1667
|
+
hidden = self.projection(hidden)
|
|
1668
|
+
logits = self.head(hidden)
|
|
1669
|
+
if self.scale != 1.0:
|
|
1670
|
+
logits = logits * self.scale
|
|
1671
|
+
if self.divisor != 1.0:
|
|
1672
|
+
logits = logits / self.divisor
|
|
1673
|
+
if self.softcap is not None:
|
|
1674
|
+
logits = (logits / self.softcap).tanh() * self.softcap
|
|
1675
|
+
return logits
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
def get_final_norm(model: PreTrainedModel) -> nn.Module:
|
|
1679
|
+
"""Return the final pre-unembedding normalization module.
|
|
1680
|
+
|
|
1681
|
+
Every supported decoder keeps its final norm as a sibling of the
|
|
1682
|
+
transformer block list (``.norm`` on the llama/qwen/gemma families,
|
|
1683
|
+
``.ln_f`` on the GPT-2 family, ``.final_layernorm`` on GLM-shaped
|
|
1684
|
+
models), so the owner of the ``get_layers`` ModuleList is searched for
|
|
1685
|
+
the first matching attribute rather than adding a second per-architecture
|
|
1686
|
+
accessor table.
|
|
1687
|
+
"""
|
|
1688
|
+
layers = get_layers(model)
|
|
1689
|
+
for module in model.modules():
|
|
1690
|
+
if any(child is layers for child in module.children()):
|
|
1691
|
+
for attr in _FINAL_NORM_ATTRS:
|
|
1692
|
+
cand = getattr(module, attr, None)
|
|
1693
|
+
if isinstance(cand, nn.Module):
|
|
1694
|
+
return cand
|
|
1695
|
+
if model.config.model_type == "opt" and module.final_layer_norm is None:
|
|
1696
|
+
return nn.Identity()
|
|
1697
|
+
raise ValueError(
|
|
1698
|
+
f"model_type {model.config.model_type!r}: no final norm found next to "
|
|
1699
|
+
f"the layer list (tried attributes {', '.join(_FINAL_NORM_ATTRS)})"
|
|
1700
|
+
)
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
def _text_config(model: PreTrainedModel) -> Any:
|
|
1704
|
+
"""Return the text-specific config, handling multimodal wrappers."""
|
|
1705
|
+
cfg = model.config
|
|
1706
|
+
return getattr(cfg, "text_config", cfg)
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
def get_model_info(model: PreTrainedModel, tokenizer: PreTrainedTokenizerBase) -> dict[str, Any]:
|
|
1710
|
+
"""Summary dict: model_type, num_layers, hidden_dim, device, dtype, vram_used_gb, param_count."""
|
|
1711
|
+
layers = get_layers(model)
|
|
1712
|
+
first_param = next(model.parameters())
|
|
1713
|
+
model_id = getattr(model.config, "_name_or_path", "unknown")
|
|
1714
|
+
param_count = model.num_parameters()
|
|
1715
|
+
return {
|
|
1716
|
+
"model_id": model_id,
|
|
1717
|
+
"model_type": model.config.model_type,
|
|
1718
|
+
"num_layers": len(layers),
|
|
1719
|
+
"hidden_dim": _text_config(model).hidden_size,
|
|
1720
|
+
"device": str(first_param.device),
|
|
1721
|
+
"dtype": str(first_param.dtype),
|
|
1722
|
+
"vram_used_gb": _get_memory_gb(str(first_param.device)),
|
|
1723
|
+
"param_count": param_count,
|
|
1724
|
+
}
|