Repository navigation
Conversation
|
/bot review |
Automated code reviewReview of PR #32517 ( Blocking(point 1) Backward-compat risk for existing hy_v4 GGUFs from the NORM->IMROPE switch. (point 2) Flash VL and M-RoPE: silently dropped or dead plumbing? Will slow the review(point 3) ~700 lines of the k-pool machinery are duplicated from (point 4) Unreachable by-order code in the new file. (point 5) Test coverage gaps in
Nits(point 6) Overflow-guard can itself wrap at (point 7) Copy-paste error message at (point 8) (point 9) NotesGood things worth keeping as-is: the main attention routes through This review was generated automatically by pi coding agent using |
|
@Little0o0 your AI did not follow AGENTS.md carefully ask it to read the full AGENTS.md again and rerun code-review skill offline |
|
Maybe I'm somehow doing something wrong, but this doesn't seem to work with the official release from https://huggingface.co/tencent/Hy4-flash Is this PR only for the pre-release from a while ago? I think the architecture name changed in the flash release, although I don't think any of the actual format did |
@ngxson Dear Xuan-son, I have revised them. |
@ryant00000 Dear Ryan, yes, architecture name changed in the flash release. I have modified the code to fit the name for the released bf16 model. It can pack the gguf from https://huggingface.co/tencent/Hy4-flash now. |
Add the hy_v4_flash architecture (hybrid sparse/sliding-window attention with a k-pool indexer, Engram embeddings, latent MoE and an MTP draft block), M-RoPE VL support for hy_v4, and the hy_v4_flash / hy_v4_vl mmproj projectors. Assisted-by: Claude Opus 5.5
Share the k-pool indexer code between llama_memory_hybrid_idx and llama_memory_idx_iswa via llama_kv_cache_kpool, drop the VL / mmproj changes and keep hy_v4 on NORM rope, trim comments. Assisted-by: Claude Opus 5.5
The released Hy4-flash checkpoints name the architecture HYV4Flash*, call the sparse layers deepseek_sparse_attention, drop engram_enable and ship the Engram token map as a lookup_table tensor instead of engram_vocab_map.npz. Read the map from the tensor when it is there, keep the npz path for the checkpoints that carry it, and skip the dfly draft layers. Assisted-by: Claude Opus 5, GPT-6
Read the M-RoPE sections of the HY4 VL text model again (IMROPE over NeoX ordered rope rows) and add back the hy_v4_vl mmproj projector. Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
|
I was eager to try this out and I am reporting what I see ( Please let me know if you need more - I have the model running here and can debug. |
Upstream llama.cpp doesn't run Hy4 flash yet (ggml-org/llama.cpp#32517 is open). Tencent's AngelSlim publishes one patch against a pinned llama.cpp commit that adds the architecture, its vision tower, multi-token prediction and SPARK-4Bit kernels tuned for the GB10. The image fetches that patch at a pinned Hugging Face revision, checks its SHA-256, and builds llama-server with CUDA 13.4.3 for sm_121a, setting AngelSlim's recommended kernel switches. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Very nice @Little0o0! I've gone from 8t/s with the initial PR to 15t/s with this recent MTP commit... then combining "--spec-draft-n-max 4" with "--spec-draft-p-min 0.8", I'm hitting 19t/s! |
|
Hello @Little0o0 , thanks for your work! I get My running config in .ini presets file is I compiled from source and commit history is |
Published files carry no rope sections, so default them to the checkpoint's [12, 10, 10, 0] and reorder the rope rows to NeoX in the graph. The weights stay as published. The vision tower is the hy_v4_vl one, so hy_v4_flash reuses its projector code. Its encoder ffn uses the tanh gelu (bias_activation_fusion). Assisted-by: Claude Opus 5
|
Hi @ryant00000 and @EmilPi . The issue was caused by my forgetting to add the mmproj to Hy4-Flash. I’ve added them now, and it has no bug now! |
Thanks for sharing the data point and recipes! |
With M-RoPE a whole image shares one position, so pools of consecutive positions never form for image cells and the forced tail resolves every image token to the same cell. Group consecutive cells instead, as qwen4exp does. Text is unaffected: its positions are consecutive. Assisted-by: Claude Opus 5
|
/bot review |
Automated code reviewReview of the delta since the last automated pass (commit Verified in the new commits (no action needed)
Will slow the review(point 1) (point 2) Still open from the previous review: the MTP draft block ( Notes(point 3) Switching hy_v4_flash to M-RoPE disables context shift: Nits(point 4) The mrope branch in (point 5) Carried over, not addressed: the position-embedding error under (point 6) Carried over, not addressed: Reminder on the previous review's point 1The This review was generated automatically by pi coding agent using |
… path The conversion now writes rope.dimension_sections from the checkpoint, so a variant with a different rope split no longer depends on the loader default. The default stays as the fallback for the already published files. Also warn when an image marker token is missing instead of silently dropping it, name the projector type in the position-embedding error, and run the arch test without an indexer. Assisted-by: Claude Opus 5
Automated code review
Regarding the points mentioned above, I provide the following explanation as to how these points have been fixed or why they have not been fixed.
|
|
@Little0o0 Getting logs like this on image input after rebasing on master: Other models handle same image fine. Config: [Hy4-Flash-Q3]
hf = AngelSlim/Hy4-flash-GGUF:Q3_K
ctx-size = 131072
ctk = q8_0
ctv = q8_0
no-mmproj-offload = true
fit = off
cmoe = true
moe-cache-mib = 33768
load-mode = none
spec-draft-n-max = 4
spec-draft-p-min = 0.8Short git log: |
quoted reply
@EmilPi The Hy4-flash image decode failure above because its sliding-window KV cache must hold the whole image at once, and the server does not cap image size for this causal model so it returns a 500 instead of a clear error. The minimum values needed for the -b/-ub should be image tokens + 512. So it can use |
An image is decoded as one batch whose positions share one M-RoPE value, so sliding-window masking never frees its cells. The whole image must fit in the sliding-window cache, which is sized from -b and -ub. When an image fails to decode on such a model, print the image token count and the minimum -b and -ub that fit it. Assisted-by: Claude Opus 5
|
This is for the 3840x2160 image with ub/b = 3072: Did I understand right this is an architectural constraint, and text tokens do not count into |
|
@EmilPi Yes. There is a constraint that |
| // returns the full text of the first token starting with prefix, for marker tokens that embed a per-revision tokenizer hash (hy-v4) | ||
| std::string lookup_token_text_prefix(const std::string & prefix) { |
There was a problem hiding this comment.
I don't get why this is needed, are we doing backward compatibility or something?
why can't we support only the latest version of tokenizer, what's the pre-revision?
There was a problem hiding this comment.
I move these codes into tools/mtmd/models/hy-v4.cpp. Now it will not disturb the common code. These codes are used for backward compatibility for the official released gguf on https://huggingface.co/AngelSlim/Hy4-flash-GGUF .
There was a problem hiding this comment.
it's recommended to just reconvert the gguf, it's more simple to do than having a compat code in here
There was a problem hiding this comment.
we decide to merge #32960 instead because it's less changes to the code base
please reach out to https://huggingface.co/AngelSlim so they can update the gguf with the merged version
| if (chunk_type == MTMD_INPUT_CHUNK_TYPE_IMAGE && llama_model_n_swa(llama_get_model(lctx)) > 0) { | ||
| // the whole image must stay in the sliding-window cache until it is decoded, see docs | ||
| LOG_ERR("the image has %d tokens, but -b is %d and -ub is %d. with sliding-window attention " | ||
| "the batch and ubatch must each cover the image, use -b and -ub of at least %d\n", | ||
| n_tokens, n_batch, llama_n_ubatch(lctx), n_tokens + 512); | ||
| } | ||
| return ret; |
There was a problem hiding this comment.
remove this, it's never been tested to make sure it's not break other models
There was a problem hiding this comment.
I have remove them on the latest commit.
|
I opened #32960 as a smaller alternative to this one that leaves the memory API untouched: no new KV cache type and no change to llama-memory-hybrid-idx. It runs hy_v4_flash on the existing llama_kv_cache_dsa_iswa like dots3note, and rebuilds the indexer pools from the cache cells at each ubatch instead of keeping a pooled state. MTP and the VL path are not in #32960, they could come on top of it once the base is in. |
This reverts commit a09e624.
Co-Authored-By: Claude Haiku 5.5 <[email protected]>
|
Again there are conflicts with master... |
|
support is already added in #32960 closing this for now |
Adds the Tencent Hy4 Flash model,
hy_v4_flasharchitecture (HYV4FlashForCausalLM,HYV4FlashForConditionalGeneration), VL support forhy_v4(IMROPE text tower,HYV4VLForConditionalGeneration), and thehy_v4_vlmmproj projectors.hy_v4_flash keeps hy_v4's iHC, gated MLA and attention sinks, and adds a hybrid stack of sparse full-attention layers alternating with sliding-window layers, a compressed k-pool indexer on the sparse layers, Engram n-gram hash embeddings, latent-space routed experts and an MTP draft block.
Hy4 Flash model: https://huggingface.co/tencent/Hy4-flash
hy_v4_flash gguf: https://huggingface.co/AngelSlim/Hy4-flash-GGUF
Overview
Adds the
hy_v4_flasharchitecture (HYV4FlashForCausalLM,HYV4FlashForConditionalGeneration), VL support forhy_v4(IMROPE text tower,HYV4VLForConditionalGeneration), and thehy_v4_vlmmproj projectors.hy_v4_flash keeps hy_v4's iHC, gated MLA and attention sinks, and adds a hybrid stack of sparse full-attention layers alternating with sliding-window layers, a compressed k-pool indexer on the sparse layers, Engram n-gram hash embeddings, latent-space routed experts and an MTP draft block.
Additional information
New files:
src/llama-kv-cache-kpool.{h,cpp},src/llama-memory-idx-iswa.{h,cpp},conversion/hy_v4_flash.py,src/models/hy-v4-flash.cpp,tools/mtmd/models/hy-v4.cpp.llama-memory-idx-iswais a new memory type becausellama_memory_hybrid_idxpairs one KV cache with a recurrent cache, while hy_v4_flash needs an iSWA pair plus the indexer cache and has no recurrent layers. We move the k-pool code from thellama_memory_hybrid_idxintollama_kv_cache_kpool. Sollama_memory_hybrid_idxandllama-memory-idx-iswashare the k-pool code.M-RoPE necessarily makes
n_pos_per_embd() == 4, so KV-shift is off for every hy_v4_flash user, including text-only users who never touch images. At full context they now get "context full" instead of an automatic shift. However, without M-RoPE the image positions cannot be encoded correctly. This is the standard trade-off for every M-RoPE model in llama.cpp (qwen-vl behaves the same).Requirements
Assisted-by: Claude Opus 5.5, GPT-6