FlorianVal commited on
Commit
de74b71
·
verified ·
1 Parent(s): 74679d4

Vendor dssd 79aec34 (source attribution fix)

Browse files
Files changed (2) hide show
  1. dssd/VENDORED.txt +1 -1
  2. dssd/fast.py +6 -3
dssd/VENDORED.txt CHANGED
@@ -1 +1 @@
1
- Vendored from BranchyLLM 73b3f27 (dssd-pub); do not edit here.
 
1
+ Vendored from BranchyLLM 79aec34 (dssd-pub); do not edit here.
dssd/fast.py CHANGED
@@ -907,13 +907,14 @@ class FastDecoder:
907
  c_max = b[-1]
908
  nxt = dict(zip(b, b[1:]))
909
  tok, par, dep, ld, kids, origin, q = [], [], [], [], [], [], []
 
910
 
911
  def add(t, parent, how, qv=0.0):
912
  if len(tok) >= W:
913
  return None
914
  i = len(tok)
915
  tok.append(t); par.append(parent); dep.append(0 if parent is None else dep[parent] + 1)
916
- ld.append(0); kids.append({}); origin.append(how); q.append(float(qv))
917
  if parent is not None:
918
  kids[parent][t] = i
919
  self._embed_row(i, t)
@@ -1016,6 +1017,8 @@ class FastDecoder:
1016
  st.exits[exited] = st.exits.get(exited, 0) + 1
1017
  else:
1018
  q[n] = max(q[n], q_head)
 
 
1019
  c = n
1020
  drafted += 1
1021
  if t_k in eos_ids:
@@ -1058,7 +1061,7 @@ class FastDecoder:
1058
  st.pld_accepted += sum(1 for i in acc if origin[i] == "copy")
1059
  kept_kids = [v for v in kids[node].values() if v in kept]
1060
  st.rejected_cycles += int(bool(kept_kids)) # some draft below the last accepted node failed
1061
- info = {"path": [origin[i] for i in acc], "n_nodes": n_rows - 1,
1062
  "failed": origin[max(kept_kids, key=lambda v: q[v])] if kept_kids else None,
1063
  "stop": None if kept_kids else (gate_p[node], float(target[node] in kids[node]))}
1064
  src = [pos0 + i for i in acc]
@@ -1203,7 +1206,7 @@ class FastDecoder:
1203
  st.lab_n += len(cyc.labels)
1204
  st.lab_s += float(sum(cyc.labels))
1205
  account(cost, len(committed), True)
1206
- stopped = self._commit(out, committed, info["path"] + ["model"], index, stop, eos_ids,
1207
  max_new, st, on_commit) or stopped
1208
  while star is not None and not stopped and len(out) < max_new and out[-1] not in eos_ids:
1209
  pos0 = len(prompt) + len(out) - 1
 
907
  c_max = b[-1]
908
  nxt = dict(zip(b, b[1:]))
909
  tok, par, dep, ld, kids, origin, q = [], [], [], [], [], [], []
910
+ shown = [] # provenance reported to the user (st.sources); origin feeds the statistics
911
 
912
  def add(t, parent, how, qv=0.0):
913
  if len(tok) >= W:
914
  return None
915
  i = len(tok)
916
  tok.append(t); par.append(parent); dep.append(0 if parent is None else dep[parent] + 1)
917
+ ld.append(0); kids.append({}); origin.append(how); shown.append(how); q.append(float(qv))
918
  if parent is not None:
919
  kids[parent][t] = i
920
  self._embed_row(i, t)
 
1017
  st.exits[exited] = st.exits.get(exited, 0) + 1
1018
  else:
1019
  q[n] = max(q[n], q_head)
1020
+ if origin[n] == "star": # the star's rank-0 candidate is the chain's own token
1021
+ shown[n] = "head"
1022
  c = n
1023
  drafted += 1
1024
  if t_k in eos_ids:
 
1061
  st.pld_accepted += sum(1 for i in acc if origin[i] == "copy")
1062
  kept_kids = [v for v in kids[node].values() if v in kept]
1063
  st.rejected_cycles += int(bool(kept_kids)) # some draft below the last accepted node failed
1064
+ info = {"path": [origin[i] for i in acc], "sources": [shown[i] for i in acc], "n_nodes": n_rows - 1,
1065
  "failed": origin[max(kept_kids, key=lambda v: q[v])] if kept_kids else None,
1066
  "stop": None if kept_kids else (gate_p[node], float(target[node] in kids[node]))}
1067
  src = [pos0 + i for i in acc]
 
1206
  st.lab_n += len(cyc.labels)
1207
  st.lab_s += float(sum(cyc.labels))
1208
  account(cost, len(committed), True)
1209
+ stopped = self._commit(out, committed, info["sources"] + ["model"], index, stop, eos_ids,
1210
  max_new, st, on_commit) or stopped
1211
  while star is not None and not stopped and len(out) < max_new and out[-1] not in eos_ids:
1212
  pos0 = len(prompt) + len(out) - 1