8000 Add GetTensorRaw and ToGGMLQuantType for GGML quantized weights by ajroetker · Pull Request #18 · gomlx/go-huggingface · GitHub
[go: up one dir, main page]

Skip to content
8000

Add GetTensorRaw and ToGGMLQuantType for GGML quantized weights - #18

Merged
janpfeifer merged 170 commits into
gomlx:mainfrom
ajroetker:gguf-quantized-types
Nov 5, 2026
Merged

janpfeifer merged 170 commits into
gomlx:mainfrom
ajroetker:gguf-quantized-types

Conversation

@ajroetker
Copy link
Copy Markdown
Contributor
  • Add Model.GetTensorRaw() to load raw tensor bytes without dequantization, keeping quantized weights in their native GGML block format
  • Add TensorType.ToGGMLQuantType() mapping GGUF tensor types to GoMLX GGMLQuantType (Q4_0, Q8_0, IQ4_NL, Q2_K–Q6_K)
  • Update go.mod dependencies

Dependencies

Depends on ajroetker/gomlx#6 — the go.mod replace directive will be updated to a proper module version once that PR merges.

- Add Model.GetTensorRaw() to load raw tensor bytes without
  dequantization, enabling quantized weights to stay in native format
- Add TensorType.ToGGMLQuantType() mapping GGUF tensor types to
  GoMLX GGMLQuantType (Q4_0, Q8_0, IQ4_NL, Q2_K–Q6_K)
- Update go.mod dependencies

Depends on: ajroetker/gomlx#6
- Multi-file GGUF: support multimodal models (e.g. LLaVA) that split
  tensors across multiple GGUF files via LoadAll/LoadFiles/ListGGUFFiles.
  Tensors are looked up across all files transparently.
- Pair extra files with their readers in a single extraEntry struct to
  prevent parallel-slice divergence and enable per-file lazy reader init.
- Fix Close() to close all readers instead of leaking on first error.
- Deduplicate .gguf filename filtering into a shared ggufFileNames helper.
- Add FlexToken type to handle HuggingFace token config fields that can
  be either a plain string or an object with a "content" field.
- Update go-xla, golang.org/x/sys, k8s.io/klog dependencies.
Comment thread models/gguf/model.go Resolved
…p FlexToken

- Rename GetTensor→ReadTensor, GetTensorRaw→ReadTensorBytes per reviewer
  convention (Read prefix for I/O methods)
- Merge findTensorFile+fileForIndex into findTensor to avoid double map
  lookup in GetTensorInfo and readerForTensor
- Return error instead of silently swallowing invalid JSON in
  FlexToken.UnmarshalJSON
- Remove unused FlexToken.String() method
- Replace 7 copy-pasted config fallback blocks in resolveSpecialTokens
  with table-driven loop
@ajroetker
ajroetker requested a review from janpfeifer March 16, 2026 18:40
janpfeifer and others added 23 commits March 19, 2026 23:13
…ormer models.

 (Tested with tencent/KaLM-Embedding-Gemma3-12B-2511)
Added  the `models/transformer` package.
Cleanup, improved documentation.
- Refactor `hub.Repo` functionality so it can be shared with `datasets`
Added dataset pretty printing.
Added API to iterate over parquet files.
Support for HuggingFace Datasets.
…ethods.

- Updated README.md and added some examples.
- Updated go.mod dependencies.
GetTokenizers/SetTokenizers; README.md
Fixed Model.LoadContext to return an error.
janpfeifer and others added 28 commits September 10, 2026 20:33
…oader bug fixes (gomlx#62)

* Fixed report of false error, described in gomlx#61

* Replaced Semaphore with a FIFOSemaphore;
Added support for Context in the FIFOSemaphore;
Fixes gomlx#60

* - 20Cache and offline reliability improvements in `hub`:
    - Avoid re-downloading model revision info when it is already cached by default. Documented update polling via `DownloadInfo(true)`.
    - Short-circuit revision lookup when `revision` is already a 40-character commit hash.
    - Removed unused `revisionHashRefreshed` field.
    - Fixed `LockedDownload` to preserve existing cached files until a forced re-download successfully completes and atomically replaces them, avoiding cache deletion on network failure (issue gomlx#59).

* Updated CHANGELOG with other bug fixes.

* Added .agents/AGENTS.md
* fix(hub): accept string or array for cardData.license

Hugging Face Hub may return license as a JSON array; unmarshaling into a
string field broke DownloadInfo for datasets like bigcode/the-stack.

Signed-off-by: Sobha Cheruku <scheruku@redhat.com>

* test: skip live Hub license test in short mode

* fix: update CardData.License as []string

---------

Signed-off-by: Sobha Cheruku <scheruku@redhat.com>
…mlx#66)

* Added package documentation.
Auto-detect `CausalMask` for the model.

* Removed `-use_causal_mask` flag, that was previously being ignored and now was setting the causal mask to the wrong value.
…rmalizer (fixes gomlx#67) (gomlx#68)

* Created issue gomlx#67 test.

* Refactored the normalizer out of `hftokenizer.go` into `normalizer.go`
Large cleanups and simplification of the code, in particular the handling of the offsets from the normalize string to the original string.

* Refactored tests into their corresponding files.
…/ `Repo.SaveCtx` when `linkOnly=true` so hard links point to the underlying blob files rather than copying relative snapshot symlinks. (gomlx#70)
…ation models (models/timestral) (gomlx#71)

* Updated dependencies.

* Added `timestral` times series foundational model support.
…without mmap (gomlx#72)

* Make loading files with MMap optional.

* More memory debugging options; added -mmap flag.

* Removed the inserted GC used for debugging.

* Updated dependen
8
cies.

* - `models/timestral`:
    - Fused attention `_gate` projection (`Dense` + `Sigmoid`) into a single `nn.Dense(..., activation.TypeSigmoid)` (`FusedDense` with `ActivationSigmoid`).
    - Swapped `w12` `[gate; up]` halves to `[up; gate]` at weight-load time and replaced manual `Slice` + `Silu` + `Mul` in `FusedSwiGLU` with `activation.SwiGLU(w12)`.
  - `examples/timestral`: Format elapsed durations using `humanize.Duration()`.

* Updated dependencies.
…via `github.com/gomlx/onnx-gomlx` when `.safetensors` files are not available in the model repository (e.g. `KnightsAnalytics/all-MiniLM-L6-v2`).

  - `models/transformer`:
    - Added `Model.SentenceEmbeddingFromLastHiddenState(lastHiddenState, seqLen)` to apply post-Transformer sentence embedding modules (pooling and L2 normalization) to an existing hidden-state tensor.
@janpfeifer
janpfeifer merged commit 6bf69c3 into gomlx:main Nov 5, 2026
1 check passed
@janpfeifer
Copy link
Copy Markdown
Contributor

hey @ajroetker , sorry this was never followed up on. You are probably not interested in this anymore, but just FYI, I merged the updates, did a couple of fixes, and merged everything 😃 THanks again for all contributions!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

0