Run this model with HF Jobs

Run tencent/Hy-Memory-30B-A3B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/tencent/Hy-Memory-30B-A3B. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/tencent/Hy-Memory-30B-A3B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/tencent/Hy-Memory-30B-A3B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/tencent/Hy-Memory-30B-A3B. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Notes from a 4-bit port (NVFP4) — config/tokenizer quirks and observed behaviour

#4
by alexmv2025 - opened

Hi, I ported Hy-Memory-30B-A3B to an independent inference engine (logestix, C++/CUDA, Blackwell) and converted the body to NVFP4 (4-bit weights, FP16 embed/lm_head). Everything below was measured against the source bf16 safetensors as the oracle, so it's observed behaviour, not guesses. Posting it here because a few of the details are easy to get wrong and might be worth documenting.

  1. moe_intermediate_size vs expert_hidden_dim
    config.json carries both:
  • moe_intermediate_size: 1536
  • expert_hidden_dim: 768
    The actual tensors are 768 wide (mlp.experts.E.gate_proj.weight is [768, 2048], the shared expert mlp.shared_mlp.* is also 768). So moe_intermediate_size looks like a leftover from the Hy3 lineage, and expert_hidden_dim is the real width. Feeding 1536 into a stock HYV3Config builds an HYV3Experts/shared expert with the wrong shapes. Worth a comment in the config or a note in the model card.
  1. Tokenizer: no CR token, no single-byte tokens for invalid UTF-8 lead bytes
    The vocabulary has 242 single-character entries, and 14 bytes have no single-byte token:
  • 0x0D (CR) — the reference tokenizer drops it: encode("\r") == [] and encode("a\rb") == encode("a b")-ish (it splits on CR first, so it yields the ids of a and b).
  • 0xC0, 0xC1, 0xF5…0xFF — never valid in UTF-8, so harmless, but they make a naive "all 256 bytes must exist" tokenizer bridge fail at load time.
    Also: \r\n encodes to just the \n token. Anyone re-implementing the tokenizer needs a "skip unmapped byte" policy rather than an UNK fallback.
  1. Added tokens are special: false but matched literally
    The control markers (, , , , , , , , …) and <|reasoning_mode|> are all special: false. The HF tokenizer still matches them as single ids (AddedVocabulary), but a plain byte-level BPE pass over raw text will fragment them into ordinary sub-tokens. If you inject these markers by id (recommended) you also need to handle CR: the two behaviours interact.

  2. Chat template: the default effort is no_think, and it lands in two places
    With add_generation_prompt=True and no reasoning_effort, the rendered prompt is:
    <|reasoning_mode|>reasoning_effort:no_think<|hy_User|>…<|hy_Assistant|>
    i.e. the reasoning-mode switch is appended to the system block only when no tools are present; with tools it moves to the end of the tool instructions, right after . Our renderer reproduces the reference ids id-for-id on 14 captured cases (control prompt, multi-turn, tools, tool round-trip), including the Python-tojson formatting of the tool schema ({"type": "function", "function": …} with ", " / ": " separators) — that whitespace is part of the token stream, so it matters.

  3. Behaviour worth knowing for a memory writer

  • It answers ordinary knowledge prompts directly: "The capital of France is" → Paris (greedy, deterministic; logits hash stable across runs).
  • On "return the formula" prompts it substitutes numeric values instead of keeping symbolic names (e.g. it wrote Balance_Alpha=(((100000000*1.083541)-0.0005)*83.152402-0.0005)*0.011104-0.0005 where the prompt's template asked for Rate_A/Slip_A/…). That is a real, reproducible form deviation, not sampling noise — if you rely on symbolic output, say so explicitly in the prompt.
  • Greedy decoding is bit-exact run-to-run (3 runs per prompt, identical gen_tokens), including on the 4-bit tree.
  • The native tool call works out of the box: with one tool in scope it emits \nget_weather\ncity\nParis\n\n and the arguments parse cleanly.
  1. Quantization tolerance (one data point)
    4-bit NVFP4 on every attention/expert/shared projection, with embed_tokens and lm_head kept FP16 and the router gate + expert_bias kept high precision (the bias changes the selection, so it is not a "blur an output" tensor). That was enough to keep all parity gates green against the source: 3/3 on three different prompt sets, plus the determinism gate. No residual/second NVFP4 plane was needed — unlike some other 30B-class models I've converted, the near-tie answers here did not flip at 4 bits.
    Numbers on one RTX 5090 (32 GB)
  • 16.5 GiB resident (all 6016 experts resident; no expert streaming).
  • 87 t/s at 2048 generated tokens, TTFT ~194 ms (token-by-token prefill — correctness first in this engine).
  • Decode sits around 12% of the DRAM roofline; the weight-streaming GEMV, not the router readback, is the bottleneck.

Happy to share the exact template renderer/tokenizer edge cases (including the CR rule and the tool-block serialization) if it helps anyone else integrate the checkpoint — and if any of the above is not what the intended reference does, I'd like to know, since it would mean my oracle is off rather than the model.

Sign up or log in to comment