Xunzhuo commited on
Commit
a443f81
·
verified ·
1 Parent(s): 3d309f3

d3 v3.0.6

Browse files
Files changed (4) hide show
  1. MODEL_MANIFEST.json +8 -8
  2. README.md +1 -1
  3. d3_fast.py +28 -1
  4. d3_runtime.py +41 -2
MODEL_MANIFEST.json CHANGED
@@ -564,8 +564,8 @@
564
  },
565
  "runtime": {
566
  "files_sha256": {
567
- "d3_runtime.py": "88fcaf3451edcc2139ffcb0db53ea4f9d03152e2736e0ffbb47386b40f618d52",
568
- "d3_fast.py": "c8f6e74968e2835732e0865814b98a21e4b604c80ecb0416c270219eb8e64c05",
569
  "d3_kernels.py": "8f7534ca1e1846ebf7c4c73058002f3be4dbf0d5d426f0815150ae0cbe7677bd",
570
  "modeling_d3.py": "55314f36206484a505e9525db373621d672df7447ddc07b71329a1f2857e8227",
571
  "pipeline_d3.py": "c0975a91316bcda9c09c5f14bf634ceec94e6980ed7e76a29b718fb451fe4091",
@@ -588,11 +588,11 @@
588
  }
589
  ]
590
  },
591
- "built_utc": "2026-10-11T00:45:04+00:00",
592
  "files_sha256": {
593
  "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
594
  "NOTICE": "61f4ea488e1fed0c3fce97171506a23152c2591116442f78f15827fb9e6af469",
595
- "README.md": "f6ea1fb7823c805d4ac277032a2008d8f28ab8e1a8a33aa71720308f3f596253",
596
  "assets/banner.png": "eb7ecc949232e1de544247899dd55ee629a36cfe276042d5795f65178b9c64c5",
597
  "assets/example-receipt.png": "b9dbb8b103bacd45f1de824d844a3c07b81d57cb1a7466712ef060ad7dcb3926",
598
  "assets/index-areas.png": "602d4e76437b22dec2c5389b870349fc2ac9a68ee757ea67b0db10182962458d",
@@ -600,10 +600,10 @@
600
  "chat_template.jinja": "c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041",
601
  "config.json": "7e16284fafd2d54b73c10073c0391bfd6804886ceaf2cbe37fdb62d4c6813dea",
602
  "d3_engine.py": "ab638d785325d944d3dac891f77448dfc91cad1b8d55a7302bd527c5f1e0e251",
603
- "d3_fast.py": "c8f6e74968e2835732e0865814b98a21e4b604c80ecb0416c270219eb8e64c05",
604
  "d3_format.py": "e5036154d2e54793f59b320c8726632957bc343c382bac26d825b263a6e9ce62",
605
  "d3_kernels.py": "8f7534ca1e1846ebf7c4c73058002f3be4dbf0d5d426f0815150ae0cbe7677bd",
606
- "d3_runtime.py": "88fcaf3451edcc2139ffcb0db53ea4f9d03152e2736e0ffbb47386b40f618d52",
607
  "d3_server.py": "434d6aa5e8572b649e1068588bf1811ff970412e409684b80832bd5544080bca",
608
  "decision_config.json": "6b80ca11bd6ba481df4b3c187db8a5d1983786563ca05e2edccb0bdac0d2fc4f",
609
  "merges.txt": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d",
@@ -640,10 +640,10 @@
640
  "chat_template.jinja": 8952,
641
  "config.json": 3949,
642
  "d3_engine.py": 3726,
643
- "d3_fast.py": 21284,
644
  "d3_format.py": 4882,
645
  "d3_kernels.py": 16129,
646
- "d3_runtime.py": 57795,
647
  "d3_server.py": 8295,
648
  "decision_config.json": 5503,
649
  "merges.txt": 3353259,
 
564
  },
565
  "runtime": {
566
  "files_sha256": {
567
+ "d3_runtime.py": "139ece85007c5771b5e374da9658dc8832eb23aabfeaabe29f18e56d59d7f82f",
568
+ "d3_fast.py": "68a1fb9a2c3bde9ac2763bf504decae592ca12722698fbde1b39a31262955535",
569
  "d3_kernels.py": "8f7534ca1e1846ebf7c4c73058002f3be4dbf0d5d426f0815150ae0cbe7677bd",
570
  "modeling_d3.py": "55314f36206484a505e9525db373621d672df7447ddc07b71329a1f2857e8227",
571
  "pipeline_d3.py": "c0975a91316bcda9c09c5f14bf634ceec94e6980ed7e76a29b718fb451fe4091",
 
588
  }
589
  ]
590
  },
591
+ "built_utc": "2026-10-11T00:53:37+00:00",
592
  "files_sha256": {
593
  "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
594
  "NOTICE": "61f4ea488e1fed0c3fce97171506a23152c2591116442f78f15827fb9e6af469",
595
+ "README.md": "5249d8f3fb32ce7b113b15a42c57f1cef6ba800cad4d4e2d4574a91e3571296d",
596
  "assets/banner.png": "eb7ecc949232e1de544247899dd55ee629a36cfe276042d5795f65178b9c64c5",
597
  "assets/example-receipt.png": "b9dbb8b103bacd45f1de824d844a3c07b81d57cb1a7466712ef060ad7dcb3926",
598
  "assets/index-areas.png": "602d4e76437b22dec2c5389b870349fc2ac9a68ee757ea67b0db10182962458d",
 
600
  "chat_template.jinja": "c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041",
601
  "config.json": "7e16284fafd2d54b73c10073c0391bfd6804886ceaf2cbe37fdb62d4c6813dea",
602
  "d3_engine.py": "ab638d785325d944d3dac891f77448dfc91cad1b8d55a7302bd527c5f1e0e251",
603
+ "d3_fast.py": "68a1fb9a2c3bde9ac2763bf504decae592ca12722698fbde1b39a31262955535",
604
  "d3_format.py": "e5036154d2e54793f59b320c8726632957bc343c382bac26d825b263a6e9ce62",
605
  "d3_kernels.py": "8f7534ca1e1846ebf7c4c73058002f3be4dbf0d5d426f0815150ae0cbe7677bd",
606
+ "d3_runtime.py": "139ece85007c5771b5e374da9658dc8832eb23aabfeaabe29f18e56d59d7f82f",
607
  "d3_server.py": "434d6aa5e8572b649e1068588bf1811ff970412e409684b80832bd5544080bca",
608
  "decision_config.json": "6b80ca11bd6ba481df4b3c187db8a5d1983786563ca05e2edccb0bdac0d2fc4f",
609
  "merges.txt": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d",
 
640
  "chat_template.jinja": 8952,
641
  "config.json": 3949,
642
  "d3_engine.py": 3726,
643
+ "d3_fast.py": 22331,
644
  "d3_format.py": 4882,
645
  "d3_kernels.py": 16129,
646
+ "d3_runtime.py": 59432,
647
  "d3_server.py": 8295,
648
  "decision_config.json": 5503,
649
  "merges.txt": 3353259,
README.md CHANGED
@@ -31,7 +31,7 @@ tags:
31
  - **Jev Decision Index 0.3, public suite: 65.45**, measured with the official 0.3 kit on the released weights: all 140,178 public requests answered, none unsupported.
32
  - **+8.5 on the public suite over Decision 2.0** (its 27B model: 56.97 on the board), ahead in all five areas.
33
  - **Reads images:** multiple images per request (PNG, JPEG or WebP), given as paths, URLs, PIL images or base64 data URLs; every question of the request sees all of them.
34
- - **Speed:** text requests take a median of 54 ms, and requests with an image a median of 277 ms, on one AMD Instinct MI325X, one request at a time.
35
  - **Many questions, one call:** Choice, Yes / No and Score questions about the same input are answered together, each from its own forward pass over the input, with a probability for every option.
36
 
37
  ## Quickstart
 
31
  - **Jev Decision Index 0.3, public suite: 65.45**, measured with the official 0.3 kit on the released weights: all 140,178 public requests answered, none unsupported.
32
  - **+8.5 on the public suite over Decision 2.0** (its 27B model: 56.97 on the board), ahead in all five areas.
33
  - **Reads images:** multiple images per request (PNG, JPEG or WebP), given as paths, URLs, PIL images or base64 data URLs; every question of the request sees all of them.
34
+ - **Speed:** text requests take a median of 55 ms, and requests with an image a median of 273 ms, on one AMD Instinct MI325X, one request at a time.
35
  - **Many questions, one call:** Choice, Yes / No and Score questions about the same input are answered together, each from its own forward pass over the input, with a probability for every option.
36
 
37
  ## Quickstart
d3_fast.py CHANGED
@@ -71,6 +71,30 @@ def fusable(model: Any) -> str | None:
71
  return "needs " + ", ".join(missing) if missing else None
72
 
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  class FusedLayers:
75
  """The decoder layers and final norm of a Qwen3.5 text model through ``d3_kernels`` (eager values)."""
76
 
@@ -82,7 +106,10 @@ class FusedLayers:
82
  try:
83
  from . import d3_kernels as kernels
84
  except ImportError:
85
- kernels = importlib.import_module("d3_kernels")
 
 
 
86
  self.k = kernels
87
  self.torch = torch
88
  self.chunk = modeling.torch_chunk_gated_delta_rule
 
71
  return "needs " + ", ".join(missing) if missing else None
72
 
73
 
74
+ def kernels_next_to_this_file():
75
+ """``d3_kernels.py`` of this file's directory, imported by path once per file (see ``d3_runtime.fast_module``)."""
76
+ import hashlib
77
+ import importlib.util
78
+ import sys
79
+ from pathlib import Path
80
+
81
+ # Not resolved: in a Hub snapshot the .py names are links to blobs without a suffix.
82
+ path = Path(__file__).absolute().with_name("d3_kernels.py")
83
+ name = f"d3_kernels_{hashlib.sha256(str(path).encode()).hexdigest()[:16]}"
84
+ if name not in sys.modules:
85
+ spec = importlib.util.spec_from_file_location(name, str(path))
86
+ if spec is None or spec.loader is None:
87
+ raise ImportError(f"no loader for {path}")
88
+ module = importlib.util.module_from_spec(spec)
89
+ sys.modules[name] = module
90
+ try:
91
+ spec.loader.exec_module(module)
92
+ except BaseException:
93
+ del sys.modules[name]
94
+ raise
95
+ return sys.modules[name]
96
+
97
+
98
  class FusedLayers:
99
  """The decoder layers and final norm of a Qwen3.5 text model through ``d3_kernels`` (eager values)."""
100
 
 
106
  try:
107
  from . import d3_kernels as kernels
108
  except ImportError:
109
+ try:
110
+ kernels = importlib.import_module("d3_kernels")
111
+ except ImportError:
112
+ kernels = kernels_next_to_this_file()
113
  self.k = kernels
114
  self.torch = torch
115
  self.chunk = modeling.torch_chunk_gated_delta_rule
d3_runtime.py CHANGED
@@ -463,6 +463,39 @@ def sha256_file(path: Path) -> str:
463
  return digest.hexdigest()
464
 
465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  def resolve_dir(
467
  name_or_path: str | os.PathLike, revision: str | None = None, **hub: Any
468
  ) -> Path:
@@ -799,8 +832,14 @@ class D3:
799
  self.image_unavailable = (
800
  f"the image processor failed to load ({type(exc).__name__}: {exc})"
801
  )
802
- self.fast_skipped = None if d3_fast else "d3_fast.py is not present"
803
- self.fast = d3_fast.install(self) if d3_fast else None
 
 
 
 
 
 
804
  self.loaded_seconds = time.perf_counter() - started
805
 
806
  @classmethod
 
463
  return digest.hexdigest()
464
 
465
 
466
+ def load_file_module(path: Path):
467
+ """Import a flat package file by its path, once per file (two checkpoints can share a process)."""
468
+ import importlib.util
469
+ import sys
470
+
471
+ # Not resolved: in a Hub snapshot the .py name is a link to a blob without a suffix, which has no loader.
472
+ path = Path(path).absolute()
473
+ name = f"{path.stem}_{hashlib.sha256(str(path).encode()).hexdigest()[:16]}"
474
+ if name not in sys.modules:
475
+ spec = importlib.util.spec_from_file_location(name, str(path))
476
+ if spec is None or spec.loader is None:
477
+ raise ImportError(f"no loader for {path}")
478
+ module = importlib.util.module_from_spec(spec)
479
+ sys.modules[name] = module
480
+ try:
481
+ spec.loader.exec_module(module)
482
+ except BaseException:
483
+ del sys.modules[name]
484
+ raise
485
+ return sys.modules[name]
486
+
487
+
488
+ def fast_module(root: Path):
489
+ """``d3_fast.py`` of the checkpoint directory when it is not importable as a module.
490
+
491
+ ``AutoModel.from_pretrained(..., trust_remote_code=True)`` copies only the modeling files and their
492
+ ``from .x import y`` imports into its module cache; the package's own copy (verified against
493
+ ``MODEL_MANIFEST.json``) is next to the weights.
494
+ """
495
+ path = Path(root) / "d3_fast.py"
496
+ return load_file_module(path) if path.is_file() else None
497
+
498
+
499
  def resolve_dir(
500
  name_or_path: str | os.PathLike, revision: str | None = None, **hub: Any
501
  ) -> Path:
 
832
  self.image_unavailable = (
833
  f"the image processor failed to load ({type(exc).__name__}: {exc})"
834
  )
835
+ fast, reason = d3_fast, "d3_fast.py is not present"
836
+ if fast is None:
837
+ try:
838
+ fast = fast_module(self.root)
839
+ except Exception as exc: # noqa: BLE001 - the plain path always loads
840
+ reason = f"d3_fast.py failed to import ({type(exc).__name__}: {exc})"
841
+ self.fast_skipped = None if fast else reason
842
+ self.fast = fast.install(self) if fast else None
843
  self.loaded_seconds = time.perf_counter() - started
844
 
845
  @classmethod